/
originAccessIdentity.go
443 lines (391 loc) · 16.2 KB
/
originAccessIdentity.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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
// 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 cloudfront
import (
"context"
"reflect"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// Creates an Amazon CloudFront origin access identity.
//
// For information about CloudFront distributions, see the
// [Amazon CloudFront Developer Guide](http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html). For more information on generating
// origin access identities, see
// [Using an Origin Access Identity to Restrict Access to Your Amazon S3 Content][2].
//
// ## Example Usage
//
// The following example below creates a CloudFront origin access identity.
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := cloudfront.NewOriginAccessIdentity(ctx, "example", &cloudfront.OriginAccessIdentityArgs{
// Comment: pulumi.String("Some comment"),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ## Using With CloudFront
//
// Normally, when referencing an origin access identity in CloudFront, you need to
// prefix the ID with the `origin-access-identity/cloudfront/` special path.
// The `cloudfrontAccessIdentityPath` allows this to be circumvented.
// The below snippet demonstrates use with the `s3OriginConfig` structure for the
// `cloudfront.Distribution` resource:
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/cloudfront"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := cloudfront.NewDistribution(ctx, "example", &cloudfront.DistributionArgs{
// Origins: cloudfront.DistributionOriginArray{
// &cloudfront.DistributionOriginArgs{
// S3OriginConfig: &cloudfront.DistributionOriginS3OriginConfigArgs{
// OriginAccessIdentity: pulumi.Any(exampleAwsCloudfrontOriginAccessIdentity.CloudfrontAccessIdentityPath),
// },
// },
// },
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
//
// ```
// <!--End PulumiCodeChooser -->
//
// ### Updating your bucket policy
//
// Note that the AWS API may translate the `s3CanonicalUserId` `CanonicalUser`
// principal into an `AWS` IAM ARN principal when supplied in an
// `s3.BucketV2` bucket policy, causing spurious diffs. If
// you see this behaviour, use the `iamArn` instead:
//
// <!--Start PulumiCodeChooser -->
// ```go
// package main
//
// import (
//
// "fmt"
//
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
// "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3"
// "github.com/pulumi/pulumi/sdk/v3/go/pulumi"
//
// )
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// s3Policy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
// Statements: []iam.GetPolicyDocumentStatement{
// {
// Actions: []string{
// "s3:GetObject",
// },
// Resources: []string{
// fmt.Sprintf("%v/*", exampleAwsS3Bucket.Arn),
// },
// Principals: []iam.GetPolicyDocumentStatementPrincipal{
// {
// Type: "AWS",
// Identifiers: interface{}{
// exampleAwsCloudfrontOriginAccessIdentity.IamArn,
// },
// },
// },
// },
// },
// }, nil);
// if err != nil {
// return err
// }
// _, err = s3.NewBucketPolicy(ctx, "example", &s3.BucketPolicyArgs{
// Bucket: pulumi.Any(exampleAwsS3Bucket.Id),
// Policy: pulumi.String(s3Policy.Json),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
// <!--End PulumiCodeChooser -->
//
// ## Import
//
// Using `pulumi import`, import Cloudfront Origin Access Identities using the `id`. For example:
//
// ```sh
// $ pulumi import aws:cloudfront/originAccessIdentity:OriginAccessIdentity origin_access E74FTE3AEXAMPLE
// ```
//
// [2]: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
//
// [1]: http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Introduction.html
type OriginAccessIdentity struct {
pulumi.CustomResourceState
// Internal value used by CloudFront to allow future
// updates to the origin access identity.
CallerReference pulumi.StringOutput `pulumi:"callerReference"`
// A shortcut to the full path for the
// origin access identity to use in CloudFront, see below.
CloudfrontAccessIdentityPath pulumi.StringOutput `pulumi:"cloudfrontAccessIdentityPath"`
// An optional comment for the origin access identity.
Comment pulumi.StringPtrOutput `pulumi:"comment"`
// The current version of the origin access identity's information.
// For example: `E2QWRUHAPOMQZL`.
Etag pulumi.StringOutput `pulumi:"etag"`
// A pre-generated ARN for use in S3 bucket policies (see below).
// Example: `arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity
// E2QWRUHAPOMQZL`.
IamArn pulumi.StringOutput `pulumi:"iamArn"`
// The Amazon S3 canonical user ID for the origin
// access identity, which you use when giving the origin access identity read
// permission to an object in Amazon S3.
S3CanonicalUserId pulumi.StringOutput `pulumi:"s3CanonicalUserId"`
}
// NewOriginAccessIdentity registers a new resource with the given unique name, arguments, and options.
func NewOriginAccessIdentity(ctx *pulumi.Context,
name string, args *OriginAccessIdentityArgs, opts ...pulumi.ResourceOption) (*OriginAccessIdentity, error) {
if args == nil {
args = &OriginAccessIdentityArgs{}
}
opts = internal.PkgResourceDefaultOpts(opts)
var resource OriginAccessIdentity
err := ctx.RegisterResource("aws:cloudfront/originAccessIdentity:OriginAccessIdentity", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetOriginAccessIdentity gets an existing OriginAccessIdentity 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 GetOriginAccessIdentity(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *OriginAccessIdentityState, opts ...pulumi.ResourceOption) (*OriginAccessIdentity, error) {
var resource OriginAccessIdentity
err := ctx.ReadResource("aws:cloudfront/originAccessIdentity:OriginAccessIdentity", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering OriginAccessIdentity resources.
type originAccessIdentityState struct {
// Internal value used by CloudFront to allow future
// updates to the origin access identity.
CallerReference *string `pulumi:"callerReference"`
// A shortcut to the full path for the
// origin access identity to use in CloudFront, see below.
CloudfrontAccessIdentityPath *string `pulumi:"cloudfrontAccessIdentityPath"`
// An optional comment for the origin access identity.
Comment *string `pulumi:"comment"`
// The current version of the origin access identity's information.
// For example: `E2QWRUHAPOMQZL`.
Etag *string `pulumi:"etag"`
// A pre-generated ARN for use in S3 bucket policies (see below).
// Example: `arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity
// E2QWRUHAPOMQZL`.
IamArn *string `pulumi:"iamArn"`
// The Amazon S3 canonical user ID for the origin
// access identity, which you use when giving the origin access identity read
// permission to an object in Amazon S3.
S3CanonicalUserId *string `pulumi:"s3CanonicalUserId"`
}
type OriginAccessIdentityState struct {
// Internal value used by CloudFront to allow future
// updates to the origin access identity.
CallerReference pulumi.StringPtrInput
// A shortcut to the full path for the
// origin access identity to use in CloudFront, see below.
CloudfrontAccessIdentityPath pulumi.StringPtrInput
// An optional comment for the origin access identity.
Comment pulumi.StringPtrInput
// The current version of the origin access identity's information.
// For example: `E2QWRUHAPOMQZL`.
Etag pulumi.StringPtrInput
// A pre-generated ARN for use in S3 bucket policies (see below).
// Example: `arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity
// E2QWRUHAPOMQZL`.
IamArn pulumi.StringPtrInput
// The Amazon S3 canonical user ID for the origin
// access identity, which you use when giving the origin access identity read
// permission to an object in Amazon S3.
S3CanonicalUserId pulumi.StringPtrInput
}
func (OriginAccessIdentityState) ElementType() reflect.Type {
return reflect.TypeOf((*originAccessIdentityState)(nil)).Elem()
}
type originAccessIdentityArgs struct {
// An optional comment for the origin access identity.
Comment *string `pulumi:"comment"`
}
// The set of arguments for constructing a OriginAccessIdentity resource.
type OriginAccessIdentityArgs struct {
// An optional comment for the origin access identity.
Comment pulumi.StringPtrInput
}
func (OriginAccessIdentityArgs) ElementType() reflect.Type {
return reflect.TypeOf((*originAccessIdentityArgs)(nil)).Elem()
}
type OriginAccessIdentityInput interface {
pulumi.Input
ToOriginAccessIdentityOutput() OriginAccessIdentityOutput
ToOriginAccessIdentityOutputWithContext(ctx context.Context) OriginAccessIdentityOutput
}
func (*OriginAccessIdentity) ElementType() reflect.Type {
return reflect.TypeOf((**OriginAccessIdentity)(nil)).Elem()
}
func (i *OriginAccessIdentity) ToOriginAccessIdentityOutput() OriginAccessIdentityOutput {
return i.ToOriginAccessIdentityOutputWithContext(context.Background())
}
func (i *OriginAccessIdentity) ToOriginAccessIdentityOutputWithContext(ctx context.Context) OriginAccessIdentityOutput {
return pulumi.ToOutputWithContext(ctx, i).(OriginAccessIdentityOutput)
}
// OriginAccessIdentityArrayInput is an input type that accepts OriginAccessIdentityArray and OriginAccessIdentityArrayOutput values.
// You can construct a concrete instance of `OriginAccessIdentityArrayInput` via:
//
// OriginAccessIdentityArray{ OriginAccessIdentityArgs{...} }
type OriginAccessIdentityArrayInput interface {
pulumi.Input
ToOriginAccessIdentityArrayOutput() OriginAccessIdentityArrayOutput
ToOriginAccessIdentityArrayOutputWithContext(context.Context) OriginAccessIdentityArrayOutput
}
type OriginAccessIdentityArray []OriginAccessIdentityInput
func (OriginAccessIdentityArray) ElementType() reflect.Type {
return reflect.TypeOf((*[]*OriginAccessIdentity)(nil)).Elem()
}
func (i OriginAccessIdentityArray) ToOriginAccessIdentityArrayOutput() OriginAccessIdentityArrayOutput {
return i.ToOriginAccessIdentityArrayOutputWithContext(context.Background())
}
func (i OriginAccessIdentityArray) ToOriginAccessIdentityArrayOutputWithContext(ctx context.Context) OriginAccessIdentityArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(OriginAccessIdentityArrayOutput)
}
// OriginAccessIdentityMapInput is an input type that accepts OriginAccessIdentityMap and OriginAccessIdentityMapOutput values.
// You can construct a concrete instance of `OriginAccessIdentityMapInput` via:
//
// OriginAccessIdentityMap{ "key": OriginAccessIdentityArgs{...} }
type OriginAccessIdentityMapInput interface {
pulumi.Input
ToOriginAccessIdentityMapOutput() OriginAccessIdentityMapOutput
ToOriginAccessIdentityMapOutputWithContext(context.Context) OriginAccessIdentityMapOutput
}
type OriginAccessIdentityMap map[string]OriginAccessIdentityInput
func (OriginAccessIdentityMap) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*OriginAccessIdentity)(nil)).Elem()
}
func (i OriginAccessIdentityMap) ToOriginAccessIdentityMapOutput() OriginAccessIdentityMapOutput {
return i.ToOriginAccessIdentityMapOutputWithContext(context.Background())
}
func (i OriginAccessIdentityMap) ToOriginAccessIdentityMapOutputWithContext(ctx context.Context) OriginAccessIdentityMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(OriginAccessIdentityMapOutput)
}
type OriginAccessIdentityOutput struct{ *pulumi.OutputState }
func (OriginAccessIdentityOutput) ElementType() reflect.Type {
return reflect.TypeOf((**OriginAccessIdentity)(nil)).Elem()
}
func (o OriginAccessIdentityOutput) ToOriginAccessIdentityOutput() OriginAccessIdentityOutput {
return o
}
func (o OriginAccessIdentityOutput) ToOriginAccessIdentityOutputWithContext(ctx context.Context) OriginAccessIdentityOutput {
return o
}
// Internal value used by CloudFront to allow future
// updates to the origin access identity.
func (o OriginAccessIdentityOutput) CallerReference() pulumi.StringOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringOutput { return v.CallerReference }).(pulumi.StringOutput)
}
// A shortcut to the full path for the
// origin access identity to use in CloudFront, see below.
func (o OriginAccessIdentityOutput) CloudfrontAccessIdentityPath() pulumi.StringOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringOutput { return v.CloudfrontAccessIdentityPath }).(pulumi.StringOutput)
}
// An optional comment for the origin access identity.
func (o OriginAccessIdentityOutput) Comment() pulumi.StringPtrOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringPtrOutput { return v.Comment }).(pulumi.StringPtrOutput)
}
// The current version of the origin access identity's information.
// For example: `E2QWRUHAPOMQZL`.
func (o OriginAccessIdentityOutput) Etag() pulumi.StringOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringOutput { return v.Etag }).(pulumi.StringOutput)
}
// A pre-generated ARN for use in S3 bucket policies (see below).
// Example: `arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity
// E2QWRUHAPOMQZL`.
func (o OriginAccessIdentityOutput) IamArn() pulumi.StringOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringOutput { return v.IamArn }).(pulumi.StringOutput)
}
// The Amazon S3 canonical user ID for the origin
// access identity, which you use when giving the origin access identity read
// permission to an object in Amazon S3.
func (o OriginAccessIdentityOutput) S3CanonicalUserId() pulumi.StringOutput {
return o.ApplyT(func(v *OriginAccessIdentity) pulumi.StringOutput { return v.S3CanonicalUserId }).(pulumi.StringOutput)
}
type OriginAccessIdentityArrayOutput struct{ *pulumi.OutputState }
func (OriginAccessIdentityArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]*OriginAccessIdentity)(nil)).Elem()
}
func (o OriginAccessIdentityArrayOutput) ToOriginAccessIdentityArrayOutput() OriginAccessIdentityArrayOutput {
return o
}
func (o OriginAccessIdentityArrayOutput) ToOriginAccessIdentityArrayOutputWithContext(ctx context.Context) OriginAccessIdentityArrayOutput {
return o
}
func (o OriginAccessIdentityArrayOutput) Index(i pulumi.IntInput) OriginAccessIdentityOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) *OriginAccessIdentity {
return vs[0].([]*OriginAccessIdentity)[vs[1].(int)]
}).(OriginAccessIdentityOutput)
}
type OriginAccessIdentityMapOutput struct{ *pulumi.OutputState }
func (OriginAccessIdentityMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]*OriginAccessIdentity)(nil)).Elem()
}
func (o OriginAccessIdentityMapOutput) ToOriginAccessIdentityMapOutput() OriginAccessIdentityMapOutput {
return o
}
func (o OriginAccessIdentityMapOutput) ToOriginAccessIdentityMapOutputWithContext(ctx context.Context) OriginAccessIdentityMapOutput {
return o
}
func (o OriginAccessIdentityMapOutput) MapIndex(k pulumi.StringInput) OriginAccessIdentityOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) *OriginAccessIdentity {
return vs[0].(map[string]*OriginAccessIdentity)[vs[1].(string)]
}).(OriginAccessIdentityOutput)
}
func init() {
pulumi.RegisterInputType(reflect.TypeOf((*OriginAccessIdentityInput)(nil)).Elem(), &OriginAccessIdentity{})
pulumi.RegisterInputType(reflect.TypeOf((*OriginAccessIdentityArrayInput)(nil)).Elem(), OriginAccessIdentityArray{})
pulumi.RegisterInputType(reflect.TypeOf((*OriginAccessIdentityMapInput)(nil)).Elem(), OriginAccessIdentityMap{})
pulumi.RegisterOutputType(OriginAccessIdentityOutput{})
pulumi.RegisterOutputType(OriginAccessIdentityArrayOutput{})
pulumi.RegisterOutputType(OriginAccessIdentityMapOutput{})
}