Amir
Amir

Reputation: 335

terraform .% and .# and <computed> meaning

When creating a resource and calling terraform plan, I see names like:

tags.%:                           "" => "1"
dns_servers.#:                    <computed>

I was wondering what does .% and .# mean; and what does the value "" => "1" mean for tags.%

Also, what does the value computed really represent?

Upvotes: 0

Views: 1244

Answers (1)

Eric M. Johnson
Eric M. Johnson

Reputation: 7337

tags.%: refers to an the number of parts to the tags attribute of the resource.

"" => "1" means that he number of those parts is going from undefined before apply to 1 after apply. In this example, that probably means there are currently no tags, and if you apply there will be 1 tag. In general, "foo" => "bar" in a plan means Terraform detects that the value is currently "foo" and after applying this plan it would be "bar".

dns_servers.# means there are multiple parts to the dns_servers attribute, and this line references a particular part identified by that unique number. For example, if you make several tags, there could be several tags tag.1, tag.2, etc. This numbering is decided by the provider.

<computed> means that the value cannot be known until you actually apply. For instance, you create an EIP and an EC2 instance that uses that EIP, Terraform will show the EIP's allocation_id as <COMPUTED> because you cannot know this until it is created (ie. it is returned from AWS on EIP creation). Terraform aims to converge in a single run (ie. you need not run apply multiple times to get the final result), and a tradeoff for this goal is that you will not see these values in the terraform plan before the resource is created.

Upvotes: 3

Related Questions