Skip to content

Commit

Permalink
API Gateway v2 API tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kit Ewbank authored and ewbankkit committed Jul 26, 2019
1 parent 73a910f commit c1c60ba
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
5 changes: 5 additions & 0 deletions aws/resource_aws_api_gateway2_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ func resourceAwsApiGateway2ApiRead(d *schema.ResourceData, meta interface{}) err
}
d.Set("version", resp.Version)

err = getTagsApiGateway2(conn, d, d.Get("arn").(string))
if err != nil {
return fmt.Errorf("error reading API Gateway v2 API tags (%s): %s", d.Id(), err)
}

return nil
}

Expand Down
18 changes: 18 additions & 0 deletions aws/tags_apigateway2.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ import (
"github.com/hashicorp/terraform/helper/schema"
)

// getTags is a helper to get the tags for a resource. It expects the
// tags field to be named "tags"
func getTagsApiGateway2(conn *apigatewayv2.ApiGatewayV2, d *schema.ResourceData, arn string) error {
resp, err := conn.GetTags(&apigatewayv2.GetTagsInput{
ResourceArn: aws.String(arn),
})
if err != nil {
return err
}

err = d.Set("tags", tagsToMapGeneric(resp.Tags))
if err != nil {
return err
}

return nil
}

// setTags is a helper to set the tags for a resource. It expects the
// tags field to be named "tags"
func setTagsApiGateway2(conn *apigatewayv2.ApiGatewayV2, d *schema.ResourceData, arn string) error {
Expand Down

0 comments on commit c1c60ba

Please sign in to comment.