/
instanceProfile.go
395 lines (340 loc) · 20.5 KB
/
instanceProfile.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
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
// Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
// *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
package iam
import (
"context"
"reflect"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Provides an IAM instance profile.
//
// > **NOTE:** When managing instance profiles, remember that the `name` attribute must always be unique. This means that even if you have different `role` or `path` values, duplicating an existing instance profile `name` will lead to an `EntityAlreadyExists` error.
//
// ## Example Usage
//
// <!--Start PulumiCodeChooser -->
// ```go
// 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 {
// assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
// Statements: []iam.GetPolicyDocumentStatement{
// {
// Effect: pulumi.StringRef("Allow"),
// Principals: []iam.GetPolicyDocumentStatementPrincipal{
// {
// Type: "Service",
// Identifiers: []string{
// "ec2.amazonaws.com",
// },
// },
// },
// Actions: []string{
// "sts:AssumeRole",
// },
// },
// },
// }, nil)
// if err != nil {
// return err
// }
// role, err := iam.NewRole(ctx, "role", &iam.RoleArgs{
// Name: pulumi.String("test_role"),
// Path: pulumi.String("/"),
// AssumeRolePolicy: pulumi.String(assumeRole.Json),
// })
// if err != nil {
// return err
// }
// _, err = iam.NewInstanceProfile(ctx, "test_profile", &iam.InstanceProfileArgs{
// Name: pulumi.String("test_profile"),
// Role: role.Name,
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import Instance Profiles using the `name`. For example:
//
// ```sh
// $ pulumi import aws:iam/instanceProfile:InstanceProfile test_profile app-instance-profile-1
// ```
type InstanceProfile struct {
pulumi.CustomResourceState
// ARN assigned by AWS to the instance profile.
Arn pulumi.StringOutput `pulumi:"arn"`
// Creation timestamp of the instance profile.
CreateDate pulumi.StringOutput `pulumi:"createDate"`
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
Name pulumi.StringOutput `pulumi:"name"`
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
NamePrefix pulumi.StringOutput `pulumi:"namePrefix"`
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
Path pulumi.StringPtrOutput `pulumi:"path"`
// Name of the role to add to the profile.
Role pulumi.StringPtrOutput `pulumi:"role"`
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapOutput `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapOutput `pulumi:"tagsAll"`
// [Unique ID][1] assigned by AWS.
UniqueId pulumi.StringOutput `pulumi:"uniqueId"`
}
// NewInstanceProfile registers a new resource with the given unique name, arguments, and options.
func NewInstanceProfile(ctx *pulumi.Context,
name string, args *InstanceProfileArgs, opts ...pulumi.ResourceOption) (*InstanceProfile, error) {
if args == nil {
args = &InstanceProfileArgs{}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource InstanceProfile
err := ctx.RegisterResource("aws:iam/instanceProfile:InstanceProfile", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetInstanceProfile gets an existing InstanceProfile 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 GetInstanceProfile(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *InstanceProfileState, opts ...pulumi.ResourceOption) (*InstanceProfile, error) {
var resource InstanceProfile
err := ctx.ReadResource("aws:iam/instanceProfile:InstanceProfile", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering InstanceProfile resources.
type instanceProfileState struct {
// ARN assigned by AWS to the instance profile.
Arn *string `pulumi:"arn"`
// Creation timestamp of the instance profile.
CreateDate *string `pulumi:"createDate"`
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
Name *string `pulumi:"name"`
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
NamePrefix *string `pulumi:"namePrefix"`
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
Path *string `pulumi:"path"`
// Name of the role to add to the profile.
Role interface{} `pulumi:"role"`
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll map[string]string `pulumi:"tagsAll"`
// [Unique ID][1] assigned by AWS.
UniqueId *string `pulumi:"uniqueId"`
}
type InstanceProfileState struct {
// ARN assigned by AWS to the instance profile.
Arn pulumi.StringPtrInput
// Creation timestamp of the instance profile.
CreateDate pulumi.StringPtrInput
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
Name pulumi.StringPtrInput
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
NamePrefix pulumi.StringPtrInput
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
Path pulumi.StringPtrInput
// Name of the role to add to the profile.
Role pulumi.Input
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
TagsAll pulumi.StringMapInput
// [Unique ID][1] assigned by AWS.
UniqueId pulumi.StringPtrInput
}
func (InstanceProfileState) ElementType() reflect.Type {
return reflect.TypeOf((*instanceProfileState)(nil)).Elem()
}
type instanceProfileArgs struct {
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
Name *string `pulumi:"name"`
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
NamePrefix *string `pulumi:"namePrefix"`
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
Path *string `pulumi:"path"`
// Name of the role to add to the profile.
Role interface{} `pulumi:"role"`
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags map[string]string `pulumi:"tags"`
}
// The set of arguments for constructing a InstanceProfile resource.
type InstanceProfileArgs struct {
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
Name pulumi.StringPtrInput
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
NamePrefix pulumi.StringPtrInput
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
Path pulumi.StringPtrInput
// Name of the role to add to the profile.
Role pulumi.Input
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
Tags pulumi.StringMapInput
}
func (InstanceProfileArgs) ElementType() reflect.Type {
return reflect.TypeOf((*instanceProfileArgs)(nil)).Elem()
}
type InstanceProfileInput interface {
pulumi.Input
ToInstanceProfileOutput() InstanceProfileOutput
ToInstanceProfileOutputWithContext(ctx context.Context) InstanceProfileOutput
}
func (*InstanceProfile) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceProfile)(nil)).Elem()
}
func (i *InstanceProfile) ToInstanceProfileOutput() InstanceProfileOutput {
return i.ToInstanceProfileOutputWithContext(context.Background())
}
func (i *InstanceProfile) ToInstanceProfileOutputWithContext(ctx context.Context) InstanceProfileOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceProfileOutput)
}
// InstanceProfileArrayInput is an input type that accepts InstanceProfileArray and InstanceProfileArrayOutput values.
// You can construct a concrete instance of `InstanceProfileArrayInput` via:
//
// InstanceProfileArray{ InstanceProfileArgs{...} }
type InstanceProfileArrayInput interface {
pulumi.Input
ToInstanceProfileArrayOutput() InstanceProfileArrayOutput
ToInstanceProfileArrayOutputWithContext(context.Context) InstanceProfileArrayOutput
}
type InstanceProfileArray []InstanceProfileInput
func (InstanceProfileArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*InstanceProfile)(nil)).Elem()
}
func (i InstanceProfileArray) ToInstanceProfileArrayOutput() InstanceProfileArrayOutput {
return i.ToInstanceProfileArrayOutputWithContext(context.Background())
}
func (i InstanceProfileArray) ToInstanceProfileArrayOutputWithContext(ctx context.Context) InstanceProfileArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceProfileArrayOutput)
}
// InstanceProfileMapInput is an input type that accepts InstanceProfileMap and InstanceProfileMapOutput values.
// You can construct a concrete instance of `InstanceProfileMapInput` via:
//
// InstanceProfileMap{ "key": InstanceProfileArgs{...} }
type InstanceProfileMapInput interface {
pulumi.Input
ToInstanceProfileMapOutput() InstanceProfileMapOutput
ToInstanceProfileMapOutputWithContext(context.Context) InstanceProfileMapOutput
}
type InstanceProfileMap map[string]InstanceProfileInput
func (InstanceProfileMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*InstanceProfile)(nil)).Elem()
}
func (i InstanceProfileMap) ToInstanceProfileMapOutput() InstanceProfileMapOutput {
return i.ToInstanceProfileMapOutputWithContext(context.Background())
}
func (i InstanceProfileMap) ToInstanceProfileMapOutputWithContext(ctx context.Context) InstanceProfileMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(InstanceProfileMapOutput)
}
type InstanceProfileOutput struct{ *pulumi.OutputState }
func (InstanceProfileOutput) ElementType() reflect.Type {
return reflect.TypeOf((**InstanceProfile)(nil)).Elem()
}
func (o InstanceProfileOutput) ToInstanceProfileOutput() InstanceProfileOutput {
return o
}
func (o InstanceProfileOutput) ToInstanceProfileOutputWithContext(ctx context.Context) InstanceProfileOutput {
return o
}
// ARN assigned by AWS to the instance profile.
func (o InstanceProfileOutput) Arn() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringOutput { return v.Arn }).(pulumi.StringOutput)
}
// Creation timestamp of the instance profile.
func (o InstanceProfileOutput) CreateDate() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringOutput { return v.CreateDate }).(pulumi.StringOutput)
}
// Name of the instance profile. If omitted, this provider will assign a random, unique name. Conflicts with `namePrefix`. Can be a string of characters consisting of upper and lowercase alphanumeric characters and these special characters: `_`, `+`, `=`, `,`, `.`, `@`, `-`. Spaces are not allowed. The `name` must be unique, regardless of the `path` or `role`. In other words, if there are different `role` or `path` values but the same `name` as an existing instance profile, it will still cause an `EntityAlreadyExists` error.
func (o InstanceProfileOutput) Name() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringOutput { return v.Name }).(pulumi.StringOutput)
}
// Creates a unique name beginning with the specified prefix. Conflicts with `name`.
func (o InstanceProfileOutput) NamePrefix() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringOutput { return v.NamePrefix }).(pulumi.StringOutput)
}
// Path to the instance profile. For more information about paths, see [IAM Identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html) in the IAM User Guide. Can be a string of characters consisting of either a forward slash (`/`) by itself or a string that must begin and end with forward slashes. Can include any ASCII character from the ! (\u0021) through the DEL character (\u007F), including most punctuation characters, digits, and upper and lowercase letters.
func (o InstanceProfileOutput) Path() pulumi.StringPtrOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringPtrOutput { return v.Path }).(pulumi.StringPtrOutput)
}
// Name of the role to add to the profile.
func (o InstanceProfileOutput) Role() pulumi.StringPtrOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringPtrOutput { return v.Role }).(pulumi.StringPtrOutput)
}
// Map of resource tags for the IAM Instance Profile. If configured with a provider `defaultTags` configuration block present, tags with matching keys will overwrite those defined at the provider-level.
func (o InstanceProfileOutput) Tags() pulumi.StringMapOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringMapOutput { return v.Tags }).(pulumi.StringMapOutput)
}
// A map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
//
// Deprecated: Please use `tags` instead.
func (o InstanceProfileOutput) TagsAll() pulumi.StringMapOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringMapOutput { return v.TagsAll }).(pulumi.StringMapOutput)
}
// [Unique ID][1] assigned by AWS.
func (o InstanceProfileOutput) UniqueId() pulumi.StringOutput {
return o.ApplyT(func(v *InstanceProfile) pulumi.StringOutput { return v.UniqueId }).(pulumi.StringOutput)
}
type InstanceProfileArrayOutput struct{ *pulumi.OutputState }
func (InstanceProfileArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*InstanceProfile)(nil)).Elem()
}
func (o InstanceProfileArrayOutput) ToInstanceProfileArrayOutput() InstanceProfileArrayOutput {
return o
}
func (o InstanceProfileArrayOutput) ToInstanceProfileArrayOutputWithContext(ctx context.Context) InstanceProfileArrayOutput {
return o
}
func (o InstanceProfileArrayOutput) Index(i pulumi.IntInput) InstanceProfileOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *InstanceProfile {
return vs[0].([]*InstanceProfile)[vs[1].(int)]
}).(InstanceProfileOutput)
}
type InstanceProfileMapOutput struct{ *pulumi.OutputState }
func (InstanceProfileMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*InstanceProfile)(nil)).Elem()
}
func (o InstanceProfileMapOutput) ToInstanceProfileMapOutput() InstanceProfileMapOutput {
return o
}
func (o InstanceProfileMapOutput) ToInstanceProfileMapOutputWithContext(ctx context.Context) InstanceProfileMapOutput {
return o
}
func (o InstanceProfileMapOutput) MapIndex(k pulumi.StringInput) InstanceProfileOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *InstanceProfile {
return vs[0].(map[string]*InstanceProfile)[vs[1].(string)]
}).(InstanceProfileOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*InstanceProfileInput)(nil)).Elem(), &InstanceProfile{})
pulumi.RegisterInputType(reflect.TypeOf((*InstanceProfileArrayInput)(nil)).Elem(), InstanceProfileArray{})
pulumi.RegisterInputType(reflect.TypeOf((*InstanceProfileMapInput)(nil)).Elem(), InstanceProfileMap{})
pulumi.RegisterOutputType(InstanceProfileOutput{})
pulumi.RegisterOutputType(InstanceProfileArrayOutput{})
pulumi.RegisterOutputType(InstanceProfileMapOutput{})
}