github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketPublicAccessBlock.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 s3 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 // 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). 16 // 17 // > This resource cannot be used with S3 directory buckets. 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/s3" 28 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 29 // 30 // ) 31 // 32 // func main() { 33 // pulumi.Run(func(ctx *pulumi.Context) error { 34 // example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{ 35 // Bucket: pulumi.String("example"), 36 // }) 37 // if err != nil { 38 // return err 39 // } 40 // _, err = s3.NewBucketPublicAccessBlock(ctx, "example", &s3.BucketPublicAccessBlockArgs{ 41 // Bucket: example.ID(), 42 // BlockPublicAcls: pulumi.Bool(true), 43 // BlockPublicPolicy: pulumi.Bool(true), 44 // IgnorePublicAcls: pulumi.Bool(true), 45 // RestrictPublicBuckets: pulumi.Bool(true), 46 // }) 47 // if err != nil { 48 // return err 49 // } 50 // return nil 51 // }) 52 // } 53 // 54 // ``` 55 // <!--End PulumiCodeChooser --> 56 // 57 // ## Import 58 // 59 // Using `pulumi import`, import `aws_s3_bucket_public_access_block` using the bucket name. For example: 60 // 61 // ```sh 62 // $ pulumi import aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock example my-bucket 63 // ``` 64 type BucketPublicAccessBlock struct { 65 pulumi.CustomResourceState 66 67 // 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: 68 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 69 // * PUT Object calls will fail if the request includes an object ACL. 70 BlockPublicAcls pulumi.BoolPtrOutput `pulumi:"blockPublicAcls"` 71 // 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: 72 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 73 BlockPublicPolicy pulumi.BoolPtrOutput `pulumi:"blockPublicPolicy"` 74 // S3 Bucket to which this Public Access Block configuration should be applied. 75 Bucket pulumi.StringOutput `pulumi:"bucket"` 76 // 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: 77 // * Ignore public ACLs on this bucket and any objects that it contains. 78 IgnorePublicAcls pulumi.BoolPtrOutput `pulumi:"ignorePublicAcls"` 79 // 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`: 80 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 81 RestrictPublicBuckets pulumi.BoolPtrOutput `pulumi:"restrictPublicBuckets"` 82 } 83 84 // NewBucketPublicAccessBlock registers a new resource with the given unique name, arguments, and options. 85 func NewBucketPublicAccessBlock(ctx *pulumi.Context, 86 name string, args *BucketPublicAccessBlockArgs, opts ...pulumi.ResourceOption) (*BucketPublicAccessBlock, error) { 87 if args == nil { 88 return nil, errors.New("missing one or more required arguments") 89 } 90 91 if args.Bucket == nil { 92 return nil, errors.New("invalid value for required argument 'Bucket'") 93 } 94 opts = internal.PkgResourceDefaultOpts(opts) 95 var resource BucketPublicAccessBlock 96 err := ctx.RegisterResource("aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock", name, args, &resource, opts...) 97 if err != nil { 98 return nil, err 99 } 100 return &resource, nil 101 } 102 103 // GetBucketPublicAccessBlock gets an existing BucketPublicAccessBlock resource's state with the given name, ID, and optional 104 // state properties that are used to uniquely qualify the lookup (nil if not required). 105 func GetBucketPublicAccessBlock(ctx *pulumi.Context, 106 name string, id pulumi.IDInput, state *BucketPublicAccessBlockState, opts ...pulumi.ResourceOption) (*BucketPublicAccessBlock, error) { 107 var resource BucketPublicAccessBlock 108 err := ctx.ReadResource("aws:s3/bucketPublicAccessBlock:BucketPublicAccessBlock", name, id, state, &resource, opts...) 109 if err != nil { 110 return nil, err 111 } 112 return &resource, nil 113 } 114 115 // Input properties used for looking up and filtering BucketPublicAccessBlock resources. 116 type bucketPublicAccessBlockState struct { 117 // 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: 118 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 119 // * PUT Object calls will fail if the request includes an object ACL. 120 BlockPublicAcls *bool `pulumi:"blockPublicAcls"` 121 // 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: 122 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 123 BlockPublicPolicy *bool `pulumi:"blockPublicPolicy"` 124 // S3 Bucket to which this Public Access Block configuration should be applied. 125 Bucket *string `pulumi:"bucket"` 126 // 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: 127 // * Ignore public ACLs on this bucket and any objects that it contains. 128 IgnorePublicAcls *bool `pulumi:"ignorePublicAcls"` 129 // 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`: 130 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 131 RestrictPublicBuckets *bool `pulumi:"restrictPublicBuckets"` 132 } 133 134 type BucketPublicAccessBlockState struct { 135 // 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: 136 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 137 // * PUT Object calls will fail if the request includes an object ACL. 138 BlockPublicAcls pulumi.BoolPtrInput 139 // 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: 140 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 141 BlockPublicPolicy pulumi.BoolPtrInput 142 // S3 Bucket to which this Public Access Block configuration should be applied. 143 Bucket pulumi.StringPtrInput 144 // 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: 145 // * Ignore public ACLs on this bucket and any objects that it contains. 146 IgnorePublicAcls pulumi.BoolPtrInput 147 // 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`: 148 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 149 RestrictPublicBuckets pulumi.BoolPtrInput 150 } 151 152 func (BucketPublicAccessBlockState) ElementType() reflect.Type { 153 return reflect.TypeOf((*bucketPublicAccessBlockState)(nil)).Elem() 154 } 155 156 type bucketPublicAccessBlockArgs struct { 157 // 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: 158 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 159 // * PUT Object calls will fail if the request includes an object ACL. 160 BlockPublicAcls *bool `pulumi:"blockPublicAcls"` 161 // 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: 162 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 163 BlockPublicPolicy *bool `pulumi:"blockPublicPolicy"` 164 // S3 Bucket to which this Public Access Block configuration should be applied. 165 Bucket string `pulumi:"bucket"` 166 // 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: 167 // * Ignore public ACLs on this bucket and any objects that it contains. 168 IgnorePublicAcls *bool `pulumi:"ignorePublicAcls"` 169 // 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`: 170 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 171 RestrictPublicBuckets *bool `pulumi:"restrictPublicBuckets"` 172 } 173 174 // The set of arguments for constructing a BucketPublicAccessBlock resource. 175 type BucketPublicAccessBlockArgs struct { 176 // 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: 177 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 178 // * PUT Object calls will fail if the request includes an object ACL. 179 BlockPublicAcls pulumi.BoolPtrInput 180 // 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: 181 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 182 BlockPublicPolicy pulumi.BoolPtrInput 183 // S3 Bucket to which this Public Access Block configuration should be applied. 184 Bucket pulumi.StringInput 185 // 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: 186 // * Ignore public ACLs on this bucket and any objects that it contains. 187 IgnorePublicAcls pulumi.BoolPtrInput 188 // 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`: 189 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 190 RestrictPublicBuckets pulumi.BoolPtrInput 191 } 192 193 func (BucketPublicAccessBlockArgs) ElementType() reflect.Type { 194 return reflect.TypeOf((*bucketPublicAccessBlockArgs)(nil)).Elem() 195 } 196 197 type BucketPublicAccessBlockInput interface { 198 pulumi.Input 199 200 ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput 201 ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput 202 } 203 204 func (*BucketPublicAccessBlock) ElementType() reflect.Type { 205 return reflect.TypeOf((**BucketPublicAccessBlock)(nil)).Elem() 206 } 207 208 func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput { 209 return i.ToBucketPublicAccessBlockOutputWithContext(context.Background()) 210 } 211 212 func (i *BucketPublicAccessBlock) ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput { 213 return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockOutput) 214 } 215 216 // BucketPublicAccessBlockArrayInput is an input type that accepts BucketPublicAccessBlockArray and BucketPublicAccessBlockArrayOutput values. 217 // You can construct a concrete instance of `BucketPublicAccessBlockArrayInput` via: 218 // 219 // BucketPublicAccessBlockArray{ BucketPublicAccessBlockArgs{...} } 220 type BucketPublicAccessBlockArrayInput interface { 221 pulumi.Input 222 223 ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput 224 ToBucketPublicAccessBlockArrayOutputWithContext(context.Context) BucketPublicAccessBlockArrayOutput 225 } 226 227 type BucketPublicAccessBlockArray []BucketPublicAccessBlockInput 228 229 func (BucketPublicAccessBlockArray) ElementType() reflect.Type { 230 return reflect.TypeOf((*[]*BucketPublicAccessBlock)(nil)).Elem() 231 } 232 233 func (i BucketPublicAccessBlockArray) ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput { 234 return i.ToBucketPublicAccessBlockArrayOutputWithContext(context.Background()) 235 } 236 237 func (i BucketPublicAccessBlockArray) ToBucketPublicAccessBlockArrayOutputWithContext(ctx context.Context) BucketPublicAccessBlockArrayOutput { 238 return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockArrayOutput) 239 } 240 241 // BucketPublicAccessBlockMapInput is an input type that accepts BucketPublicAccessBlockMap and BucketPublicAccessBlockMapOutput values. 242 // You can construct a concrete instance of `BucketPublicAccessBlockMapInput` via: 243 // 244 // BucketPublicAccessBlockMap{ "key": BucketPublicAccessBlockArgs{...} } 245 type BucketPublicAccessBlockMapInput interface { 246 pulumi.Input 247 248 ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput 249 ToBucketPublicAccessBlockMapOutputWithContext(context.Context) BucketPublicAccessBlockMapOutput 250 } 251 252 type BucketPublicAccessBlockMap map[string]BucketPublicAccessBlockInput 253 254 func (BucketPublicAccessBlockMap) ElementType() reflect.Type { 255 return reflect.TypeOf((*map[string]*BucketPublicAccessBlock)(nil)).Elem() 256 } 257 258 func (i BucketPublicAccessBlockMap) ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput { 259 return i.ToBucketPublicAccessBlockMapOutputWithContext(context.Background()) 260 } 261 262 func (i BucketPublicAccessBlockMap) ToBucketPublicAccessBlockMapOutputWithContext(ctx context.Context) BucketPublicAccessBlockMapOutput { 263 return pulumi.ToOutputWithContext(ctx, i).(BucketPublicAccessBlockMapOutput) 264 } 265 266 type BucketPublicAccessBlockOutput struct{ *pulumi.OutputState } 267 268 func (BucketPublicAccessBlockOutput) ElementType() reflect.Type { 269 return reflect.TypeOf((**BucketPublicAccessBlock)(nil)).Elem() 270 } 271 272 func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockOutput() BucketPublicAccessBlockOutput { 273 return o 274 } 275 276 func (o BucketPublicAccessBlockOutput) ToBucketPublicAccessBlockOutputWithContext(ctx context.Context) BucketPublicAccessBlockOutput { 277 return o 278 } 279 280 // 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: 281 // * PUT Bucket acl and PUT Object acl calls will fail if the specified ACL allows public access. 282 // * PUT Object calls will fail if the request includes an object ACL. 283 func (o BucketPublicAccessBlockOutput) BlockPublicAcls() pulumi.BoolPtrOutput { 284 return o.ApplyT(func(v *BucketPublicAccessBlock) pulumi.BoolPtrOutput { return v.BlockPublicAcls }).(pulumi.BoolPtrOutput) 285 } 286 287 // 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: 288 // * Reject calls to PUT Bucket policy if the specified bucket policy allows public access. 289 func (o BucketPublicAccessBlockOutput) BlockPublicPolicy() pulumi.BoolPtrOutput { 290 return o.ApplyT(func(v *BucketPublicAccessBlock) pulumi.BoolPtrOutput { return v.BlockPublicPolicy }).(pulumi.BoolPtrOutput) 291 } 292 293 // S3 Bucket to which this Public Access Block configuration should be applied. 294 func (o BucketPublicAccessBlockOutput) Bucket() pulumi.StringOutput { 295 return o.ApplyT(func(v *BucketPublicAccessBlock) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput) 296 } 297 298 // 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: 299 // * Ignore public ACLs on this bucket and any objects that it contains. 300 func (o BucketPublicAccessBlockOutput) IgnorePublicAcls() pulumi.BoolPtrOutput { 301 return o.ApplyT(func(v *BucketPublicAccessBlock) pulumi.BoolPtrOutput { return v.IgnorePublicAcls }).(pulumi.BoolPtrOutput) 302 } 303 304 // 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`: 305 // * Only the bucket owner and AWS Services can access this buckets if it has a public policy. 306 func (o BucketPublicAccessBlockOutput) RestrictPublicBuckets() pulumi.BoolPtrOutput { 307 return o.ApplyT(func(v *BucketPublicAccessBlock) pulumi.BoolPtrOutput { return v.RestrictPublicBuckets }).(pulumi.BoolPtrOutput) 308 } 309 310 type BucketPublicAccessBlockArrayOutput struct{ *pulumi.OutputState } 311 312 func (BucketPublicAccessBlockArrayOutput) ElementType() reflect.Type { 313 return reflect.TypeOf((*[]*BucketPublicAccessBlock)(nil)).Elem() 314 } 315 316 func (o BucketPublicAccessBlockArrayOutput) ToBucketPublicAccessBlockArrayOutput() BucketPublicAccessBlockArrayOutput { 317 return o 318 } 319 320 func (o BucketPublicAccessBlockArrayOutput) ToBucketPublicAccessBlockArrayOutputWithContext(ctx context.Context) BucketPublicAccessBlockArrayOutput { 321 return o 322 } 323 324 func (o BucketPublicAccessBlockArrayOutput) Index(i pulumi.IntInput) BucketPublicAccessBlockOutput { 325 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketPublicAccessBlock { 326 return vs[0].([]*BucketPublicAccessBlock)[vs[1].(int)] 327 }).(BucketPublicAccessBlockOutput) 328 } 329 330 type BucketPublicAccessBlockMapOutput struct{ *pulumi.OutputState } 331 332 func (BucketPublicAccessBlockMapOutput) ElementType() reflect.Type { 333 return reflect.TypeOf((*map[string]*BucketPublicAccessBlock)(nil)).Elem() 334 } 335 336 func (o BucketPublicAccessBlockMapOutput) ToBucketPublicAccessBlockMapOutput() BucketPublicAccessBlockMapOutput { 337 return o 338 } 339 340 func (o BucketPublicAccessBlockMapOutput) ToBucketPublicAccessBlockMapOutputWithContext(ctx context.Context) BucketPublicAccessBlockMapOutput { 341 return o 342 } 343 344 func (o BucketPublicAccessBlockMapOutput) MapIndex(k pulumi.StringInput) BucketPublicAccessBlockOutput { 345 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketPublicAccessBlock { 346 return vs[0].(map[string]*BucketPublicAccessBlock)[vs[1].(string)] 347 }).(BucketPublicAccessBlockOutput) 348 } 349 350 func init() { 351 pulumi.RegisterInputType(reflect.TypeOf((*BucketPublicAccessBlockInput)(nil)).Elem(), &BucketPublicAccessBlock{}) 352 pulumi.RegisterInputType(reflect.TypeOf((*BucketPublicAccessBlockArrayInput)(nil)).Elem(), BucketPublicAccessBlockArray{}) 353 pulumi.RegisterInputType(reflect.TypeOf((*BucketPublicAccessBlockMapInput)(nil)).Elem(), BucketPublicAccessBlockMap{}) 354 pulumi.RegisterOutputType(BucketPublicAccessBlockOutput{}) 355 pulumi.RegisterOutputType(BucketPublicAccessBlockArrayOutput{}) 356 pulumi.RegisterOutputType(BucketPublicAccessBlockMapOutput{}) 357 }