Skip to content

Commit

Permalink
Adds tag listing for Server Certificates
Browse files Browse the repository at this point in the history
  • Loading branch information
gdavison committed May 15, 2024
1 parent 773ba71 commit 4b2f709
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/service/iam/server_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,14 @@ func stripCR(b []byte) []byte {
func suppressNormalizeCertRemoval(k, old, new string, d *schema.ResourceData) bool {
return normalizeCert(new) == old
}

func serverCertificateTags(ctx context.Context, conn *iam.Client, identifier string) ([]awstypes.Tag, error) {
output, err := conn.ListServerCertificateTags(ctx, &iam.ListServerCertificateTagsInput{
ServerCertificateName: aws.String(identifier),
})
if err != nil {
return nil, err
}

return output.Tags, nil
}
12 changes: 12 additions & 0 deletions internal/service/iam/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,15 @@ func serverCertificateCreateTags(ctx context.Context, conn *iam.Client, identifi
return serverCertificateUpdateTags(ctx, conn, identifier, nil, KeyValueTags(ctx, tags))
}

func serverCertificateKeyValueTags(ctx context.Context, conn *iam.Client, identifier string) (tftags.KeyValueTags, error) {
tags, err := serverCertificateTags(ctx, conn, identifier)
if err != nil {
return tftags.New(ctx, nil), fmt.Errorf("listing tags for resource (%s): %w", identifier, err)
}

return KeyValueTags(ctx, tags), nil
}

// userUpdateTags updates IAM user tags.
// The identifier is the user name.
func userUpdateTags(ctx context.Context, conn *iam.Client, identifier string, oldTagsMap, newTagsMap any) error {
Expand Down Expand Up @@ -479,6 +488,9 @@ func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier, res
}
tags, err = roleKeyValueTags(ctx, meta.(*conns.AWSClient).IAMClient(ctx), roleName)

case "ServerCertificate":
tags, err = serverCertificateKeyValueTags(ctx, meta.(*conns.AWSClient).IAMClient(ctx), identifier)

case "User":
tags, err = userKeyValueTags(ctx, meta.(*conns.AWSClient).IAMClient(ctx), identifier)

Expand Down

0 comments on commit 4b2f709

Please sign in to comment.