Skip to content

Commit

Permalink
Remove tagging boilerplate for Plugin SDK resources - serverlessrepo.
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Apr 11, 2023
1 parent 788a5e6 commit b93b471
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
20 changes: 4 additions & 16 deletions internal/service/serverlessrepo/cloudformation_stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const (
cloudFormationStackTagSemanticVersion = "serverlessrepo:semanticVersion"
)

// @SDKResource("aws_serverlessapplicationrepository_cloudformation_stack")
// @SDKResource("aws_serverlessapplicationrepository_cloudformation_stack", name="CloudFormation Stack")
// @Tags
func ResourceCloudFormationStack() *schema.Resource {
return &schema.Resource{
CreateWithoutTimeout: resourceCloudFormationStackCreate,
Expand Down Expand Up @@ -132,8 +133,6 @@ func resourceCloudFormationStackRead(ctx context.Context, d *schema.ResourceData
var diags diag.Diagnostics
serverlessConn := meta.(*conns.AWSClient).ServerlessRepoConn()
cfConn := meta.(*conns.AWSClient).CloudFormationConn()
defaultTagsConfig := meta.(*conns.AWSClient).DefaultTagsConfig
ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig

stack, err := tfcloudformation.FindStackByID(ctx, cfConn, d.Id())

Expand Down Expand Up @@ -166,16 +165,7 @@ func resourceCloudFormationStackRead(ctx context.Context, d *schema.ResourceData
return sdkdiag.AppendErrorf(diags, "describing Serverless Application Repository CloudFormation Stack (%s): missing required tag \"%s\"", d.Id(), cloudFormationStackTagSemanticVersion)
}

tags = tags.IgnoreServerlessApplicationRepository().IgnoreConfig(ignoreTagsConfig)

//lintignore:AWSR002
if err = d.Set("tags", tags.RemoveDefaultConfig(defaultTagsConfig).Map()); err != nil {
return sdkdiag.AppendErrorf(diags, "to set tags: %s", err)
}

if err := d.Set("tags_all", tags.Map()); err != nil {
return sdkdiag.AppendErrorf(diags, "to set tags_all: %s", err)
}
SetTagsOut(ctx, Tags(tags))

if err = d.Set("outputs", flattenCloudFormationOutputs(stack.Outputs)); err != nil {
return sdkdiag.AppendErrorf(diags, "to set outputs: %s", err)
Expand Down Expand Up @@ -305,15 +295,13 @@ func resourceCloudFormationStackImport(ctx context.Context, d *schema.ResourceDa
func createCloudFormationChangeSet(ctx context.Context, d *schema.ResourceData, client *conns.AWSClient) (*cloudformation.DescribeChangeSetOutput, error) {
serverlessConn := client.ServerlessRepoConn()
cfConn := client.CloudFormationConn()
defaultTagsConfig := client.DefaultTagsConfig
tags := defaultTagsConfig.MergeTags(tftags.New(ctx, d.Get("tags").(map[string]interface{})))

stackName := d.Get("name").(string)
changeSetRequest := serverlessrepo.CreateCloudFormationChangeSetRequest{
StackName: aws.String(stackName),
ApplicationId: aws.String(d.Get("application_id").(string)),
Capabilities: flex.ExpandStringSet(d.Get("capabilities").(*schema.Set)),
Tags: Tags(tags.IgnoreServerlessApplicationRepository()),
Tags: GetTagsIn(ctx),
}
if v, ok := d.GetOk("semantic_version"); ok {
changeSetRequest.SemanticVersion = aws.String(v.(string))
Expand Down
2 changes: 2 additions & 0 deletions internal/service/serverlessrepo/service_package_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b93b471

Please sign in to comment.