From a8754f6865cc3ee390c5ce623135a63f997ceadd Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Mon, 4 Nov 2019 23:55:37 +0200 Subject: [PATCH 1/5] cloudwatchlogs support --- .../keyvaluetags/generators/listtags/main.go | 5 +++++ .../keyvaluetags/generators/updatetags/main.go | 9 +++++++++ .../service_generation_customizations.go | 12 ++++++++++++ 3 files changed, 26 insertions(+) diff --git a/aws/internal/keyvaluetags/generators/listtags/main.go b/aws/internal/keyvaluetags/generators/listtags/main.go index 172834073ba..23f0d991a77 100644 --- a/aws/internal/keyvaluetags/generators/listtags/main.go +++ b/aws/internal/keyvaluetags/generators/listtags/main.go @@ -28,6 +28,7 @@ var serviceNames = []string{ "cloudhsmv2", "cloudwatch", "cloudwatchevents", + "cloudwatchlogs", "codecommit", "codedeploy", "codepipeline", @@ -192,6 +193,8 @@ func ServiceListTagsFunction(serviceName string) string { return "ListTags" case "cloudhsmv2": return "ListTags" + case "cloudwatchlogs": + return "ListTagsLogGroup" case "dax": return "ListTags" case "dynamodb": @@ -242,6 +245,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string { return "ResourceARN" case "cloudwatchevents": return "ResourceARN" + case "cloudwatchlogs": + return "LogGroupName" case "dax": return "ResourceName" case "devicefarm": diff --git a/aws/internal/keyvaluetags/generators/updatetags/main.go b/aws/internal/keyvaluetags/generators/updatetags/main.go index fa30e9a8595..e0bbd895dab 100644 --- a/aws/internal/keyvaluetags/generators/updatetags/main.go +++ b/aws/internal/keyvaluetags/generators/updatetags/main.go @@ -30,6 +30,7 @@ var serviceNames = []string{ "cloudhsmv2", "cloudwatch", "cloudwatchevents", + "cloudwatchlogs", "codecommit", "codedeploy", "codepipeline", @@ -231,6 +232,8 @@ func ServiceTagFunction(serviceName string) string { return "AddTagsToCertificate" case "acmpca": return "TagCertificateAuthority" + case "cloudwatchlogs": + return "TagLogGroup" case "databasemigrationservice": return "AddTagsToResource" case "datapipeline": @@ -293,6 +296,8 @@ func ServiceTagInputIdentifierField(serviceName string) string { return "ResourceARN" case "cloudwatchevents": return "ResourceARN" + case "cloudwatchlogs": + return "LogGroupName" case "datapipeline": return "PipelineId" case "dax": @@ -405,6 +410,8 @@ func ServiceUntagFunction(serviceName string) string { return "RemoveTagsFromCertificate" case "acmpca": return "UntagCertificateAuthority" + case "cloudwatchlogs": + return "UntagLogGroup" case "databasemigrationservice": return "RemoveTagsFromResource" case "datapipeline": @@ -477,6 +484,8 @@ func ServiceUntagInputTagsField(serviceName string) string { return "TagKeyList" case "cloudhsmv2": return "TagKeyList" + case "cloudwatchlogs": + return "Tags" case "datasync": return "Keys" case "ec2": diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index 60eea88b476..38c0fa49862 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -16,10 +16,13 @@ import ( "github.com/aws/aws-sdk-go/service/appsync" "github.com/aws/aws-sdk-go/service/athena" "github.com/aws/aws-sdk-go/service/backup" + "github.com/aws/aws-sdk-go/service/batch" + "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/aws/aws-sdk-go/service/cloudhsmv2" "github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/codecommit" "github.com/aws/aws-sdk-go/service/codedeploy" "github.com/aws/aws-sdk-go/service/codepipeline" @@ -86,6 +89,7 @@ import ( "github.com/aws/aws-sdk-go/service/swf" "github.com/aws/aws-sdk-go/service/transfer" "github.com/aws/aws-sdk-go/service/waf" + "github.com/aws/aws-sdk-go/service/wafregional" "github.com/aws/aws-sdk-go/service/workspaces" ) @@ -116,6 +120,10 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(athena.New) case "backup": funcType = reflect.TypeOf(backup.New) + case "batch": + funcType = reflect.TypeOf(batch.New) + case "cloudformation": + funcType = reflect.TypeOf(cloudformation.New) case "cloudfront": funcType = reflect.TypeOf(cloudfront.New) case "cloudhsmv2": @@ -124,6 +132,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(cloudwatch.New) case "cloudwatchevents": funcType = reflect.TypeOf(cloudwatchevents.New) + case "cloudwatchlogs": + funcType = reflect.TypeOf(cloudwatchlogs.New) case "codecommit": funcType = reflect.TypeOf(codecommit.New) case "codedeploy": @@ -256,6 +266,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(transfer.New) case "waf": funcType = reflect.TypeOf(waf.New) + case "wafregional": + funcType = reflect.TypeOf(wafregional.New) case "workspaces": funcType = reflect.TypeOf(workspaces.New) default: From 213fcd42ba11e60b1757d9e8010e47a826b725f7 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Mon, 4 Nov 2019 23:57:32 +0200 Subject: [PATCH 2/5] remove wafregional, it uses waf tags --- aws/internal/keyvaluetags/service_generation_customizations.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index 38c0fa49862..985b4160047 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -89,7 +89,6 @@ import ( "github.com/aws/aws-sdk-go/service/swf" "github.com/aws/aws-sdk-go/service/transfer" "github.com/aws/aws-sdk-go/service/waf" - "github.com/aws/aws-sdk-go/service/wafregional" "github.com/aws/aws-sdk-go/service/workspaces" ) @@ -266,8 +265,6 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(transfer.New) case "waf": funcType = reflect.TypeOf(waf.New) - case "wafregional": - funcType = reflect.TypeOf(wafregional.New) case "workspaces": funcType = reflect.TypeOf(workspaces.New) default: From 002f52514a2c899ea313fdc34fe733dd7ea184c6 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Mon, 4 Nov 2019 23:59:42 +0200 Subject: [PATCH 3/5] also no need for batch --- aws/internal/keyvaluetags/service_generation_customizations.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index 985b4160047..4c22582e102 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -16,7 +16,6 @@ import ( "github.com/aws/aws-sdk-go/service/appsync" "github.com/aws/aws-sdk-go/service/athena" "github.com/aws/aws-sdk-go/service/backup" - "github.com/aws/aws-sdk-go/service/batch" "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/aws/aws-sdk-go/service/cloudhsmv2" @@ -119,8 +118,6 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(athena.New) case "backup": funcType = reflect.TypeOf(backup.New) - case "batch": - funcType = reflect.TypeOf(batch.New) case "cloudformation": funcType = reflect.TypeOf(cloudformation.New) case "cloudfront": From 4494b37a0846ae6b73c3070176e8837cbd51941e Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 5 Nov 2019 00:02:19 +0200 Subject: [PATCH 4/5] also cloudformation --- aws/internal/keyvaluetags/service_generation_customizations.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/aws/internal/keyvaluetags/service_generation_customizations.go b/aws/internal/keyvaluetags/service_generation_customizations.go index 4c22582e102..1e1e7c36dc8 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -16,7 +16,6 @@ import ( "github.com/aws/aws-sdk-go/service/appsync" "github.com/aws/aws-sdk-go/service/athena" "github.com/aws/aws-sdk-go/service/backup" - "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/aws/aws-sdk-go/service/cloudfront" "github.com/aws/aws-sdk-go/service/cloudhsmv2" "github.com/aws/aws-sdk-go/service/cloudwatch" @@ -118,8 +117,6 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(athena.New) case "backup": funcType = reflect.TypeOf(backup.New) - case "cloudformation": - funcType = reflect.TypeOf(cloudformation.New) case "cloudfront": funcType = reflect.TypeOf(cloudfront.New) case "cloudhsmv2": From e752de2400d0ef2240c82ec9bc1bb9d8eeae1a84 Mon Sep 17 00:00:00 2001 From: DrFaust92 Date: Tue, 5 Nov 2019 00:31:58 +0200 Subject: [PATCH 5/5] add sqs support --- .../keyvaluetags/generators/listtags/main.go | 5 ++ .../generators/updatetags/main.go | 7 ++ aws/internal/keyvaluetags/list_tags_gen.go | 36 +++++++++ .../service_generation_customizations.go | 3 + aws/internal/keyvaluetags/update_tags_gen.go | 74 +++++++++++++++++++ 5 files changed, 125 insertions(+) diff --git a/aws/internal/keyvaluetags/generators/listtags/main.go b/aws/internal/keyvaluetags/generators/listtags/main.go index 23f0d991a77..92c0a8ca642 100644 --- a/aws/internal/keyvaluetags/generators/listtags/main.go +++ b/aws/internal/keyvaluetags/generators/listtags/main.go @@ -80,6 +80,7 @@ var serviceNames = []string{ "securityhub", "sfn", "sns", + "sqs", "ssm", "storagegateway", "swf", @@ -223,6 +224,8 @@ func ServiceListTagsFunction(serviceName string) string { return "GetTags" case "sagemaker": return "ListTags" + case "sqs": + return "ListQueueTags" case "workspaces": return "DescribeTags" default: @@ -287,6 +290,8 @@ func ServiceListTagsInputIdentifierField(serviceName string) string { return "ResourceName" case "resourcegroups": return "Arn" + case "sqs": + return "QueueUrl" case "ssm": return "ResourceId" case "storagegateway": diff --git a/aws/internal/keyvaluetags/generators/updatetags/main.go b/aws/internal/keyvaluetags/generators/updatetags/main.go index e0bbd895dab..524f2549916 100644 --- a/aws/internal/keyvaluetags/generators/updatetags/main.go +++ b/aws/internal/keyvaluetags/generators/updatetags/main.go @@ -88,6 +88,7 @@ var serviceNames = []string{ "securityhub", "sfn", "sns", + "sqs", "ssm", "storagegateway", "swf", @@ -270,6 +271,8 @@ func ServiceTagFunction(serviceName string) string { return "Tag" case "sagemaker": return "AddTags" + case "sqs": + return "TagQueue" case "ssm": return "AddTagsToResource" case "storagegateway": @@ -352,6 +355,8 @@ func ServiceTagInputIdentifierField(serviceName string) string { return "Arn" case "secretsmanager": return "SecretId" + case "sqs": + return "QueueUrl" case "ssm": return "ResourceId" case "storagegateway": @@ -448,6 +453,8 @@ func ServiceUntagFunction(serviceName string) string { return "Untag" case "sagemaker": return "DeleteTags" + case "sqs": + return "UntagQueue" case "ssm": return "RemoveTagsFromResource" case "storagegateway": diff --git a/aws/internal/keyvaluetags/list_tags_gen.go b/aws/internal/keyvaluetags/list_tags_gen.go index 52a03874a94..5765d2b3268 100644 --- a/aws/internal/keyvaluetags/list_tags_gen.go +++ b/aws/internal/keyvaluetags/list_tags_gen.go @@ -15,6 +15,7 @@ import ( "github.com/aws/aws-sdk-go/service/cloudhsmv2" "github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/codecommit" "github.com/aws/aws-sdk-go/service/codedeploy" "github.com/aws/aws-sdk-go/service/codepipeline" @@ -66,6 +67,7 @@ import ( "github.com/aws/aws-sdk-go/service/securityhub" "github.com/aws/aws-sdk-go/service/sfn" "github.com/aws/aws-sdk-go/service/sns" + "github.com/aws/aws-sdk-go/service/sqs" "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/storagegateway" "github.com/aws/aws-sdk-go/service/swf" @@ -261,6 +263,23 @@ func CloudwatcheventsListTags(conn *cloudwatchevents.CloudWatchEvents, identifie return CloudwatcheventsKeyValueTags(output.Tags), nil } +// CloudwatchlogsListTags lists cloudwatchlogs service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func CloudwatchlogsListTags(conn *cloudwatchlogs.CloudWatchLogs, identifier string) (KeyValueTags, error) { + input := &cloudwatchlogs.ListTagsLogGroupInput{ + LogGroupName: aws.String(identifier), + } + + output, err := conn.ListTagsLogGroup(input) + + if err != nil { + return New(nil), err + } + + return CloudwatchlogsKeyValueTags(output.Tags), nil +} + // CodecommitListTags lists codecommit service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -1128,6 +1147,23 @@ func SnsListTags(conn *sns.SNS, identifier string) (KeyValueTags, error) { return SnsKeyValueTags(output.Tags), nil } +// SqsListTags lists sqs service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func SqsListTags(conn *sqs.SQS, identifier string) (KeyValueTags, error) { + input := &sqs.ListQueueTagsInput{ + QueueUrl: aws.String(identifier), + } + + output, err := conn.ListQueueTags(input) + + if err != nil { + return New(nil), err + } + + return SqsKeyValueTags(output.Tags), nil +} + // SsmListTags lists ssm 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 1e1e7c36dc8..0b3c2eca82e 100644 --- a/aws/internal/keyvaluetags/service_generation_customizations.go +++ b/aws/internal/keyvaluetags/service_generation_customizations.go @@ -82,6 +82,7 @@ import ( "github.com/aws/aws-sdk-go/service/securityhub" "github.com/aws/aws-sdk-go/service/sfn" "github.com/aws/aws-sdk-go/service/sns" + "github.com/aws/aws-sdk-go/service/sqs" "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/storagegateway" "github.com/aws/aws-sdk-go/service/swf" @@ -249,6 +250,8 @@ func ServiceClientType(serviceName string) string { funcType = reflect.TypeOf(sfn.New) case "sns": funcType = reflect.TypeOf(sns.New) + case "sqs": + funcType = reflect.TypeOf(sqs.New) case "ssm": funcType = reflect.TypeOf(ssm.New) case "storagegateway": diff --git a/aws/internal/keyvaluetags/update_tags_gen.go b/aws/internal/keyvaluetags/update_tags_gen.go index 8570c0aa3ae..6b10dccda20 100644 --- a/aws/internal/keyvaluetags/update_tags_gen.go +++ b/aws/internal/keyvaluetags/update_tags_gen.go @@ -19,6 +19,7 @@ import ( "github.com/aws/aws-sdk-go/service/cloudhsmv2" "github.com/aws/aws-sdk-go/service/cloudwatch" "github.com/aws/aws-sdk-go/service/cloudwatchevents" + "github.com/aws/aws-sdk-go/service/cloudwatchlogs" "github.com/aws/aws-sdk-go/service/codecommit" "github.com/aws/aws-sdk-go/service/codedeploy" "github.com/aws/aws-sdk-go/service/codepipeline" @@ -76,6 +77,7 @@ import ( "github.com/aws/aws-sdk-go/service/securityhub" "github.com/aws/aws-sdk-go/service/sfn" "github.com/aws/aws-sdk-go/service/sns" + "github.com/aws/aws-sdk-go/service/sqs" "github.com/aws/aws-sdk-go/service/ssm" "github.com/aws/aws-sdk-go/service/storagegateway" "github.com/aws/aws-sdk-go/service/swf" @@ -552,6 +554,42 @@ func CloudwatcheventsUpdateTags(conn *cloudwatchevents.CloudWatchEvents, identif return nil } +// CloudwatchlogsUpdateTags updates cloudwatchlogs service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func CloudwatchlogsUpdateTags(conn *cloudwatchlogs.CloudWatchLogs, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &cloudwatchlogs.UntagLogGroupInput{ + LogGroupName: aws.String(identifier), + Tags: aws.StringSlice(removedTags.Keys()), + } + + _, err := conn.UntagLogGroup(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &cloudwatchlogs.TagLogGroupInput{ + LogGroupName: aws.String(identifier), + Tags: updatedTags.IgnoreAws().CloudwatchlogsTags(), + } + + _, err := conn.TagLogGroup(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // CodecommitUpdateTags updates codecommit service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. @@ -2604,6 +2642,42 @@ func SnsUpdateTags(conn *sns.SNS, identifier string, oldTagsMap interface{}, new return nil } +// SqsUpdateTags updates sqs service tags. +// The identifier is typically the Amazon Resource Name (ARN), although +// it may also be a different identifier depending on the service. +func SqsUpdateTags(conn *sqs.SQS, identifier string, oldTagsMap interface{}, newTagsMap interface{}) error { + oldTags := New(oldTagsMap) + newTags := New(newTagsMap) + + if removedTags := oldTags.Removed(newTags); len(removedTags) > 0 { + input := &sqs.UntagQueueInput{ + QueueUrl: aws.String(identifier), + TagKeys: aws.StringSlice(removedTags.Keys()), + } + + _, err := conn.UntagQueue(input) + + if err != nil { + return fmt.Errorf("error untagging resource (%s): %w", identifier, err) + } + } + + if updatedTags := oldTags.Updated(newTags); len(updatedTags) > 0 { + input := &sqs.TagQueueInput{ + QueueUrl: aws.String(identifier), + Tags: updatedTags.IgnoreAws().SqsTags(), + } + + _, err := conn.TagQueue(input) + + if err != nil { + return fmt.Errorf("error tagging resource (%s): %w", identifier, err) + } + } + + return nil +} + // SsmUpdateTags updates ssm service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service.