resource "aws_ebs_volume" "example" {
availability_zone = "eu-west-1a"
size = 8
tags = {for k, v in merge({ Name = "Myvolume" }, var.project_tags): k => lower(v)}
}
Init the modules,
$ terraform init
Let's examine the output,
$ terraform plan
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following
symbols:
+ create
Terraform will perform the following actions:
# aws_ebs_volume.example will be created
+ resource "aws_ebs_volume" "example" {
+ arn = (known after apply)
+ availability_zone = "eu-west-1a"
+ encrypted = (known after apply)
+ id = (known after apply)
+ iops = (known after apply)
+ kms_key_id = (known after apply)
+ size = 8
+ snapshot_id = (known after apply)
+ tags = {
+ "Component" = "frontend"
+ "Environment" = "production"
+ "Name" = "myvolume"
}
+ tags_all = {
+ "Component" = "frontend"
+ "Environment" = "production"
+ "Name" = "myvolume"
}
+ throughput = (known after apply)
+ type = (known after apply)
}
Plan: 1 to add, 0 to change, 0 to destroy.
Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run
"terraform apply" now.
For-Each loops
Let's start this by creating a file with the name provider.tf,