- If you run
terraform plan
agains themain.tf
as-is, you get this output:
+ aws_ebs_volume.ebs_vol
availability_zone: "us-east-1"
encrypted: "<computed>"
iops: "<computed>"
kms_key_id: "<computed>"
size: "40"
snapshot_id: "<computed>"
tags.%: "1"
tags.Name: "foo"
type: "<computed>"
+ aws_instance.instance
ami: "ami-7feb3f14"
associate_public_ip_address: "<computed>"
availability_zone: "<computed>"
ebs_block_device.#: "<computed>"
ephemeral_block_device.#: "<computed>"
instance_state: "<computed>"
instance_type: "t2.small"
ipv6_address_count: "<computed>"
ipv6_addresses.#: "<computed>"
key_name: "<computed>"
network_interface.#: "<computed>"
network_interface_id: "<computed>"
placement_group: "<computed>"
primary_network_interface_id: "<computed>"
private_dns: "<computed>"
private_ip: "<computed>"
public_dns: "<computed>"
public_ip: "<computed>"
root_block_device.#: "<computed>"
security_groups.#: "<computed>"
source_dest_check: "true"
subnet_id: "subnet-825a8da9"
tags.%: "1"
tags.Name: "foo"
tenancy: "<computed>"
volume_tags.%: "<computed>"
vpc_security_group_ids.#: "3"
vpc_security_group_ids.2444810777: "sg-6e682617"
vpc_security_group_ids.2522428491: "sg-4b5a2737"
vpc_security_group_ids.3953773689: "sg-69682610"
+ null_resource.null
triggers.%: "1"
triggers.Name: "foo"
There is one tag to apply and it is Name => foo
.
2. If you run terraform plan
against main.tf
using the data sources named dummy
, you this as your output:
+ aws_ebs_volume.ebs_vol
availability_zone: "us-east-1"
encrypted: "<computed>"
iops: "<computed>"
kms_key_id: "<computed>"
size: "40"
snapshot_id: "<computed>"
tags.%: "<computed>"
type: "<computed>"
+ aws_instance.instance
ami: "ami-7feb3f14"
associate_public_ip_address: "<computed>"
availability_zone: "<computed>"
ebs_block_device.#: "<computed>"
ephemeral_block_device.#: "<computed>"
instance_state: "<computed>"
instance_type: "t2.small"
ipv6_address_count: "<computed>"
ipv6_addresses.#: "<computed>"
key_name: "<computed>"
network_interface.#: "<computed>"
network_interface_id: "<computed>"
placement_group: "<computed>"
primary_network_interface_id: "<computed>"
private_dns: "<computed>"
private_ip: "<computed>"
public_dns: "<computed>"
public_ip: "<computed>"
root_block_device.#: "<computed>"
security_groups.#: "<computed>"
source_dest_check: "true"
subnet_id: "subnet-825a8da9"
tags.%: "<computed>"
tenancy: "<computed>"
volume_tags.%: "<computed>"
vpc_security_group_ids.#: "3"
vpc_security_group_ids.2444810777: "sg-6e682617"
vpc_security_group_ids.2522428491: "sg-4b5a2737"
vpc_security_group_ids.3953773689: "sg-69682610"
+ null_resource.null
triggers.%: "1"
triggers.Name: "foo"
There are no tags to apply
3. If you run terraform plan
against the main.tf
with the conditional tags
value, this is the output:
Error running plan: 2 error(s) occurred:
* aws_ebs_volume.ebs_vol: 1 error(s) occurred:
* aws_ebs_volume.ebs_vol: At column 3, line 1: true and false expression types must match; have type list and type map in:
${var.use_null_resource == 0 ? data.aws_ebs_volume.dummy.tags : null_resource.null.triggers}
* aws_instance.instance: 1 error(s) occurred:
* aws_instance.instance: At column 3, line 1: true and false expression types must match; have type list and type map in:
${var.use_null_resource == 0 ? data.aws_instance.dummy.tags : null_resource.null.triggers}
Even though the triggers
property of the null_resource
and the tags
property of the aws_instance
should have the
same map type, one is being treated as a list
and the other as a map
.
Just to shake any doubt that the AWS instance has tags on it, here's the result of importing it:
$ terraform import aws_instance.wackamole i-3c6e8abc
aws_instance.wackamole: Importing from ID "i-3c6e8abc"...
aws_instance.wackamole: Import complete!
Imported aws_instance (ID: i-3c6e8abc)
aws_instance.wackamole: Refreshing state... (ID: i-3c6e8abc)
Import success! The resources imported are shown above. These are
now in your Terraform state. Import does not currently generate
configuration, so you must do this next. If you do not create configuration
for the above resources, then the next `terraform plan` will mark
them for destruction.
$ terraform state show aws_instance.wackamole
...
id = i-3c6e8abc
...
tags.% = 5
tags.ENV = stg
tags.Name = terraform-stg-consul-1
tags.provisioned-by = terraform
tags.service = consul
tags.stackdriver_monitor = false
tenancy = default
...