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

Set object locking conditionally #8

Closed
miguelaferreira opened this issue Nov 19, 2019 · 4 comments
Closed

Set object locking conditionally #8

miguelaferreira opened this issue Nov 19, 2019 · 4 comments
Labels

Comments

@miguelaferreira
Copy link

I'm not able to set object locking conditionally (ie. based on the value of a variable). When disabling object locking I set the input variable object_lock_configuration to an empty map {}. However that results in a type error.

Error: Inconsistent conditional result types

  on ../../main.tf line 79, in module "bucket":
  79:   object_lock_configuration = var.enable_object_locking ? {
  80:     object_lock_enabled = "Enabled"
  81:     rule                = {
  82:       default_retention = {
  83:         mode = var.object_retention_mode
  84:         days = 1
  85:       }
  86:     }
  87:   } : {}

The true and false result expressions must have consistent types. The given
expressions are object and object, respectively.

Similar issues have been reported upstream hashicorp/terraform#22405

@miguelaferreira
Copy link
Author

Further investigation points to this issue only being present with heterogeneous objects, that is, objects that have fields with different types. I've identified two input variables where this issue arises: cors_rule and object_lock_configuration.

miguelaferreira added a commit to miguelaferreira/terraform-aws-s3-bucket that referenced this issue Nov 19, 2019
... because these parameters take heterogeneous objects which are not
easily overriden with empty values.

See
terraform-aws-modules#8
miguelaferreira added a commit to miguelaferreira/terraform-aws-s3-bucket that referenced this issue Nov 19, 2019
... because these parameters take heterogeneous objects which are not
easily overridden with empty values.

See
terraform-aws-modules#8
yarda7 pushed a commit to yarda7/terraform-aws-s3-bucket that referenced this issue Jan 20, 2021
@github-actions
Copy link

This issue has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this issue will be closed in 10 days

@github-actions github-actions bot added the stale label Jan 12, 2022
@github-actions
Copy link

This issue was automatically closed because of stale in 10 days

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant