1. Packages
  2. AWS Classic
  3. API Docs
  4. iam
  5. GroupPolicyAttachment

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

aws.iam.GroupPolicyAttachment

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi

    Attaches a Managed IAM Policy to an IAM group

    NOTE: The usage of this resource conflicts with the aws.iam.PolicyAttachment resource and will permanently show a difference if both are defined.

    Example Usage

    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var @group = new Aws.Iam.Group("group");
    
        var policy = new Aws.Iam.Policy("policy", new()
        {
            Description = "A test policy",
            PolicyDocument = "{ ... policy JSON ... }",
        });
    
        var test_attach = new Aws.Iam.GroupPolicyAttachment("test-attach", new()
        {
            Group = @group.Name,
            PolicyArn = policy.Arn,
        });
    
    });
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		group, err := iam.NewGroup(ctx, "group", nil)
    		if err != nil {
    			return err
    		}
    		policy, err := iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{
    			Description: pulumi.String("A test policy"),
    			Policy:      pulumi.Any("{ ... policy JSON ... }"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = iam.NewGroupPolicyAttachment(ctx, "test-attach", &iam.GroupPolicyAttachmentArgs{
    			Group:     group.Name,
    			PolicyArn: policy.Arn,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.iam.Group;
    import com.pulumi.aws.iam.Policy;
    import com.pulumi.aws.iam.PolicyArgs;
    import com.pulumi.aws.iam.GroupPolicyAttachment;
    import com.pulumi.aws.iam.GroupPolicyAttachmentArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var group = new Group("group");
    
            var policy = new Policy("policy", PolicyArgs.builder()        
                .description("A test policy")
                .policy("{ ... policy JSON ... }")
                .build());
    
            var test_attach = new GroupPolicyAttachment("test-attach", GroupPolicyAttachmentArgs.builder()        
                .group(group.name())
                .policyArn(policy.arn())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    group = aws.iam.Group("group")
    policy = aws.iam.Policy("policy",
        description="A test policy",
        policy="{ ... policy JSON ... }")
    test_attach = aws.iam.GroupPolicyAttachment("test-attach",
        group=group.name,
        policy_arn=policy.arn)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    
    const group = new aws.iam.Group("group", {});
    const policy = new aws.iam.Policy("policy", {
        description: "A test policy",
        policy: "{ ... policy JSON ... }",
    });
    const test_attach = new aws.iam.GroupPolicyAttachment("test-attach", {
        group: group.name,
        policyArn: policy.arn,
    });
    
    resources:
      group:
        type: aws:iam:Group
      policy:
        type: aws:iam:Policy
        properties:
          description: A test policy
          policy: '{ ... policy JSON ... }'
      test-attach:
        type: aws:iam:GroupPolicyAttachment
        properties:
          group: ${group.name}
          policyArn: ${policy.arn}
    

    Create GroupPolicyAttachment Resource

    new GroupPolicyAttachment(name: string, args: GroupPolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def GroupPolicyAttachment(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              group: Optional[str] = None,
                              policy_arn: Optional[str] = None)
    @overload
    def GroupPolicyAttachment(resource_name: str,
                              args: GroupPolicyAttachmentArgs,
                              opts: Optional[ResourceOptions] = None)
    func NewGroupPolicyAttachment(ctx *Context, name string, args GroupPolicyAttachmentArgs, opts ...ResourceOption) (*GroupPolicyAttachment, error)
    public GroupPolicyAttachment(string name, GroupPolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public GroupPolicyAttachment(String name, GroupPolicyAttachmentArgs args)
    public GroupPolicyAttachment(String name, GroupPolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: aws:iam:GroupPolicyAttachment
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args GroupPolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args GroupPolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args GroupPolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GroupPolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GroupPolicyAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    GroupPolicyAttachment Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    The GroupPolicyAttachment resource accepts the following input properties:

    Group string | string
    The group the policy should be applied to
    PolicyArn string
    The ARN of the policy you want to apply
    Group string | string
    The group the policy should be applied to
    PolicyArn string
    The ARN of the policy you want to apply
    group String | String
    The group the policy should be applied to
    policyArn String
    The ARN of the policy you want to apply
    group string | Group
    The group the policy should be applied to
    policyArn ARN
    The ARN of the policy you want to apply
    group str | str
    The group the policy should be applied to
    policy_arn str
    The ARN of the policy you want to apply
    group String |
    The group the policy should be applied to
    policyArn
    The ARN of the policy you want to apply

    Outputs

    All input properties are implicitly available as output properties. Additionally, the GroupPolicyAttachment 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 string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing GroupPolicyAttachment Resource

    Get an existing GroupPolicyAttachment 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?: GroupPolicyAttachmentState, opts?: CustomResourceOptions): GroupPolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            group: Optional[str] = None,
            policy_arn: Optional[str] = None) -> GroupPolicyAttachment
    func GetGroupPolicyAttachment(ctx *Context, name string, id IDInput, state *GroupPolicyAttachmentState, opts ...ResourceOption) (*GroupPolicyAttachment, error)
    public static GroupPolicyAttachment Get(string name, Input<string> id, GroupPolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static GroupPolicyAttachment get(String name, Output<String> id, GroupPolicyAttachmentState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    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:
    Group string | string
    The group the policy should be applied to
    PolicyArn string
    The ARN of the policy you want to apply
    Group string | string
    The group the policy should be applied to
    PolicyArn string
    The ARN of the policy you want to apply
    group String | String
    The group the policy should be applied to
    policyArn String
    The ARN of the policy you want to apply
    group string | Group
    The group the policy should be applied to
    policyArn ARN
    The ARN of the policy you want to apply
    group str | str
    The group the policy should be applied to
    policy_arn str
    The ARN of the policy you want to apply
    group String |
    The group the policy should be applied to
    policyArn
    The ARN of the policy you want to apply

    Import

    Using pulumi import, import IAM group policy attachments using the group name and policy arn separated by /. For example:

     $ pulumi import aws:iam/groupPolicyAttachment:GroupPolicyAttachment test-attach test-group/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy
    

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the aws Terraform Provider.
    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.23.0 published on Thursday, Feb 22, 2024 by Pulumi