Tagged s3

Terraform: Optional Nested Dynamic Blocks - January 19, 2024
Recently, I was creating a terraform module that creates an S3 bucket. An S3 bucket can only have one aws_s3_bucket_policy, and the module needed to include a default policy to force TLS v1.2. I also needed to be able to pass additional policy statements to the module which may or may not include a condition. Unfortunately, there is not an obvious way to include the condition only when it is part of the policy. This post shows how you can include a nested dynamic condition block when the block exists, and exclude it if it doesn't.
Tags [ terraform ] [ optional ] [ dynamic ] [ aws ] [ iam ] [ s3 ]