diff --git a/aws/internal/keyvaluetags/generators/listtags/main.go b/aws/internal/keyvaluetags/generators/listtags/main.go index 2ab099b640aa..172834073ba4 100644 --- a/aws/internal/keyvaluetags/generators/listtags/main.go +++ b/aws/internal/keyvaluetags/generators/listtags/main.go @@ -17,6 +17,7 @@ import ( const filename = `list_tags_gen.go` var serviceNames = []string{ + "acm", "acmpca", "amplify", "appmesh", @@ -47,6 +48,7 @@ var serviceNames = []string{ "elasticache", "elasticbeanstalk", "elasticsearchservice", + "elbv2", "firehose", "fsx", "glue", @@ -71,6 +73,7 @@ var serviceNames = []string{ "organizations", "qldb", "rds", + "resourcegroups", "route53resolver", "sagemaker", "securityhub", @@ -96,12 +99,13 @@ func main() { ServiceNames: serviceNames, } templateFuncMap := template.FuncMap{ - "ClientType": keyvaluetags.ServiceClientType, - "ListTagsFunction": ServiceListTagsFunction, - "ListTagsInputIdentifierField": ServiceListTagsInputIdentifierField, - "ListTagsInputResourceTypeField": ServiceListTagsInputResourceTypeField, - "ListTagsOutputTagsField": ServiceListTagsOutputTagsField, - "Title": strings.Title, + "ClientType": keyvaluetags.ServiceClientType, + "ListTagsFunction": ServiceListTagsFunction, + "ListTagsInputIdentifierField": ServiceListTagsInputIdentifierField, + "ListTagsInputIdentifierRequiresSlice": ServiceListTagsInputIdentifierRequiresSlice, + "ListTagsInputResourceTypeField": ServiceListTagsInputResourceTypeField, + "ListTagsOutputTagsField": ServiceListTagsOutputTagsField, + "Title": strings.Title, } tmpl, err := template.New("listtags").Funcs(templateFuncMap).Parse(templateBody) @@ -156,7 +160,11 @@ import ( // it may also be a different identifier depending on the service. func {{ . | Title }}ListTags(conn {{ . | ClientType }}, identifier string{{ if . | ListTagsInputResourceTypeField }}, resourceType string{{ end }}) (KeyValueTags, error) { input := &{{ . }}.{{ . | ListTagsFunction }}Input{ + {{- if . | ListTagsInputIdentifierRequiresSlice }} + {{ . | ListTagsInputIdentifierField }}: aws.StringSlice([]string{identifier}), + {{- else }} {{ . | ListTagsInputIdentifierField }}: aws.String(identifier), + {{- end }} {{- if . | ListTagsInputResourceTypeField }} {{ . | ListTagsInputResourceTypeField }}: aws.String(resourceType), {{- end }} @@ -176,6 +184,8 @@ func {{ . | Title }}ListTags(conn {{ . | ClientType }}, identifier string{{ if . // ServiceListTagsFunction determines the service tagging function. func ServiceListTagsFunction(serviceName string) string { switch serviceName { + case "acm": + return "ListTagsForCertificate" case "acmpca": return "ListTags" case "backup": @@ -190,6 +200,8 @@ func ServiceListTagsFunction(serviceName string) string { return "DescribeTags" case "elasticsearchservice": return "ListTags" + case "elbv2": + return "DescribeTags" case "firehose": return "ListTagsForDeliveryStream" case "glue": @@ -204,6 +216,8 @@ func ServiceListTagsFunction(serviceName string) string { return "ListTags" case "redshift": return "DescribeTags" + case "resourcegroups": + return "GetTags" case "sagemaker": return "ListTags" case "workspaces": @@ -216,6 +230,8 @@ func ServiceListTagsFunction(serviceName string) string { // ServiceListTagsInputIdentifierField determines the service tag identifier field. func ServiceListTagsInputIdentifierField(serviceName string) string { switch serviceName { + case "acm": + return "CertificateArn" case "acmpca": return "CertificateAuthorityArn" case "athena": @@ -240,6 +256,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string { return "ResourceName" case "elasticsearchservice": return "ARN" + case "elbv2": + return "ResourceArns" case "firehose": return "DeliveryStreamName" case "fsx": @@ -262,6 +280,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string { return "ResourceName" case "redshift": return "ResourceName" + case "resourcegroups": + return "Arn" case "ssm": return "ResourceId" case "storagegateway": @@ -277,6 +297,16 @@ func ServiceListTagsInputIdentifierField(serviceName string) string { } } +// ServiceTagInputIdentifierRequiresSlice determines if the service tagging resource field requires a slice. +func ServiceListTagsInputIdentifierRequiresSlice(serviceName string) string { + switch serviceName { + case "elbv2": + return "yes" + default: + return "" + } +} + // ServiceListTagsInputResourceTypeField determines the service tagging resource type field. func ServiceListTagsInputResourceTypeField(serviceName string) string { switch serviceName { @@ -304,6 +334,8 @@ func ServiceListTagsOutputTagsField(serviceName string) string { return "ResourceTags" case "elasticsearchservice": return "TagList" + case "elbv2": + return "TagDescriptions[0].Tags" case "neptune": return "TagList" case "rds": diff --git a/aws/internal/keyvaluetags/generators/updatetags/main.go b/aws/internal/keyvaluetags/generators/updatetags/main.go index ab99add1ce30..fa30e9a85953 100644 --- a/aws/internal/keyvaluetags/generators/updatetags/main.go +++ b/aws/internal/keyvaluetags/generators/updatetags/main.go @@ -17,6 +17,8 @@ import ( const filename = `update_tags_gen.go` var serviceNames = []string{ + "acm", + "acmpca", "amplify", "apigateway", "apigatewayv2", @@ -50,6 +52,7 @@ var serviceNames = []string{ "eks", "elasticache", "elasticsearchservice", + "elbv2", "emr", "firehose", "fsx", @@ -78,6 +81,7 @@ var serviceNames = []string{ "ram", "rds", "redshift", + "resourcegroups", "route53resolver", "secretsmanager", "securityhub", @@ -223,6 +227,10 @@ func {{ . | Title }}UpdateTags(conn {{ . | ClientType }}, identifier string{{ if // ServiceTagFunction determines the service tagging function. func ServiceTagFunction(serviceName string) string { switch serviceName { + case "acm": + return "AddTagsToCertificate" + case "acmpca": + return "TagCertificateAuthority" case "databasemigrationservice": return "AddTagsToResource" case "datapipeline": @@ -239,6 +247,8 @@ func ServiceTagFunction(serviceName string) string { return "AddTagsToResource" case "elasticsearchservice": return "AddTags" + case "elbv2": + return "AddTags" case "emr": return "AddTags" case "firehose": @@ -253,6 +263,8 @@ func ServiceTagFunction(serviceName string) string { return "AddTagsToResource" case "redshift": return "CreateTags" + case "resourcegroups": + return "Tag" case "sagemaker": return "AddTags" case "ssm": @@ -269,6 +281,10 @@ func ServiceTagFunction(serviceName string) string { // ServiceTagInputIdentifierField determines the service tag identifier field. func ServiceTagInputIdentifierField(serviceName string) string { switch serviceName { + case "acm": + return "CertificateArn" + case "acmpca": + return "CertificateAuthorityArn" case "athena": return "ResourceARN" case "cloudhsmv2": @@ -295,6 +311,8 @@ func ServiceTagInputIdentifierField(serviceName string) string { return "ResourceName" case "elasticsearchservice": return "ARN" + case "elbv2": + return "ResourceArns" case "emr": return "ResourceId" case "firehose": @@ -325,6 +343,8 @@ func ServiceTagInputIdentifierField(serviceName string) string { return "ResourceName" case "redshift": return "ResourceName" + case "resourcegroups": + return "Arn" case "secretsmanager": return "SecretId" case "ssm": @@ -347,6 +367,8 @@ func ServiceTagInputIdentifierRequiresSlice(serviceName string) string { switch serviceName { case "ec2": return "yes" + case "elbv2": + return "yes" default: return "" } @@ -379,6 +401,10 @@ func ServiceTagInputResourceTypeField(serviceName string) string { // ServiceUntagFunction determines the service untagging function. func ServiceUntagFunction(serviceName string) string { switch serviceName { + case "acm": + return "RemoveTagsFromCertificate" + case "acmpca": + return "UntagCertificateAuthority" case "databasemigrationservice": return "RemoveTagsFromResource" case "datapipeline": @@ -395,6 +421,8 @@ func ServiceUntagFunction(serviceName string) string { return "RemoveTagsFromResource" case "elasticsearchservice": return "RemoveTags" + case "elbv2": + return "RemoveTags" case "emr": return "RemoveTags" case "firehose": @@ -409,6 +437,8 @@ func ServiceUntagFunction(serviceName string) string { return "RemoveTagsFromResource" case "redshift": return "DeleteTags" + case "resourcegroups": + return "Untag" case "sagemaker": return "DeleteTags" case "ssm": @@ -425,6 +455,10 @@ func ServiceUntagFunction(serviceName string) string { // ServiceUntagInputRequiresTagType determines if the service untagging requires full Tag type. func ServiceUntagInputRequiresTagType(serviceName string) string { switch serviceName { + case "acm": + return "yes" + case "acmpca": + return "yes" case "ec2": return "yes" default: @@ -435,6 +469,10 @@ func ServiceUntagInputRequiresTagType(serviceName string) string { // ServiceUntagInputTagsField determines the service untagging tags field. func ServiceUntagInputTagsField(serviceName string) string { switch serviceName { + case "acm": + return "Tags" + case "acmpca": + return "Tags" case "backup": return "TagKeyList" case "cloudhsmv2": @@ -445,6 +483,8 @@ func ServiceUntagInputTagsField(serviceName string) string { return "Tags" case "glue": return "TagsToRemove" + case "resourcegroups": + return "Keys" default: return "TagKeys" } diff --git a/aws/internal/keyvaluetags/list_tags_gen.go b/aws/internal/keyvaluetags/list_tags_gen.go index d8ac3aaf1d2b..52a03874a94e 100644 --- a/aws/internal/keyvaluetags/list_tags_gen.go +++ b/aws/internal/keyvaluetags/list_tags_gen.go @@ -4,6 +4,7 @@ package keyvaluetags import ( "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/acm" "github.com/aws/aws-sdk-go/service/acmpca" "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/appmesh" @@ -34,6 +35,7 @@ import ( "github.com/aws/aws-sdk-go/service/elasticache" "github.com/aws/aws-sdk-go/service/elasticbeanstalk" "github.com/aws/aws-sdk-go/service/elasticsearchservice" + "github.com/aws/aws-sdk-go/service/elbv2" "github.com/aws/aws-sdk-go/service/firehose" "github.com/aws/aws-sdk-go/service/fsx" "github.com/aws/aws-sdk-go/service/glue" @@ -58,6 +60,7 @@ import ( "github.com/aws/aws-sdk-go/service/organizations" "github.com/aws/aws-sdk-go/service/qldb" "github.com/aws/aws-sdk-go/service/rds" + "github.com/aws/aws-sdk-go/service/resourcegroups" "github.com/aws/aws-sdk-go/service/route53resolver" "github.com/aws/aws-sdk-go/service/sagemaker" "github.com/aws/aws-sdk-go/service/securityhub" @@ -71,6 +74,23 @@ import ( "github.com/aws/aws-sdk-go/service/workspaces" ) +// AcmListTags lists acm service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func AcmListTags(conn *acm.ACM, identifier string) (KeyValueTags, error) { + input := &acm.ListTagsForCertificateInput{ + CertificateArn: aws.String(identifier), + } + + output, err := conn.ListTagsForCertificate(input) + + if err != nil { + return New(nil), err + } + + return AcmKeyValueTags(output.Tags), nil +} + // AcmpcaListTags lists acmpca service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -581,6 +601,23 @@ func ElasticsearchserviceListTags(conn *elasticsearchservice.ElasticsearchServic return ElasticsearchserviceKeyValueTags(output.TagList), nil } +// Elbv2ListTags lists elbv2 service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func Elbv2ListTags(conn *elbv2.ELBV2, identifier string) (KeyValueTags, error) { + input := &elbv2.DescribeTagsInput{ + ResourceArns: aws.StringSlice([]string{identifier}), + } + + output, err := conn.DescribeTags(input) + + if err != nil { + return New(nil), err + } + + return Elbv2KeyValueTags(output.TagDescriptions[0].Tags), nil +} + // FirehoseListTags lists firehose service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -989,6 +1026,23 @@ func RdsListTags(conn *rds.RDS, identifier string) (KeyValueTags, error) { return RdsKeyValueTags(output.TagList), nil } +// ResourcegroupsListTags lists resourcegroups service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func ResourcegroupsListTags(conn *resourcegroups.ResourceGroups, identifier string) (KeyValueTags, error) { + input := &resourcegroups.GetTagsInput{ + Arn: aws.String(identifier), + } + + output, err := conn.GetTags(input) + + if err != nil { + return New(nil), err + } + + return ResourcegroupsKeyValueTags(output.Tags), nil +} + // Route53resolverListTags lists route53resolver service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index f2321892d0ab..60eea88b4764 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -6,6 +6,7 @@ import ( "fmt" "reflect" + "github.com/aws/aws-sdk-go/service/acm" "github.com/aws/aws-sdk-go/service/acmpca" "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigateway" @@ -42,6 +43,7 @@ import ( "github.com/aws/aws-sdk-go/service/elasticache" "github.com/aws/aws-sdk-go/service/elasticbeanstalk" "github.com/aws/aws-sdk-go/service/elasticsearchservice" + "github.com/aws/aws-sdk-go/service/elbv2" "github.com/aws/aws-sdk-go/service/emr" "github.com/aws/aws-sdk-go/service/firehose" "github.com/aws/aws-sdk-go/service/fsx" @@ -72,6 +74,7 @@ import ( "github.com/aws/aws-sdk-go/service/ram" "github.com/aws/aws-sdk-go/service/rds" "github.com/aws/aws-sdk-go/service/redshift" + "github.com/aws/aws-sdk-go/service/resourcegroups" "github.com/aws/aws-sdk-go/service/route53resolver" "github.com/aws/aws-sdk-go/service/sagemaker" "github.com/aws/aws-sdk-go/service/secretsmanager" @@ -93,6 +96,8 @@ func ServiceClientType(serviceName string) string { var funcType reflect.Type switch serviceName { + case "acm": + funcType = reflect.TypeOf(acm.New) case "acmpca": funcType = reflect.TypeOf(acmpca.New) case "amplify": @@ -165,6 +170,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(elasticbeanstalk.New) case "elasticsearchservice": funcType = reflect.TypeOf(elasticsearchservice.New) + case "elbv2": + funcType = reflect.TypeOf(elbv2.New) case "emr": funcType = reflect.TypeOf(emr.New) case "firehose": @@ -225,6 +232,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(rds.New) case "redshift": funcType = reflect.TypeOf(redshift.New) + case "resourcegroups": + funcType = reflect.TypeOf(resourcegroups.New) case "route53resolver": funcType = reflect.TypeOf(route53resolver.New) case "sagemaker": diff --git a/aws/internal/keyvaluetags/update_tags_gen.go b/aws/internal/keyvaluetags/update_tags_gen.go index 5811f2b4e1eb..8570c0aa3ae1 100644 --- a/aws/internal/keyvaluetags/update_tags_gen.go +++ b/aws/internal/keyvaluetags/update_tags_gen.go @@ -6,6 +6,8 @@ import ( "fmt" "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/service/acm" + "github.com/aws/aws-sdk-go/service/acmpca" "github.com/aws/aws-sdk-go/service/amplify" "github.com/aws/aws-sdk-go/service/apigateway" "github.com/aws/aws-sdk-go/service/apigatewayv2" @@ -39,6 +41,7 @@ import ( "github.com/aws/aws-sdk-go/service/eks" "github.com/aws/aws-sdk-go/service/elasticache" "github.com/aws/aws-sdk-go/service/elasticsearchservice" + "github.com/aws/aws-sdk-go/service/elbv2" "github.com/aws/aws-sdk-go/service/emr" "github.com/aws/aws-sdk-go/service/firehose" "github.com/aws/aws-sdk-go/service/fsx" @@ -67,6 +70,7 @@ import ( "github.com/aws/aws-sdk-go/service/ram" "github.com/aws/aws-sdk-go/service/rds" "github.com/aws/aws-sdk-go/service/redshift" + "github.com/aws/aws-sdk-go/service/resourcegroups" "github.com/aws/aws-sdk-go/service/route53resolver" "github.com/aws/aws-sdk-go/service/secretsmanager" "github.com/aws/aws-sdk-go/service/securityhub" @@ -80,6 +84,78 @@ import ( "github.com/aws/aws-sdk-go/service/workspaces" ) +// AcmUpdateTags updates acm service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func AcmUpdateTags(conn *acm.ACM, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &acm.RemoveTagsFromCertificateInput{ + CertificateArn: aws.String(identifier), + Tags: removedTags.IgnoreAws().AcmTags(), + } + + _, err := conn.RemoveTagsFromCertificate(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &acm.AddTagsToCertificateInput{ + CertificateArn: aws.String(identifier), + Tags: updatedTags.IgnoreAws().AcmTags(), + } + + _, err := conn.AddTagsToCertificate(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + +// AcmpcaUpdateTags updates acmpca service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func AcmpcaUpdateTags(conn *acmpca.ACMPCA, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &acmpca.UntagCertificateAuthorityInput{ + CertificateAuthorityArn: aws.String(identifier), + Tags: removedTags.IgnoreAws().AcmpcaTags(), + } + + _, err := conn.UntagCertificateAuthority(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &acmpca.TagCertificateAuthorityInput{ + CertificateAuthorityArn: aws.String(identifier), + Tags: updatedTags.IgnoreAws().AcmpcaTags(), + } + + _, err := conn.TagCertificateAuthority(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // AmplifyUpdateTags updates amplify service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -1268,6 +1344,42 @@ func ElasticsearchserviceUpdateTags(conn *elasticsearchservice.ElasticsearchServ return nil } +// Elbv2UpdateTags updates elbv2 service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func Elbv2UpdateTags(conn *elbv2.ELBV2, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &elbv2.RemoveTagsInput{ + ResourceArns: aws.StringSlice([]string{identifier}), + TagKeys: aws.StringSlice(removedTags.Keys()), + } + + _, err := conn.RemoveTags(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &elbv2.AddTagsInput{ + ResourceArns: aws.StringSlice([]string{identifier}), + Tags: updatedTags.IgnoreAws().Elbv2Tags(), + } + + _, err := conn.AddTags(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // EmrUpdateTags updates emr service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -2276,6 +2388,42 @@ func RedshiftUpdateTags(conn *redshift.Redshift, identifier string, oldTagsMap i return nil } +// ResourcegroupsUpdateTags updates resourcegroups service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func ResourcegroupsUpdateTags(conn *resourcegroups.ResourceGroups, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &resourcegroups.UntagInput{ + Arn: aws.String(identifier), + Keys: aws.StringSlice(removedTags.Keys()), + } + + _, err := conn.Untag(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &resourcegroups.TagInput{ + Arn: aws.String(identifier), + Tags: updatedTags.IgnoreAws().ResourcegroupsTags(), + } + + _, err := conn.Tag(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // Route53resolverUpdateTags updates route53resolver service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service.