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

Gsi projection and ttl fix #17

Merged
merged 17 commits into from
Jan 31, 2024
Merged

Gsi projection and ttl fix #17

merged 17 commits into from
Jan 31, 2024

Conversation

evgenygigi
Copy link
Contributor

This is a continuation of #14
In this PR we implementing the TTL a bit different due to the know bug/feature of AWS.
When you passing ttl_attribute_name attribute the TTL will be enabled on your dynamodb table otherwise it will not be crated at all.

Copy link
Contributor

@srinivas-toluna srinivas-toluna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved

Copy link

@waseemkh88 waseemkh88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added one minor comment below.

}

dynamic "ttl" {
for_each = var.ttl_attribute_name != null ? [1] : []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @evgenygigi , the ttl_attribute_name is string and not a list, and I am confused with the foreach loop that you are having here. Can you please explain?

Copy link
Contributor Author

@evgenygigi evgenygigi Jan 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of how dynamic block works https://developer.hashicorp.com/terraform/language/expressions/dynamic-blocks
If var.ttl_attribute_name is not null (meaning it has a value), the for_each expression evaluates to [1], creating a single iteration of the block.
If var.ttl_attribute_name is null, the expression evaluates to an empty list ([]), effectively skipping the block's execution.

the [1] indicates the number of iterations.

@evgenygigi evgenygigi merged commit 78389b2 into master Jan 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants