Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply tags to Elastic Search domain resources after creation. #1399

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,19 @@ func resourceAwsElasticSearchDomainCreate(d *schema.ResourceData, meta interface

d.SetId(*out.DomainStatus.ARN)

// Whilst the domain is being created, we can initialise the tags.
// This should mean that if the creation fails (eg because your token expired
// whilst the operation is being performed), we still get the required tags on
// the resources.
tags := tagsFromMapElasticsearchService(d.Get("tags").(map[string]interface{}))

if err := setTagsElasticsearchService(conn, d, *out.DomainStatus.ARN); err != nil {
return err
}

d.Set("tags", tagsToMapElasticsearchService(tags))
d.SetPartial("tags")

log.Printf("[DEBUG] Waiting for ElasticSearch domain %q to be created", d.Id())
err = resource.Retry(60*time.Minute, func() *resource.RetryError {
out, err := conn.DescribeElasticsearchDomain(&elasticsearch.DescribeElasticsearchDomainInput{
Expand All @@ -264,15 +277,6 @@ func resourceAwsElasticSearchDomainCreate(d *schema.ResourceData, meta interface
if err != nil {
return err
}

tags := tagsFromMapElasticsearchService(d.Get("tags").(map[string]interface{}))

if err := setTagsElasticsearchService(conn, d, *out.DomainStatus.ARN); err != nil {
return err
}

d.Set("tags", tagsToMapElasticsearchService(tags))
d.SetPartial("tags")
d.Partial(false)

log.Printf("[DEBUG] ElasticSearch domain %q created", d.Id())
Expand Down