External Data Source
https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source
https://www.terraform.io/docs/configuration/syntax-json.html
https://stackoverflow.com/questions/63296646/iterate-through-list-of-dictionaries-to-create-terraform-resources-with-differen
variable query_dict {
    default = [
        {
            name = "query1"
            workgroup = "bar"
            query = "SELECT * FROM foo"   
        },
        {
            name = "query2"
            workgroup = "bar"
            query = "SELECT * FROM baz"   
        }
    ]
}resource "aws_athena_named_query" "olap" {
  for_each = {for idx, query in var.query_dict: idx => query}
  
  name = each.value.name
  query = each.value.query
  database = "test"
  workgroup = each.value.workgroup
} 
In the above you create map with idx as a key:
{
  "0" = {
    "name" = "query1"
    "query" = "SELECT * FROM foo"
    "workgroup" = "bar"
  }
  "1" = {
    "name" = "query2"
    "query" = "SELECT * FROM baz"
    "workgroup" = "bar"
  }
}https://github.com/hashicorp/terraform-provider-external/issues?q=is%3Aissue+is%3Aopen+list
https://technology.amis.nl/2020/02/24/set-terraform-resource-properties-from-an-element-in-a-list-retrieved-by-a-data-source-using-a-local-value/
https://stackoverflow.com/questions/51946982/dependency-on-local-file-creation
https://registry.terraform.io/providers/hashicorp/external/latest/docs/data-sources/data_source
https://paulbrice.com/terraform/python/2017/12/18/external-provider-terraform.htmlLoop and ifhttps://blog.gruntwork.io/terraform-tips-tricks-loops-if-statements-and-gotchas-f739bbae55f9
No comments:
Post a Comment