Skip to content

Commit

Permalink
Reinstate restricted check for China cloud only
Browse files Browse the repository at this point in the history
  • Loading branch information
domwong committed Jul 9, 2018
1 parent 983eb02 commit fd64094
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions aws/resource_aws_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit fd64094

Please sign in to comment.