/
policyAttachment.go
365 lines (304 loc) · 12.3 KB
/
policyAttachment.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package organizations
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides a resource to attach an AWS Organizations policy to an organization account, root, or unit.
//
// ## Example Usage
// ### Organization Account
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := organizations.NewPolicyAttachment(ctx, "account", &organizations.PolicyAttachmentArgs{
// PolicyId: pulumi.Any(aws_organizations_policy.Example.Id),
// TargetId: pulumi.String("123456789012"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Organization Root
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := organizations.NewPolicyAttachment(ctx, "root", &organizations.PolicyAttachmentArgs{
// PolicyId: pulumi.Any(aws_organizations_policy.Example.Id),
// TargetId: pulumi.Any(aws_organizations_organization.Example.Roots[0].Id),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// ### Organization Unit
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v4/go/aws/organizations"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := organizations.NewPolicyAttachment(ctx, "unit", &organizations.PolicyAttachmentArgs{
// PolicyId: pulumi.Any(aws_organizations_policy.Example.Id),
// TargetId: pulumi.Any(aws_organizations_organizational_unit.Example.Id),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// `aws_organizations_policy_attachment` can be imported by using the target ID and policy ID, e.g. with an account target
//
// ```sh
// $ pulumi import aws:organizations/policyAttachment:PolicyAttachment account 123456789012:p-12345678
// ```
type PolicyAttachment struct {
pulumi.CustomResourceState
// The unique identifier (ID) of the policy that you want to attach to the target.
PolicyId pulumi.StringOutput `pulumi:"policyId"`
// The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
TargetId pulumi.StringOutput `pulumi:"targetId"`
}
// NewPolicyAttachment registers a new resource with the given unique name, arguments, and options.
func NewPolicyAttachment(ctx *pulumi.Context,
name string, args *PolicyAttachmentArgs, opts ...pulumi.ResourceOption) (*PolicyAttachment, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.PolicyId == nil {
return nil, errors.New("invalid value for required argument 'PolicyId'")
}
if args.TargetId == nil {
return nil, errors.New("invalid value for required argument 'TargetId'")
}
var resource PolicyAttachment
err := ctx.RegisterResource("aws:organizations/policyAttachment:PolicyAttachment", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetPolicyAttachment gets an existing PolicyAttachment resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetPolicyAttachment(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *PolicyAttachmentState, opts ...pulumi.ResourceOption) (*PolicyAttachment, error) {
var resource PolicyAttachment
err := ctx.ReadResource("aws:organizations/policyAttachment:PolicyAttachment", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering PolicyAttachment resources.
type policyAttachmentState struct {
// The unique identifier (ID) of the policy that you want to attach to the target.
PolicyId *string `pulumi:"policyId"`
// The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
TargetId *string `pulumi:"targetId"`
}
type PolicyAttachmentState struct {
// The unique identifier (ID) of the policy that you want to attach to the target.
PolicyId pulumi.StringPtrInput
// The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
TargetId pulumi.StringPtrInput
}
func (PolicyAttachmentState) ElementType() reflect.Type {
return reflect.TypeOf((*policyAttachmentState)(nil)).Elem()
}
type policyAttachmentArgs struct {
// The unique identifier (ID) of the policy that you want to attach to the target.
PolicyId string `pulumi:"policyId"`
// The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
TargetId string `pulumi:"targetId"`
}
// The set of arguments for constructing a PolicyAttachment resource.
type PolicyAttachmentArgs struct {
// The unique identifier (ID) of the policy that you want to attach to the target.
PolicyId pulumi.StringInput
// The unique identifier (ID) of the root, organizational unit, or account number that you want to attach the policy to.
TargetId pulumi.StringInput
}
func (PolicyAttachmentArgs) ElementType() reflect.Type {
return reflect.TypeOf((*policyAttachmentArgs)(nil)).Elem()
}
type PolicyAttachmentInput interface {
pulumi.Input
ToPolicyAttachmentOutput() PolicyAttachmentOutput
ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput
}
func (*PolicyAttachment) ElementType() reflect.Type {
return reflect.TypeOf((*PolicyAttachment)(nil))
}
func (i *PolicyAttachment) ToPolicyAttachmentOutput() PolicyAttachmentOutput {
return i.ToPolicyAttachmentOutputWithContext(context.Background())
}
func (i *PolicyAttachment) ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentOutput)
}
func (i *PolicyAttachment) ToPolicyAttachmentPtrOutput() PolicyAttachmentPtrOutput {
return i.ToPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (i *PolicyAttachment) ToPolicyAttachmentPtrOutputWithContext(ctx context.Context) PolicyAttachmentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentPtrOutput)
}
type PolicyAttachmentPtrInput interface {
pulumi.Input
ToPolicyAttachmentPtrOutput() PolicyAttachmentPtrOutput
ToPolicyAttachmentPtrOutputWithContext(ctx context.Context) PolicyAttachmentPtrOutput
}
type policyAttachmentPtrType PolicyAttachmentArgs
func (*policyAttachmentPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**PolicyAttachment)(nil))
}
func (i *policyAttachmentPtrType) ToPolicyAttachmentPtrOutput() PolicyAttachmentPtrOutput {
return i.ToPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (i *policyAttachmentPtrType) ToPolicyAttachmentPtrOutputWithContext(ctx context.Context) PolicyAttachmentPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentPtrOutput)
}
// PolicyAttachmentArrayInput is an input type that accepts PolicyAttachmentArray and PolicyAttachmentArrayOutput values.
// You can construct a concrete instance of `PolicyAttachmentArrayInput` via:
//
// PolicyAttachmentArray{ PolicyAttachmentArgs{...} }
type PolicyAttachmentArrayInput interface {
pulumi.Input
ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput
ToPolicyAttachmentArrayOutputWithContext(context.Context) PolicyAttachmentArrayOutput
}
type PolicyAttachmentArray []PolicyAttachmentInput
func (PolicyAttachmentArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*PolicyAttachment)(nil)).Elem()
}
func (i PolicyAttachmentArray) ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput {
return i.ToPolicyAttachmentArrayOutputWithContext(context.Background())
}
func (i PolicyAttachmentArray) ToPolicyAttachmentArrayOutputWithContext(ctx context.Context) PolicyAttachmentArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentArrayOutput)
}
// PolicyAttachmentMapInput is an input type that accepts PolicyAttachmentMap and PolicyAttachmentMapOutput values.
// You can construct a concrete instance of `PolicyAttachmentMapInput` via:
//
// PolicyAttachmentMap{ "key": PolicyAttachmentArgs{...} }
type PolicyAttachmentMapInput interface {
pulumi.Input
ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput
ToPolicyAttachmentMapOutputWithContext(context.Context) PolicyAttachmentMapOutput
}
type PolicyAttachmentMap map[string]PolicyAttachmentInput
func (PolicyAttachmentMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*PolicyAttachment)(nil)).Elem()
}
func (i PolicyAttachmentMap) ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput {
return i.ToPolicyAttachmentMapOutputWithContext(context.Background())
}
func (i PolicyAttachmentMap) ToPolicyAttachmentMapOutputWithContext(ctx context.Context) PolicyAttachmentMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(PolicyAttachmentMapOutput)
}
type PolicyAttachmentOutput struct{ *pulumi.OutputState }
func (PolicyAttachmentOutput) ElementType() reflect.Type {
return reflect.TypeOf((*PolicyAttachment)(nil))
}
func (o PolicyAttachmentOutput) ToPolicyAttachmentOutput() PolicyAttachmentOutput {
return o
}
func (o PolicyAttachmentOutput) ToPolicyAttachmentOutputWithContext(ctx context.Context) PolicyAttachmentOutput {
return o
}
func (o PolicyAttachmentOutput) ToPolicyAttachmentPtrOutput() PolicyAttachmentPtrOutput {
return o.ToPolicyAttachmentPtrOutputWithContext(context.Background())
}
func (o PolicyAttachmentOutput) ToPolicyAttachmentPtrOutputWithContext(ctx context.Context) PolicyAttachmentPtrOutput {
return o.ApplyTWithContext(ctx, func(_ context.Context, v PolicyAttachment) *PolicyAttachment {
return &v
}).(PolicyAttachmentPtrOutput)
}
type PolicyAttachmentPtrOutput struct{ *pulumi.OutputState }
func (PolicyAttachmentPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**PolicyAttachment)(nil))
}
func (o PolicyAttachmentPtrOutput) ToPolicyAttachmentPtrOutput() PolicyAttachmentPtrOutput {
return o
}
func (o PolicyAttachmentPtrOutput) ToPolicyAttachmentPtrOutputWithContext(ctx context.Context) PolicyAttachmentPtrOutput {
return o
}
func (o PolicyAttachmentPtrOutput) Elem() PolicyAttachmentOutput {
return o.ApplyT(func(v *PolicyAttachment) PolicyAttachment {
if v != nil {
return *v
}
var ret PolicyAttachment
return ret
}).(PolicyAttachmentOutput)
}
type PolicyAttachmentArrayOutput struct{ *pulumi.OutputState }
func (PolicyAttachmentArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]PolicyAttachment)(nil))
}
func (o PolicyAttachmentArrayOutput) ToPolicyAttachmentArrayOutput() PolicyAttachmentArrayOutput {
return o
}
func (o PolicyAttachmentArrayOutput) ToPolicyAttachmentArrayOutputWithContext(ctx context.Context) PolicyAttachmentArrayOutput {
return o
}
func (o PolicyAttachmentArrayOutput) Index(i pulumi.IntInput) PolicyAttachmentOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) PolicyAttachment {
return vs[0].([]PolicyAttachment)[vs[1].(int)]
}).(PolicyAttachmentOutput)
}
type PolicyAttachmentMapOutput struct{ *pulumi.OutputState }
func (PolicyAttachmentMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]PolicyAttachment)(nil))
}
func (o PolicyAttachmentMapOutput) ToPolicyAttachmentMapOutput() PolicyAttachmentMapOutput {
return o
}
func (o PolicyAttachmentMapOutput) ToPolicyAttachmentMapOutputWithContext(ctx context.Context) PolicyAttachmentMapOutput {
return o
}
func (o PolicyAttachmentMapOutput) MapIndex(k pulumi.StringInput) PolicyAttachmentOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) PolicyAttachment {
return vs[0].(map[string]PolicyAttachment)[vs[1].(string)]
}).(PolicyAttachmentOutput)
}
func init() {
pulumi.RegisterOutputType(PolicyAttachmentOutput{})
pulumi.RegisterOutputType(PolicyAttachmentPtrOutput{})
pulumi.RegisterOutputType(PolicyAttachmentArrayOutput{})
pulumi.RegisterOutputType(PolicyAttachmentMapOutput{})
}