From fd64094fdbf7bac4970ad64db215161ce5368f79 Mon Sep 17 00:00:00 2001 From: domwong Date: Mon, 9 Jul 2018 17:58:31 +0100 Subject: [PATCH] Reinstate restricted check for China cloud only --- aws/resource_aws_instance.go | 45 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/aws/resource_aws_instance.go b/aws/resource_aws_instance.go index 52daead2d5fc..3937084d3710 100644 --- a/aws/resource_aws_instance.go +++ b/aws/resource_aws_instance.go @@ -514,32 +514,36 @@ func resourceAwsInstanceCreate(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Only 1 of `ipv6_address_count` or `ipv6_addresses` can be specified") } - tagsSpec := make([]*ec2.TagSpecification, 0) + restricted := meta.(*AWSClient).IsChinaCloud() + if !restricted { - if v, ok := d.GetOk("tags"); ok { - tags := tagsFromMap(v.(map[string]interface{})) + tagsSpec := make([]*ec2.TagSpecification, 0) - spec := &ec2.TagSpecification{ - ResourceType: aws.String("instance"), - Tags: tags, + if v, ok := d.GetOk("tags"); ok { + tags := tagsFromMap(v.(map[string]interface{})) + + spec := &ec2.TagSpecification{ + ResourceType: aws.String("instance"), + Tags: tags, + } + + tagsSpec = append(tagsSpec, spec) } - tagsSpec = append(tagsSpec, spec) - } + if v, ok := d.GetOk("volume_tags"); ok { + tags := tagsFromMap(v.(map[string]interface{})) - if v, ok := d.GetOk("volume_tags"); ok { - tags := tagsFromMap(v.(map[string]interface{})) + spec := &ec2.TagSpecification{ + ResourceType: aws.String("volume"), + Tags: tags, + } - spec := &ec2.TagSpecification{ - ResourceType: aws.String("volume"), - Tags: tags, + tagsSpec = append(tagsSpec, spec) } - tagsSpec = append(tagsSpec, spec) - } - - if len(tagsSpec) > 0 { - runOpts.TagSpecifications = tagsSpec + if len(tagsSpec) > 0 { + runOpts.TagSpecifications = tagsSpec + } } // Create the instance @@ -838,9 +842,10 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error { conn := meta.(*AWSClient).ec2conn d.Partial(true) + restricted := meta.(*AWSClient).IsChinaCloud() if d.HasChange("tags") { - if !d.IsNewResource() { + if !d.IsNewResource() || restricted { if err := setTags(conn, d); err != nil { return err } else { @@ -849,7 +854,7 @@ func resourceAwsInstanceUpdate(d *schema.ResourceData, meta interface{}) error { } } if d.HasChange("volume_tags") { - if !d.IsNewResource() { + if !d.IsNewResource() || restricted { if err := setVolumeTags(conn, d); err != nil { return err } else {