By Morgan Lucas, thanks to the resources below.
What are they?
It's a way to construct dynamically repeatable nested blocks in Terraform code. Think about using for_each
- This is often used to make individual resources with a value to iterate over.
Contents;
I’ve done something like this, but it involved the multiple function (*) and a stand-in variable ${var.ex}
.
network_interface_ids = ["${element(azurerm_network_interface.CA-NetInt.*.id, 01)}"]
The index (01) picks the network_interface_ids
in a list. More about that here.
Was that unknowingly a dynamic block, or something else? By all means, comment what you think.
Here is a dynamic block.
resource "aws_elastic_beanstalk_environment" "tfenvtest" {
name = "tf-test-name"
application = "${aws_elastic_beanstalk_application.tftest.name}"
solution_stack_name = "64bit Amazon Linux 2018.03 v2.11.4 running Go 1.12.6"
dynamic "setting" {
for_each = var.settings
content {
namespace = setting.value["namespace"]
name = setting.value["name"]
value = setting.value["value"]
}
}
}
setting
up there is one. Others are list
and map
,and will reference different values.