/
bucketPublicAccessBlock.go
369 lines (309 loc) · 19.3 KB
/
bucketPublicAccessBlock.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
// *** 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 s3
import (
"context"
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Manages S3 bucket-level Public Access Block configuration. For more information about these settings, see the [AWS S3 Block Public Access documentation](https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-block-public-access.html).
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-aws/sdk/v3/go/aws/s3"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// exampleBucket, err := s3.NewBucket(ctx, "exampleBucket", nil)
// if err != nil {
// return err
// }
// _, err = s3.NewBucketPublicAccessBlock(ctx, "exampleBucketPublicAccessBlock", &s3.BucketPublicAccessBlockArgs{
// Bucket: exampleBucket.ID(),
// BlockPublicAcls: pulumi.Bool(true),
// BlockPublicPolicy: pulumi.Bool(true),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
//
// ## Import
//
// `aws_s3_bucket_public_access_block` can be imported by using the bucket name, e.g.
//
// ```sh
// $ pulumi import aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock example my-bucket
// ```
type BucketPublicAccessBlock struct {
pulumi.CustomResourceState
// Whether Amazon S3 should block public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect existing policies or ACLs. When set to `true` causes the following behavior:
// * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access.
// * PUT Object calls will fail if the request includes an object ACL.
BlockPublicAcls pulumi.BoolPtrOutput `pulumi:"blockPublicAcls"`
// Whether Amazon S3 should block public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the existing bucket policy. When set to `true` causes Amazon S3 to:
// * Reject calls to PUT Bucket policy if the specified bucket policy allows public access.
BlockPublicPolicy pulumi.BoolPtrOutput `pulumi:"blockPublicPolicy"`
// S3 Bucket to which this Public Access Block configuration should be applied.
Bucket pulumi.StringOutput `pulumi:"bucket"`
// Whether Amazon S3 should ignore public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect the persistence of any existing ACLs and doesn't prevent new public ACLs from being set. When set to `true` causes Amazon S3 to:
// * Ignore public ACLs on this bucket and any objects that it contains.
IgnorePublicAcls pulumi.BoolPtrOutput `pulumi:"ignorePublicAcls"`
// Whether Amazon S3 should restrict public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the previously stored bucket policy, except that public and cross-account access within the public bucket policy, including non-public delegation to specific accounts, is blocked. When set to `true`:
// * Only the bucket owner and AWS Services can access this buckets if it has a public policy.
RestrictPublicBuckets pulumi.BoolPtrOutput `pulumi:"restrictPublicBuckets"`
}
// NewBucketPublicAccessBlock registers a new resource with the given unique name, arguments, and options.
func NewBucketPublicAccessBlock(ctx *pulumi.Context,
name string, args *BucketPublicAccessBlockArgs, opts ...pulumi.ResourceOption) (*BucketPublicAccessBlock, error) {
if args == nil {
return nil, errors.New("missing one or more required arguments")
}
if args.Bucket == nil {
return nil, errors.New("invalid value for required argument 'Bucket'")
}
var resource BucketPublicAccessBlock
err := ctx.RegisterResource("aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetBucketPublicAccessBlock gets an existing BucketPublicAccessBlock 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 GetBucketPublicAccessBlock(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *BucketPublicAccessBlockState, opts ...pulumi.ResourceOption) (*BucketPublicAccessBlock, error) {
var resource BucketPublicAccessBlock
err := ctx.ReadResource("aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering BucketPublicAccessBlock resources.
type bucketPublicAccessBlockState struct {
// Whether Amazon S3 should block public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect existing policies or ACLs. When set to `true` causes the following behavior:
// * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access.
// * PUT Object calls will fail if the request includes an object ACL.
BlockPublicAcls *bool `pulumi:"blockPublicAcls"`
// Whether Amazon S3 should block public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the existing bucket policy. When set to `true` causes Amazon S3 to:
// * Reject calls to PUT Bucket policy if the specified bucket policy allows public access.
BlockPublicPolicy *bool `pulumi:"blockPublicPolicy"`
// S3 Bucket to which this Public Access Block configuration should be applied.
Bucket *string `pulumi:"bucket"`
// Whether Amazon S3 should ignore public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect the persistence of any existing ACLs and doesn't prevent new public ACLs from being set. When set to `true` causes Amazon S3 to:
// * Ignore public ACLs on this bucket and any objects that it contains.
IgnorePublicAcls *bool `pulumi:"ignorePublicAcls"`
// Whether Amazon S3 should restrict public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the previously stored bucket policy, except that public and cross-account access within the public bucket policy, including non-public delegation to specific accounts, is blocked. When set to `true`:
// * Only the bucket owner and AWS Services can access this buckets if it has a public policy.
RestrictPublicBuckets *bool `pulumi:"restrictPublicBuckets"`
}
type BucketPublicAccessBlockState struct {
// Whether Amazon S3 should block public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect existing policies or ACLs. When set to `true` causes the following behavior:
// * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access.
// * PUT Object calls will fail if the request includes an object ACL.
BlockPublicAcls pulumi.BoolPtrInput
// Whether Amazon S3 should block public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the existing bucket policy. When set to `true` causes Amazon S3 to:
// * Reject calls to PUT Bucket policy if the specified bucket policy allows public access.
BlockPublicPolicy pulumi.BoolPtrInput
// S3 Bucket to which this Public Access Block configuration should be applied.
Bucket pulumi.StringPtrInput
// Whether Amazon S3 should ignore public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect the persistence of any existing ACLs and doesn't prevent new public ACLs from being set. When set to `true` causes Amazon S3 to:
// * Ignore public ACLs on this bucket and any objects that it contains.
IgnorePublicAcls pulumi.BoolPtrInput
// Whether Amazon S3 should restrict public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the previously stored bucket policy, except that public and cross-account access within the public bucket policy, including non-public delegation to specific accounts, is blocked. When set to `true`:
// * Only the bucket owner and AWS Services can access this buckets if it has a public policy.
RestrictPublicBuckets pulumi.BoolPtrInput
}
func (BucketPublicAccessBlockState) ElementType() reflect.Type {
return reflect.TypeOf((*bucketPublicAccessBlockState)(nil)).Elem()
}
type bucketPublicAccessBlockArgs struct {
// Whether Amazon S3 should block public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect existing policies or ACLs. When set to `true` causes the following behavior:
// * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access.
// * PUT Object calls will fail if the request includes an object ACL.
BlockPublicAcls *bool `pulumi:"blockPublicAcls"`
// Whether Amazon S3 should block public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the existing bucket policy. When set to `true` causes Amazon S3 to:
// * Reject calls to PUT Bucket policy if the specified bucket policy allows public access.
BlockPublicPolicy *bool `pulumi:"blockPublicPolicy"`
// S3 Bucket to which this Public Access Block configuration should be applied.
Bucket string `pulumi:"bucket"`
// Whether Amazon S3 should ignore public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect the persistence of any existing ACLs and doesn't prevent new public ACLs from being set. When set to `true` causes Amazon S3 to:
// * Ignore public ACLs on this bucket and any objects that it contains.
IgnorePublicAcls *bool `pulumi:"ignorePublicAcls"`
// Whether Amazon S3 should restrict public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the previously stored bucket policy, except that public and cross-account access within the public bucket policy, including non-public delegation to specific accounts, is blocked. When set to `true`:
// * Only the bucket owner and AWS Services can access this buckets if it has a public policy.
RestrictPublicBuckets *bool `pulumi:"restrictPublicBuckets"`
}
// The set of arguments for constructing a BucketPublicAccessBlock resource.
type BucketPublicAccessBlockArgs struct {
// Whether Amazon S3 should block public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect existing policies or ACLs. When set to `true` causes the following behavior:
// * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access.
// * PUT Object calls will fail if the request includes an object ACL.
BlockPublicAcls pulumi.BoolPtrInput
// Whether Amazon S3 should block public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the existing bucket policy. When set to `true` causes Amazon S3 to:
// * Reject calls to PUT Bucket policy if the specified bucket policy allows public access.
BlockPublicPolicy pulumi.BoolPtrInput
// S3 Bucket to which this Public Access Block configuration should be applied.
Bucket pulumi.StringInput
// Whether Amazon S3 should ignore public ACLs for this bucket. Defaults to `false`. Enabling this setting does not affect the persistence of any existing ACLs and doesn't prevent new public ACLs from being set. When set to `true` causes Amazon S3 to:
// * Ignore public ACLs on this bucket and any objects that it contains.
IgnorePublicAcls pulumi.BoolPtrInput
// Whether Amazon S3 should restrict public bucket policies for this bucket. Defaults to `false`. Enabling this setting does not affect the previously stored bucket policy, except that public and cross-account access within the public bucket policy, including non-public delegation to specific accounts, is blocked. When set to `true`:
// * Only the bucket owner and AWS Services can access this buckets if it has a public policy.
RestrictPublicBuckets pulumi.BoolPtrInput
}
func (BucketPublicAccessBlockArgs) ElementType() reflect.Type {
return reflect.TypeOf((*bucketPublicAccessBlockArgs)(nil)).Elem()
}
type BucketPublicAccessBlockInput interface {
pulumi.Input
ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput
ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput
}
func (*BucketPublicAccessBlock) ElementType() reflect.Type {
return reflect.TypeOf((*BucketPublicAccessBlock)(nil))
}
func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput {
return i.ToBucketPublicAccessBlockOutputWithContext(context.Background())
}
func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockOutput)
}
func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockPtrOutput() BucketPublicAccessBlockPtrOutput {
return i.ToBucketPublicAccessBlockPtrOutputWithContext(context.Background())
}
func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockPtrOutputWithContext(ctx context.Context) BucketPublicAccessBlockPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockPtrOutput)
}
type BucketPublicAccessBlockPtrInput interface {
pulumi.Input
ToBucketPublicAccessBlockPtrOutput() BucketPublicAccessBlockPtrOutput
ToBucketPublicAccessBlockPtrOutputWithContext(ctx context.Context) BucketPublicAccessBlockPtrOutput
}
type bucketPublicAccessBlockPtrType BucketPublicAccessBlockArgs
func (*bucketPublicAccessBlockPtrType) ElementType() reflect.Type {
return reflect.TypeOf((**BucketPublicAccessBlock)(nil))
}
func (i *bucketPublicAccessBlockPtrType) ToBucketPublicAccessBlockPtrOutput() BucketPublicAccessBlockPtrOutput {
return i.ToBucketPublicAccessBlockPtrOutputWithContext(context.Background())
}
func (i *bucketPublicAccessBlockPtrType) ToBucketPublicAccessBlockPtrOutputWithContext(ctx context.Context) BucketPublicAccessBlockPtrOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockPtrOutput)
}
// BucketPublicAccessBlockArrayInput is an input type that accepts BucketPublicAccessBlockArray and BucketPublicAccessBlockArrayOutput values.
// You can construct a concrete instance of `BucketPublicAccessBlockArrayInput` via:
//
// BucketPublicAccessBlockArray{ BucketPublicAccessBlockArgs{...} }
type BucketPublicAccessBlockArrayInput interface {
pulumi.Input
ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput
ToBucketPublicAccessBlockArrayOutputWithContext(context.Context) BucketPublicAccessBlockArrayOutput
}
type BucketPublicAccessBlockArray []BucketPublicAccessBlockInput
func (BucketPublicAccessBlockArray) ElementType() reflect.Type {
return reflect.TypeOf(([]*BucketPublicAccessBlock)(nil))
}
func (i BucketPublicAccessBlockArray) ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput {
return i.ToBucketPublicAccessBlockArrayOutputWithContext(context.Background())
}
func (i BucketPublicAccessBlockArray) ToBucketPublicAccessBlockArrayOutputWithContext(ctx context.Context) BucketPublicAccessBlockArrayOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockArrayOutput)
}
// BucketPublicAccessBlockMapInput is an input type that accepts BucketPublicAccessBlockMap and BucketPublicAccessBlockMapOutput values.
// You can construct a concrete instance of `BucketPublicAccessBlockMapInput` via:
//
// BucketPublicAccessBlockMap{ "key": BucketPublicAccessBlockArgs{...} }
type BucketPublicAccessBlockMapInput interface {
pulumi.Input
ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput
ToBucketPublicAccessBlockMapOutputWithContext(context.Context) BucketPublicAccessBlockMapOutput
}
type BucketPublicAccessBlockMap map[string]BucketPublicAccessBlockInput
func (BucketPublicAccessBlockMap) ElementType() reflect.Type {
return reflect.TypeOf((map[string]*BucketPublicAccessBlock)(nil))
}
func (i BucketPublicAccessBlockMap) ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput {
return i.ToBucketPublicAccessBlockMapOutputWithContext(context.Background())
}
func (i BucketPublicAccessBlockMap) ToBucketPublicAccessBlockMapOutputWithContext(ctx context.Context) BucketPublicAccessBlockMapOutput {
return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockMapOutput)
}
type BucketPublicAccessBlockOutput struct {
*pulumi.OutputState
}
func (BucketPublicAccessBlockOutput) ElementType() reflect.Type {
return reflect.TypeOf((*BucketPublicAccessBlock)(nil))
}
func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput {
return o
}
func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput {
return o
}
func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockPtrOutput() BucketPublicAccessBlockPtrOutput {
return o.ToBucketPublicAccessBlockPtrOutputWithContext(context.Background())
}
func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockPtrOutputWithContext(ctx context.Context) BucketPublicAccessBlockPtrOutput {
return o.ApplyT(func(v BucketPublicAccessBlock) *BucketPublicAccessBlock {
return &v
}).(BucketPublicAccessBlockPtrOutput)
}
type BucketPublicAccessBlockPtrOutput struct {
*pulumi.OutputState
}
func (BucketPublicAccessBlockPtrOutput) ElementType() reflect.Type {
return reflect.TypeOf((**BucketPublicAccessBlock)(nil))
}
func (o BucketPublicAccessBlockPtrOutput) ToBucketPublicAccessBlockPtrOutput() BucketPublicAccessBlockPtrOutput {
return o
}
func (o BucketPublicAccessBlockPtrOutput) ToBucketPublicAccessBlockPtrOutputWithContext(ctx context.Context) BucketPublicAccessBlockPtrOutput {
return o
}
type BucketPublicAccessBlockArrayOutput struct{ *pulumi.OutputState }
func (BucketPublicAccessBlockArrayOutput) ElementType() reflect.Type {
return reflect.TypeOf((*[]BucketPublicAccessBlock)(nil))
}
func (o BucketPublicAccessBlockArrayOutput) ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput {
return o
}
func (o BucketPublicAccessBlockArrayOutput) ToBucketPublicAccessBlockArrayOutputWithContext(ctx context.Context) BucketPublicAccessBlockArrayOutput {
return o
}
func (o BucketPublicAccessBlockArrayOutput) Index(i pulumi.IntInput) BucketPublicAccessBlockOutput {
return pulumi.All(o, i).ApplyT(func(vs []interface{}) BucketPublicAccessBlock {
return vs[0].([]BucketPublicAccessBlock)[vs[1].(int)]
}).(BucketPublicAccessBlockOutput)
}
type BucketPublicAccessBlockMapOutput struct{ *pulumi.OutputState }
func (BucketPublicAccessBlockMapOutput) ElementType() reflect.Type {
return reflect.TypeOf((*map[string]BucketPublicAccessBlock)(nil))
}
func (o BucketPublicAccessBlockMapOutput) ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput {
return o
}
func (o BucketPublicAccessBlockMapOutput) ToBucketPublicAccessBlockMapOutputWithContext(ctx context.Context) BucketPublicAccessBlockMapOutput {
return o
}
func (o BucketPublicAccessBlockMapOutput) MapIndex(k pulumi.StringInput) BucketPublicAccessBlockOutput {
return pulumi.All(o, k).ApplyT(func(vs []interface{}) BucketPublicAccessBlock {
return vs[0].(map[string]BucketPublicAccessBlock)[vs[1].(string)]
}).(BucketPublicAccessBlockOutput)
}
func init() {
pulumi.RegisterOutputType(BucketPublicAccessBlockOutput{})
pulumi.RegisterOutputType(BucketPublicAccessBlockPtrOutput{})
pulumi.RegisterOutputType(BucketPublicAccessBlockArrayOutput{})
pulumi.RegisterOutputType(BucketPublicAccessBlockMapOutput{})
}