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

[WIP] Adding tags to elasticsearch #3619

Closed
wants to merge 1 commit into from
Closed
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
23 changes: 23 additions & 0 deletions builtin/providers/aws/resource_aws_elasticsearch_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func resourceAwsElasticSearchDomain() *schema.Resource {
},
},
},
"tags": tagsSchema(),
},
}
}
Expand Down Expand Up @@ -274,6 +275,22 @@ func resourceAwsElasticSearchDomainRead(d *schema.ResourceData, meta interface{}

d.Set("arn", *ds.ARN)

// get tags
type ListTagsRequest struct {
ARN string
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The AWS SDK already defines this for you, so you don't have to make your own struct, you can just use theirs:

req := &elasticsearch.ListTagsInput{
    ARN:   aws.String(ds.ARN),
}


req := ListTagsRequest{
ARN: *ds.ARN
}

resp, err := elasticsearch.ListTags(req)
if err != nil {
return err
}

d.Set("tags", resp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this likely won't work, as the Tags are a schema set and the results of ListTags will be a slice of []*elasticsearch.Tags. We have to do a few steps here, see ELB as a resource:

Which leads to a tagsELB.go file, which we'll need for elasticsearch as well. I can likely help there if you need, otherwise it should be pretty easy to just copy tagsELB.go


return nil
}

Expand Down Expand Up @@ -353,6 +370,12 @@ func resourceAwsElasticSearchDomainUpdate(d *schema.ResourceData, meta interface
return err
}

// if err := setTagsR53(conn, d, "hostedzone"); err != nil {
// return err
// } else {
// d.SetPartial("tags")
// }

return resourceAwsElasticSearchDomainRead(d, meta)
}

Expand Down