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

def PolicyAttachment(resource_name, opts=None, policy_id=None, target_id=None, __props__=None);
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:

PolicyId string

The unique identifier (ID) of the policy that you want to attach to the target.

TargetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

PolicyId string

The unique identifier (ID) of the policy that you want to attach to the target.

TargetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

policyId string

The unique identifier (ID) of the policy that you want to attach to the target.

targetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

policy_id str

The unique identifier (ID) of the policy that you want to attach to the target.

target_id str

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

Outputs

All input properties are implicitly available as output properties. Additionally, the PolicyAttachment resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

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): PolicyAttachment
static 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:

PolicyId string

The unique identifier (ID) of the policy that you want to attach to the target.

TargetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

PolicyId string

The unique identifier (ID) of the policy that you want to attach to the target.

TargetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

policyId string

The unique identifier (ID) of the policy that you want to attach to the target.

targetId string

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

policy_id str

The unique identifier (ID) of the policy that you want to attach to the target.

target_id str

The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.