Commit e83b8b07 authored by Anton Babenko's avatar Anton Babenko Committed by GitHub

feat: Added workaround for variable type `any` (#79)

parent a3ac47c5
......@@ -69,6 +69,22 @@ module "s3_bucket" {
}
```
## Terragrunt and `variable "..." { type = any }`
There is a bug [#1211](https://github.com/gruntwork-io/terragrunt/issues/1211) in Terragrunt related to the way how the variables of type `any` are passed to Terraform.
This module solves this issue by supporting `jsonencode()`-string in addition to the expected type (`list` or `map`).
In `terragrunt.hcl` you can write:
```terraform
inputs = {
bucket = "foobar" # `bucket` has type `string`, no need to jsonencode()
cors_rule = jsonencode([...]) # `cors_rule` has type `any`, so `jsonencode()` is required
}
```
## Examples:
* [Complete](https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/tree/master/examples/complete) - Complete S3 bucket with most of supported features enabled
......
......@@ -28,7 +28,7 @@ resource "aws_s3_bucket" "this" {
}
dynamic "cors_rule" {
for_each = var.cors_rule
for_each = try(jsondecode(var.cors_rule), var.cors_rule)
content {
allowed_methods = cors_rule.value.allowed_methods
......@@ -58,7 +58,7 @@ resource "aws_s3_bucket" "this" {
}
dynamic "grant" {
for_each = var.grant
for_each = try(jsondecode(var.grant), var.grant)
content {
id = lookup(grant.value, "id", null)
......@@ -69,7 +69,7 @@ resource "aws_s3_bucket" "this" {
}
dynamic "lifecycle_rule" {
for_each = var.lifecycle_rule
for_each = try(jsondecode(var.lifecycle_rule), var.lifecycle_rule)
content {
id = lookup(lifecycle_rule.value, "id", null)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment