Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't set storage_class to inherit the source object in replication rules #207

Open
NoaBM opened this issue Nov 27, 2023 · 1 comment
Open
Labels
bug 🐛 An issue with the system

Comments

@NoaBM
Copy link

NoaBM commented Nov 27, 2023

Describe the Bug

When creating s3 bucket with s3_replication_rules, the storage_class inside destination is always enabled as "STANDARD" and can't be set to null, when the null should use the source replication bucket.

Expected Behavior

storage_class for replication should not be set, and should be taken from the source replication bucket.

Steps to Reproduce

call the module with all relevant fields including the replication fields -

module "s3_bucket" {
    source                  = "cloudposse/s3-bucket/aws"
    version                 = "4.0.1"
    s3_replication_rules = [{
         destination = {
              storage_class = null
          }
     }]
}

see in aws console that the "Destination storage class" is set to Standard and not as it should be unmarked.
Screenshot 2023-11-27 at 14 07 31

Screenshots

No response

Environment

  • Terraform version - 1.5
  • module version - 4.0.1

Additional Context

I tested a fix to the module in variables.tf line 267 and changed it to - storage_class = optional(string, null), and it seems to work either if :

  • we don't send "storage_class" to the module at all, the result is inherited from the source bucket

  • we do send "storage_class = STANDARD" it's sets it to standard.

@NoaBM NoaBM added the bug 🐛 An issue with the system label Nov 27, 2023
@nitrocode
Copy link
Member

Seems like this is functioning as per the terraform docs

https://developer.hashicorp.com/terraform/language/expressions/type-constraints

There doesn't seem to be a way to explicitly set the nested key to null without it getting replaced with the default value

variable "s3_replication_rules" {

destination = object({
bucket = optional(string) # destination bucket ARN, overrides s3_replica_bucket_arn
storage_class = optional(string, "STANDARD")

So you're right, we can either

  1. change the default to null (breaking change)
  2. remove the default (breaking change)
  3. Add a separate input to the map e.g. s3_replication_rules.storage_class_inherit_enabled and if true, set the argument to null
  4. Add a completely separate input e.g. var.s3_replica_storage_class_inherit_enabled
  5. Allow an empty string in storage_class to get converted to null

I'm leaning more towards 3. What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 An issue with the system
Projects
None yet
Development

No branches or pull requests

2 participants