Skip to content

Commit

Permalink
r/s3_bucket: deprecate 'lifecycle_rule'
Browse files Browse the repository at this point in the history
  • Loading branch information
anGie44 committed Jan 13, 2022
1 parent 21e5c25 commit 61414d9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 28 deletions.
35 changes: 26 additions & 9 deletions internal/service/s3/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,19 +276,23 @@ func ResourceBucket() *schema.Resource {
Optional: true,
Computed: true,
ValidateFunc: validation.StringLenBetween(0, 255),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"prefix": {
Type: schema.TypeString,
Optional: true,
Type: schema.TypeString,
Optional: true,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"tags": tftags.TagsSchema(),
"tags": tftags.TagsSchemaDeprecated("Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead."),
"enabled": {
Type: schema.TypeBool,
Required: true,
Type: schema.TypeBool,
Required: true,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"abort_incomplete_multipart_upload_days": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"expiration": {
Type: schema.TypeList,
Expand All @@ -300,15 +304,18 @@ func ResourceBucket() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validBucketLifecycleTimestamp,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"days": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"expired_object_delete_marker": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
},
},
Expand All @@ -323,9 +330,11 @@ func ResourceBucket() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(1),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
},
},
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"transition": {
Type: schema.TypeSet,
Expand All @@ -337,19 +346,23 @@ func ResourceBucket() *schema.Resource {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validBucketLifecycleTimestamp,
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"days": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"storage_class": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(s3.TransitionStorageClass_Values(), false),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
},
},
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"noncurrent_version_transition": {
Type: schema.TypeSet,
Expand All @@ -361,17 +374,21 @@ func ResourceBucket() *schema.Resource {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(0),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
"storage_class": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice(s3.TransitionStorageClass_Values(), false),
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
},
},
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},
},
},
Deprecated: "Will be read-only in the next major version. Use the aws_s3_bucket_lifecycle_configuration resource instead.",
},

"force_destroy": {
Expand Down
10 changes: 10 additions & 0 deletions internal/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ func TagsSchemaComputed() *schema.Schema {
}
}

func TagsSchemaDeprecated(message string) *schema.Schema {
return &schema.Schema{
Type: schema.TypeMap,
Optional: true,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
Deprecated: message,
}
}

func TagsSchemaForceNew() *schema.Schema {
return &schema.Schema{
Type: schema.TypeMap,
Expand Down
50 changes: 31 additions & 19 deletions website/docs/r/s3_bucket.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ resource "aws_s3_bucket" "b" {

### Using object lifecycle

~> **NOTE:** See the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) for additional configuration features.

```terraform
resource "aws_s3_bucket" "bucket" {
bucket = "my-bucket"
Expand Down Expand Up @@ -363,7 +365,7 @@ The following arguments are supported:
* `cors_rule` - (Optional) A rule of [Cross-Origin Resource Sharing](https://docs.aws.amazon.com/AmazonS3/latest/dev/cors.html) (documented below).
* `versioning` - (Optional) A state of [versioning](https://docs.aws.amazon.com/AmazonS3/latest/dev/Versioning.html) (documented below)
* `logging` - (Optional) A settings of [bucket logging](https://docs.aws.amazon.com/AmazonS3/latest/UG/ManagingBucketLogging.html) (documented below).
* `lifecycle_rule` - (Optional) A configuration of [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html) (documented below).
* `lifecycle_rule` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. A configuration of [object lifecycle management](http://docs.aws.amazon.com/AmazonS3/latest/dev/object-lifecycle-mgmt.html) (documented below).
* `acceleration_status` - (Optional) Sets the accelerate configuration of an existing bucket. Can be `Enabled` or `Suspended`.
* `request_payer` - (Optional) Specifies who should bear the cost of Amazon S3 data transfer.
Can be either `BucketOwner` or `Requester`. By default, the owner of the S3 bucket would incur
Expand Down Expand Up @@ -403,38 +405,48 @@ The `logging` object supports the following:

The `lifecycle_rule` object supports the following:

* `id` - (Optional) Unique identifier for the rule. Must be less than or equal to 255 characters in length.
* `prefix` - (Optional) Object key prefix identifying one or more objects to which the rule applies.
* `tags` - (Optional) Specifies object tags key and value.
* `enabled` - (Required) Specifies lifecycle rule status.
* `abort_incomplete_multipart_upload_days` (Optional) Specifies the number of days after initiating a multipart upload when the multipart upload must be completed.
* `expiration` - (Optional) Specifies a period in the object's expire (documented below).
* `transition` - (Optional) Specifies a period in the object's transitions (documented below).
* `noncurrent_version_expiration` - (Optional) Specifies when noncurrent object versions expire (documented below).
* `noncurrent_version_transition` - (Optional) Specifies when noncurrent object versions transitions (documented below).
~> **NOTE:** See the [`aws_s3_bucket_lifecycle_configuration` resource documentation](s3_bucket_lifecycle_configuration.html) to avoid conflicts. Lifecycle configuration can only be defined in one resource not both. When using the independent lifecycle configuration resource the following lifecycle rule is needed on the `aws_s3_bucket` resource.

```
lifecycle {
ignore_changes = [
lifecycle_rule
]
}
```

* `id` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Unique identifier for the rule. Must be less than or equal to 255 characters in length.
* `prefix` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Object key prefix identifying one or more objects to which the rule applies.
* `tags` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies object tags key and value.
* `enabled` - (Required, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies lifecycle rule status.
* `abort_incomplete_multipart_upload_days` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the number of days after initiating a multipart upload when the multipart upload must be completed.
* `expiration` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies a period in the object's expire (documented below).
* `transition` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies a period in the object's transitions (documented below).
* `noncurrent_version_expiration` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies when noncurrent object versions expire (documented below).
* `noncurrent_version_transition` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies when noncurrent object versions transitions (documented below).

At least one of `abort_incomplete_multipart_upload_days`, `expiration`, `transition`, `noncurrent_version_expiration`, `noncurrent_version_transition` must be specified.

The `expiration` object supports the following

* `date` (Optional) Specifies the date after which you want the corresponding action to take effect.
* `days` (Optional) Specifies the number of days after object creation when the specific rule action takes effect.
* `expired_object_delete_marker` (Optional) On a versioned bucket (versioning-enabled or versioning-suspended bucket), you can add this element in the lifecycle configuration to direct Amazon S3 to delete expired object delete markers. This cannot be specified with Days or Date in a Lifecycle Expiration Policy.
* `date` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the date after which you want the corresponding action to take effect.
* `days` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the number of days after object creation when the specific rule action takes effect.
* `expired_object_delete_marker` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. On a versioned bucket (versioning-enabled or versioning-suspended bucket), you can add this element in the lifecycle configuration to direct Amazon S3 to delete expired object delete markers. This cannot be specified with Days or Date in a Lifecycle Expiration Policy.

The `transition` object supports the following

* `date` (Optional) Specifies the date after which you want the corresponding action to take effect.
* `days` (Optional) Specifies the number of days after object creation when the specific rule action takes effect.
* `storage_class` (Required) Specifies the Amazon S3 [storage class](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Transition.html#AmazonS3-Type-Transition-StorageClass) to which you want the object to transition.
* `date` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the date after which you want the corresponding action to take effect.
* `days` - (Optional, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the number of days after object creation when the specific rule action takes effect.
* `storage_class` - (Required, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the Amazon S3 [storage class](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Transition.html#AmazonS3-Type-Transition-StorageClass) to which you want the object to transition.

The `noncurrent_version_expiration` object supports the following

* `days` (Required) Specifies the number of days noncurrent object versions expire.
* `days` - (Required, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the number of days noncurrent object versions expire.

The `noncurrent_version_transition` object supports the following

* `days` (Required) Specifies the number of days noncurrent object versions transition.
* `storage_class` (Required) Specifies the Amazon S3 [storage class](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Transition.html#AmazonS3-Type-Transition-StorageClass) to which you want the object to transition.
* `days` - (Required, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the number of days noncurrent object versions transition.
* `storage_class` - (Required, **DEPRECATED**) Use the [`aws_s3_bucket_lifecycle_configuration` resource](s3_bucket_lifecycle_configuration.html) instead. Specifies the Amazon S3 [storage class](https://docs.aws.amazon.com/AmazonS3/latest/API/API_Transition.html#AmazonS3-Type-Transition-StorageClass) to which you want the object to transition.

The `replication_configuration` object supports the following:

Expand Down

0 comments on commit 61414d9

Please sign in to comment.