Skip to content

Commit

Permalink
add tag on create for aws_sqs_queue resource
Browse files Browse the repository at this point in the history
  • Loading branch information
teraken0509 committed Sep 24, 2019
1 parent 1f8efa5 commit 606f0ad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion aws/resource_aws_sqs_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/service/sqs"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
Expand Down Expand Up @@ -170,6 +171,11 @@ func resourceAwsSqsQueueCreate(d *schema.ResourceData, meta interface{}) error {
QueueName: aws.String(name),
}

// Tag-on-create is currently only supported in AWS Commercial
if v, ok := d.GetOk("tags"); ok && meta.(*AWSClient).partition == endpoints.AwsPartitionID {
req.Tags = tagsFromMapGeneric(v.(map[string]interface{}))
}

attributes := make(map[string]*string)

queueResource := *resourceAwsSqsQueue()
Expand Down Expand Up @@ -215,7 +221,12 @@ func resourceAwsSqsQueueCreate(d *schema.ResourceData, meta interface{}) error {

d.SetId(aws.StringValue(output.QueueUrl))

return resourceAwsSqsQueueUpdate(d, meta)
// Tag-on-create is currently only supported in AWS Commercial
if meta.(*AWSClient).partition == endpoints.AwsPartitionID {
return resourceAwsSqsQueueRead(d, meta)
} else {
return resourceAwsSqsQueueUpdate(d, meta)
}
}

func resourceAwsSqsQueueUpdate(d *schema.ResourceData, meta interface{}) error {
Expand Down

0 comments on commit 606f0ad

Please sign in to comment.