PolicyAttachment
Provides a resource to attach an AWS Organizations policy to an organization account, root, or unit.
Example Usage
Organization Account
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var account = new Aws.Organizations.PolicyAttachment("account", new Aws.Organizations.PolicyAttachmentArgs
{
PolicyId = aws_organizations_policy.Example.Id,
TargetId = "123456789012",
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/organizations"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := organizations.NewPolicyAttachment(ctx, "account", &organizations.PolicyAttachmentArgs{
PolicyId: pulumi.String(aws_organizations_policy.Example.Id),
TargetId: pulumi.String("123456789012"),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
account = aws.organizations.PolicyAttachment("account",
policy_id=aws_organizations_policy["example"]["id"],
target_id="123456789012")import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const account = new aws.organizations.PolicyAttachment("account", {
policyId: aws_organizations_policy_example.id,
targetId: "123456789012",
});Organization Root
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var root = new Aws.Organizations.PolicyAttachment("root", new Aws.Organizations.PolicyAttachmentArgs
{
PolicyId = aws_organizations_policy.Example.Id,
TargetId = aws_organizations_organization.Example.Roots[0].Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/organizations"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := organizations.NewPolicyAttachment(ctx, "root", &organizations.PolicyAttachmentArgs{
PolicyId: pulumi.String(aws_organizations_policy.Example.Id),
TargetId: pulumi.String(aws_organizations_organization.Example.Roots[0].Id),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
root = aws.organizations.PolicyAttachment("root",
policy_id=aws_organizations_policy["example"]["id"],
target_id=aws_organizations_organization["example"]["roots"][0]["id"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const root = new aws.organizations.PolicyAttachment("root", {
policyId: aws_organizations_policy_example.id,
targetId: aws_organizations_organization_example.roots.0.id,
});Organization Unit
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var unit = new Aws.Organizations.PolicyAttachment("unit", new Aws.Organizations.PolicyAttachmentArgs
{
PolicyId = aws_organizations_policy.Example.Id,
TargetId = aws_organizations_organizational_unit.Example.Id,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws/organizations"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := organizations.NewPolicyAttachment(ctx, "unit", &organizations.PolicyAttachmentArgs{
PolicyId: pulumi.String(aws_organizations_policy.Example.Id),
TargetId: pulumi.String(aws_organizations_organizational_unit.Example.Id),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
unit = aws.organizations.PolicyAttachment("unit",
policy_id=aws_organizations_policy["example"]["id"],
target_id=aws_organizations_organizational_unit["example"]["id"])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const unit = new aws.organizations.PolicyAttachment("unit", {
policyId: aws_organizations_policy_example.id,
targetId: aws_organizations_organizational_unit_example.id,
});Create a PolicyAttachment Resource
new PolicyAttachment(name: string, args: PolicyAttachmentArgs, opts?: CustomResourceOptions);def PolicyAttachment(resource_name, opts=None, policy_id=None, target_id=None, __props__=None);func NewPolicyAttachment(ctx *Context, name string, args PolicyAttachmentArgs, opts ...ResourceOption) (*PolicyAttachment, error)public PolicyAttachment(string name, PolicyAttachmentArgs args, CustomResourceOptions? opts = null)- name string
- The unique name of the resource.
- args PolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- opts ResourceOptions
- A bag of options that control this resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args PolicyAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args PolicyAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
PolicyAttachment Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Programming Model docs.
Inputs
The PolicyAttachment resource accepts the following input properties:
Outputs
All input properties are implicitly available as output properties. Additionally, the PolicyAttachment resource produces the following output properties:
Look up an Existing PolicyAttachment Resource
Get an existing PolicyAttachment resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: PolicyAttachmentState, opts?: CustomResourceOptions): PolicyAttachmentstatic get(resource_name, id, opts=None, policy_id=None, target_id=None, __props__=None);func GetPolicyAttachment(ctx *Context, name string, id IDInput, state *PolicyAttachmentState, opts ...ResourceOption) (*PolicyAttachment, error)public static PolicyAttachment Get(string name, Input<string> id, PolicyAttachmentState? state, CustomResourceOptions? opts = null)- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
The following state arguments are supported:
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.