From 62347ea83355878878392916838e4e27ca40cfe4 Mon Sep 17 00:00:00 2001 From: Paul Stack Date: Thu, 18 May 2017 17:28:37 +0300 Subject: [PATCH] provider/aws: Fall back to old tagging mechanism for AWS gov and aws China (#14627) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #14535 When in a `restricted` cloud, we should fall back to the old method of tagging. Before this change we saw the following: ``` % terraform apply ✭ aws_instance.foo: Creating... ami: "" => "ami-0fa3c42c" associate_public_ip_address: "" => "" availability_zone: "" => "" ebs_block_device.#: "" => "" ephemeral_block_device.#: "" => "" instance_state: "" => "" instance_type: "" => "m1.small" ipv6_address_count: "" => "" ipv6_addresses.#: "" => "" key_name: "" => "" network_interface.#: "" => "" network_interface_id: "" => "" placement_group: "" => "" primary_network_interface_id: "" => "" private_dns: "" => "" private_ip: "" => "" public_dns: "" => "" public_ip: "" => "" root_block_device.#: "" => "" security_groups.#: "" => "" source_dest_check: "" => "true" subnet_id: "" => "" tags.%: "" => "1" tags.foo: "" => "bar" tenancy: "" => "" volume_tags.%: "" => "" vpc_security_group_ids.#: "" => "" aws_instance.foo: Creation complete (ID: i-0009f227ae24791b9) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. % terraform plan ✭ Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_instance.foo: Refreshing state... (ID: i-0009f227ae24791b9) The Terraform execution plan has been generated and is shown below. Resources are shown in alphabetical order for quick scanning. Green resources will be created (or destroyed and then created if an existing resource exists), yellow resources are being changed in-place, and red resources will be destroyed. Cyan entries are data sources to be read. Note: You didn't specify an "-out" parameter to save this plan, so when "apply" is called, Terraform can't guarantee this is what will execute. ~ aws_instance.foo tags.%: "0" => "1" tags.foo: "" => "bar" Plan: 0 to add, 1 to change, 0 to destroy. ``` After this patch, we see the following: ``` % terraform apply ✹ ✭ [WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider. If you did not expect to see this message you will need to remove the old plugin. See https://www.terraform.io/docs/internals/internal-plugins.html aws_instance.foo: Creating... ami: "" => "ami-0fa3c42c" associate_public_ip_address: "" => "" availability_zone: "" => "" ebs_block_device.#: "" => "" ephemeral_block_device.#: "" => "" instance_state: "" => "" instance_type: "" => "m1.small" ipv6_address_count: "" => "" ipv6_addresses.#: "" => "" key_name: "" => "" network_interface.#: "" => "" network_interface_id: "" => "" placement_group: "" => "" primary_network_interface_id: "" => "" private_dns: "" => "" private_ip: "" => "" public_dns: "" => "" public_ip: "" => "" root_block_device.#: "" => "" security_groups.#: "" => "" source_dest_check: "" => "true" subnet_id: "" => "" tags.%: "" => "1" tags.foo: "" => "bar" tenancy: "" => "" volume_tags.%: "" => "" vpc_security_group_ids.#: "" => "" aws_instance.foo: Creation complete (ID: i-04cd122e28f167a14) Apply complete! Resources: 1 added, 0 changed, 0 destroyed. % terraform plan ✹ ✭ [WARN] /Users/stacko/Code/go/bin/terraform-provider-aws overrides an internal plugin for aws-provider. If you did not expect to see this message you will need to remove the old plugin. See https://www.terraform.io/docs/internals/internal-plugins.html Refreshing Terraform state in-memory prior to plan... The refreshed state will be used to calculate this plan, but will not be persisted to local or remote state storage. aws_instance.foo: Refreshing state... (ID: i-04cd122e28f167a14) No changes. Infrastructure is up-to-date. This means that Terraform did not detect any differences between your configuration and real physical resources that exist. As a result, Terraform doesn't need to do anything. ``` --- builtin/providers/aws/resource_aws_instance.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/providers/aws/resource_aws_instance.go b/builtin/providers/aws/resource_aws_instance.go index 5d0bdac99..8a03b607c 100644 --- a/builtin/providers/aws/resource_aws_instance.go +++ b/builtin/providers/aws/resource_aws_instance.go @@ -732,7 +732,7 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error { restricted := meta.(*AWSClient).IsGovCloud() || meta.(*AWSClient).IsChinaCloud() if d.HasChange("tags") { - if !d.IsNewResource() || !restricted { + if !d.IsNewResource() || restricted { if err := setTags(conn, d); err != nil { return err } else {