github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/iam/groupPolicyAttachment.go (about) 1 // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT. 2 // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! *** 3 4 package iam 5 6 import ( 7 "context" 8 "reflect" 9 10 "errors" 11 "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal" 12 "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 13 ) 14 15 // Attaches a Managed IAM Policy to an IAM group 16 // 17 // > **NOTE:** The usage of this resource conflicts with the `iam.PolicyAttachment` resource and will permanently show a difference if both are defined. 18 // 19 // ## Example Usage 20 // 21 // <!--Start PulumiCodeChooser --> 22 // ```go 23 // package main 24 // 25 // import ( 26 // 27 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // group, err := iam.NewGroup(ctx, "group", &iam.GroupArgs{ 35 // Name: pulumi.String("test-group"), 36 // }) 37 // if err != nil { 38 // return err 39 // } 40 // policy, err := iam.NewPolicy(ctx, "policy", &iam.PolicyArgs{ 41 // Name: pulumi.String("test-policy"), 42 // Description: pulumi.String("A test policy"), 43 // Policy: pulumi.Any("{ ... policy JSON ... }"), 44 // }) 45 // if err != nil { 46 // return err 47 // } 48 // _, err = iam.NewGroupPolicyAttachment(ctx, "test-attach", &iam.GroupPolicyAttachmentArgs{ 49 // Group: group.Name, 50 // PolicyArn: policy.Arn, 51 // }) 52 // if err != nil { 53 // return err 54 // } 55 // return nil 56 // }) 57 // } 58 // 59 // ``` 60 // <!--End PulumiCodeChooser --> 61 // 62 // ## Import 63 // 64 // Using `pulumi import`, import IAM group policy attachments using the group name and policy arn separated by `/`. For example: 65 // 66 // ```sh 67 // $ pulumi import aws:iam/groupPolicyAttachment:GroupPolicyAttachment test-attach test-group/arn:aws:iam::xxxxxxxxxxxx:policy/test-policy 68 // ``` 69 type GroupPolicyAttachment struct { 70 pulumi.CustomResourceState 71 72 // The group the policy should be applied to 73 Group pulumi.StringOutput `pulumi:"group"` 74 // The ARN of the policy you want to apply 75 PolicyArn pulumi.StringOutput `pulumi:"policyArn"` 76 } 77 78 // NewGroupPolicyAttachment registers a new resource with the given unique name, arguments, and options. 79 func NewGroupPolicyAttachment(ctx *pulumi.Context, 80 name string, args *GroupPolicyAttachmentArgs, opts ...pulumi.ResourceOption) (*GroupPolicyAttachment, error) { 81 if args == nil { 82 return nil, errors.New("missing one or more required arguments") 83 } 84 85 if args.Group == nil { 86 return nil, errors.New("invalid value for required argument 'Group'") 87 } 88 if args.PolicyArn == nil { 89 return nil, errors.New("invalid value for required argument 'PolicyArn'") 90 } 91 opts = internal.PkgResourceDefaultOpts(opts) 92 var resource GroupPolicyAttachment 93 err := ctx.RegisterResource("aws:iam/groupPolicyAttachment:GroupPolicyAttachment", name, args, &resource, opts...) 94 if err != nil { 95 return nil, err 96 } 97 return &resource, nil 98 } 99 100 // GetGroupPolicyAttachment gets an existing GroupPolicyAttachment resource's state with the given name, ID, and optional 101 // state properties that are used to uniquely qualify the lookup (nil if not required). 102 func GetGroupPolicyAttachment(ctx *pulumi.Context, 103 name string, id pulumi.IDInput, state *GroupPolicyAttachmentState, opts ...pulumi.ResourceOption) (*GroupPolicyAttachment, error) { 104 var resource GroupPolicyAttachment 105 err := ctx.ReadResource("aws:iam/groupPolicyAttachment:GroupPolicyAttachment", name, id, state, &resource, opts...) 106 if err != nil { 107 return nil, err 108 } 109 return &resource, nil 110 } 111 112 // Input properties used for looking up and filtering GroupPolicyAttachment resources. 113 type groupPolicyAttachmentState struct { 114 // The group the policy should be applied to 115 Group interface{} `pulumi:"group"` 116 // The ARN of the policy you want to apply 117 PolicyArn *string `pulumi:"policyArn"` 118 } 119 120 type GroupPolicyAttachmentState struct { 121 // The group the policy should be applied to 122 Group pulumi.Input 123 // The ARN of the policy you want to apply 124 PolicyArn pulumi.StringPtrInput 125 } 126 127 func (GroupPolicyAttachmentState) ElementType() reflect.Type { 128 return reflect.TypeOf((*groupPolicyAttachmentState)(nil)).Elem() 129 } 130 131 type groupPolicyAttachmentArgs struct { 132 // The group the policy should be applied to 133 Group interface{} `pulumi:"group"` 134 // The ARN of the policy you want to apply 135 PolicyArn string `pulumi:"policyArn"` 136 } 137 138 // The set of arguments for constructing a GroupPolicyAttachment resource. 139 type GroupPolicyAttachmentArgs struct { 140 // The group the policy should be applied to 141 Group pulumi.Input 142 // The ARN of the policy you want to apply 143 PolicyArn pulumi.StringInput 144 } 145 146 func (GroupPolicyAttachmentArgs) ElementType() reflect.Type { 147 return reflect.TypeOf((*groupPolicyAttachmentArgs)(nil)).Elem() 148 } 149 150 type GroupPolicyAttachmentInput interface { 151 pulumi.Input 152 153 ToGroupPolicyAttachmentOutput() GroupPolicyAttachmentOutput 154 ToGroupPolicyAttachmentOutputWithContext(ctx context.Context) GroupPolicyAttachmentOutput 155 } 156 157 func (*GroupPolicyAttachment) ElementType() reflect.Type { 158 return reflect.TypeOf((**GroupPolicyAttachment)(nil)).Elem() 159 } 160 161 func (i *GroupPolicyAttachment) ToGroupPolicyAttachmentOutput() GroupPolicyAttachmentOutput { 162 return i.ToGroupPolicyAttachmentOutputWithContext(context.Background()) 163 } 164 165 func (i *GroupPolicyAttachment) ToGroupPolicyAttachmentOutputWithContext(ctx context.Context) GroupPolicyAttachmentOutput { 166 return pulumi.ToOutputWithContext(ctx, i).(GroupPolicyAttachmentOutput) 167 } 168 169 // GroupPolicyAttachmentArrayInput is an input type that accepts GroupPolicyAttachmentArray and GroupPolicyAttachmentArrayOutput values. 170 // You can construct a concrete instance of `GroupPolicyAttachmentArrayInput` via: 171 // 172 // GroupPolicyAttachmentArray{ GroupPolicyAttachmentArgs{...} } 173 type GroupPolicyAttachmentArrayInput interface { 174 pulumi.Input 175 176 ToGroupPolicyAttachmentArrayOutput() GroupPolicyAttachmentArrayOutput 177 ToGroupPolicyAttachmentArrayOutputWithContext(context.Context) GroupPolicyAttachmentArrayOutput 178 } 179 180 type GroupPolicyAttachmentArray []GroupPolicyAttachmentInput 181 182 func (GroupPolicyAttachmentArray) ElementType() reflect.Type { 183 return reflect.TypeOf((*[]*GroupPolicyAttachment)(nil)).Elem() 184 } 185 186 func (i GroupPolicyAttachmentArray) ToGroupPolicyAttachmentArrayOutput() GroupPolicyAttachmentArrayOutput { 187 return i.ToGroupPolicyAttachmentArrayOutputWithContext(context.Background()) 188 } 189 190 func (i GroupPolicyAttachmentArray) ToGroupPolicyAttachmentArrayOutputWithContext(ctx context.Context) GroupPolicyAttachmentArrayOutput { 191 return pulumi.ToOutputWithContext(ctx, i).(GroupPolicyAttachmentArrayOutput) 192 } 193 194 // GroupPolicyAttachmentMapInput is an input type that accepts GroupPolicyAttachmentMap and GroupPolicyAttachmentMapOutput values. 195 // You can construct a concrete instance of `GroupPolicyAttachmentMapInput` via: 196 // 197 // GroupPolicyAttachmentMap{ "key": GroupPolicyAttachmentArgs{...} } 198 type GroupPolicyAttachmentMapInput interface { 199 pulumi.Input 200 201 ToGroupPolicyAttachmentMapOutput() GroupPolicyAttachmentMapOutput 202 ToGroupPolicyAttachmentMapOutputWithContext(context.Context) GroupPolicyAttachmentMapOutput 203 } 204 205 type GroupPolicyAttachmentMap map[string]GroupPolicyAttachmentInput 206 207 func (GroupPolicyAttachmentMap) ElementType() reflect.Type { 208 return reflect.TypeOf((*map[string]*GroupPolicyAttachment)(nil)).Elem() 209 } 210 211 func (i GroupPolicyAttachmentMap) ToGroupPolicyAttachmentMapOutput() GroupPolicyAttachmentMapOutput { 212 return i.ToGroupPolicyAttachmentMapOutputWithContext(context.Background()) 213 } 214 215 func (i GroupPolicyAttachmentMap) ToGroupPolicyAttachmentMapOutputWithContext(ctx context.Context) GroupPolicyAttachmentMapOutput { 216 return pulumi.ToOutputWithContext(ctx, i).(GroupPolicyAttachmentMapOutput) 217 } 218 219 type GroupPolicyAttachmentOutput struct{ *pulumi.OutputState } 220 221 func (GroupPolicyAttachmentOutput) ElementType() reflect.Type { 222 return reflect.TypeOf((**GroupPolicyAttachment)(nil)).Elem() 223 } 224 225 func (o GroupPolicyAttachmentOutput) ToGroupPolicyAttachmentOutput() GroupPolicyAttachmentOutput { 226 return o 227 } 228 229 func (o GroupPolicyAttachmentOutput) ToGroupPolicyAttachmentOutputWithContext(ctx context.Context) GroupPolicyAttachmentOutput { 230 return o 231 } 232 233 // The group the policy should be applied to 234 func (o GroupPolicyAttachmentOutput) Group() pulumi.StringOutput { 235 return o.ApplyT(func(v *GroupPolicyAttachment) pulumi.StringOutput { return v.Group }).(pulumi.StringOutput) 236 } 237 238 // The ARN of the policy you want to apply 239 func (o GroupPolicyAttachmentOutput) PolicyArn() pulumi.StringOutput { 240 return o.ApplyT(func(v *GroupPolicyAttachment) pulumi.StringOutput { return v.PolicyArn }).(pulumi.StringOutput) 241 } 242 243 type GroupPolicyAttachmentArrayOutput struct{ *pulumi.OutputState } 244 245 func (GroupPolicyAttachmentArrayOutput) ElementType() reflect.Type { 246 return reflect.TypeOf((*[]*GroupPolicyAttachment)(nil)).Elem() 247 } 248 249 func (o GroupPolicyAttachmentArrayOutput) ToGroupPolicyAttachmentArrayOutput() GroupPolicyAttachmentArrayOutput { 250 return o 251 } 252 253 func (o GroupPolicyAttachmentArrayOutput) ToGroupPolicyAttachmentArrayOutputWithContext(ctx context.Context) GroupPolicyAttachmentArrayOutput { 254 return o 255 } 256 257 func (o GroupPolicyAttachmentArrayOutput) Index(i pulumi.IntInput) GroupPolicyAttachmentOutput { 258 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *GroupPolicyAttachment { 259 return vs[0].([]*GroupPolicyAttachment)[vs[1].(int)] 260 }).(GroupPolicyAttachmentOutput) 261 } 262 263 type GroupPolicyAttachmentMapOutput struct{ *pulumi.OutputState } 264 265 func (GroupPolicyAttachmentMapOutput) ElementType() reflect.Type { 266 return reflect.TypeOf((*map[string]*GroupPolicyAttachment)(nil)).Elem() 267 } 268 269 func (o GroupPolicyAttachmentMapOutput) ToGroupPolicyAttachmentMapOutput() GroupPolicyAttachmentMapOutput { 270 return o 271 } 272 273 func (o GroupPolicyAttachmentMapOutput) ToGroupPolicyAttachmentMapOutputWithContext(ctx context.Context) GroupPolicyAttachmentMapOutput { 274 return o 275 } 276 277 func (o GroupPolicyAttachmentMapOutput) MapIndex(k pulumi.StringInput) GroupPolicyAttachmentOutput { 278 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *GroupPolicyAttachment { 279 return vs[0].(map[string]*GroupPolicyAttachment)[vs[1].(string)] 280 }).(GroupPolicyAttachmentOutput) 281 } 282 283 func init() { 284 pulumi.RegisterInputType(reflect.TypeOf((*GroupPolicyAttachmentInput)(nil)).Elem(), &GroupPolicyAttachment{}) 285 pulumi.RegisterInputType(reflect.TypeOf((*GroupPolicyAttachmentArrayInput)(nil)).Elem(), GroupPolicyAttachmentArray{}) 286 pulumi.RegisterInputType(reflect.TypeOf((*GroupPolicyAttachmentMapInput)(nil)).Elem(), GroupPolicyAttachmentMap{}) 287 pulumi.RegisterOutputType(GroupPolicyAttachmentOutput{}) 288 pulumi.RegisterOutputType(GroupPolicyAttachmentArrayOutput{}) 289 pulumi.RegisterOutputType(GroupPolicyAttachmentMapOutput{}) 290 }