github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/s3/bucketObjectLockConfigurationV2.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 // Provides an S3 bucket Object Lock configuration resource. For more information about Object Locking, go to [Using S3 Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) in the Amazon S3 User Guide. 16 // 17 // > This resource can be used enable Object Lock for **new** and **existing** buckets. 18 // 19 // > This resource cannot be used with S3 directory buckets. 20 // 21 // ## Example Usage 22 // 23 // ### Object Lock configuration for new or existing buckets 24 // 25 // <!--Start PulumiCodeChooser --> 26 // ```go 27 // package main 28 // 29 // import ( 30 // 31 // "github.com/pulumi/pulumi-aws/sdk/v6/go/aws/s3" 32 // "github.com/pulumi/pulumi/sdk/v3/go/pulumi" 33 // 34 // ) 35 // 36 // func main() { 37 // pulumi.Run(func(ctx *pulumi.Context) error { 38 // example, err := s3.NewBucketV2(ctx, "example", &s3.BucketV2Args{ 39 // Bucket: pulumi.String("mybucket"), 40 // }) 41 // if err != nil { 42 // return err 43 // } 44 // _, err = s3.NewBucketVersioningV2(ctx, "example", &s3.BucketVersioningV2Args{ 45 // Bucket: example.ID(), 46 // VersioningConfiguration: &s3.BucketVersioningV2VersioningConfigurationArgs{ 47 // Status: pulumi.String("Enabled"), 48 // }, 49 // }) 50 // if err != nil { 51 // return err 52 // } 53 // _, err = s3.NewBucketObjectLockConfigurationV2(ctx, "example", &s3.BucketObjectLockConfigurationV2Args{ 54 // Bucket: example.ID(), 55 // Rule: &s3.BucketObjectLockConfigurationV2RuleArgs{ 56 // DefaultRetention: &s3.BucketObjectLockConfigurationV2RuleDefaultRetentionArgs{ 57 // Mode: pulumi.String("COMPLIANCE"), 58 // Days: pulumi.Int(5), 59 // }, 60 // }, 61 // }) 62 // if err != nil { 63 // return err 64 // } 65 // return nil 66 // }) 67 // } 68 // 69 // ``` 70 // <!--End PulumiCodeChooser --> 71 // 72 // ## Import 73 // 74 // If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`): 75 // 76 // import { 77 // to = aws_s3_bucket_object_lock_configuration.example 78 // id = "bucket-name,123456789012" 79 // } 80 // 81 // __Using `pulumi import` to import__ S3 bucket Object Lock configuration using the `bucket` or using the `bucket` and `expected_bucket_owner` separated by a comma (`,`). For example: 82 // 83 // If the owner (account ID) of the source bucket is the same account used to configure the AWS Provider, import using the `bucket`: 84 // 85 // ```sh 86 // $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name 87 // ``` 88 // If the owner (account ID) of the source bucket differs from the account used to configure the AWS Provider, import using the `bucket` and `expected_bucket_owner` separated by a comma (`,`): 89 // 90 // ```sh 91 // $ pulumi import aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2 example bucket-name,123456789012 92 // ``` 93 type BucketObjectLockConfigurationV2 struct { 94 pulumi.CustomResourceState 95 96 // Name of the bucket. 97 Bucket pulumi.StringOutput `pulumi:"bucket"` 98 // Account ID of the expected bucket owner. 99 ExpectedBucketOwner pulumi.StringPtrOutput `pulumi:"expectedBucketOwner"` 100 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 101 ObjectLockEnabled pulumi.StringPtrOutput `pulumi:"objectLockEnabled"` 102 // Configuration block for specifying the Object Lock rule for the specified object. See below. 103 Rule BucketObjectLockConfigurationV2RulePtrOutput `pulumi:"rule"` 104 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 105 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 106 Token pulumi.StringPtrOutput `pulumi:"token"` 107 } 108 109 // NewBucketObjectLockConfigurationV2 registers a new resource with the given unique name, arguments, and options. 110 func NewBucketObjectLockConfigurationV2(ctx *pulumi.Context, 111 name string, args *BucketObjectLockConfigurationV2Args, opts ...pulumi.ResourceOption) (*BucketObjectLockConfigurationV2, error) { 112 if args == nil { 113 return nil, errors.New("missing one or more required arguments") 114 } 115 116 if args.Bucket == nil { 117 return nil, errors.New("invalid value for required argument 'Bucket'") 118 } 119 if args.Token != nil { 120 args.Token = pulumi.ToSecret(args.Token).(pulumi.StringPtrInput) 121 } 122 secrets := pulumi.AdditionalSecretOutputs([]string{ 123 "token", 124 }) 125 opts = append(opts, secrets) 126 opts = internal.PkgResourceDefaultOpts(opts) 127 var resource BucketObjectLockConfigurationV2 128 err := ctx.RegisterResource("aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2", name, args, &resource, opts...) 129 if err != nil { 130 return nil, err 131 } 132 return &resource, nil 133 } 134 135 // GetBucketObjectLockConfigurationV2 gets an existing BucketObjectLockConfigurationV2 resource's state with the given name, ID, and optional 136 // state properties that are used to uniquely qualify the lookup (nil if not required). 137 func GetBucketObjectLockConfigurationV2(ctx *pulumi.Context, 138 name string, id pulumi.IDInput, state *BucketObjectLockConfigurationV2State, opts ...pulumi.ResourceOption) (*BucketObjectLockConfigurationV2, error) { 139 var resource BucketObjectLockConfigurationV2 140 err := ctx.ReadResource("aws:s3/bucketObjectLockConfigurationV2:BucketObjectLockConfigurationV2", name, id, state, &resource, opts...) 141 if err != nil { 142 return nil, err 143 } 144 return &resource, nil 145 } 146 147 // Input properties used for looking up and filtering BucketObjectLockConfigurationV2 resources. 148 type bucketObjectLockConfigurationV2State struct { 149 // Name of the bucket. 150 Bucket *string `pulumi:"bucket"` 151 // Account ID of the expected bucket owner. 152 ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"` 153 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 154 ObjectLockEnabled *string `pulumi:"objectLockEnabled"` 155 // Configuration block for specifying the Object Lock rule for the specified object. See below. 156 Rule *BucketObjectLockConfigurationV2Rule `pulumi:"rule"` 157 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 158 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 159 Token *string `pulumi:"token"` 160 } 161 162 type BucketObjectLockConfigurationV2State struct { 163 // Name of the bucket. 164 Bucket pulumi.StringPtrInput 165 // Account ID of the expected bucket owner. 166 ExpectedBucketOwner pulumi.StringPtrInput 167 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 168 ObjectLockEnabled pulumi.StringPtrInput 169 // Configuration block for specifying the Object Lock rule for the specified object. See below. 170 Rule BucketObjectLockConfigurationV2RulePtrInput 171 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 172 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 173 Token pulumi.StringPtrInput 174 } 175 176 func (BucketObjectLockConfigurationV2State) ElementType() reflect.Type { 177 return reflect.TypeOf((*bucketObjectLockConfigurationV2State)(nil)).Elem() 178 } 179 180 type bucketObjectLockConfigurationV2Args struct { 181 // Name of the bucket. 182 Bucket string `pulumi:"bucket"` 183 // Account ID of the expected bucket owner. 184 ExpectedBucketOwner *string `pulumi:"expectedBucketOwner"` 185 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 186 ObjectLockEnabled *string `pulumi:"objectLockEnabled"` 187 // Configuration block for specifying the Object Lock rule for the specified object. See below. 188 Rule *BucketObjectLockConfigurationV2Rule `pulumi:"rule"` 189 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 190 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 191 Token *string `pulumi:"token"` 192 } 193 194 // The set of arguments for constructing a BucketObjectLockConfigurationV2 resource. 195 type BucketObjectLockConfigurationV2Args struct { 196 // Name of the bucket. 197 Bucket pulumi.StringInput 198 // Account ID of the expected bucket owner. 199 ExpectedBucketOwner pulumi.StringPtrInput 200 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 201 ObjectLockEnabled pulumi.StringPtrInput 202 // Configuration block for specifying the Object Lock rule for the specified object. See below. 203 Rule BucketObjectLockConfigurationV2RulePtrInput 204 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 205 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 206 Token pulumi.StringPtrInput 207 } 208 209 func (BucketObjectLockConfigurationV2Args) ElementType() reflect.Type { 210 return reflect.TypeOf((*bucketObjectLockConfigurationV2Args)(nil)).Elem() 211 } 212 213 type BucketObjectLockConfigurationV2Input interface { 214 pulumi.Input 215 216 ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output 217 ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output 218 } 219 220 func (*BucketObjectLockConfigurationV2) ElementType() reflect.Type { 221 return reflect.TypeOf((**BucketObjectLockConfigurationV2)(nil)).Elem() 222 } 223 224 func (i *BucketObjectLockConfigurationV2) ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output { 225 return i.ToBucketObjectLockConfigurationV2OutputWithContext(context.Background()) 226 } 227 228 func (i *BucketObjectLockConfigurationV2) ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output { 229 return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2Output) 230 } 231 232 // BucketObjectLockConfigurationV2ArrayInput is an input type that accepts BucketObjectLockConfigurationV2Array and BucketObjectLockConfigurationV2ArrayOutput values. 233 // You can construct a concrete instance of `BucketObjectLockConfigurationV2ArrayInput` via: 234 // 235 // BucketObjectLockConfigurationV2Array{ BucketObjectLockConfigurationV2Args{...} } 236 type BucketObjectLockConfigurationV2ArrayInput interface { 237 pulumi.Input 238 239 ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput 240 ToBucketObjectLockConfigurationV2ArrayOutputWithContext(context.Context) BucketObjectLockConfigurationV2ArrayOutput 241 } 242 243 type BucketObjectLockConfigurationV2Array []BucketObjectLockConfigurationV2Input 244 245 func (BucketObjectLockConfigurationV2Array) ElementType() reflect.Type { 246 return reflect.TypeOf((*[]*BucketObjectLockConfigurationV2)(nil)).Elem() 247 } 248 249 func (i BucketObjectLockConfigurationV2Array) ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput { 250 return i.ToBucketObjectLockConfigurationV2ArrayOutputWithContext(context.Background()) 251 } 252 253 func (i BucketObjectLockConfigurationV2Array) ToBucketObjectLockConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2ArrayOutput { 254 return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2ArrayOutput) 255 } 256 257 // BucketObjectLockConfigurationV2MapInput is an input type that accepts BucketObjectLockConfigurationV2Map and BucketObjectLockConfigurationV2MapOutput values. 258 // You can construct a concrete instance of `BucketObjectLockConfigurationV2MapInput` via: 259 // 260 // BucketObjectLockConfigurationV2Map{ "key": BucketObjectLockConfigurationV2Args{...} } 261 type BucketObjectLockConfigurationV2MapInput interface { 262 pulumi.Input 263 264 ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput 265 ToBucketObjectLockConfigurationV2MapOutputWithContext(context.Context) BucketObjectLockConfigurationV2MapOutput 266 } 267 268 type BucketObjectLockConfigurationV2Map map[string]BucketObjectLockConfigurationV2Input 269 270 func (BucketObjectLockConfigurationV2Map) ElementType() reflect.Type { 271 return reflect.TypeOf((*map[string]*BucketObjectLockConfigurationV2)(nil)).Elem() 272 } 273 274 func (i BucketObjectLockConfigurationV2Map) ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput { 275 return i.ToBucketObjectLockConfigurationV2MapOutputWithContext(context.Background()) 276 } 277 278 func (i BucketObjectLockConfigurationV2Map) ToBucketObjectLockConfigurationV2MapOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2MapOutput { 279 return pulumi.ToOutputWithContext(ctx, i).(BucketObjectLockConfigurationV2MapOutput) 280 } 281 282 type BucketObjectLockConfigurationV2Output struct{ *pulumi.OutputState } 283 284 func (BucketObjectLockConfigurationV2Output) ElementType() reflect.Type { 285 return reflect.TypeOf((**BucketObjectLockConfigurationV2)(nil)).Elem() 286 } 287 288 func (o BucketObjectLockConfigurationV2Output) ToBucketObjectLockConfigurationV2Output() BucketObjectLockConfigurationV2Output { 289 return o 290 } 291 292 func (o BucketObjectLockConfigurationV2Output) ToBucketObjectLockConfigurationV2OutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2Output { 293 return o 294 } 295 296 // Name of the bucket. 297 func (o BucketObjectLockConfigurationV2Output) Bucket() pulumi.StringOutput { 298 return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringOutput { return v.Bucket }).(pulumi.StringOutput) 299 } 300 301 // Account ID of the expected bucket owner. 302 func (o BucketObjectLockConfigurationV2Output) ExpectedBucketOwner() pulumi.StringPtrOutput { 303 return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.ExpectedBucketOwner }).(pulumi.StringPtrOutput) 304 } 305 306 // Indicates whether this bucket has an Object Lock configuration enabled. Defaults to `Enabled`. Valid values: `Enabled`. 307 func (o BucketObjectLockConfigurationV2Output) ObjectLockEnabled() pulumi.StringPtrOutput { 308 return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.ObjectLockEnabled }).(pulumi.StringPtrOutput) 309 } 310 311 // Configuration block for specifying the Object Lock rule for the specified object. See below. 312 func (o BucketObjectLockConfigurationV2Output) Rule() BucketObjectLockConfigurationV2RulePtrOutput { 313 return o.ApplyT(func(v *BucketObjectLockConfigurationV2) BucketObjectLockConfigurationV2RulePtrOutput { return v.Rule }).(BucketObjectLockConfigurationV2RulePtrOutput) 314 } 315 316 // Token to allow Object Lock to be enabled for an existing bucket. You must contact AWS support for the bucket's "Object Lock token". 317 // The token is generated in the back-end when [versioning](https://docs.aws.amazon.com/AmazonS3/latest/userguide/manage-versioning-examples.html) is enabled on a bucket. For more details on versioning, see the `s3.BucketVersioningV2` resource. 318 func (o BucketObjectLockConfigurationV2Output) Token() pulumi.StringPtrOutput { 319 return o.ApplyT(func(v *BucketObjectLockConfigurationV2) pulumi.StringPtrOutput { return v.Token }).(pulumi.StringPtrOutput) 320 } 321 322 type BucketObjectLockConfigurationV2ArrayOutput struct{ *pulumi.OutputState } 323 324 func (BucketObjectLockConfigurationV2ArrayOutput) ElementType() reflect.Type { 325 return reflect.TypeOf((*[]*BucketObjectLockConfigurationV2)(nil)).Elem() 326 } 327 328 func (o BucketObjectLockConfigurationV2ArrayOutput) ToBucketObjectLockConfigurationV2ArrayOutput() BucketObjectLockConfigurationV2ArrayOutput { 329 return o 330 } 331 332 func (o BucketObjectLockConfigurationV2ArrayOutput) ToBucketObjectLockConfigurationV2ArrayOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2ArrayOutput { 333 return o 334 } 335 336 func (o BucketObjectLockConfigurationV2ArrayOutput) Index(i pulumi.IntInput) BucketObjectLockConfigurationV2Output { 337 return pulumi.All(o, i).ApplyT(func(vs []interface{}) *BucketObjectLockConfigurationV2 { 338 return vs[0].([]*BucketObjectLockConfigurationV2)[vs[1].(int)] 339 }).(BucketObjectLockConfigurationV2Output) 340 } 341 342 type BucketObjectLockConfigurationV2MapOutput struct{ *pulumi.OutputState } 343 344 func (BucketObjectLockConfigurationV2MapOutput) ElementType() reflect.Type { 345 return reflect.TypeOf((*map[string]*BucketObjectLockConfigurationV2)(nil)).Elem() 346 } 347 348 func (o BucketObjectLockConfigurationV2MapOutput) ToBucketObjectLockConfigurationV2MapOutput() BucketObjectLockConfigurationV2MapOutput { 349 return o 350 } 351 352 func (o BucketObjectLockConfigurationV2MapOutput) ToBucketObjectLockConfigurationV2MapOutputWithContext(ctx context.Context) BucketObjectLockConfigurationV2MapOutput { 353 return o 354 } 355 356 func (o BucketObjectLockConfigurationV2MapOutput) MapIndex(k pulumi.StringInput) BucketObjectLockConfigurationV2Output { 357 return pulumi.All(o, k).ApplyT(func(vs []interface{}) *BucketObjectLockConfigurationV2 { 358 return vs[0].(map[string]*BucketObjectLockConfigurationV2)[vs[1].(string)] 359 }).(BucketObjectLockConfigurationV2Output) 360 } 361 362 func init() { 363 pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2Input)(nil)).Elem(), &BucketObjectLockConfigurationV2{}) 364 pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2ArrayInput)(nil)).Elem(), BucketObjectLockConfigurationV2Array{}) 365 pulumi.RegisterInputType(reflect.TypeOf((*BucketObjectLockConfigurationV2MapInput)(nil)).Elem(), BucketObjectLockConfigurationV2Map{}) 366 pulumi.RegisterOutputType(BucketObjectLockConfigurationV2Output{}) 367 pulumi.RegisterOutputType(BucketObjectLockConfigurationV2ArrayOutput{}) 368 pulumi.RegisterOutputType(BucketObjectLockConfigurationV2MapOutput{}) 369 }