From 800676a298a97525a7be076b1e9d786eb5b1f97d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:49 -0400 Subject: [PATCH 01/78] ci: Prefer constant for string literals --- .ci/.semgrep-constants.yml | 100 +++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/.ci/.semgrep-constants.yml b/.ci/.semgrep-constants.yml index 423e7cbeb10..9070fee3044 100644 --- a/.ci/.semgrep-constants.yml +++ b/.ci/.semgrep-constants.yml @@ -190,6 +190,16 @@ rules: - pattern: '"configuration"' severity: ERROR fix: "names.AttrConfiguration" + - id: literal-content-string-constant + languages: [go] + message: Use the constant `names.AttrContent` for the string literal "content" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"content"' + severity: ERROR + fix: "names.AttrContent" - id: literal-content_type-string-constant languages: [go] message: Use the constant `names.AttrContentType` for the string literal "content_type" @@ -240,6 +250,26 @@ rules: - pattern: '"creation_time"' severity: ERROR fix: "names.AttrCreationTime" + - id: literal-dns_name-string-constant + languages: [go] + message: Use the constant `names.AttrDNSName` for the string literal "dns_name" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"dns_name"' + severity: ERROR + fix: "names.AttrDNSName" + - id: literal-database-string-constant + languages: [go] + message: Use the constant `names.AttrDatabase` for the string literal "database" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"database"' + severity: ERROR + fix: "names.AttrDatabase" - id: literal-database_name-string-constant languages: [go] message: Use the constant `names.AttrDatabaseName` for the string literal "database_name" @@ -310,6 +340,16 @@ rules: - pattern: '"display_name"' severity: ERROR fix: "names.AttrDisplayName" + - id: literal-domain-string-constant + languages: [go] + message: Use the constant `names.AttrDomain` for the string literal "domain" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"domain"' + severity: ERROR + fix: "names.AttrDomain" - id: literal-domain_name-string-constant languages: [go] message: Use the constant `names.AttrDomainName` for the string literal "domain_name" @@ -320,6 +360,16 @@ rules: - pattern: '"domain_name"' severity: ERROR fix: "names.AttrDomainName" + - id: literal-duration-string-constant + languages: [go] + message: Use the constant `names.AttrDuration` for the string literal "duration" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"duration"' + severity: ERROR + fix: "names.AttrDuration" - id: literal-enabled-string-constant languages: [go] message: Use the constant `names.AttrEnabled` for the string literal "enabled" @@ -570,6 +620,16 @@ rules: - pattern: '"log_group_name"' severity: ERROR fix: "names.AttrLogGroupName" + - id: literal-logging_configuration-string-constant + languages: [go] + message: Use the constant `names.AttrLoggingConfiguration` for the string literal "logging_configuration" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"logging_configuration"' + severity: ERROR + fix: "names.AttrLoggingConfiguration" - id: literal-max-string-constant languages: [go] message: Use the constant `names.AttrMax` for the string literal "max" @@ -860,6 +920,16 @@ rules: - pattern: '"role_arn"' severity: ERROR fix: "names.AttrRoleARN" + - id: literal-s3_bucket-string-constant + languages: [go] + message: Use the constant `names.AttrS3Bucket` for the string literal "s3_bucket" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"s3_bucket"' + severity: ERROR + fix: "names.AttrS3Bucket" - id: literal-s3_bucket_name-string-constant languages: [go] message: Use the constant `names.AttrS3BucketName` for the string literal "s3_bucket_name" @@ -900,6 +970,16 @@ rules: - pattern: '"schedule_expression"' severity: ERROR fix: "names.AttrScheduleExpression" + - id: literal-schema-string-constant + languages: [go] + message: Use the constant `names.AttrSchema` for the string literal "schema" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"schema"' + severity: ERROR + fix: "names.AttrSchema" - id: literal-secret_key-string-constant languages: [go] message: Use the constant `names.AttrSecretKey` for the string literal "secret_key" @@ -1030,6 +1110,16 @@ rules: - pattern: '"subnet_ids"' severity: ERROR fix: "names.AttrSubnetIDs" + - id: literal-subnets-string-constant + languages: [go] + message: Use the constant `names.AttrSubnets` for the string literal "subnets" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"subnets"' + severity: ERROR + fix: "names.AttrSubnets" - id: literal-table_name-string-constant languages: [go] message: Use the constant `names.AttrTableName` for the string literal "table_name" @@ -1210,3 +1300,13 @@ rules: - pattern: '"version"' severity: ERROR fix: "names.AttrVersion" + - id: literal-weight-string-constant + languages: [go] + message: Use the constant `names.AttrWeight` for the string literal "weight" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"weight"' + severity: ERROR + fix: "names.AttrWeight" From be667493abd004a5953a0f4cb784252d01f0287a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:49 -0400 Subject: [PATCH 02/78] names: Add constant for string literals --- names/attr_consts_gen.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/names/attr_consts_gen.go b/names/attr_consts_gen.go index bebaaddaf4e..0c05509575d 100644 --- a/names/attr_consts_gen.go +++ b/names/attr_consts_gen.go @@ -28,11 +28,14 @@ const ( AttrClientID = "client_id" AttrClusterIdentifier = "cluster_identifier" AttrConfiguration = "configuration" + AttrContent = "content" AttrContentType = "content_type" AttrCreatedAt = "created_at" AttrCreatedDate = "created_date" AttrCreationDate = "creation_date" AttrCreationTime = "creation_time" + AttrDNSName = "dns_name" + AttrDatabase = "database" AttrDatabaseName = "database_name" AttrDeleteOnTermination = "delete_on_termination" AttrDescription = "description" @@ -40,7 +43,9 @@ const ( AttrDestinationARN = "destination_arn" AttrDeviceName = "device_name" AttrDisplayName = "display_name" + AttrDomain = "domain" AttrDomainName = "domain_name" + AttrDuration = "duration" AttrEnabled = "enabled" AttrEncrypted = "encrypted" AttrEncryptionConfiguration = "encryption_configuration" @@ -66,6 +71,7 @@ const ( AttrKey = "key" AttrLastUpdatedDate = "last_updated_date" AttrLogGroupName = "log_group_name" + AttrLoggingConfiguration = "logging_configuration" AttrMax = "max" AttrMetricName = "metric_name" AttrMin = "min" @@ -95,10 +101,12 @@ const ( AttrResourceARN = "resource_arn" AttrResourceType = "resource_type" AttrRoleARN = "role_arn" + AttrS3Bucket = "s3_bucket" AttrS3BucketName = "s3_bucket_name" AttrSNSTopicARN = "sns_topic_arn" AttrSchedule = "schedule" AttrScheduleExpression = "schedule_expression" + AttrSchema = "schema" AttrSecretKey = "secret_key" AttrSecurityGroupIDs = "security_group_ids" AttrSecurityGroups = "security_groups" @@ -112,6 +120,7 @@ const ( AttrStatus = "status" AttrSubnetID = "subnet_id" AttrSubnetIDs = "subnet_ids" + AttrSubnets = "subnets" AttrTableName = "table_name" AttrTags = "tags" AttrTagsAll = "tags_all" @@ -130,6 +139,7 @@ const ( AttrValue = "value" AttrValues = "values" AttrVersion = "version" + AttrWeight = "weight" ) // ConstOrQuote returns the constant name for the given attribute if it exists. @@ -156,11 +166,14 @@ func ConstOrQuote(constant string) string { "client_id": "AttrClientID", "cluster_identifier": "AttrClusterIdentifier", "configuration": "AttrConfiguration", + "content": "AttrContent", "content_type": "AttrContentType", "created_at": "AttrCreatedAt", "created_date": "AttrCreatedDate", "creation_date": "AttrCreationDate", "creation_time": "AttrCreationTime", + "dns_name": "AttrDNSName", + "database": "AttrDatabase", "database_name": "AttrDatabaseName", "delete_on_termination": "AttrDeleteOnTermination", "description": "AttrDescription", @@ -168,7 +181,9 @@ func ConstOrQuote(constant string) string { "destination_arn": "AttrDestinationARN", "device_name": "AttrDeviceName", "display_name": "AttrDisplayName", + "domain": "AttrDomain", "domain_name": "AttrDomainName", + "duration": "AttrDuration", "enabled": "AttrEnabled", "encrypted": "AttrEncrypted", "encryption_configuration": "AttrEncryptionConfiguration", @@ -194,6 +209,7 @@ func ConstOrQuote(constant string) string { "key": "AttrKey", "last_updated_date": "AttrLastUpdatedDate", "log_group_name": "AttrLogGroupName", + "logging_configuration": "AttrLoggingConfiguration", "max": "AttrMax", "metric_name": "AttrMetricName", "min": "AttrMin", @@ -223,10 +239,12 @@ func ConstOrQuote(constant string) string { "resource_arn": "AttrResourceARN", "resource_type": "AttrResourceType", "role_arn": "AttrRoleARN", + "s3_bucket": "AttrS3Bucket", "s3_bucket_name": "AttrS3BucketName", "sns_topic_arn": "AttrSNSTopicARN", "schedule": "AttrSchedule", "schedule_expression": "AttrScheduleExpression", + "schema": "AttrSchema", "secret_key": "AttrSecretKey", "security_group_ids": "AttrSecurityGroupIDs", "security_groups": "AttrSecurityGroups", @@ -240,6 +258,7 @@ func ConstOrQuote(constant string) string { "status": "AttrStatus", "subnet_id": "AttrSubnetID", "subnet_ids": "AttrSubnetIDs", + "subnets": "AttrSubnets", "table_name": "AttrTableName", "tags": "AttrTags", "tags_all": "AttrTagsAll", @@ -258,6 +277,7 @@ func ConstOrQuote(constant string) string { "value": "AttrValue", "values": "AttrValues", "version": "AttrVersion", + "weight": "AttrWeight", } if v, ok := allConstants[constant]; ok { From 0e328785c4769a78e8e2bf77ed93470e3063df10 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:50 -0400 Subject: [PATCH 03/78] acm: Use constants for strings --- internal/service/acm/certificate_data_source.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/acm/certificate_data_source.go b/internal/service/acm/certificate_data_source.go index 4437d5b873c..2f70b2fa462 100644 --- a/internal/service/acm/certificate_data_source.go +++ b/internal/service/acm/certificate_data_source.go @@ -38,7 +38,7 @@ func dataSourceCertificate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, }, @@ -80,7 +80,7 @@ func dataSourceCertificateRead(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).ACMClient(ctx) ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig - domain := d.Get("domain") + domain := d.Get(names.AttrDomain) input := &acm.ListCertificatesInput{} if v, ok := d.GetOk("key_types"); ok && v.(*schema.Set).Len() > 0 { From 28b89e9f55e2e3f7e8b839625531f2330e79377c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:50 -0400 Subject: [PATCH 04/78] amp: Use constants for strings --- internal/service/amp/workspace.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/amp/workspace.go b/internal/service/amp/workspace.go index ecedcb0372a..4a6d5e8f4ab 100644 --- a/internal/service/amp/workspace.go +++ b/internal/service/amp/workspace.go @@ -62,7 +62,7 @@ func resourceWorkspace() *schema.Resource { ForceNew: true, ValidateFunc: verify.ValidARN, }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -114,7 +114,7 @@ func resourceWorkspaceCreate(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "waiting for Prometheus Workspace (%s) create: %s", d.Id(), err) } - if v, ok := d.GetOk("logging_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrLoggingConfiguration); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) input := &.CreateLoggingConfigurationInput{ LogGroupArn: aws.String(tfMap["log_group_arn"].(string)), @@ -160,11 +160,11 @@ func resourceWorkspaceRead(ctx context.Context, d *schema.ResourceData, meta int loggingConfiguration, err := findLoggingConfigurationByWorkspaceID(ctx, conn, d.Id()) if tfresource.NotFound(err) { - d.Set("logging_configuration", nil) + d.Set(names.AttrLoggingConfiguration, nil) } else if err != nil { return sdkdiag.AppendErrorf(diags, "reading Prometheus Workspace (%s) logging configuration: %s", d.Id(), err) } else { - if err := d.Set("logging_configuration", []interface{}{flattenLoggingConfigurationMetadata(loggingConfiguration)}); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, []interface{}{flattenLoggingConfigurationMetadata(loggingConfiguration)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting logging_configuration: %s", err) } } @@ -193,11 +193,11 @@ func resourceWorkspaceUpdate(ctx context.Context, d *schema.ResourceData, meta i } } - if d.HasChange("logging_configuration") { - if v, ok := d.GetOk("logging_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if d.HasChange(names.AttrLoggingConfiguration) { + if v, ok := d.GetOk(names.AttrLoggingConfiguration); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) - if o, _ := d.GetChange("logging_configuration"); o == nil || len(o.([]interface{})) == 0 || o.([]interface{})[0] == nil { + if o, _ := d.GetChange(names.AttrLoggingConfiguration); o == nil || len(o.([]interface{})) == 0 || o.([]interface{})[0] == nil { input := &.CreateLoggingConfigurationInput{ LogGroupArn: aws.String(tfMap["log_group_arn"].(string)), WorkspaceId: aws.String(d.Id()), From 93e11fd042b202842c4d82e9247487a46d059769 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:50 -0400 Subject: [PATCH 05/78] apigateway: Use constants for strings --- internal/service/apigateway/model.go | 10 +++++----- internal/service/apigateway/model_test.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/apigateway/model.go b/internal/service/apigateway/model.go index 20dc4813da2..acb4b57b2a9 100644 --- a/internal/service/apigateway/model.go +++ b/internal/service/apigateway/model.go @@ -78,7 +78,7 @@ func resourceModel() *schema.Resource { Required: true, ForceNew: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringIsJSON, @@ -107,7 +107,7 @@ func resourceModelCreate(ctx context.Context, d *schema.ResourceData, meta inter input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("schema"); ok { + if v, ok := d.GetOk(names.AttrSchema); ok { input.Schema = aws.String(v.(string)) } @@ -140,7 +140,7 @@ func resourceModelRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set(names.AttrContentType, model.ContentType) d.Set(names.AttrDescription, model.Description) - d.Set("schema", model.Schema) + d.Set(names.AttrSchema, model.Schema) return diags } @@ -159,11 +159,11 @@ func resourceModelUpdate(ctx context.Context, d *schema.ResourceData, meta inter }) } - if d.HasChange("schema") { + if d.HasChange(names.AttrSchema) { operations = append(operations, types.PatchOperation{ Op: types.OpReplace, Path: aws.String("/schema"), - Value: aws.String(d.Get("schema").(string)), + Value: aws.String(d.Get(names.AttrSchema).(string)), }) } diff --git a/internal/service/apigateway/model_test.go b/internal/service/apigateway/model_test.go index 08538c3c4e5..c96058b2a0b 100644 --- a/internal/service/apigateway/model_test.go +++ b/internal/service/apigateway/model_test.go @@ -46,7 +46,7 @@ func TestAccAPIGatewayModel_basic(t *testing.T) { ImportState: true, ImportStateIdFunc: testAccModelImportStateIdFunc(resourceName), ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"schema"}, + ImportStateVerifyIgnore: []string{names.AttrSchema}, }, }, }) From f269e3839cfc6f01494b02802ed83731282ab537 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:51 -0400 Subject: [PATCH 06/78] apigatewayv2: Use constants for strings --- internal/service/apigatewayv2/model.go | 10 +++++----- internal/service/apigatewayv2/model_test.go | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/apigatewayv2/model.go b/internal/service/apigatewayv2/model.go index 148e075b72e..ff7792f4280 100644 --- a/internal/service/apigatewayv2/model.go +++ b/internal/service/apigatewayv2/model.go @@ -62,7 +62,7 @@ func resourceModel() *schema.Resource { validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), "must be alphanumeric"), ), }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -89,7 +89,7 @@ func resourceModelCreate(ctx context.Context, d *schema.ResourceData, meta inter ApiId: aws.String(d.Get("api_id").(string)), ContentType: aws.String(d.Get(names.AttrContentType).(string)), Name: aws.String(name), - Schema: aws.String(d.Get("schema").(string)), + Schema: aws.String(d.Get(names.AttrSchema).(string)), } if v, ok := d.GetOk(names.AttrDescription); ok { @@ -126,7 +126,7 @@ func resourceModelRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set(names.AttrContentType, output.ContentType) d.Set(names.AttrDescription, output.Description) d.Set(names.AttrName, output.Name) - d.Set("schema", output.Schema) + d.Set(names.AttrSchema, output.Schema) return diags } @@ -152,8 +152,8 @@ func resourceModelUpdate(ctx context.Context, d *schema.ResourceData, meta inter input.Name = aws.String(d.Get(names.AttrName).(string)) } - if d.HasChange("schema") { - input.Schema = aws.String(d.Get("schema").(string)) + if d.HasChange(names.AttrSchema) { + input.Schema = aws.String(d.Get(names.AttrSchema).(string)) } _, err := conn.UpdateModel(ctx, input) diff --git a/internal/service/apigatewayv2/model_test.go b/internal/service/apigatewayv2/model_test.go index b115aa6ebd9..82a5703b446 100644 --- a/internal/service/apigatewayv2/model_test.go +++ b/internal/service/apigatewayv2/model_test.go @@ -53,7 +53,7 @@ func TestAccAPIGatewayV2Model_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrContentType, "application/json"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - acctest.CheckResourceAttrEquivalentJSON(resourceName, "schema", schema), + acctest.CheckResourceAttrEquivalentJSON(resourceName, names.AttrSchema, schema), ), }, { @@ -152,7 +152,7 @@ func TestAccAPIGatewayV2Model_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrContentType, "text/x-json"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "test"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - acctest.CheckResourceAttrEquivalentJSON(resourceName, "schema", schema1), + acctest.CheckResourceAttrEquivalentJSON(resourceName, names.AttrSchema, schema1), ), }, { @@ -162,7 +162,7 @@ func TestAccAPIGatewayV2Model_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrContentType, "application/json"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - acctest.CheckResourceAttrEquivalentJSON(resourceName, "schema", schema2), + acctest.CheckResourceAttrEquivalentJSON(resourceName, names.AttrSchema, schema2), ), }, { @@ -172,7 +172,7 @@ func TestAccAPIGatewayV2Model_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrContentType, "text/x-json"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "test"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - acctest.CheckResourceAttrEquivalentJSON(resourceName, "schema", schema1), + acctest.CheckResourceAttrEquivalentJSON(resourceName, names.AttrSchema, schema1), ), }, { From fb3fd1fc730fd888bbce8c98986f97420df79f47 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:51 -0400 Subject: [PATCH 07/78] appconfig: Use constants for strings --- internal/service/appconfig/configuration_profile.go | 6 +++--- .../appconfig/configuration_profile_data_source.go | 2 +- .../appconfig/configuration_profile_data_source_test.go | 4 ++-- internal/service/appconfig/configuration_profile_test.go | 8 ++++---- .../service/appconfig/hosted_configuration_version.go | 6 +++--- .../appconfig/hosted_configuration_version_test.go | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index e60bde7350f..086a0d67aff 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -96,7 +96,7 @@ func ResourceConfigurationProfile() *schema.Resource { MaxItems: 2, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, Sensitive: true, @@ -309,7 +309,7 @@ func expandValidator(tfMap map[string]interface{}) awstypes.Validator { validator := awstypes.Validator{} // AppConfig API supports empty content - if v, ok := tfMap["content"].(string); ok { + if v, ok := tfMap[names.AttrContent].(string); ok { validator.Content = aws.String(v) } @@ -343,7 +343,7 @@ func flattenValidator(validator awstypes.Validator) map[string]interface{} { tfMap := map[string]interface{}{} if v := validator.Content; v != nil { - tfMap["content"] = aws.ToString(v) + tfMap[names.AttrContent] = aws.ToString(v) } tfMap[names.AttrType] = string(validator.Type) diff --git a/internal/service/appconfig/configuration_profile_data_source.go b/internal/service/appconfig/configuration_profile_data_source.go index 00e21823524..9b79b682f4b 100644 --- a/internal/service/appconfig/configuration_profile_data_source.go +++ b/internal/service/appconfig/configuration_profile_data_source.go @@ -69,7 +69,7 @@ func DataSourceConfigurationProfile() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/appconfig/configuration_profile_data_source_test.go b/internal/service/appconfig/configuration_profile_data_source_test.go index 448ff9ba290..6ce25630b53 100644 --- a/internal/service/appconfig/configuration_profile_data_source_test.go +++ b/internal/service/appconfig/configuration_profile_data_source_test.go @@ -45,8 +45,8 @@ func TestAccAppConfigConfigurationProfileDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "tags.key1", "value1"), resource.TestCheckResourceAttr(dataSourceName, names.AttrType, "AWS.Freeform"), resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "validator.*", map[string]string{ - "content": "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", - names.AttrType: string(awstypes.ValidatorTypeJsonSchema), + names.AttrContent: "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", + names.AttrType: string(awstypes.ValidatorTypeJsonSchema), }), ), }, diff --git a/internal/service/appconfig/configuration_profile_test.go b/internal/service/appconfig/configuration_profile_test.go index 36a27199f58..c9ec846d755 100644 --- a/internal/service/appconfig/configuration_profile_test.go +++ b/internal/service/appconfig/configuration_profile_test.go @@ -134,8 +134,8 @@ func TestAccAppConfigConfigurationProfile_Validators_json(t *testing.T) { testAccCheckConfigurationProfileExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "validator.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ - "content": "", - names.AttrType: string(awstypes.ValidatorTypeJsonSchema), + names.AttrContent: "", + names.AttrType: string(awstypes.ValidatorTypeJsonSchema), }), ), }, @@ -212,8 +212,8 @@ func TestAccAppConfigConfigurationProfile_Validators_multiple(t *testing.T) { testAccCheckConfigurationProfileExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "validator.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ - "content": "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", - names.AttrType: string(awstypes.ValidatorTypeJsonSchema), + names.AttrContent: "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", + names.AttrType: string(awstypes.ValidatorTypeJsonSchema), }), resource.TestCheckTypeSetElemAttrPair(resourceName, "validator.*.content", "aws_lambda_function.test", names.AttrARN), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ diff --git a/internal/service/appconfig/hosted_configuration_version.go b/internal/service/appconfig/hosted_configuration_version.go index 89caed767d5..5d991be7840 100644 --- a/internal/service/appconfig/hosted_configuration_version.go +++ b/internal/service/appconfig/hosted_configuration_version.go @@ -51,7 +51,7 @@ func ResourceHostedConfigurationVersion() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9a-z]{4,7}`), ""), }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -87,7 +87,7 @@ func resourceHostedConfigurationVersionCreate(ctx context.Context, d *schema.Res input := &appconfig.CreateHostedConfigurationVersionInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(profileID), - Content: []byte(d.Get("content").(string)), + Content: []byte(d.Get(names.AttrContent).(string)), ContentType: aws.String(d.Get(names.AttrContentType).(string)), } @@ -140,7 +140,7 @@ func resourceHostedConfigurationVersionRead(ctx context.Context, d *schema.Resou d.Set("application_id", output.ApplicationId) d.Set("configuration_profile_id", output.ConfigurationProfileId) - d.Set("content", string(output.Content)) + d.Set(names.AttrContent, string(output.Content)) d.Set(names.AttrContentType, output.ContentType) d.Set(names.AttrDescription, output.Description) d.Set("version_number", output.VersionNumber) diff --git a/internal/service/appconfig/hosted_configuration_version_test.go b/internal/service/appconfig/hosted_configuration_version_test.go index cbbccb92af4..5849f0a36af 100644 --- a/internal/service/appconfig/hosted_configuration_version_test.go +++ b/internal/service/appconfig/hosted_configuration_version_test.go @@ -40,7 +40,7 @@ func TestAccAppConfigHostedConfigurationVersion_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "appconfig", regexache.MustCompile(`application/[0-9a-z]{4,7}/configurationprofile/[0-9a-z]{4,7}/hostedconfigurationversion/[0-9]+`)), resource.TestCheckResourceAttrPair(resourceName, "application_id", "aws_appconfig_application.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "configuration_profile_id", "aws_appconfig_configuration_profile.test", "configuration_profile_id"), - resource.TestCheckResourceAttr(resourceName, "content", "{\"foo\":\"bar\"}"), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, "{\"foo\":\"bar\"}"), resource.TestCheckResourceAttr(resourceName, names.AttrContentType, "application/json"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, rName), resource.TestCheckResourceAttr(resourceName, "version_number", "1"), From efcfc0716e8da232bdb4f2edc5c289dd9c965159 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:51 -0400 Subject: [PATCH 08/78] appmesh: Use constants for strings --- internal/service/appmesh/flex.go | 24 ++++++++++++------------ internal/service/appmesh/route.go | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/service/appmesh/flex.go b/internal/service/appmesh/flex.go index 7d0798331b0..bf0e8b258eb 100644 --- a/internal/service/appmesh/flex.go +++ b/internal/service/appmesh/flex.go @@ -188,7 +188,7 @@ func expandGRPCRoute(vGrpcRoute []interface{}) *appmesh.GrpcRoute { if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { weightedTarget.VirtualNode = aws.String(vVirtualNode) } - if vWeight, ok := mWeightedTarget["weight"].(int); ok { + if vWeight, ok := mWeightedTarget[names.AttrWeight].(int); ok { weightedTarget.Weight = aws.Int64(int64(vWeight)) } @@ -360,7 +360,7 @@ func expandHTTPRoute(vHttpRoute []interface{}) *appmesh.HttpRoute { if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { weightedTarget.VirtualNode = aws.String(vVirtualNode) } - if vWeight, ok := mWeightedTarget["weight"].(int); ok { + if vWeight, ok := mWeightedTarget[names.AttrWeight].(int); ok { weightedTarget.Weight = aws.Int64(int64(vWeight)) } @@ -632,7 +632,7 @@ func expandTCPRoute(vTcpRoute []interface{}) *appmesh.TcpRoute { if vVirtualNode, ok := mWeightedTarget["virtual_node"].(string); ok && vVirtualNode != "" { weightedTarget.VirtualNode = aws.String(vVirtualNode) } - if vWeight, ok := mWeightedTarget["weight"].(int); ok { + if vWeight, ok := mWeightedTarget[names.AttrWeight].(int); ok { weightedTarget.Weight = aws.Int64(int64(vWeight)) } @@ -1321,9 +1321,9 @@ func flattenGRPCRoute(grpcRoute *appmesh.GrpcRoute) []interface{} { for _, weightedTarget := range weightedTargets { mWeightedTarget := map[string]interface{}{ - "virtual_node": aws.StringValue(weightedTarget.VirtualNode), - "weight": int(aws.Int64Value(weightedTarget.Weight)), - names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + names.AttrWeight: int(aws.Int64Value(weightedTarget.Weight)), + names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), } vWeightedTargets = append(vWeightedTargets, mWeightedTarget) @@ -1422,9 +1422,9 @@ func flattenHTTPRoute(httpRoute *appmesh.HttpRoute) []interface{} { for _, weightedTarget := range weightedTargets { mWeightedTarget := map[string]interface{}{ - "virtual_node": aws.StringValue(weightedTarget.VirtualNode), - "weight": int(aws.Int64Value(weightedTarget.Weight)), - names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + names.AttrWeight: int(aws.Int64Value(weightedTarget.Weight)), + names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), } vWeightedTargets = append(vWeightedTargets, mWeightedTarget) @@ -1596,9 +1596,9 @@ func flattenTCPRoute(tcpRoute *appmesh.TcpRoute) []interface{} { for _, weightedTarget := range weightedTargets { mWeightedTarget := map[string]interface{}{ - "virtual_node": aws.StringValue(weightedTarget.VirtualNode), - "weight": int(aws.Int64Value(weightedTarget.Weight)), - names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), + "virtual_node": aws.StringValue(weightedTarget.VirtualNode), + names.AttrWeight: int(aws.Int64Value(weightedTarget.Weight)), + names.AttrPort: int(aws.Int64Value(weightedTarget.Port)), } vWeightedTargets = append(vWeightedTargets, mWeightedTarget) diff --git a/internal/service/appmesh/route.go b/internal/service/appmesh/route.go index ec13d218751..069c7bc6b63 100644 --- a/internal/service/appmesh/route.go +++ b/internal/service/appmesh/route.go @@ -126,7 +126,7 @@ func resourceRouteSpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 100), @@ -420,7 +420,7 @@ func resourceRouteSpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 100), @@ -677,7 +677,7 @@ func resourceRouteSpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(0, 100), From 84bccedbe44d8a158c1de31670b0480cc6064d92 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:51 -0400 Subject: [PATCH 09/78] apprunner: Use constants for strings --- internal/service/apprunner/vpc_connector.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/apprunner/vpc_connector.go b/internal/service/apprunner/vpc_connector.go index 85ffc9966e0..972cde124f3 100644 --- a/internal/service/apprunner/vpc_connector.go +++ b/internal/service/apprunner/vpc_connector.go @@ -54,7 +54,7 @@ func resourceVPCConnector() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, ForceNew: true, @@ -86,7 +86,7 @@ func resourceVPCConnectorCreate(ctx context.Context, d *schema.ResourceData, met name := d.Get("vpc_connector_name").(string) input := &apprunner.CreateVpcConnectorInput{ SecurityGroups: flex.ExpandStringValueSet(d.Get(names.AttrSecurityGroups).(*schema.Set)), - Subnets: flex.ExpandStringValueSet(d.Get("subnets").(*schema.Set)), + Subnets: flex.ExpandStringValueSet(d.Get(names.AttrSubnets).(*schema.Set)), Tags: getTagsIn(ctx), VpcConnectorName: aws.String(name), } @@ -126,7 +126,7 @@ func resourceVPCConnectorRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, vpcConnector.VpcConnectorArn) d.Set(names.AttrSecurityGroups, vpcConnector.SecurityGroups) d.Set(names.AttrStatus, vpcConnector.Status) - d.Set("subnets", vpcConnector.Subnets) + d.Set(names.AttrSubnets, vpcConnector.Subnets) d.Set("vpc_connector_name", vpcConnector.VpcConnectorName) d.Set("vpc_connector_revision", vpcConnector.VpcConnectorRevision) From 7ab2cc9ad428f2285671c1c5f7e1f797b726ba5e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:52 -0400 Subject: [PATCH 10/78] appsync: Use constants for strings --- internal/service/appsync/appsync_test.go | 2 +- internal/service/appsync/datasource.go | 6 +++--- internal/service/appsync/graphql_api.go | 8 ++++---- internal/service/appsync/graphql_api_test.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/appsync/appsync_test.go b/internal/service/appsync/appsync_test.go index 8f67789c438..9863188e6f2 100644 --- a/internal/service/appsync/appsync_test.go +++ b/internal/service/appsync/appsync_test.go @@ -40,7 +40,7 @@ func TestAccAppSync_serial(t *testing.T) { "basic": testAccGraphQLAPI_basic, "disappears": testAccGraphQLAPI_disappears, names.AttrTags: testAccGraphQLAPI_tags, - "schema": testAccGraphQLAPI_schema, + names.AttrSchema: testAccGraphQLAPI_schema, "authenticationType": testAccGraphQLAPI_authenticationType, "AuthenticationType_apiKey": testAccGraphQLAPI_AuthenticationType_apiKey, "AuthenticationType_awsIAM": testAccGraphQLAPI_AuthenticationType_iam, diff --git a/internal/service/appsync/datasource.go b/internal/service/appsync/datasource.go index 93e89a5a1c4..ccc851941a1 100644 --- a/internal/service/appsync/datasource.go +++ b/internal/service/appsync/datasource.go @@ -246,7 +246,7 @@ func ResourceDataSource() *schema.Resource { Optional: true, Computed: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Optional: true, }, @@ -886,7 +886,7 @@ func testAccDataSourceConfig_expandRDSHTTPEndpoint(l []interface{}, currentRegio result.DbClusterIdentifier = aws.String(v.(string)) } - if v, ok := configured["schema"]; ok && v.(string) != "" { + if v, ok := configured[names.AttrSchema]; ok && v.(string) != "" { result.Schema = aws.String(v.(string)) } @@ -917,7 +917,7 @@ func flattenRDSHTTPEndpointConfig(config *appsync.RdsHttpEndpointConfig) []map[s } if config.Schema != nil { - result["schema"] = aws.StringValue(config.Schema) + result[names.AttrSchema] = aws.StringValue(config.Schema) } return []map[string]interface{}{result} diff --git a/internal/service/appsync/graphql_api.go b/internal/service/appsync/graphql_api.go index 5af2e0a7f75..d6996a1681e 100644 --- a/internal/service/appsync/graphql_api.go +++ b/internal/service/appsync/graphql_api.go @@ -237,7 +237,7 @@ func ResourceGraphQLAPI() *schema.Resource { Default: 0, ValidateFunc: validation.IntBetween(0, 10000), }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Optional: true, }, @@ -351,7 +351,7 @@ func resourceGraphQLAPICreate(ctx context.Context, d *schema.ResourceData, meta d.SetId(aws.StringValue(output.GraphqlApi.ApiId)) - if v, ok := d.GetOk("schema"); ok { + if v, ok := d.GetOk(names.AttrSchema); ok { if err := putSchema(ctx, conn, d.Id(), v.(string), d.Timeout(schema.TimeoutCreate)); err != nil { return sdkdiag.AppendFromErr(diags, err) } @@ -461,8 +461,8 @@ func resourceGraphQLAPIUpdate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "updating AppSync GraphQL API (%s): %s", d.Id(), err) } - if d.HasChange("schema") { - if v, ok := d.GetOk("schema"); ok { + if d.HasChange(names.AttrSchema) { + if v, ok := d.GetOk(names.AttrSchema); ok { if err := putSchema(ctx, conn, d.Id(), v.(string), d.Timeout(schema.TimeoutCreate)); err != nil { return sdkdiag.AppendFromErr(diags, err) } diff --git a/internal/service/appsync/graphql_api_test.go b/internal/service/appsync/graphql_api_test.go index 84501fe983f..4e51ddedc39 100644 --- a/internal/service/appsync/graphql_api_test.go +++ b/internal/service/appsync/graphql_api_test.go @@ -112,7 +112,7 @@ func testAccGraphQLAPI_schema(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "user_pool_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "lambda_authorizer_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "xray_enabled", "false"), - resource.TestCheckResourceAttrSet(resourceName, "schema"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrSchema), resource.TestCheckResourceAttrSet(resourceName, "uris.%"), resource.TestCheckResourceAttrSet(resourceName, "uris.GRAPHQL"), testAccCheckGraphQLAPITypeExists(ctx, resourceName, "Post"), @@ -122,7 +122,7 @@ func testAccGraphQLAPI_schema(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"schema"}, + ImportStateVerifyIgnore: []string{names.AttrSchema}, }, { Config: testAccGraphQLAPIConfig_schemaUpdate(rName), From 95fbf233d9fc18a1392a699e628152fbb8a90051 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:52 -0400 Subject: [PATCH 11/78] athena: Use constants for strings --- internal/service/athena/named_query.go | 6 +++--- internal/service/athena/named_query_data_source.go | 4 ++-- internal/service/athena/named_query_data_source_test.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/athena/named_query.go b/internal/service/athena/named_query.go index 4e28add390d..d910dd799f7 100644 --- a/internal/service/athena/named_query.go +++ b/internal/service/athena/named_query.go @@ -32,7 +32,7 @@ func resourceNamedQuery() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -68,7 +68,7 @@ func resourceNamedQueryCreate(ctx context.Context, d *schema.ResourceData, meta name := d.Get(names.AttrName).(string) input := &athena.CreateNamedQueryInput{ - Database: aws.String(d.Get("database").(string)), + Database: aws.String(d.Get(names.AttrDatabase).(string)), Name: aws.String(name), QueryString: aws.String(d.Get("query").(string)), } @@ -108,7 +108,7 @@ func resourceNamedQueryRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "reading Athena Named Query (%s): %s", d.Id(), err) } - d.Set("database", namedQuery.Database) + d.Set(names.AttrDatabase, namedQuery.Database) d.Set(names.AttrDescription, namedQuery.Description) d.Set(names.AttrName, namedQuery.Name) d.Set("query", namedQuery.QueryString) diff --git a/internal/service/athena/named_query_data_source.go b/internal/service/athena/named_query_data_source.go index cffe875482f..717b4ece536 100644 --- a/internal/service/athena/named_query_data_source.go +++ b/internal/service/athena/named_query_data_source.go @@ -24,7 +24,7 @@ func dataSourceNamedQuery() *schema.Resource { ReadWithoutTimeout: dataSourceNamedQueryRead, Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Computed: true, }, @@ -77,7 +77,7 @@ func dataSourceNamedQueryRead(ctx context.Context, d *schema.ResourceData, meta } d.SetId(aws.ToString(query.NamedQueryId)) - d.Set("database", query.Database) + d.Set(names.AttrDatabase, query.Database) d.Set(names.AttrDescription, query.Description) d.Set(names.AttrName, query.Name) d.Set("querystring", query.QueryString) diff --git a/internal/service/athena/named_query_data_source_test.go b/internal/service/athena/named_query_data_source_test.go index cbaf000f4b0..307dbc88611 100644 --- a/internal/service/athena/named_query_data_source_test.go +++ b/internal/service/athena/named_query_data_source_test.go @@ -25,7 +25,7 @@ func TestAccAthenaNamedQueryDataSource_basic(t *testing.T) { { Config: testAccNamedQueryDataSourceConfig_basic(), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair(dataSourceName, "database", resourceName, "database"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDatabase, resourceName, names.AttrDatabase), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDescription, resourceName, names.AttrDescription), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName), From 2060f4439f43cb4d1dd26fa44f8c6972ea74d0fe Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:52 -0400 Subject: [PATCH 12/78] batch: Use constants for strings --- internal/service/batch/compute_environment.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/batch/compute_environment.go b/internal/service/batch/compute_environment.go index b9fde4383d3..04343160244 100644 --- a/internal/service/batch/compute_environment.go +++ b/internal/service/batch/compute_environment.go @@ -183,7 +183,7 @@ func ResourceComputeEnvironment() *schema.Resource { ForceNew: true, ValidateFunc: verify.ValidARN, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -946,7 +946,7 @@ func expandComputeResource(ctx context.Context, tfMap map[string]interface{}) *b apiObject.SpotIamFleetRole = aws.String(v) } - if v, ok := tfMap["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { apiObject.Subnets = flex.ExpandStringSet(v) } @@ -1167,7 +1167,7 @@ func flattenComputeResource(ctx context.Context, apiObject *batch.ComputeResourc } if v := apiObject.Subnets; v != nil { - tfMap["subnets"] = aws.StringValueSlice(v) + tfMap[names.AttrSubnets] = aws.StringValueSlice(v) } if v := apiObject.Tags; v != nil { From f3f926c49cd47bf8f1cdbb001bfd2134f79875d7 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:52 -0400 Subject: [PATCH 13/78] bcmdataexports: Use constants for strings --- internal/service/bcmdataexports/export.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/bcmdataexports/export.go b/internal/service/bcmdataexports/export.go index e3233c693f0..5e4ffa7b430 100644 --- a/internal/service/bcmdataexports/export.go +++ b/internal/service/bcmdataexports/export.go @@ -115,7 +115,7 @@ func (r *resourceExport) Schema(ctx context.Context, req resource.SchemaRequest, CustomType: fwtypes.NewListNestedObjectTypeOf[s3Destination](ctx), NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "s3_bucket": schema.StringAttribute{ + names.AttrS3Bucket: schema.StringAttribute{ Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), From 5904cc7f62cfd56d5f93918d1460b6d01dec4d99 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:53 -0400 Subject: [PATCH 14/78] chime: Use constants for strings --- internal/service/chime/voice_connector_origination.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/chime/voice_connector_origination.go b/internal/service/chime/voice_connector_origination.go index 9df678a136d..4d598e1e4f5 100644 --- a/internal/service/chime/voice_connector_origination.go +++ b/internal/service/chime/voice_connector_origination.go @@ -67,7 +67,7 @@ func ResourceVoiceConnectorOrigination() *schema.Resource { Required: true, ValidateDiagFunc: enum.Validate[awstypes.OriginationRouteProtocol](), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(1, 99), @@ -203,7 +203,7 @@ func expandOriginationRoutes(data []interface{}) []awstypes.OriginationRoute { Port: aws.Int32(int32(item[names.AttrPort].(int))), Priority: aws.Int32(int32(item[names.AttrPriority].(int))), Protocol: awstypes.OriginationRouteProtocol(item[names.AttrProtocol].(string)), - Weight: aws.Int32(int32(item["weight"].(int))), + Weight: aws.Int32(int32(item[names.AttrWeight].(int))), }) } @@ -219,7 +219,7 @@ func flattenOriginationRoutes(routes []awstypes.OriginationRoute) []interface{} names.AttrPort: aws.ToInt32(route.Port), names.AttrPriority: aws.ToInt32(route.Priority), names.AttrProtocol: string(route.Protocol), - "weight": aws.ToInt32(route.Weight), + names.AttrWeight: aws.ToInt32(route.Weight), } rawRoutes = append(rawRoutes, r) From b173cf72e6719a154d378464de8a682169359bbe Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:53 -0400 Subject: [PATCH 15/78] cleanrooms: Use constants for strings --- internal/service/cleanrooms/configured_table_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/cleanrooms/configured_table_test.go b/internal/service/cleanrooms/configured_table_test.go index 378725fdb74..2ca0278c1c9 100644 --- a/internal/service/cleanrooms/configured_table_test.go +++ b/internal/service/cleanrooms/configured_table_test.go @@ -349,7 +349,7 @@ func checkConfiguredTableIsTheSame(name string, configuredTable *cleanrooms.GetC const TEST_ALLOWED_COLUMNS = "[\"my_column_1\",\"my_column_2\"]" const TEST_ANALYSIS_METHOD = "DIRECT_QUERY" -const TEST_DATABASE_NAME = "database" +const TEST_DATABASE_NAME = names.AttrDatabase const TEST_TABLE_NAME = "table" func testAccConfiguredTableConfig_basic(name string, description string, tagValue string, rName string) string { From 4b293c603dd3eaf8b42b286c4f23d97dd18d8a3e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:53 -0400 Subject: [PATCH 16/78] cloudcontrol: Use constants for strings --- internal/service/cloudcontrol/resource.go | 8 ++++---- internal/service/cloudcontrol/resource_test.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/cloudcontrol/resource.go b/internal/service/cloudcontrol/resource.go index eddc29ca059..f9d299657b5 100644 --- a/internal/service/cloudcontrol/resource.go +++ b/internal/service/cloudcontrol/resource.go @@ -58,7 +58,7 @@ func resourceResource() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Optional: true, Computed: true, @@ -244,7 +244,7 @@ func resourceResourceDelete(ctx context.Context, d *schema.ResourceData, meta in func resourceResourceCustomizeDiffGetSchema(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { conn := meta.(*conns.AWSClient).CloudFormationClient(ctx) - resourceSchema := diff.Get("schema").(string) + resourceSchema := diff.Get(names.AttrSchema).(string) if resourceSchema != "" { return nil @@ -258,7 +258,7 @@ func resourceResourceCustomizeDiffGetSchema(ctx context.Context, diff *schema.Re return fmt.Errorf("reading CloudFormation Type (%s): %w", typeName, err) } - if err := diff.SetNew("schema", output.Schema); err != nil { + if err := diff.SetNew(names.AttrSchema, output.Schema); err != nil { return fmt.Errorf("setting schema New: %w", err) } @@ -267,7 +267,7 @@ func resourceResourceCustomizeDiffGetSchema(ctx context.Context, diff *schema.Re func resourceResourceCustomizeDiffSchemaDiff(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { oldDesiredStateRaw, newDesiredStateRaw := diff.GetChange("desired_state") - newSchema := diff.Get("schema").(string) + newSchema := diff.Get(names.AttrSchema).(string) newDesiredState, ok := newDesiredStateRaw.(string) diff --git a/internal/service/cloudcontrol/resource_test.go b/internal/service/cloudcontrol/resource_test.go index 851a9adcddd..b18cec467db 100644 --- a/internal/service/cloudcontrol/resource_test.go +++ b/internal/service/cloudcontrol/resource_test.go @@ -47,7 +47,7 @@ func TestAccCloudControlResource_basic(t *testing.T) { Config: testAccResourceConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`^\{.*\}$`)), - resource.TestMatchResourceAttr(resourceName, "schema", regexache.MustCompile(`^\{.*`)), + resource.TestMatchResourceAttr(resourceName, names.AttrSchema, regexache.MustCompile(`^\{.*`)), ), }, }, @@ -484,7 +484,7 @@ func TestAccCloudControlResource_resourceSchema(t *testing.T) { { Config: testAccResourceConfig_schema(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "schema", "data.aws_cloudformation_type.test", "schema"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrSchema, "data.aws_cloudformation_type.test", names.AttrSchema), ), }, }, @@ -514,7 +514,7 @@ func TestAccCloudControlResource_lambdaFunction(t *testing.T) { Config: testAccResourceConfig_lambdaFunction(rName), Check: resource.ComposeAggregateTestCheckFunc( resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`^\{.*\}$`)), - resource.TestMatchResourceAttr(resourceName, "schema", regexache.MustCompile(`^\{.*`)), + resource.TestMatchResourceAttr(resourceName, names.AttrSchema, regexache.MustCompile(`^\{.*`)), ), }, }, From e4c9427497f0572b0481da77bc8ba7e44613a42f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:53 -0400 Subject: [PATCH 17/78] cloudformation: Use constants for strings --- internal/service/cloudformation/type.go | 4 ++-- internal/service/cloudformation/type_data_source.go | 4 ++-- internal/service/cloudformation/type_data_source_test.go | 8 ++++---- internal/service/cloudformation/type_test.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/cloudformation/type.go b/internal/service/cloudformation/type.go index fb77be8be82..403f4c6f7ff 100644 --- a/internal/service/cloudformation/type.go +++ b/internal/service/cloudformation/type.go @@ -94,7 +94,7 @@ func resourceType() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Computed: true, }, @@ -217,7 +217,7 @@ func resourceTypeRead(ctx context.Context, d *schema.ResourceData, meta interfac d.Set("logging_config", nil) } d.Set("provisioning_type", output.ProvisioningType) - d.Set("schema", output.Schema) + d.Set(names.AttrSchema, output.Schema) d.Set("source_url", output.SourceUrl) d.Set(names.AttrType, output.Type) d.Set("type_arn", typeARN) diff --git a/internal/service/cloudformation/type_data_source.go b/internal/service/cloudformation/type_data_source.go index 3b5e789654d..25f436c70c7 100644 --- a/internal/service/cloudformation/type_data_source.go +++ b/internal/service/cloudformation/type_data_source.go @@ -74,7 +74,7 @@ func dataSourceType() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Computed: true, }, @@ -157,7 +157,7 @@ func dataSourceTypeRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("logging_config", nil) } d.Set("provisioning_type", output.ProvisioningType) - d.Set("schema", output.Schema) + d.Set(names.AttrSchema, output.Schema) d.Set("source_url", output.SourceUrl) d.Set(names.AttrType, output.Type) d.Set("type_name", output.TypeName) diff --git a/internal/service/cloudformation/type_data_source_test.go b/internal/service/cloudformation/type_data_source_test.go index dee7b351bb5..7351a603fe1 100644 --- a/internal/service/cloudformation/type_data_source_test.go +++ b/internal/service/cloudformation/type_data_source_test.go @@ -40,7 +40,7 @@ func TestAccCloudFormationTypeDataSource_ARN_private(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, "is_default_version", resourceName, "is_default_version"), resource.TestCheckResourceAttrPair(dataSourceName, "logging_config.#", resourceName, "logging_config.#"), resource.TestCheckResourceAttrPair(dataSourceName, "provisioning_type", resourceName, "provisioning_type"), - resource.TestCheckResourceAttrPair(dataSourceName, "schema", resourceName, "schema"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSchema, resourceName, names.AttrSchema), resource.TestCheckResourceAttrPair(dataSourceName, "source_url", resourceName, "source_url"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrType, resourceName, names.AttrType), resource.TestCheckResourceAttrPair(dataSourceName, "type_name", resourceName, "type_name"), @@ -71,7 +71,7 @@ func TestAccCloudFormationTypeDataSource_ARN_public(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "is_default_version", "true"), resource.TestCheckResourceAttr(dataSourceName, "logging_config.#", "0"), resource.TestCheckResourceAttr(dataSourceName, "provisioning_type", string(awstypes.ProvisioningTypeFullyMutable)), - resource.TestMatchResourceAttr(dataSourceName, "schema", regexache.MustCompile(`^\{.*`)), + resource.TestMatchResourceAttr(dataSourceName, names.AttrSchema, regexache.MustCompile(`^\{.*`)), resource.TestMatchResourceAttr(dataSourceName, "source_url", regexache.MustCompile(`^https://.+`)), resource.TestCheckResourceAttr(dataSourceName, names.AttrType, string(awstypes.RegistryTypeResource)), resource.TestCheckResourceAttr(dataSourceName, "type_name", "AWS::Athena::WorkGroup"), @@ -107,7 +107,7 @@ func TestAccCloudFormationTypeDataSource_TypeName_private(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, "is_default_version", resourceName, "is_default_version"), resource.TestCheckResourceAttrPair(dataSourceName, "logging_config.#", resourceName, "logging_config.#"), resource.TestCheckResourceAttrPair(dataSourceName, "provisioning_type", resourceName, "provisioning_type"), - resource.TestCheckResourceAttrPair(dataSourceName, "schema", resourceName, "schema"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSchema, resourceName, names.AttrSchema), resource.TestCheckResourceAttrPair(dataSourceName, "source_url", resourceName, "source_url"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrType, resourceName, names.AttrType), resource.TestCheckResourceAttrPair(dataSourceName, "type_name", resourceName, "type_name"), @@ -138,7 +138,7 @@ func TestAccCloudFormationTypeDataSource_TypeName_public(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "is_default_version", "true"), resource.TestCheckResourceAttr(dataSourceName, "logging_config.#", "0"), resource.TestCheckResourceAttr(dataSourceName, "provisioning_type", string(awstypes.ProvisioningTypeFullyMutable)), - resource.TestMatchResourceAttr(dataSourceName, "schema", regexache.MustCompile(`^\{.*`)), + resource.TestMatchResourceAttr(dataSourceName, names.AttrSchema, regexache.MustCompile(`^\{.*`)), resource.TestMatchResourceAttr(dataSourceName, "source_url", regexache.MustCompile(`^https://.+`)), resource.TestCheckResourceAttr(dataSourceName, names.AttrType, string(awstypes.RegistryTypeResource)), resource.TestCheckResourceAttr(dataSourceName, "type_name", "AWS::Athena::WorkGroup"), diff --git a/internal/service/cloudformation/type_test.go b/internal/service/cloudformation/type_test.go index 34c6d866740..30fa1f1d0ef 100644 --- a/internal/service/cloudformation/type_test.go +++ b/internal/service/cloudformation/type_test.go @@ -53,7 +53,7 @@ func TestAccCloudFormationType_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "logging_config.#", "0"), resource.TestCheckResourceAttr(resourceName, "provisioning_type", string(awstypes.ProvisioningTypeFullyMutable)), resource.TestCheckResourceAttr(resourceName, "schema_handler_package", fmt.Sprintf("s3://%s/test", rName)), - resource.TestMatchResourceAttr(resourceName, "schema", regexache.MustCompile(`^\{.*`)), + resource.TestMatchResourceAttr(resourceName, names.AttrSchema, regexache.MustCompile(`^\{.*`)), resource.TestCheckResourceAttr(resourceName, "source_url", "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git"), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(awstypes.RegistryTypeResource)), acctest.CheckResourceAttrRegionalARN(resourceName, "type_arn", "cloudformation", fmt.Sprintf("type/resource/%s", strings.ReplaceAll(typeName, "::", "-"))), From b2d60217b00b1940c71f6ac388349b04289331e0 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:54 -0400 Subject: [PATCH 18/78] cloudfront: Use constants for strings --- internal/service/cloudfront/continuous_deployment_policy.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/cloudfront/continuous_deployment_policy.go b/internal/service/cloudfront/continuous_deployment_policy.go index d7d7f1fdeab..317f803370a 100644 --- a/internal/service/cloudfront/continuous_deployment_policy.go +++ b/internal/service/cloudfront/continuous_deployment_policy.go @@ -112,7 +112,7 @@ func (r *continuousDeploymentPolicyResource) Schema(ctx context.Context, request }, NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "weight": schema.Float64Attribute{ + names.AttrWeight: schema.Float64Attribute{ Required: true, }, }, From 232e567f3a7ab3723d4138a94d4fad7753694748 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:54 -0400 Subject: [PATCH 19/78] codeartifact: Use constants for strings --- .../codeartifact/authorization_token_data_source.go | 5 +++-- internal/service/codeartifact/codeartifact_test.go | 6 +++--- internal/service/codeartifact/domain.go | 6 +++--- .../codeartifact/domain_permissions_policy.go | 6 +++--- .../codeartifact/domain_permissions_policy_test.go | 12 ++++++------ internal/service/codeartifact/domain_test.go | 10 +++++----- internal/service/codeartifact/repository.go | 6 +++--- .../codeartifact/repository_endpoint_data_source.go | 4 ++-- .../codeartifact/repository_permissions_policy.go | 6 +++--- .../repository_permissions_policy_test.go | 12 ++++++------ internal/service/codeartifact/repository_test.go | 8 ++++---- 11 files changed, 41 insertions(+), 40 deletions(-) diff --git a/internal/service/codeartifact/authorization_token_data_source.go b/internal/service/codeartifact/authorization_token_data_source.go index e5e71fb0c39..1e240b7abd6 100644 --- a/internal/service/codeartifact/authorization_token_data_source.go +++ b/internal/service/codeartifact/authorization_token_data_source.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKDataSource("aws_codeartifact_authorization_token", name="Authoiration Token") @@ -28,7 +29,7 @@ func dataSourceAuthorizationToken() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, }, @@ -58,7 +59,7 @@ func dataSourceAuthorizationTokenRead(ctx context.Context, d *schema.ResourceDat var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CodeArtifactClient(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) var domainOwner string if v, ok := d.GetOk("domain_owner"); ok { domainOwner = v.(string) diff --git a/internal/service/codeartifact/codeartifact_test.go b/internal/service/codeartifact/codeartifact_test.go index 542dc602a9e..0c93acf661e 100644 --- a/internal/service/codeartifact/codeartifact_test.go +++ b/internal/service/codeartifact/codeartifact_test.go @@ -15,9 +15,9 @@ func TestAccCodeArtifact_serial(t *testing.T) { testCases := map[string]map[string]func(t *testing.T){ "AuthorizationTokenDataSource": { - "basic": testAccAuthorizationTokenDataSource_basic, - "duration": testAccAuthorizationTokenDataSource_duration, - "owner": testAccAuthorizationTokenDataSource_owner, + "basic": testAccAuthorizationTokenDataSource_basic, + names.AttrDuration: testAccAuthorizationTokenDataSource_duration, + "owner": testAccAuthorizationTokenDataSource_owner, }, "Domain": { "basic": testAccDomain_basic, diff --git a/internal/service/codeartifact/domain.go b/internal/service/codeartifact/domain.go index 4c9953b2fa6..599bad6ab07 100644 --- a/internal/service/codeartifact/domain.go +++ b/internal/service/codeartifact/domain.go @@ -52,7 +52,7 @@ func resourceDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -88,7 +88,7 @@ func resourceDomainCreate(ctx context.Context, d *schema.ResourceData, meta inte var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CodeArtifactClient(ctx) - domain := d.Get("domain").(string) + domain := d.Get(names.AttrDomain).(string) input := &codeartifact.CreateDomainInput{ Domain: aws.String(domain), Tags: getTagsIn(ctx), @@ -135,7 +135,7 @@ func resourceDomainRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set(names.AttrARN, domain.Arn) d.Set("asset_size_bytes", strconv.FormatInt(domain.AssetSizeBytes, 10)) d.Set("created_time", domain.CreatedTime.Format(time.RFC3339)) - d.Set("domain", domain.Name) + d.Set(names.AttrDomain, domain.Name) d.Set("encryption_key", domain.EncryptionKey) d.Set("owner", domain.Owner) d.Set("repository_count", domain.RepositoryCount) diff --git a/internal/service/codeartifact/domain_permissions_policy.go b/internal/service/codeartifact/domain_permissions_policy.go index 04628a10337..dc993dd6c7b 100644 --- a/internal/service/codeartifact/domain_permissions_policy.go +++ b/internal/service/codeartifact/domain_permissions_policy.go @@ -36,7 +36,7 @@ func resourceDomainPermissionsPolicy() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -81,7 +81,7 @@ func resourceDomainPermissionsPolicyPut(ctx context.Context, d *schema.ResourceD } input := &codeartifact.PutDomainPermissionsPolicyInput{ - Domain: aws.String(d.Get("domain").(string)), + Domain: aws.String(d.Get(names.AttrDomain).(string)), PolicyDocument: aws.String(policy), } @@ -127,7 +127,7 @@ func resourceDomainPermissionsPolicyRead(ctx context.Context, d *schema.Resource return sdkdiag.AppendErrorf(diags, "reading CodeArtifact Domain Permissions Policy (%s): %s", d.Id(), err) } - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) d.Set("domain_owner", owner) d.Set("policy_revision", policy.Revision) d.Set(names.AttrResourceARN, policy.ResourceArn) diff --git a/internal/service/codeartifact/domain_permissions_policy_test.go b/internal/service/codeartifact/domain_permissions_policy_test.go index 8b01c9efb4a..3f55e851f59 100644 --- a/internal/service/codeartifact/domain_permissions_policy_test.go +++ b/internal/service/codeartifact/domain_permissions_policy_test.go @@ -35,7 +35,7 @@ func testAccDomainPermissionsPolicy_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_domain.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), ), @@ -50,7 +50,7 @@ func testAccDomainPermissionsPolicy_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_domain.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:ListRepositoriesInDomain")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), @@ -76,7 +76,7 @@ func testAccDomainPermissionsPolicy_ignoreEquivalent(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_domain.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:ListRepositoriesInDomain")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), @@ -106,7 +106,7 @@ func testAccDomainPermissionsPolicy_owner(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_domain.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), ), @@ -175,7 +175,7 @@ func testAccCheckDomainPermissionsExists(ctx context.Context, n string) resource conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindDomainPermissionsPolicyByTwoPartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"]) + _, err := tfcodeartifact.FindDomainPermissionsPolicyByTwoPartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain]) return err } @@ -190,7 +190,7 @@ func testAccCheckDomainPermissionsDestroy(ctx context.Context) resource.TestChec conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindDomainPermissionsPolicyByTwoPartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"]) + _, err := tfcodeartifact.FindDomainPermissionsPolicyByTwoPartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain]) if tfresource.NotFound(err) { continue diff --git a/internal/service/codeartifact/domain_test.go b/internal/service/codeartifact/domain_test.go index e7cb1f6cd6e..1a8d405297f 100644 --- a/internal/service/codeartifact/domain_test.go +++ b/internal/service/codeartifact/domain_test.go @@ -35,7 +35,7 @@ func testAccDomain_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "codeartifact", fmt.Sprintf("domain/%s", rName)), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestCheckResourceAttr(resourceName, "asset_size_bytes", "0"), resource.TestCheckResourceAttr(resourceName, "repository_count", "0"), resource.TestCheckResourceAttrSet(resourceName, "s3_bucket_arn"), @@ -71,7 +71,7 @@ func testAccDomain_defaultEncryptionKey(t *testing.T) { testAccCheckDomainExists(ctx, resourceName), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "codeartifact", fmt.Sprintf("domain/%s", rName)), acctest.MatchResourceAttrRegionalARN(resourceName, "encryption_key", "kms", regexache.MustCompile(`key/.+`)), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestCheckResourceAttr(resourceName, "asset_size_bytes", "0"), resource.TestCheckResourceAttr(resourceName, "repository_count", "0"), resource.TestCheckResourceAttrSet(resourceName, "s3_bucket_arn"), @@ -175,7 +175,7 @@ func testAccDomain_MigrateAssetSizeBytesToString(t *testing.T) { Config: testAccDomainConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckDomainExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestCheckResourceAttr(resourceName, "asset_size_bytes", "0"), ), }, @@ -197,7 +197,7 @@ func testAccCheckDomainExists(ctx context.Context, n string) resource.TestCheckF conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindDomainByTwoPartKey(ctx, conn, rs.Primary.Attributes["owner"], rs.Primary.Attributes["domain"]) + _, err := tfcodeartifact.FindDomainByTwoPartKey(ctx, conn, rs.Primary.Attributes["owner"], rs.Primary.Attributes[names.AttrDomain]) return err } @@ -212,7 +212,7 @@ func testAccCheckDomainDestroy(ctx context.Context) resource.TestCheckFunc { conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindDomainByTwoPartKey(ctx, conn, rs.Primary.Attributes["owner"], rs.Primary.Attributes["domain"]) + _, err := tfcodeartifact.FindDomainByTwoPartKey(ctx, conn, rs.Primary.Attributes["owner"], rs.Primary.Attributes[names.AttrDomain]) if tfresource.NotFound(err) { continue diff --git a/internal/service/codeartifact/repository.go b/internal/service/codeartifact/repository.go index a0a619620a1..4867e3db6e9 100644 --- a/internal/service/codeartifact/repository.go +++ b/internal/service/codeartifact/repository.go @@ -51,7 +51,7 @@ func resourceRepository() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -115,7 +115,7 @@ func resourceRepositoryCreate(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).CodeArtifactClient(ctx) input := &codeartifact.CreateRepositoryInput{ - Domain: aws.String(d.Get("domain").(string)), + Domain: aws.String(d.Get(names.AttrDomain).(string)), Repository: aws.String(d.Get("repository").(string)), Tags: getTagsIn(ctx), } @@ -185,7 +185,7 @@ func resourceRepositoryRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("administrator_account", repository.AdministratorAccount) d.Set(names.AttrARN, repository.Arn) d.Set(names.AttrDescription, repository.Description) - d.Set("domain", repository.DomainName) + d.Set(names.AttrDomain, repository.DomainName) d.Set("domain_owner", repository.DomainOwner) if err := d.Set("external_connections", flattenRepositoryExternalConnectionInfos(repository.ExternalConnections)); err != nil { return sdkdiag.AppendErrorf(diags, "setting external_connections: %s", err) diff --git a/internal/service/codeartifact/repository_endpoint_data_source.go b/internal/service/codeartifact/repository_endpoint_data_source.go index e5a8c726607..0ed73cc4f6c 100644 --- a/internal/service/codeartifact/repository_endpoint_data_source.go +++ b/internal/service/codeartifact/repository_endpoint_data_source.go @@ -25,7 +25,7 @@ func dataSourceRepositoryEndpoint() *schema.Resource { ReadWithoutTimeout: dataSourceRepositoryEndpointRead, Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, }, @@ -56,7 +56,7 @@ func dataSourceRepositoryEndpointRead(ctx context.Context, d *schema.ResourceDat var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CodeArtifactClient(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) var domainOwner string if v, ok := d.GetOk("domain_owner"); ok { domainOwner = v.(string) diff --git a/internal/service/codeartifact/repository_permissions_policy.go b/internal/service/codeartifact/repository_permissions_policy.go index 6c12bf0d217..0866efeecc1 100644 --- a/internal/service/codeartifact/repository_permissions_policy.go +++ b/internal/service/codeartifact/repository_permissions_policy.go @@ -36,7 +36,7 @@ func resourceRepositoryPermissionsPolicy() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -86,7 +86,7 @@ func resourceRepositoryPermissionsPolicyPut(ctx context.Context, d *schema.Resou } input := &codeartifact.PutRepositoryPermissionsPolicyInput{ - Domain: aws.String(d.Get("domain").(string)), + Domain: aws.String(d.Get(names.AttrDomain).(string)), PolicyDocument: aws.String(policy), Repository: aws.String(d.Get("repository").(string)), } @@ -133,7 +133,7 @@ func resourceRepositoryPermissionsPolicyRead(ctx context.Context, d *schema.Reso return sdkdiag.AppendErrorf(diags, "reading CodeArtifact Repository Permissions Policy (%s): %s", d.Id(), err) } - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) d.Set("domain_owner", owner) d.Set("policy_revision", policy.Revision) d.Set("repository", repositoryName) diff --git a/internal/service/codeartifact/repository_permissions_policy_test.go b/internal/service/codeartifact/repository_permissions_policy_test.go index 77e944e75e6..ac8c3dfb0ce 100644 --- a/internal/service/codeartifact/repository_permissions_policy_test.go +++ b/internal/service/codeartifact/repository_permissions_policy_test.go @@ -35,7 +35,7 @@ func testAccRepositoryPermissionsPolicy_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_repository.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), ), @@ -50,7 +50,7 @@ func testAccRepositoryPermissionsPolicy_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_repository.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:ListRepositoriesInDomain")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), @@ -76,7 +76,7 @@ func testAccRepositoryPermissionsPolicy_ignoreEquivalent(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_repository.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), ), @@ -105,7 +105,7 @@ func testAccRepositoryPermissionsPolicy_owner(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRepositoryPermissionsExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, names.AttrResourceARN, "aws_codeartifact_repository.test", names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestMatchResourceAttr(resourceName, "policy_document", regexache.MustCompile("codeartifact:CreateRepository")), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), ), @@ -174,7 +174,7 @@ func testAccCheckRepositoryPermissionsExists(ctx context.Context, n string) reso conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindRepositoryPermissionsPolicyByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"], rs.Primary.Attributes["repository"]) + _, err := tfcodeartifact.FindRepositoryPermissionsPolicyByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain], rs.Primary.Attributes["repository"]) return err } @@ -189,7 +189,7 @@ func testAccCheckRepositoryPermissionsDestroy(ctx context.Context) resource.Test conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindRepositoryPermissionsPolicyByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"], rs.Primary.Attributes["repository"]) + _, err := tfcodeartifact.FindRepositoryPermissionsPolicyByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain], rs.Primary.Attributes["repository"]) if tfresource.NotFound(err) { continue diff --git a/internal/service/codeartifact/repository_test.go b/internal/service/codeartifact/repository_test.go index 840609f369b..9ed5336cb98 100644 --- a/internal/service/codeartifact/repository_test.go +++ b/internal/service/codeartifact/repository_test.go @@ -35,7 +35,7 @@ func testAccRepository_basic(t *testing.T) { testAccCheckRepositoryExists(ctx, resourceName), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "codeartifact", fmt.Sprintf("repository/%s/%s", rName, rName)), resource.TestCheckResourceAttr(resourceName, "repository", rName), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), resource.TestCheckResourceAttrPair(resourceName, "administrator_account", "aws_codeartifact_domain.test", "owner"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), @@ -115,7 +115,7 @@ func testAccRepository_owner(t *testing.T) { testAccCheckRepositoryExists(ctx, resourceName), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "codeartifact", fmt.Sprintf("repository/%s/%s", rName, rName)), resource.TestCheckResourceAttr(resourceName, "repository", rName), - resource.TestCheckResourceAttr(resourceName, "domain", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), resource.TestCheckResourceAttrPair(resourceName, "domain_owner", "aws_codeartifact_domain.test", "owner"), resource.TestCheckResourceAttrPair(resourceName, "administrator_account", "aws_codeartifact_domain.test", "owner"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), @@ -290,7 +290,7 @@ func testAccCheckRepositoryExists(ctx context.Context, n string) resource.TestCh conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindRepositoryByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"], rs.Primary.Attributes["repository"]) + _, err := tfcodeartifact.FindRepositoryByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain], rs.Primary.Attributes["repository"]) return err } @@ -305,7 +305,7 @@ func testAccCheckRepositoryDestroy(ctx context.Context) resource.TestCheckFunc { conn := acctest.Provider.Meta().(*conns.AWSClient).CodeArtifactClient(ctx) - _, err := tfcodeartifact.FindRepositoryByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes["domain"], rs.Primary.Attributes["repository"]) + _, err := tfcodeartifact.FindRepositoryByThreePartKey(ctx, conn, rs.Primary.Attributes["domain_owner"], rs.Primary.Attributes[names.AttrDomain], rs.Primary.Attributes["repository"]) if tfresource.NotFound(err) { continue From cb32963811b7619d45cbf6351a0a4c0b85955e55 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:54 -0400 Subject: [PATCH 20/78] codebuild: Use constants for strings --- internal/service/codebuild/project.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/codebuild/project.go b/internal/service/codebuild/project.go index b77ce14239c..36a2fa61367 100644 --- a/internal/service/codebuild/project.go +++ b/internal/service/codebuild/project.go @@ -670,7 +670,7 @@ func resourceProject() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -1510,7 +1510,7 @@ func expandVPCConfig(tfMap map[string]interface{}) *types.VpcConfig { apiObject := &types.VpcConfig{ SecurityGroupIds: flex.ExpandStringValueSet(tfMap[names.AttrSecurityGroupIDs].(*schema.Set)), - Subnets: flex.ExpandStringValueSet(tfMap["subnets"].(*schema.Set)), + Subnets: flex.ExpandStringValueSet(tfMap[names.AttrSubnets].(*schema.Set)), VpcId: aws.String(tfMap[names.AttrVPCID].(string)), } @@ -1913,7 +1913,7 @@ func flattenVPCConfig(apiObject *types.VpcConfig) []interface{} { tfMap := map[string]interface{}{} tfMap[names.AttrVPCID] = aws.ToString(apiObject.VpcId) - tfMap["subnets"] = apiObject.Subnets + tfMap[names.AttrSubnets] = apiObject.Subnets tfMap[names.AttrSecurityGroupIDs] = apiObject.SecurityGroupIds return []interface{}{tfMap} From fceb302a60fc9bf2b0829d82ced7ab98ff05d29c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:55 -0400 Subject: [PATCH 21/78] codecommit: Use constants for strings --- internal/service/codecommit/approval_rule_template.go | 10 +++++----- .../codecommit/approval_rule_template_data_source.go | 4 ++-- .../approval_rule_template_data_source_test.go | 2 +- .../service/codecommit/approval_rule_template_test.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/codecommit/approval_rule_template.go b/internal/service/codecommit/approval_rule_template.go index 9d717bf8bf1..8468f7fb82b 100644 --- a/internal/service/codecommit/approval_rule_template.go +++ b/internal/service/codecommit/approval_rule_template.go @@ -41,7 +41,7 @@ func resourceApprovalRuleTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs, @@ -91,7 +91,7 @@ func resourceApprovalRuleTemplateCreate(ctx context.Context, d *schema.ResourceD name := d.Get(names.AttrName).(string) input := &codecommit.CreateApprovalRuleTemplateInput{ ApprovalRuleTemplateName: aws.String(name), - ApprovalRuleTemplateContent: aws.String(d.Get("content").(string)), + ApprovalRuleTemplateContent: aws.String(d.Get(names.AttrContent).(string)), } if v, ok := d.GetOk(names.AttrDescription); ok { @@ -127,7 +127,7 @@ func resourceApprovalRuleTemplateRead(ctx context.Context, d *schema.ResourceDat d.Set("approval_rule_template_id", result.ApprovalRuleTemplateId) d.Set(names.AttrDescription, result.ApprovalRuleTemplateDescription) - d.Set("content", result.ApprovalRuleTemplateContent) + d.Set(names.AttrContent, result.ApprovalRuleTemplateContent) d.Set(names.AttrCreationDate, result.CreationDate.Format(time.RFC3339)) d.Set("last_modified_date", result.LastModifiedDate.Format(time.RFC3339)) d.Set("last_modified_user", result.LastModifiedUser) @@ -154,11 +154,11 @@ func resourceApprovalRuleTemplateUpdate(ctx context.Context, d *schema.ResourceD } } - if d.HasChange("content") { + if d.HasChange(names.AttrContent) { input := &codecommit.UpdateApprovalRuleTemplateContentInput{ ApprovalRuleTemplateName: aws.String(d.Id()), ExistingRuleContentSha256: aws.String(d.Get("rule_content_sha256").(string)), - NewRuleContent: aws.String(d.Get("content").(string)), + NewRuleContent: aws.String(d.Get(names.AttrContent).(string)), } _, err := conn.UpdateApprovalRuleTemplateContent(ctx, input) diff --git a/internal/service/codecommit/approval_rule_template_data_source.go b/internal/service/codecommit/approval_rule_template_data_source.go index 12927b41dbe..434ad59c035 100644 --- a/internal/service/codecommit/approval_rule_template_data_source.go +++ b/internal/service/codecommit/approval_rule_template_data_source.go @@ -26,7 +26,7 @@ func dataSourceApprovalRuleTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -72,7 +72,7 @@ func dataSourceApprovalRuleTemplateRead(ctx context.Context, d *schema.ResourceD d.SetId(aws.ToString(result.ApprovalRuleTemplateName)) d.Set("approval_rule_template_id", result.ApprovalRuleTemplateId) - d.Set("content", result.ApprovalRuleTemplateContent) + d.Set(names.AttrContent, result.ApprovalRuleTemplateContent) d.Set(names.AttrCreationDate, result.CreationDate.Format(time.RFC3339)) d.Set(names.AttrDescription, result.ApprovalRuleTemplateDescription) d.Set("last_modified_date", result.LastModifiedDate.Format(time.RFC3339)) diff --git a/internal/service/codecommit/approval_rule_template_data_source_test.go b/internal/service/codecommit/approval_rule_template_data_source_test.go index 635a3ca4134..e58165bb027 100644 --- a/internal/service/codecommit/approval_rule_template_data_source_test.go +++ b/internal/service/codecommit/approval_rule_template_data_source_test.go @@ -29,7 +29,7 @@ func TestAccCodeCommitApprovalRuleTemplateDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(datasourceName, names.AttrDescription, resourceName, names.AttrDescription), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrCreationDate, resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrPair(datasourceName, "last_modified_date", resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(datasourceName, "last_modified_user", resourceName, "last_modified_user"), diff --git a/internal/service/codecommit/approval_rule_template_test.go b/internal/service/codecommit/approval_rule_template_test.go index 84fa3573eea..de499ca3cc7 100644 --- a/internal/service/codecommit/approval_rule_template_test.go +++ b/internal/service/codecommit/approval_rule_template_test.go @@ -150,7 +150,7 @@ func testAccCheckApprovalRuleTemplateContent(resourceName string, numApprovals i expectedContent := fmt.Sprintf(`{"Version":"2018-11-08","DestinationReferences":["refs/heads/master"],"Statements":[{"Type":"Approvers","NumberOfApprovalsNeeded":%d,"ApprovalPoolMembers":["arn:%s:sts::%s:assumed-role/CodeCommitReview/*"]}]}`, numApprovals, acctest.Partition(), acctest.AccountID(), ) - return resource.TestCheckResourceAttr(resourceName, "content", expectedContent)(s) + return resource.TestCheckResourceAttr(resourceName, names.AttrContent, expectedContent)(s) } } From 57010de6ccd4378e9d9af9a6ef5f5441e3b06cf8 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:55 -0400 Subject: [PATCH 22/78] codegurureviewer: Use constants for strings --- internal/service/codegurureviewer/repository_association.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/codegurureviewer/repository_association.go b/internal/service/codegurureviewer/repository_association.go index d4d5d790eb3..863c01d9d58 100644 --- a/internal/service/codegurureviewer/repository_association.go +++ b/internal/service/codegurureviewer/repository_association.go @@ -191,7 +191,7 @@ func resourceRepositoryAssociation() *schema.Resource { }, }, }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeList, ForceNew: true, Optional: true, @@ -555,7 +555,7 @@ func expandRepository(repository []interface{}) *types.Repository { if v, ok := tfMap["github_enterprise_server"]; ok { result.GitHubEnterpriseServer = expandThirdPartySourceRepository(v.([]interface{})) } - if v, ok := tfMap["s3_bucket"]; ok { + if v, ok := tfMap[names.AttrS3Bucket]; ok { result.S3Bucket = expandS3Repository(v.([]interface{})) } From 079cc88ba6a43645bf959dbf2f2e530ee44662b9 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:55 -0400 Subject: [PATCH 23/78] cognitoidp: Use constants for strings --- internal/service/cognitoidp/user_pool.go | 16 ++++++++-------- internal/service/cognitoidp/user_pool_domain.go | 10 +++++----- .../service/cognitoidp/user_pool_domain_test.go | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/service/cognitoidp/user_pool.go b/internal/service/cognitoidp/user_pool.go index aaa8a8d5b78..86b1dfa7265 100644 --- a/internal/service/cognitoidp/user_pool.go +++ b/internal/service/cognitoidp/user_pool.go @@ -163,7 +163,7 @@ func resourceUserPool() *schema.Resource { }, }, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Computed: true, }, @@ -408,7 +408,7 @@ func resourceUserPool() *schema.Resource { }, }, }, - "schema": { + names.AttrSchema: { Type: schema.TypeSet, Optional: true, MinItems: 1, @@ -715,7 +715,7 @@ func resourceUserPoolCreate(ctx context.Context, d *schema.ResourceData, meta in } } - if v, ok := d.GetOk("schema"); ok { + if v, ok := d.GetOk(names.AttrSchema); ok { input.Schema = expandUserPoolSchema(v.(*schema.Set).List()) } @@ -852,7 +852,7 @@ func resourceUserPoolRead(ctx context.Context, d *schema.ResourceData, meta inte if err := d.Set("device_configuration", flattenUserPoolDeviceConfiguration(userPool.DeviceConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting device_configuration: %s", err) } - d.Set("domain", userPool.Domain) + d.Set(names.AttrDomain, userPool.Domain) if err := d.Set("email_configuration", flattenUserPoolEmailConfiguration(userPool.EmailConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting email_configuration: %s", err) } @@ -869,10 +869,10 @@ func resourceUserPoolRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "setting password_policy: %s", err) } var configuredSchema []interface{} - if v, ok := d.GetOk("schema"); ok { + if v, ok := d.GetOk(names.AttrSchema); ok { configuredSchema = v.(*schema.Set).List() } - if err := d.Set("schema", flattenUserPoolSchema(expandUserPoolSchema(configuredSchema), userPool.SchemaAttributes)); err != nil { + if err := d.Set(names.AttrSchema, flattenUserPoolSchema(expandUserPoolSchema(configuredSchema), userPool.SchemaAttributes)); err != nil { return sdkdiag.AppendErrorf(diags, "setting schema: %s", err) } d.Set("sms_authentication_message", userPool.SmsAuthenticationMessage) @@ -1143,8 +1143,8 @@ func resourceUserPoolUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - if d.HasChange("schema") { - o, n := d.GetChange("schema") + if d.HasChange(names.AttrSchema) { + o, n := d.GetChange(names.AttrSchema) os, ns := o.(*schema.Set), n.(*schema.Set) if os.Difference(ns).Len() == 0 { diff --git a/internal/service/cognitoidp/user_pool_domain.go b/internal/service/cognitoidp/user_pool_domain.go index 11b2f35a291..4fa023423a0 100644 --- a/internal/service/cognitoidp/user_pool_domain.go +++ b/internal/service/cognitoidp/user_pool_domain.go @@ -58,13 +58,13 @@ func resourceUserPoolDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 63), }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Computed: true, }, @@ -90,7 +90,7 @@ func resourceUserPoolDomainCreate(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - domain := d.Get("domain").(string) + domain := d.Get(names.AttrDomain).(string) timeout := 1 * time.Minute input := &cognitoidentityprovider.CreateUserPoolDomainInput{ Domain: aws.String(domain), @@ -143,8 +143,8 @@ func resourceUserPoolDomainRead(ctx context.Context, d *schema.ResourceData, met d.Set("cloudfront_distribution", desc.CloudFrontDistribution) d.Set("cloudfront_distribution_arn", desc.CloudFrontDistribution) d.Set("cloudfront_distribution_zone_id", meta.(*conns.AWSClient).CloudFrontDistributionHostedZoneID(ctx)) - d.Set("domain", d.Id()) - d.Set("s3_bucket", desc.S3Bucket) + d.Set(names.AttrDomain, d.Id()) + d.Set(names.AttrS3Bucket, desc.S3Bucket) d.Set("user_pool_id", desc.UserPoolId) d.Set(names.AttrVersion, desc.Version) diff --git a/internal/service/cognitoidp/user_pool_domain_test.go b/internal/service/cognitoidp/user_pool_domain_test.go index 319a18da70c..234ac875533 100644 --- a/internal/service/cognitoidp/user_pool_domain_test.go +++ b/internal/service/cognitoidp/user_pool_domain_test.go @@ -40,8 +40,8 @@ func TestAccCognitoIDPUserPoolDomain_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "cloudfront_distribution"), resource.TestCheckResourceAttrSet(resourceName, "cloudfront_distribution_arn"), resource.TestCheckResourceAttr(resourceName, "cloudfront_distribution_zone_id", "Z2FDTNDATAQYW2"), - resource.TestCheckResourceAttr(resourceName, "domain", rName), - resource.TestCheckResourceAttrSet(resourceName, "s3_bucket"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, rName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrS3Bucket), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), }, @@ -103,8 +103,8 @@ func TestAccCognitoIDPUserPoolDomain_custom(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, names.AttrCertificateARN, acmCertificateResourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "cloudfront_distribution"), resource.TestCheckResourceAttr(resourceName, "cloudfront_distribution_zone_id", "Z2FDTNDATAQYW2"), - resource.TestCheckResourceAttrPair(resourceName, "domain", acmCertificateResourceName, names.AttrDomainName), - resource.TestCheckResourceAttrSet(resourceName, "s3_bucket"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrDomain, acmCertificateResourceName, names.AttrDomainName), + resource.TestCheckResourceAttrSet(resourceName, names.AttrS3Bucket), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), }, From ec58d0306c61e5e69af5a618d82b8eb626ae3d7d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:55 -0400 Subject: [PATCH 24/78] comprehend: Use constants for strings --- internal/service/comprehend/common_model.go | 4 ++-- internal/service/comprehend/document_classifier.go | 2 +- internal/service/comprehend/entity_recognizer.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/comprehend/common_model.go b/internal/service/comprehend/common_model.go index 4c560720530..ec25319fe24 100644 --- a/internal/service/comprehend/common_model.go +++ b/internal/service/comprehend/common_model.go @@ -112,7 +112,7 @@ func flattenVPCConfig(apiObject *types.VpcConfig) []interface{} { m := map[string]interface{}{ names.AttrSecurityGroupIDs: flex.FlattenStringValueSet(apiObject.SecurityGroupIds), - "subnets": flex.FlattenStringValueSet(apiObject.Subnets), + names.AttrSubnets: flex.FlattenStringValueSet(apiObject.Subnets), } return []interface{}{m} @@ -127,7 +127,7 @@ func expandVPCConfig(tfList []interface{}) *types.VpcConfig { a := &types.VpcConfig{ SecurityGroupIds: flex.ExpandStringValueSet(tfMap[names.AttrSecurityGroupIDs].(*schema.Set)), - Subnets: flex.ExpandStringValueSet(tfMap["subnets"].(*schema.Set)), + Subnets: flex.ExpandStringValueSet(tfMap[names.AttrSubnets].(*schema.Set)), } return a diff --git a/internal/service/comprehend/document_classifier.go b/internal/service/comprehend/document_classifier.go index a28e9e6dca6..eae53c1244d 100644 --- a/internal/service/comprehend/document_classifier.go +++ b/internal/service/comprehend/document_classifier.go @@ -224,7 +224,7 @@ func ResourceDocumentClassifier() *schema.Resource { Required: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, diff --git a/internal/service/comprehend/entity_recognizer.go b/internal/service/comprehend/entity_recognizer.go index 87061dcbb5e..0b6e8689d21 100644 --- a/internal/service/comprehend/entity_recognizer.go +++ b/internal/service/comprehend/entity_recognizer.go @@ -245,7 +245,7 @@ func ResourceEntityRecognizer() *schema.Resource { Required: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, From 886d3f0cf49359338109768b28fd783e4e7fd1aa Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:56 -0400 Subject: [PATCH 25/78] connect: Use constants for strings --- internal/service/connect/contact_flow.go | 12 ++++++------ internal/service/connect/contact_flow_data_source.go | 4 ++-- .../service/connect/contact_flow_data_source_test.go | 4 ++-- internal/service/connect/contact_flow_module.go | 12 ++++++------ .../connect/contact_flow_module_data_source.go | 4 ++-- .../connect/contact_flow_module_data_source_test.go | 4 ++-- internal/service/connect/contact_flow_module_test.go | 4 ++-- internal/service/connect/contact_flow_test.go | 4 ++-- internal/service/connect/vocabulary.go | 6 +++--- internal/service/connect/vocabulary_data_source.go | 4 ++-- .../service/connect/vocabulary_data_source_test.go | 4 ++-- internal/service/connect/vocabulary_test.go | 2 +- 12 files changed, 32 insertions(+), 32 deletions(-) diff --git a/internal/service/connect/contact_flow.go b/internal/service/connect/contact_flow.go index d1d9b568dad..ec83fe6c989 100644 --- a/internal/service/connect/contact_flow.go +++ b/internal/service/connect/contact_flow.go @@ -48,7 +48,7 @@ func ResourceContactFlow() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, Computed: true, @@ -71,7 +71,7 @@ func ResourceContactFlow() *schema.Resource { "filename": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"content"}, + ConflictsWith: []string{names.AttrContent}, }, names.AttrInstanceID: { Type: schema.TypeString, @@ -125,7 +125,7 @@ func resourceContactFlowCreate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err) } input.Content = aws.String(file) - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { input.Content = aws.String(v.(string)) } @@ -180,7 +180,7 @@ func resourceContactFlowRead(ctx context.Context, d *schema.ResourceData, meta i d.Set(names.AttrName, resp.ContactFlow.Name) d.Set(names.AttrDescription, resp.ContactFlow.Description) d.Set(names.AttrType, resp.ContactFlow.Type) - d.Set("content", resp.ContactFlow.Content) + d.Set(names.AttrContent, resp.ContactFlow.Content) setTagsOut(ctx, resp.ContactFlow.Tags) @@ -213,7 +213,7 @@ func resourceContactFlowUpdate(ctx context.Context, d *schema.ResourceData, meta } } - if d.HasChanges("content", "content_hash", "filename") { + if d.HasChanges(names.AttrContent, "content_hash", "filename") { updateContentInput := &connect.UpdateContactFlowContentInput{ ContactFlowId: aws.String(contactFlowID), InstanceId: aws.String(instanceID), @@ -231,7 +231,7 @@ func resourceContactFlowUpdate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err) } updateContentInput.Content = aws.String(file) - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { updateContentInput.Content = aws.String(v.(string)) } diff --git a/internal/service/connect/contact_flow_data_source.go b/internal/service/connect/contact_flow_data_source.go index de92616af87..272d24b222d 100644 --- a/internal/service/connect/contact_flow_data_source.go +++ b/internal/service/connect/contact_flow_data_source.go @@ -32,7 +32,7 @@ func DataSourceContactFlow() *schema.Resource { Computed: true, ExactlyOneOf: []string{"contact_flow_id", names.AttrName}, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -105,7 +105,7 @@ func dataSourceContactFlowRead(ctx context.Context, d *schema.ResourceData, meta d.Set("contact_flow_id", contactFlow.Id) d.Set(names.AttrName, contactFlow.Name) d.Set(names.AttrDescription, contactFlow.Description) - d.Set("content", contactFlow.Content) + d.Set(names.AttrContent, contactFlow.Content) d.Set(names.AttrType, contactFlow.Type) if err := d.Set(names.AttrTags, KeyValueTags(ctx, contactFlow.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { diff --git a/internal/service/connect/contact_flow_data_source_test.go b/internal/service/connect/contact_flow_data_source_test.go index d69b3de3a07..c827e9eeb58 100644 --- a/internal/service/connect/contact_flow_data_source_test.go +++ b/internal/service/connect/contact_flow_data_source_test.go @@ -33,7 +33,7 @@ func testAccContactFlowDataSource_contactFlowID(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrType, resourceName, names.AttrType), resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"), ), @@ -63,7 +63,7 @@ func testAccContactFlowDataSource_name(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrType, resourceName, names.AttrType), resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"), ), diff --git a/internal/service/connect/contact_flow_module.go b/internal/service/connect/contact_flow_module.go index 4b1f5a152c8..aef61eab276 100644 --- a/internal/service/connect/contact_flow_module.go +++ b/internal/service/connect/contact_flow_module.go @@ -48,7 +48,7 @@ func ResourceContactFlowModule() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, Computed: true, @@ -72,7 +72,7 @@ func ResourceContactFlowModule() *schema.Resource { "filename": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"content"}, + ConflictsWith: []string{names.AttrContent}, }, names.AttrInstanceID: { Type: schema.TypeString, @@ -119,7 +119,7 @@ func resourceContactFlowModuleCreate(ctx context.Context, d *schema.ResourceData return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err) } input.Content = aws.String(file) - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { input.Content = aws.String(v.(string)) } @@ -173,7 +173,7 @@ func resourceContactFlowModuleRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrInstanceID, instanceID) d.Set(names.AttrName, resp.ContactFlowModule.Name) d.Set(names.AttrDescription, resp.ContactFlowModule.Description) - d.Set("content", resp.ContactFlowModule.Content) + d.Set(names.AttrContent, resp.ContactFlowModule.Content) setTagsOut(ctx, resp.ContactFlowModule.Tags) @@ -206,7 +206,7 @@ func resourceContactFlowModuleUpdate(ctx context.Context, d *schema.ResourceData } } - if d.HasChanges("content", "content_hash", "filename") { + if d.HasChanges(names.AttrContent, "content_hash", "filename") { updateContentInput := &connect.UpdateContactFlowModuleContentInput{ ContactFlowModuleId: aws.String(contactFlowModuleID), InstanceId: aws.String(instanceID), @@ -224,7 +224,7 @@ func resourceContactFlowModuleUpdate(ctx context.Context, d *schema.ResourceData return sdkdiag.AppendErrorf(diags, "unable to load %q: %s", filename, err) } updateContentInput.Content = aws.String(file) - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { updateContentInput.Content = aws.String(v.(string)) } diff --git a/internal/service/connect/contact_flow_module_data_source.go b/internal/service/connect/contact_flow_module_data_source.go index 92f3c2afaa6..9675e45e265 100644 --- a/internal/service/connect/contact_flow_module_data_source.go +++ b/internal/service/connect/contact_flow_module_data_source.go @@ -32,7 +32,7 @@ func DataSourceContactFlowModule() *schema.Resource { Computed: true, ExactlyOneOf: []string{"contact_flow_module_id", names.AttrName}, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -106,7 +106,7 @@ func dataSourceContactFlowModuleRead(ctx context.Context, d *schema.ResourceData d.Set(names.AttrARN, contactFlowModule.Arn) d.Set("contact_flow_module_id", contactFlowModule.Id) - d.Set("content", contactFlowModule.Content) + d.Set(names.AttrContent, contactFlowModule.Content) d.Set(names.AttrDescription, contactFlowModule.Description) d.Set(names.AttrName, contactFlowModule.Name) d.Set(names.AttrState, contactFlowModule.State) diff --git a/internal/service/connect/contact_flow_module_data_source_test.go b/internal/service/connect/contact_flow_module_data_source_test.go index 0ee01993b70..eb34e8a98b0 100644 --- a/internal/service/connect/contact_flow_module_data_source_test.go +++ b/internal/service/connect/contact_flow_module_data_source_test.go @@ -33,7 +33,7 @@ func testAccContactFlowModuleDataSource_contactFlowModuleID(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrSet(datasourceName, names.AttrState), resource.TestCheckResourceAttrSet(datasourceName, names.AttrStatus), resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"), @@ -64,7 +64,7 @@ func testAccContactFlowModuleDataSource_name(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrSet(datasourceName, names.AttrState), resource.TestCheckResourceAttrSet(datasourceName, names.AttrStatus), resource.TestCheckResourceAttrPair(datasourceName, "tags.%", resourceName, "tags.%"), diff --git a/internal/service/connect/contact_flow_module_test.go b/internal/service/connect/contact_flow_module_test.go index 7e81a3bdfb6..20118857b39 100644 --- a/internal/service/connect/contact_flow_module_test.go +++ b/internal/service/connect/contact_flow_module_test.go @@ -39,7 +39,7 @@ func testAccContactFlowModule_basic(t *testing.T) { testAccCheckContactFlowModuleExists(ctx, resourceName, &v), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "contact_flow_module_id"), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttrSet(resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrSet(resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "Created"), @@ -57,7 +57,7 @@ func testAccContactFlowModule_basic(t *testing.T) { testAccCheckContactFlowModuleExists(ctx, resourceName, &v), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "contact_flow_module_id"), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttrSet(resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrSet(resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "Updated"), diff --git a/internal/service/connect/contact_flow_test.go b/internal/service/connect/contact_flow_test.go index 4f80327fe0e..5b7c16fcb7d 100644 --- a/internal/service/connect/contact_flow_test.go +++ b/internal/service/connect/contact_flow_test.go @@ -42,7 +42,7 @@ func testAccContactFlow_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrSet(resourceName, names.AttrName), resource.TestCheckResourceAttrSet(resourceName, names.AttrDescription), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttr(resourceName, names.AttrType, connect.ContactFlowTypeContactFlow), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), ), @@ -61,7 +61,7 @@ func testAccContactFlow_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrSet(resourceName, names.AttrName), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "Updated"), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttr(resourceName, names.AttrType, connect.ContactFlowTypeContactFlow), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), ), diff --git a/internal/service/connect/vocabulary.go b/internal/service/connect/vocabulary.go index 88e50f1ad51..0d97cd77109 100644 --- a/internal/service/connect/vocabulary.go +++ b/internal/service/connect/vocabulary.go @@ -50,7 +50,7 @@ func ResourceVocabulary() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -109,7 +109,7 @@ func resourceVocabularyCreate(ctx context.Context, d *schema.ResourceData, meta input := &connect.CreateVocabularyInput{ ClientToken: aws.String(id.UniqueId()), InstanceId: aws.String(instanceID), - Content: aws.String(d.Get("content").(string)), + Content: aws.String(d.Get(names.AttrContent).(string)), LanguageCode: aws.String(d.Get("language_code").(string)), Tags: getTagsIn(ctx), VocabularyName: aws.String(vocabularyName), @@ -171,7 +171,7 @@ func resourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta in vocabulary := resp.Vocabulary d.Set(names.AttrARN, vocabulary.Arn) - d.Set("content", vocabulary.Content) + d.Set(names.AttrContent, vocabulary.Content) d.Set("failure_reason", vocabulary.FailureReason) d.Set(names.AttrInstanceID, instanceID) d.Set("language_code", vocabulary.LanguageCode) diff --git a/internal/service/connect/vocabulary_data_source.go b/internal/service/connect/vocabulary_data_source.go index 036ee87e0bd..16665bdc5c5 100644 --- a/internal/service/connect/vocabulary_data_source.go +++ b/internal/service/connect/vocabulary_data_source.go @@ -29,7 +29,7 @@ func DataSourceVocabulary() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -113,7 +113,7 @@ func dataSourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta vocabulary := resp.Vocabulary d.Set(names.AttrARN, vocabulary.Arn) - d.Set("content", vocabulary.Content) + d.Set(names.AttrContent, vocabulary.Content) d.Set("failure_reason", vocabulary.FailureReason) d.Set(names.AttrInstanceID, instanceID) d.Set("language_code", vocabulary.LanguageCode) diff --git a/internal/service/connect/vocabulary_data_source_test.go b/internal/service/connect/vocabulary_data_source_test.go index 8b0583341fd..ae88ebf9901 100644 --- a/internal/service/connect/vocabulary_data_source_test.go +++ b/internal/service/connect/vocabulary_data_source_test.go @@ -32,7 +32,7 @@ func testAccVocabularyDataSource_vocabularyID(t *testing.T) { Config: testAccVocabularyDataSourceConfig_id(rName, rName2), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(datasourceName, names.AttrARN, resourceName, names.AttrARN), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrID, resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, "language_code", resourceName, "language_code"), @@ -67,7 +67,7 @@ func testAccVocabularyDataSource_name(t *testing.T) { Config: testAccVocabularyDataSourceConfig_name(rName, rName2), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(datasourceName, names.AttrARN, resourceName, names.AttrARN), - resource.TestCheckResourceAttrPair(datasourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrContent, resourceName, names.AttrContent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrID, resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrInstanceID, resourceName, names.AttrInstanceID), resource.TestCheckResourceAttrPair(datasourceName, "language_code", resourceName, "language_code"), diff --git a/internal/service/connect/vocabulary_test.go b/internal/service/connect/vocabulary_test.go index 4a63b6d9853..056648bc43b 100644 --- a/internal/service/connect/vocabulary_test.go +++ b/internal/service/connect/vocabulary_test.go @@ -45,7 +45,7 @@ func testAccVocabulary_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckVocabularyExists(ctx, resourceName, &v), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "content", content), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content), resource.TestCheckResourceAttrPair(resourceName, names.AttrInstanceID, "aws_connect_instance.test", names.AttrID), resource.TestCheckResourceAttr(resourceName, "language_code", languageCode), resource.TestCheckResourceAttrSet(resourceName, "last_modified_time"), From 06f559e9e2c3e00b47f9e29851f38df1dcd8b8ee Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:56 -0400 Subject: [PATCH 26/78] cur: Use constants for strings --- internal/service/cur/report_definition.go | 8 ++++---- .../service/cur/report_definition_data_source.go | 4 ++-- .../cur/report_definition_data_source_test.go | 4 ++-- internal/service/cur/report_definition_test.go | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/service/cur/report_definition.go b/internal/service/cur/report_definition.go index b643b134286..6da276f2fd0 100644 --- a/internal/service/cur/report_definition.go +++ b/internal/service/cur/report_definition.go @@ -91,7 +91,7 @@ func resourceReportDefinition() *schema.Resource { Default: types.ReportVersioningCreateNewReport, ValidateDiagFunc: enum.Validate[types.ReportVersioning](), }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Required: true, }, @@ -145,7 +145,7 @@ func resourceReportDefinitionCreate(ctx context.Context, d *schema.ResourceData, RefreshClosedReports: aws.Bool(d.Get("refresh_closed_reports").(bool)), ReportName: aws.String(reportName), ReportVersioning: reportVersioning, - S3Bucket: aws.String(d.Get("s3_bucket").(string)), + S3Bucket: aws.String(d.Get(names.AttrS3Bucket).(string)), S3Prefix: aws.String(prefix), S3Region: types.AWSRegion(d.Get("s3_region").(string)), TimeUnit: types.TimeUnit(d.Get("time_unit").(string)), @@ -196,7 +196,7 @@ func resourceReportDefinitionRead(ctx context.Context, d *schema.ResourceData, m d.Set("refresh_closed_reports", reportDefinition.RefreshClosedReports) d.Set("report_name", reportName) d.Set("report_versioning", reportDefinition.ReportVersioning) - d.Set("s3_bucket", reportDefinition.S3Bucket) + d.Set(names.AttrS3Bucket, reportDefinition.S3Bucket) d.Set("s3_prefix", reportDefinition.S3Prefix) d.Set("s3_region", reportDefinition.S3Region) d.Set("time_unit", reportDefinition.TimeUnit) @@ -233,7 +233,7 @@ func resourceReportDefinitionUpdate(ctx context.Context, d *schema.ResourceData, RefreshClosedReports: aws.Bool(d.Get("refresh_closed_reports").(bool)), ReportName: aws.String(d.Id()), ReportVersioning: reportVersioning, - S3Bucket: aws.String(d.Get("s3_bucket").(string)), + S3Bucket: aws.String(d.Get(names.AttrS3Bucket).(string)), S3Prefix: aws.String(prefix), S3Region: types.AWSRegion(d.Get("s3_region").(string)), TimeUnit: types.TimeUnit(d.Get("time_unit").(string)), diff --git a/internal/service/cur/report_definition_data_source.go b/internal/service/cur/report_definition_data_source.go index 2a1c2f14c9b..6fa5dd43655 100644 --- a/internal/service/cur/report_definition_data_source.go +++ b/internal/service/cur/report_definition_data_source.go @@ -50,7 +50,7 @@ func dataSourceReportDefinition() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Computed: true, }, @@ -89,7 +89,7 @@ func dataSourceReportDefinitionRead(ctx context.Context, d *schema.ResourceData, d.Set("refresh_closed_reports", reportDefinition.RefreshClosedReports) d.Set("report_name", reportDefinition.ReportName) d.Set("report_versioning", reportDefinition.ReportVersioning) - d.Set("s3_bucket", reportDefinition.S3Bucket) + d.Set(names.AttrS3Bucket, reportDefinition.S3Bucket) d.Set("s3_prefix", reportDefinition.S3Prefix) d.Set("s3_region", reportDefinition.S3Region) d.Set("time_unit", reportDefinition.TimeUnit) diff --git a/internal/service/cur/report_definition_data_source_test.go b/internal/service/cur/report_definition_data_source_test.go index 23006f1c31c..9afbb874689 100644 --- a/internal/service/cur/report_definition_data_source_test.go +++ b/internal/service/cur/report_definition_data_source_test.go @@ -33,7 +33,7 @@ func testAccReportDefinitionDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "time_unit", resourceName, "time_unit"), resource.TestCheckResourceAttrPair(datasourceName, "compression", resourceName, "compression"), resource.TestCheckResourceAttrPair(datasourceName, "additional_schema_elements.#", resourceName, "additional_schema_elements.#"), - resource.TestCheckResourceAttrPair(datasourceName, "s3_bucket", resourceName, "s3_bucket"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrS3Bucket, resourceName, names.AttrS3Bucket), resource.TestCheckResourceAttrPair(datasourceName, "s3_prefix", resourceName, "s3_prefix"), resource.TestCheckResourceAttrPair(datasourceName, "s3_region", resourceName, "s3_region"), resource.TestCheckResourceAttrPair(datasourceName, "additional_artifacts.#", resourceName, "additional_artifacts.#"), @@ -63,7 +63,7 @@ func testAccReportDefinitionDataSource_additional(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "time_unit", resourceName, "time_unit"), resource.TestCheckResourceAttrPair(datasourceName, "compression", resourceName, "compression"), resource.TestCheckResourceAttrPair(datasourceName, "additional_schema_elements.#", resourceName, "additional_schema_elements.#"), - resource.TestCheckResourceAttrPair(datasourceName, "s3_bucket", resourceName, "s3_bucket"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrS3Bucket, resourceName, names.AttrS3Bucket), resource.TestCheckResourceAttrPair(datasourceName, "s3_prefix", resourceName, "s3_prefix"), resource.TestCheckResourceAttrPair(datasourceName, "s3_region", resourceName, "s3_region"), resource.TestCheckResourceAttrPair(datasourceName, "additional_artifacts.#", resourceName, "additional_artifacts.#"), diff --git a/internal/service/cur/report_definition_test.go b/internal/service/cur/report_definition_test.go index 3e49a616913..cbb96751775 100644 --- a/internal/service/cur/report_definition_test.go +++ b/internal/service/cur/report_definition_test.go @@ -43,7 +43,7 @@ func testAccReportDefinition_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "time_unit", "DAILY"), resource.TestCheckResourceAttr(resourceName, "compression", "GZIP"), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", ""), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "2"), @@ -64,7 +64,7 @@ func testAccReportDefinition_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "time_unit", "DAILY"), resource.TestCheckResourceAttr(resourceName, "compression", "GZIP"), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", "test"), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "2"), @@ -102,7 +102,7 @@ func testAccReportDefinition_textOrCSV(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrFormat, format), resource.TestCheckResourceAttr(resourceName, "compression", compression), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", bucketPrefix), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "2"), @@ -147,7 +147,7 @@ func testAccReportDefinition_parquet(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrFormat, format), resource.TestCheckResourceAttr(resourceName, "compression", compression), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", bucketPrefix), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "refresh_closed_reports", "false"), @@ -191,7 +191,7 @@ func testAccReportDefinition_athena(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrFormat, format), resource.TestCheckResourceAttr(resourceName, "compression", compression), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", bucketPrefix), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "1"), @@ -236,7 +236,7 @@ func testAccReportDefinition_refresh(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrFormat, format), resource.TestCheckResourceAttr(resourceName, "compression", compression), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", bucketPrefix), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "2"), @@ -281,7 +281,7 @@ func testAccReportDefinition_overwrite(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrFormat, format), resource.TestCheckResourceAttr(resourceName, "compression", compression), resource.TestCheckResourceAttr(resourceName, "additional_schema_elements.#", "2"), - resource.TestCheckResourceAttr(resourceName, "s3_bucket", bucketName), + resource.TestCheckResourceAttr(resourceName, names.AttrS3Bucket, bucketName), resource.TestCheckResourceAttr(resourceName, "s3_prefix", ""), resource.TestCheckResourceAttrPair(resourceName, "s3_region", s3BucketResourceName, names.AttrRegion), resource.TestCheckResourceAttr(resourceName, "additional_artifacts.#", "2"), From e9735834d13d3126f1eac0bd803d4d265718bfac Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:56 -0400 Subject: [PATCH 27/78] datasync: Use constants for strings --- .../service/datasync/common_fsx_protocol_functions.go | 4 ++-- .../service/datasync/location_fsx_ontap_file_system.go | 2 +- .../service/datasync/location_fsx_windows_file_system.go | 6 +++--- internal/service/datasync/location_smb.go | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/datasync/common_fsx_protocol_functions.go b/internal/service/datasync/common_fsx_protocol_functions.go index f67a68f7758..d525827aa4f 100644 --- a/internal/service/datasync/common_fsx_protocol_functions.go +++ b/internal/service/datasync/common_fsx_protocol_functions.go @@ -68,7 +68,7 @@ func expandSMB(l []interface{}) *awstypes.FsxProtocolSmb { protocol := &awstypes.FsxProtocolSmb{ MountOptions: expandSMBMountOptions(m["mount_options"].([]interface{})), } - if v, ok := m["domain"].(string); ok && v != "" { + if v, ok := m[names.AttrDomain].(string); ok && v != "" { protocol.Domain = aws.String(v) } if v, ok := m[names.AttrPassword].(string); ok && v != "" { @@ -103,7 +103,7 @@ func flattenSMB(smb *awstypes.FsxProtocolSmb) []interface{} { "mount_options": flattenSMBMountOptions(smb.MountOptions), } if v := smb.Domain; v != nil { - m["domain"] = aws.ToString(v) + m[names.AttrDomain] = aws.ToString(v) } if v := smb.Password; v != nil { m[names.AttrPassword] = aws.ToString(v) diff --git a/internal/service/datasync/location_fsx_ontap_file_system.go b/internal/service/datasync/location_fsx_ontap_file_system.go index 3491cb465ef..6a1da8f8f0d 100644 --- a/internal/service/datasync/location_fsx_ontap_file_system.go +++ b/internal/service/datasync/location_fsx_ontap_file_system.go @@ -110,7 +110,7 @@ func resourceLocationFSxONTAPFileSystem() *schema.Resource { ExactlyOneOf: []string{"protocol.0.nfs", "protocol.0.smb"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, ForceNew: true, diff --git a/internal/service/datasync/location_fsx_windows_file_system.go b/internal/service/datasync/location_fsx_windows_file_system.go index fd06c719141..ec4a07ccc94 100644 --- a/internal/service/datasync/location_fsx_windows_file_system.go +++ b/internal/service/datasync/location_fsx_windows_file_system.go @@ -62,7 +62,7 @@ func resourceLocationFSxWindowsFileSystem() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -129,7 +129,7 @@ func resourceLocationFSxWindowsFileSystemCreate(ctx context.Context, d *schema.R User: aws.String(d.Get("user").(string)), } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -172,7 +172,7 @@ func resourceLocationFSxWindowsFileSystemRead(ctx context.Context, d *schema.Res d.Set(names.AttrARN, output.LocationArn) d.Set(names.AttrCreationTime, output.CreationTime.Format(time.RFC3339)) - d.Set("domain", output.Domain) + d.Set(names.AttrDomain, output.Domain) d.Set("fsx_filesystem_arn", d.Get("fsx_filesystem_arn")) d.Set("security_group_arns", output.SecurityGroupArns) d.Set("subdirectory", subdirectory) diff --git a/internal/service/datasync/location_smb.go b/internal/service/datasync/location_smb.go index c15e4c95ac1..df1e0d3d1d8 100644 --- a/internal/service/datasync/location_smb.go +++ b/internal/service/datasync/location_smb.go @@ -51,7 +51,7 @@ func resourceLocationSMB() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Computed: true, Optional: true, @@ -132,7 +132,7 @@ func resourceLocationSMBCreate(ctx context.Context, d *schema.ResourceData, meta User: aws.String(d.Get("user").(string)), } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -175,7 +175,7 @@ func resourceLocationSMBRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("agent_arns", output.AgentArns) d.Set(names.AttrARN, output.LocationArn) - d.Set("domain", output.Domain) + d.Set(names.AttrDomain, output.Domain) if err := d.Set("mount_options", flattenSMBMountOptions(output.MountOptions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting mount_options: %s", err) } @@ -201,7 +201,7 @@ func resourceLocationSMBUpdate(ctx context.Context, d *schema.ResourceData, meta User: aws.String(d.Get("user").(string)), } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } From a3784abac6fd04c9de117687f7269bfe7eca2c42 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:57 -0400 Subject: [PATCH 28/78] dynamodb: Use constants for strings --- internal/service/dynamodb/table_export.go | 6 +++--- internal/service/dynamodb/table_export_test.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/dynamodb/table_export.go b/internal/service/dynamodb/table_export.go index 83333809d79..ff7629d0ddc 100644 --- a/internal/service/dynamodb/table_export.go +++ b/internal/service/dynamodb/table_export.go @@ -79,7 +79,7 @@ func resourceTableExport() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -129,7 +129,7 @@ func resourceTableExportCreate(ctx context.Context, d *schema.ResourceData, meta var diags diag.Diagnostics conn := meta.(*conns.AWSClient).DynamoDBClient(ctx) - s3Bucket := d.Get("s3_bucket").(string) + s3Bucket := d.Get(names.AttrS3Bucket).(string) tableARN := d.Get("table_arn").(string) input := &dynamodb.ExportTableToPointInTimeInput{ S3Bucket: aws.String(s3Bucket), @@ -204,7 +204,7 @@ func resourceTableExportRead(ctx context.Context, d *schema.ResourceData, meta i } d.Set("item_count", desc.ItemCount) d.Set("manifest_files_s3_key", desc.ExportManifest) - d.Set("s3_bucket", desc.S3Bucket) + d.Set(names.AttrS3Bucket, desc.S3Bucket) d.Set("s3_bucket_owner", desc.S3BucketOwner) d.Set("s3_prefix", desc.S3Prefix) d.Set("s3_sse_algorithm", desc.S3SseAlgorithm) diff --git a/internal/service/dynamodb/table_export_test.go b/internal/service/dynamodb/table_export_test.go index c4d8205c3e5..fee2a8f6c4a 100644 --- a/internal/service/dynamodb/table_export_test.go +++ b/internal/service/dynamodb/table_export_test.go @@ -44,7 +44,7 @@ func TestAccDynamoDBTableExport_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "export_format", "DYNAMODB_JSON"), resource.TestCheckResourceAttr(resourceName, "export_status", "COMPLETED"), resource.TestCheckResourceAttr(resourceName, "item_count", "0"), - resource.TestCheckResourceAttrPair(resourceName, "s3_bucket", s3BucketResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrS3Bucket, s3BucketResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "s3_bucket_owner", ""), resource.TestCheckResourceAttr(resourceName, "s3_prefix", ""), resource.TestCheckResourceAttr(resourceName, "s3_sse_algorithm", "AES256"), @@ -97,7 +97,7 @@ func TestAccDynamoDBTableExport_kms(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "export_format", "DYNAMODB_JSON"), resource.TestCheckResourceAttr(resourceName, "export_status", "COMPLETED"), resource.TestCheckResourceAttr(resourceName, "item_count", "0"), - resource.TestCheckResourceAttrPair(resourceName, "s3_bucket", s3BucketResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrS3Bucket, s3BucketResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "s3_bucket_owner", ""), resource.TestCheckResourceAttr(resourceName, "s3_prefix", ""), resource.TestCheckResourceAttr(resourceName, "s3_sse_algorithm", "KMS"), @@ -150,7 +150,7 @@ func TestAccDynamoDBTableExport_s3Prefix(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "export_format", "DYNAMODB_JSON"), resource.TestCheckResourceAttr(resourceName, "export_status", "COMPLETED"), resource.TestCheckResourceAttr(resourceName, "item_count", "0"), - resource.TestCheckResourceAttrPair(resourceName, "s3_bucket", s3BucketResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrS3Bucket, s3BucketResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "s3_bucket_owner", ""), resource.TestCheckResourceAttr(resourceName, "s3_prefix", "test"), resource.TestCheckResourceAttr(resourceName, "s3_sse_algorithm", "AES256"), From c051ef2bfa2b03bc02eb48443ab8b254059bfc2e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:57 -0400 Subject: [PATCH 29/78] ec2: Use constants for strings --- internal/service/ec2/ebs_snapshot_import.go | 4 ++-- internal/service/ec2/ec2_eip.go | 8 ++++---- internal/service/ec2/ec2_eip_data_source.go | 4 ++-- internal/service/ec2/ec2_eip_data_source_test.go | 4 ++-- internal/service/ec2/ec2_eip_test.go | 6 +++--- internal/service/ec2/ec2_instance_connect_endpoint.go | 2 +- .../service/ec2/ec2_instance_connect_endpoint_test.go | 4 ++-- internal/service/ec2/vpc_endpoint.go | 4 ++-- internal/service/ec2/vpc_endpoint_data_source.go | 2 +- internal/service/ec2/vpnclient_endpoint.go | 4 ++-- internal/service/ec2/vpnclient_endpoint_data_source.go | 4 ++-- .../service/ec2/vpnclient_endpoint_data_source_test.go | 6 +++--- internal/service/ec2/vpnclient_endpoint_test.go | 2 +- internal/service/ec2/vpnclient_test.go | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/internal/service/ec2/ebs_snapshot_import.go b/internal/service/ec2/ebs_snapshot_import.go index cce3184b1f6..7edf6f93d6c 100644 --- a/internal/service/ec2/ebs_snapshot_import.go +++ b/internal/service/ec2/ebs_snapshot_import.go @@ -120,7 +120,7 @@ func ResourceEBSSnapshotImport() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -369,7 +369,7 @@ func expandUserBucket(tfMap map[string]interface{}) *awstypes.UserBucket { apiObject := &awstypes.UserBucket{} - if v, ok := tfMap["s3_bucket"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrS3Bucket].(string); ok && v != "" { apiObject.S3Bucket = aws.String(v) } diff --git a/internal/service/ec2/ec2_eip.go b/internal/service/ec2/ec2_eip.go index 3974258e54a..98d76444db3 100644 --- a/internal/service/ec2/ec2_eip.go +++ b/internal/service/ec2/ec2_eip.go @@ -82,7 +82,7 @@ func resourceEIP() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, ForceNew: true, Optional: true, @@ -140,7 +140,7 @@ func resourceEIP() *schema.Resource { ForceNew: true, Computed: true, Deprecated: "use domain attribute instead", - ConflictsWith: []string{"domain"}, + ConflictsWith: []string{names.AttrDomain}, }, }, } @@ -162,7 +162,7 @@ func resourceEIPCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.CustomerOwnedIpv4Pool = aws.String(v.(string)) } - if v := d.Get("domain"); v != nil && v.(string) != "" { + if v := d.Get(names.AttrDomain); v != nil && v.(string) != "" { input.Domain = types.DomainType(v.(string)) } @@ -238,7 +238,7 @@ func resourceEIPRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("carrier_ip", address.CarrierIp) d.Set("customer_owned_ip", address.CustomerOwnedIp) d.Set("customer_owned_ipv4_pool", address.CustomerOwnedIpv4Pool) - d.Set("domain", address.Domain) + d.Set(names.AttrDomain, address.Domain) d.Set("instance", address.InstanceId) d.Set("network_border_group", address.NetworkBorderGroup) d.Set("network_interface", address.NetworkInterfaceId) diff --git a/internal/service/ec2/ec2_eip_data_source.go b/internal/service/ec2/ec2_eip_data_source.go index 52bb4a28295..f4a8e516dd7 100644 --- a/internal/service/ec2/ec2_eip_data_source.go +++ b/internal/service/ec2/ec2_eip_data_source.go @@ -50,7 +50,7 @@ func dataSourceEIP() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Computed: true, }, @@ -159,7 +159,7 @@ func dataSourceEIPRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("carrier_ip", eip.CarrierIp) d.Set("customer_owned_ip", eip.CustomerOwnedIp) d.Set("customer_owned_ipv4_pool", eip.CustomerOwnedIpv4Pool) - d.Set("domain", eip.Domain) + d.Set(names.AttrDomain, eip.Domain) d.Set(names.AttrInstanceID, eip.InstanceId) d.Set(names.AttrNetworkInterfaceID, eip.NetworkInterfaceId) d.Set("network_interface_owner_id", eip.NetworkInterfaceOwnerId) diff --git a/internal/service/ec2/ec2_eip_data_source_test.go b/internal/service/ec2/ec2_eip_data_source_test.go index 0472d50db94..b35aa612a65 100644 --- a/internal/service/ec2/ec2_eip_data_source_test.go +++ b/internal/service/ec2/ec2_eip_data_source_test.go @@ -77,7 +77,7 @@ func TestAccEC2EIPDataSource_publicIP(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID), resource.TestCheckResourceAttrPair(dataSourceName, "public_dns", resourceName, "public_dns"), resource.TestCheckResourceAttrPair(dataSourceName, "public_ip", resourceName, "public_ip"), - resource.TestCheckResourceAttrPair(dataSourceName, "domain", resourceName, "domain"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDomain, resourceName, names.AttrDomain), ), }, }, @@ -125,7 +125,7 @@ func TestAccEC2EIPDataSource_networkInterface(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, "network_interface"), resource.TestCheckResourceAttrPair(dataSourceName, "private_dns", resourceName, "private_dns"), resource.TestCheckResourceAttrPair(dataSourceName, "private_ip", resourceName, "private_ip"), - resource.TestCheckResourceAttrPair(dataSourceName, "domain", resourceName, "domain"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDomain, resourceName, names.AttrDomain), ), }, }, diff --git a/internal/service/ec2/ec2_eip_test.go b/internal/service/ec2/ec2_eip_test.go index 63e79530f60..76656218d68 100644 --- a/internal/service/ec2/ec2_eip_test.go +++ b/internal/service/ec2/ec2_eip_test.go @@ -37,7 +37,7 @@ func TestAccEC2EIP_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckEIPExists(ctx, resourceName, &conf), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "domain", "vpc"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "vpc"), resource.TestCheckResourceAttr(resourceName, "ptr_record", ""), resource.TestCheckResourceAttrSet(resourceName, "public_ip"), testAccCheckEIPPublicDNS(ctx, resourceName), @@ -95,7 +95,7 @@ func TestAccEC2EIP_migrateVPCToDomain(t *testing.T) { Config: testAccEIPConfig_vpc, Check: resource.ComposeTestCheckFunc( testAccCheckEIPExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "domain", "vpc"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "vpc"), resource.TestCheckResourceAttrSet(resourceName, "public_ip"), testAccCheckEIPPublicDNS(ctx, resourceName), ), @@ -124,7 +124,7 @@ func TestAccEC2EIP_noVPC(t *testing.T) { Config: testAccEIPConfig_noVPC, Check: resource.ComposeTestCheckFunc( testAccCheckEIPExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "domain", "vpc"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "vpc"), resource.TestCheckResourceAttrSet(resourceName, "public_ip"), testAccCheckEIPPublicDNS(ctx, resourceName), ), diff --git a/internal/service/ec2/ec2_instance_connect_endpoint.go b/internal/service/ec2/ec2_instance_connect_endpoint.go index 8ea4e9e3226..06ac90e481e 100644 --- a/internal/service/ec2/ec2_instance_connect_endpoint.go +++ b/internal/service/ec2/ec2_instance_connect_endpoint.go @@ -68,7 +68,7 @@ func (r *instanceConnectEndpointResource) Schema(ctx context.Context, req resour stringplanmodifier.UseStateForUnknown(), }, }, - "dns_name": schema.StringAttribute{ + names.AttrDNSName: schema.StringAttribute{ Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), diff --git a/internal/service/ec2/ec2_instance_connect_endpoint_test.go b/internal/service/ec2/ec2_instance_connect_endpoint_test.go index 528161a4d4b..322e5b69ca1 100644 --- a/internal/service/ec2/ec2_instance_connect_endpoint_test.go +++ b/internal/service/ec2/ec2_instance_connect_endpoint_test.go @@ -38,7 +38,7 @@ func TestAccEC2InstanceConnectEndpoint_basic(t *testing.T) { testAccCheckInstanceConnectEndpointExists(ctx, resourceName), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "ec2", regexache.MustCompile(`instance-connect-endpoint/.+`)), resource.TestCheckResourceAttrSet(resourceName, names.AttrAvailabilityZone), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(resourceName, "fips_dns_name"), acctest.CheckResourceAttrGreaterThanOrEqualValue(resourceName, "network_interface_ids.#", 1), acctest.CheckResourceAttrAccountID(resourceName, names.AttrOwnerID), @@ -147,7 +147,7 @@ func TestAccEC2InstanceConnectEndpoint_securityGroupIDs(t *testing.T) { testAccCheckInstanceConnectEndpointExists(ctx, resourceName), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "ec2", regexache.MustCompile(`instance-connect-endpoint/.+`)), resource.TestCheckResourceAttrSet(resourceName, names.AttrAvailabilityZone), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(resourceName, "fips_dns_name"), acctest.CheckResourceAttrGreaterThanOrEqualValue(resourceName, "network_interface_ids.#", 1), resource.TestCheckResourceAttr(resourceName, "preserve_client_ip", "false"), diff --git a/internal/service/ec2/vpc_endpoint.go b/internal/service/ec2/vpc_endpoint.go index 9cc76fe5ca2..f84bbe5de91 100644 --- a/internal/service/ec2/vpc_endpoint.go +++ b/internal/service/ec2/vpc_endpoint.go @@ -67,7 +67,7 @@ func ResourceVPCEndpoint() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -538,7 +538,7 @@ func flattenDNSEntry(apiObject *ec2.DnsEntry) map[string]interface{} { tfMap := map[string]interface{}{} if v := apiObject.DnsName; v != nil { - tfMap["dns_name"] = aws.StringValue(v) + tfMap[names.AttrDNSName] = aws.StringValue(v) } if v := apiObject.HostedZoneId; v != nil { diff --git a/internal/service/ec2/vpc_endpoint_data_source.go b/internal/service/ec2/vpc_endpoint_data_source.go index 0c44bbab2a9..7d67ea08ade 100644 --- a/internal/service/ec2/vpc_endpoint_data_source.go +++ b/internal/service/ec2/vpc_endpoint_data_source.go @@ -45,7 +45,7 @@ func DataSourceVPCEndpoint() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/ec2/vpnclient_endpoint.go b/internal/service/ec2/vpnclient_endpoint.go index e3f46efca90..2d289d8cd88 100644 --- a/internal/service/ec2/vpnclient_endpoint.go +++ b/internal/service/ec2/vpnclient_endpoint.go @@ -158,7 +158,7 @@ func ResourceClientVPNEndpoint() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -343,7 +343,7 @@ func resourceClientVPNEndpointRead(ctx context.Context, d *schema.ResourceData, d.Set("connection_log_options", nil) } d.Set(names.AttrDescription, ep.Description) - d.Set("dns_name", ep.DnsName) + d.Set(names.AttrDNSName, ep.DnsName) d.Set("dns_servers", aws.StringValueSlice(ep.DnsServers)) d.Set(names.AttrSecurityGroupIDs, aws.StringValueSlice(ep.SecurityGroupIds)) if aws.StringValue(ep.SelfServicePortalUrl) != "" { diff --git a/internal/service/ec2/vpnclient_endpoint_data_source.go b/internal/service/ec2/vpnclient_endpoint_data_source.go index 3aadbeb4f65..c9b561aa5fb 100644 --- a/internal/service/ec2/vpnclient_endpoint_data_source.go +++ b/internal/service/ec2/vpnclient_endpoint_data_source.go @@ -127,7 +127,7 @@ func DataSourceClientVPNEndpoint() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -244,7 +244,7 @@ func dataSourceClientVPNEndpointRead(ctx context.Context, d *schema.ResourceData d.Set("connection_log_options", nil) } d.Set(names.AttrDescription, ep.Description) - d.Set("dns_name", ep.DnsName) + d.Set(names.AttrDNSName, ep.DnsName) d.Set("dns_servers", aws.StringValueSlice(ep.DnsServers)) d.Set(names.AttrSecurityGroupIDs, aws.StringValueSlice(ep.SecurityGroupIds)) if aws.StringValue(ep.SelfServicePortalUrl) != "" { diff --git a/internal/service/ec2/vpnclient_endpoint_data_source_test.go b/internal/service/ec2/vpnclient_endpoint_data_source_test.go index ced261857ca..0b3cfec51d3 100644 --- a/internal/service/ec2/vpnclient_endpoint_data_source_test.go +++ b/internal/service/ec2/vpnclient_endpoint_data_source_test.go @@ -41,7 +41,7 @@ func testAccClientVPNEndpointDataSource_basic(t *testing.T, semaphore tfsync.Sem resource.TestCheckResourceAttrPair(datasource1Name, "client_vpn_endpoint_id", resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasource1Name, "connection_log_options.#", resourceName, "connection_log_options.#"), resource.TestCheckResourceAttrPair(datasource1Name, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasource1Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(datasource1Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(datasource1Name, "dns_servers.#", resourceName, "dns_servers.#"), resource.TestCheckResourceAttrPair(datasource1Name, "security_group_ids.#", resourceName, "security_group_ids.#"), resource.TestCheckResourceAttrPair(datasource1Name, "self_service_portal", resourceName, "self_service_portal"), @@ -62,7 +62,7 @@ func testAccClientVPNEndpointDataSource_basic(t *testing.T, semaphore tfsync.Sem resource.TestCheckResourceAttrPair(datasource2Name, "client_vpn_endpoint_id", resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasource2Name, "connection_log_options.#", resourceName, "connection_log_options.#"), resource.TestCheckResourceAttrPair(datasource2Name, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasource2Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(datasource2Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(datasource2Name, "dns_servers.#", resourceName, "dns_servers.#"), resource.TestCheckResourceAttrPair(datasource2Name, "security_group_ids.#", resourceName, "security_group_ids.#"), resource.TestCheckResourceAttrPair(datasource2Name, "self_service_portal_url", resourceName, "self_service_portal_url"), @@ -83,7 +83,7 @@ func testAccClientVPNEndpointDataSource_basic(t *testing.T, semaphore tfsync.Sem resource.TestCheckResourceAttrPair(datasource3Name, "client_vpn_endpoint_id", resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasource3Name, "connection_log_options.#", resourceName, "connection_log_options.#"), resource.TestCheckResourceAttrPair(datasource3Name, names.AttrDescription, resourceName, names.AttrDescription), - resource.TestCheckResourceAttrPair(datasource3Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(datasource3Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(datasource3Name, "dns_servers.#", resourceName, "dns_servers.#"), resource.TestCheckResourceAttrPair(datasource3Name, "security_group_ids.#", resourceName, "security_group_ids.#"), resource.TestCheckResourceAttrPair(datasource2Name, "self_service_portal_url", resourceName, "self_service_portal_url"), diff --git a/internal/service/ec2/vpnclient_endpoint_test.go b/internal/service/ec2/vpnclient_endpoint_test.go index 397fa646794..735073756c3 100644 --- a/internal/service/ec2/vpnclient_endpoint_test.go +++ b/internal/service/ec2/vpnclient_endpoint_test.go @@ -56,7 +56,7 @@ func testAccClientVPNEndpoint_basic(t *testing.T, semaphore tfsync.Semaphore) { resource.TestCheckResourceAttr(resourceName, "connection_log_options.0.cloudwatch_log_stream", ""), resource.TestCheckResourceAttr(resourceName, "connection_log_options.0.enabled", "false"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "dns_servers.#", "0"), resource.TestCheckResourceAttr(resourceName, "security_group_ids.#", "0"), resource.TestCheckResourceAttr(resourceName, "self_service_portal", "disabled"), diff --git a/internal/service/ec2/vpnclient_test.go b/internal/service/ec2/vpnclient_test.go index fe23ce6ceaa..5773b59a047 100644 --- a/internal/service/ec2/vpnclient_test.go +++ b/internal/service/ec2/vpnclient_test.go @@ -42,7 +42,7 @@ func TestAccClientVPNEndpoint_serial(t *testing.T) { "AuthorizationRule": { "basic": testAccClientVPNAuthorizationRule_basic, "groups": testAccClientVPNAuthorizationRule_groups, - "subnets": testAccClientVPNAuthorizationRule_subnets, + names.AttrSubnets: testAccClientVPNAuthorizationRule_subnets, "disappears": testAccClientVPNAuthorizationRule_disappears, "disappearsEndpoint": testAccClientVPNAuthorizationRule_Disappears_endpoint, }, From 68754202d40e9ec9f9a3630ed45f5144056bd424 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:57 -0400 Subject: [PATCH 30/78] ecs: Use constants for strings --- internal/service/ecs/cluster_capacity_providers.go | 3 ++- .../service/ecs/cluster_capacity_providers_test.go | 12 ++++++------ internal/service/ecs/flex.go | 4 ++-- internal/service/ecs/service.go | 12 ++++++------ internal/service/ecs/task_definition.go | 8 ++++---- internal/service/ecs/task_execution_data_source.go | 4 ++-- internal/service/ecs/task_set.go | 4 ++-- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/internal/service/ecs/cluster_capacity_providers.go b/internal/service/ecs/cluster_capacity_providers.go index de20cabdb99..9277f57b959 100644 --- a/internal/service/ecs/cluster_capacity_providers.go +++ b/internal/service/ecs/cluster_capacity_providers.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/flex" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_ecs_cluster_capacity_providers") @@ -63,7 +64,7 @@ func ResourceClusterCapacityProviders() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Default: 0, Optional: true, diff --git a/internal/service/ecs/cluster_capacity_providers_test.go b/internal/service/ecs/cluster_capacity_providers_test.go index 4aa10a2206d..f79bbfb8592 100644 --- a/internal/service/ecs/cluster_capacity_providers_test.go +++ b/internal/service/ecs/cluster_capacity_providers_test.go @@ -39,7 +39,7 @@ func TestAccECSClusterCapacityProviders_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_capacity_provider_strategy.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "1", - "weight": "100", + names.AttrWeight: "100", "capacity_provider": "FARGATE", }), ), @@ -231,7 +231,7 @@ func TestAccECSClusterCapacityProviders_Update_defaultStrategy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_capacity_provider_strategy.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "1", - "weight": "100", + names.AttrWeight: "100", "capacity_provider": "FARGATE", }), ), @@ -248,12 +248,12 @@ func TestAccECSClusterCapacityProviders_Update_defaultStrategy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_capacity_provider_strategy.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "1", - "weight": "50", + names.AttrWeight: "50", "capacity_provider": "FARGATE", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "", - "weight": "50", + names.AttrWeight: "50", "capacity_provider": "FARGATE_SPOT", }), ), @@ -270,12 +270,12 @@ func TestAccECSClusterCapacityProviders_Update_defaultStrategy(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_capacity_provider_strategy.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "2", - "weight": "25", + names.AttrWeight: "25", "capacity_provider": "FARGATE", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "default_capacity_provider_strategy.*", map[string]string{ "base": "", - "weight": "75", + names.AttrWeight: "75", "capacity_provider": "FARGATE_SPOT", }), ), diff --git a/internal/service/ecs/flex.go b/internal/service/ecs/flex.go index 5ea3d0b34ea..5ff5aa811f2 100644 --- a/internal/service/ecs/flex.go +++ b/internal/service/ecs/flex.go @@ -19,7 +19,7 @@ func expandCapacityProviderStrategy(cps *schema.Set) []*ecs.CapacityProviderStra if val, ok := cp["base"]; ok { ps.Base = aws.Int64(int64(val.(int))) } - if val, ok := cp["weight"]; ok { + if val, ok := cp[names.AttrWeight]; ok { ps.Weight = aws.Int64(int64(val.(int))) } if val, ok := cp["capacity_provider"]; ok { @@ -40,7 +40,7 @@ func flattenCapacityProviderStrategy(cps []*ecs.CapacityProviderStrategyItem) [] s := make(map[string]interface{}) s["capacity_provider"] = aws.StringValue(cp.CapacityProvider) if cp.Weight != nil { - s["weight"] = aws.Int64Value(cp.Weight) + s[names.AttrWeight] = aws.Int64Value(cp.Weight) } if cp.Base != nil { s["base"] = aws.Int64Value(cp.Base) diff --git a/internal/service/ecs/service.go b/internal/service/ecs/service.go index ad323fabed8..0df5e98a33c 100644 --- a/internal/service/ecs/service.go +++ b/internal/service/ecs/service.go @@ -93,7 +93,7 @@ func ResourceService() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 1000), @@ -251,7 +251,7 @@ func ResourceService() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -389,7 +389,7 @@ func ResourceService() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Optional: true, }, @@ -1250,7 +1250,7 @@ func flattenNetworkConfiguration(nc *ecs.NetworkConfiguration) []interface{} { result := make(map[string]interface{}) result[names.AttrSecurityGroups] = flex.FlattenStringSet(nc.AwsvpcConfiguration.SecurityGroups) - result["subnets"] = flex.FlattenStringSet(nc.AwsvpcConfiguration.Subnets) + result[names.AttrSubnets] = flex.FlattenStringSet(nc.AwsvpcConfiguration.Subnets) if nc.AwsvpcConfiguration.AssignPublicIp != nil { result["assign_public_ip"] = aws.StringValue(nc.AwsvpcConfiguration.AssignPublicIp) == ecs.AssignPublicIpEnabled @@ -1268,7 +1268,7 @@ func expandNetworkConfiguration(nc []interface{}) *ecs.NetworkConfiguration { if val, ok := raw[names.AttrSecurityGroups]; ok { awsVpcConfig.SecurityGroups = flex.ExpandStringSet(val.(*schema.Set)) } - awsVpcConfig.Subnets = flex.ExpandStringSet(raw["subnets"].(*schema.Set)) + awsVpcConfig.Subnets = flex.ExpandStringSet(raw[names.AttrSubnets].(*schema.Set)) if val, ok := raw["assign_public_ip"].(bool); ok { awsVpcConfig.AssignPublicIp = aws.String(ecs.AssignPublicIpDisabled) if val { @@ -1580,7 +1580,7 @@ func expandClientAliases(srv []interface{}) []*ecs.ServiceConnectClientAlias { if v, ok := raw[names.AttrPort].(int); ok { config.Port = aws.Int64(int64(v)) } - if v, ok := raw["dns_name"].(string); ok && v != "" { + if v, ok := raw[names.AttrDNSName].(string); ok && v != "" { config.DnsName = aws.String(v) } diff --git a/internal/service/ecs/task_definition.go b/internal/service/ecs/task_definition.go index 2ff407c855b..ff705d9a9b6 100644 --- a/internal/service/ecs/task_definition.go +++ b/internal/service/ecs/task_definition.go @@ -404,7 +404,7 @@ func ResourceTaskDefinition() *schema.Resource { Required: true, ValidateFunc: verify.ValidARN, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, ForceNew: true, Required: true, @@ -745,7 +745,7 @@ func resourceTaskDefinitionVolumeHash(v interface{}) int { if v, ok := m["credentials_parameter"]; ok && v.(string) != "" { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } - if v, ok := m["domain"]; ok && v.(string) != "" { + if v, ok := m[names.AttrDomain]; ok && v.(string) != "" { buf.WriteString(fmt.Sprintf("%s-", v.(string))) } } @@ -1038,7 +1038,7 @@ func expandVolumesFSxWinVolumeAuthorizationConfig(config []interface{}) *ecs.FSx auth.CredentialsParameter = aws.String(v) } - if v, ok := authconfig["domain"].(string); ok && v != "" { + if v, ok := authconfig[names.AttrDomain].(string); ok && v != "" { auth.Domain = aws.String(v) } @@ -1174,7 +1174,7 @@ func flattenFSxWinVolumeAuthorizationConfig(config *ecs.FSxWindowsFileServerAuth m["credentials_parameter"] = aws.StringValue(v) } if v := config.Domain; v != nil { - m["domain"] = aws.StringValue(v) + m[names.AttrDomain] = aws.StringValue(v) } } diff --git a/internal/service/ecs/task_execution_data_source.go b/internal/service/ecs/task_execution_data_source.go index 70a10ef9105..030364e4faf 100644 --- a/internal/service/ecs/task_execution_data_source.go +++ b/internal/service/ecs/task_execution_data_source.go @@ -40,7 +40,7 @@ func DataSourceTaskExecution() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 1000), @@ -90,7 +90,7 @@ func DataSourceTaskExecution() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, Set: schema.HashString, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, diff --git a/internal/service/ecs/task_set.go b/internal/service/ecs/task_set.go index c0845c61b57..82fad0abcb0 100644 --- a/internal/service/ecs/task_set.go +++ b/internal/service/ecs/task_set.go @@ -62,7 +62,7 @@ func ResourceTaskSet() *schema.Resource { Required: true, ForceNew: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, ForceNew: true, @@ -148,7 +148,7 @@ func ResourceTaskSet() *schema.Resource { ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, MaxItems: 16, Required: true, From 04cb636a98bea4f482ddd232b54e93aae0f077cc Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:58 -0400 Subject: [PATCH 31/78] efs: Use constants for strings --- internal/service/efs/file_system.go | 4 ++-- internal/service/efs/file_system_data_source.go | 4 ++-- internal/service/efs/file_system_data_source_test.go | 6 +++--- internal/service/efs/file_system_test.go | 2 +- internal/service/efs/mount_target.go | 4 ++-- internal/service/efs/mount_target_data_source.go | 4 ++-- internal/service/efs/mount_target_data_source_test.go | 6 +++--- internal/service/efs/mount_target_test.go | 6 +++--- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/service/efs/file_system.go b/internal/service/efs/file_system.go index f09853d9151..303c44f0a87 100644 --- a/internal/service/efs/file_system.go +++ b/internal/service/efs/file_system.go @@ -64,7 +64,7 @@ func ResourceFileSystem() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(0, 64), }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -283,7 +283,7 @@ func resourceFileSystemRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("availability_zone_id", fs.AvailabilityZoneId) d.Set("availability_zone_name", fs.AvailabilityZoneName) d.Set("creation_token", fs.CreationToken) - d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, d.Id()+".efs")) + d.Set(names.AttrDNSName, meta.(*conns.AWSClient).RegionalHostname(ctx, d.Id()+".efs")) d.Set(names.AttrEncrypted, fs.Encrypted) d.Set(names.AttrKMSKeyID, fs.KmsKeyId) d.Set(names.AttrName, fs.Name) diff --git a/internal/service/efs/file_system_data_source.go b/internal/service/efs/file_system_data_source.go index 2afa74a925f..26ab6c1677f 100644 --- a/internal/service/efs/file_system_data_source.go +++ b/internal/service/efs/file_system_data_source.go @@ -43,7 +43,7 @@ func DataSourceFileSystem() *schema.Resource { Computed: true, ValidateFunc: validation.StringLenBetween(0, 64), }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -152,7 +152,7 @@ func dataSourceFileSystemRead(ctx context.Context, d *schema.ResourceData, meta d.Set("availability_zone_id", fs.AvailabilityZoneId) d.Set("availability_zone_name", fs.AvailabilityZoneName) d.Set("creation_token", fs.CreationToken) - d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, d.Id()+".efs")) + d.Set(names.AttrDNSName, meta.(*conns.AWSClient).RegionalHostname(ctx, d.Id()+".efs")) d.Set(names.AttrFileSystemID, fsID) d.Set(names.AttrEncrypted, fs.Encrypted) d.Set(names.AttrKMSKeyID, fs.KmsKeyId) diff --git a/internal/service/efs/file_system_data_source_test.go b/internal/service/efs/file_system_data_source_test.go index ff3561297e5..15656aabebd 100644 --- a/internal/service/efs/file_system_data_source_test.go +++ b/internal/service/efs/file_system_data_source_test.go @@ -34,7 +34,7 @@ func TestAccEFSFileSystemDataSource_id(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrEncrypted, resourceName, names.AttrEncrypted), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrKMSKeyID, resourceName, names.AttrKMSKeyID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrTags, resourceName, names.AttrTags), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(dataSourceName, "provisioned_throughput_in_mibps", resourceName, "provisioned_throughput_in_mibps"), resource.TestCheckResourceAttrPair(dataSourceName, "throughput_mode", resourceName, "throughput_mode"), @@ -66,7 +66,7 @@ func TestAccEFSFileSystemDataSource_tags(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrEncrypted, resourceName, names.AttrEncrypted), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrKMSKeyID, resourceName, names.AttrKMSKeyID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrTags, resourceName, names.AttrTags), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(dataSourceName, "provisioned_throughput_in_mibps", resourceName, "provisioned_throughput_in_mibps"), resource.TestCheckResourceAttrPair(dataSourceName, "throughput_mode", resourceName, "throughput_mode"), @@ -98,7 +98,7 @@ func TestAccEFSFileSystemDataSource_name(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrEncrypted, resourceName, names.AttrEncrypted), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrKMSKeyID, resourceName, names.AttrKMSKeyID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrTags, resourceName, names.AttrTags), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, "provisioned_throughput_in_mibps", resourceName, "provisioned_throughput_in_mibps"), resource.TestCheckResourceAttrPair(dataSourceName, "throughput_mode", resourceName, "throughput_mode"), resource.TestCheckResourceAttrPair(dataSourceName, "lifecycle_policy", resourceName, "lifecycle_policy"), diff --git a/internal/service/efs/file_system_test.go b/internal/service/efs/file_system_test.go index 0a2d00cf67e..6ba235c9bb4 100644 --- a/internal/service/efs/file_system_test.go +++ b/internal/service/efs/file_system_test.go @@ -37,7 +37,7 @@ func TestAccEFSFileSystem_basic(t *testing.T) { testAccCheckFileSystem(ctx, resourceName, &desc), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "elasticfilesystem", regexache.MustCompile(`file-system/fs-.+`)), resource.TestCheckResourceAttrSet(resourceName, "creation_token"), - acctest.MatchResourceAttrRegionalHostname(resourceName, "dns_name", "efs", regexache.MustCompile(`fs-[^.]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, names.AttrDNSName, "efs", regexache.MustCompile(`fs-[^.]+`)), resource.TestCheckResourceAttr(resourceName, names.AttrEncrypted, "false"), resource.TestCheckResourceAttr(resourceName, "lifecycle_policy.#", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrName, ""), diff --git a/internal/service/efs/mount_target.go b/internal/service/efs/mount_target.go index 2dfdc3ac32b..05a4abf1218 100644 --- a/internal/service/efs/mount_target.go +++ b/internal/service/efs/mount_target.go @@ -52,7 +52,7 @@ func ResourceMountTarget() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -173,7 +173,7 @@ func resourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta i }.String() d.Set("availability_zone_id", mt.AvailabilityZoneId) d.Set("availability_zone_name", mt.AvailabilityZoneName) - d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) + d.Set(names.AttrDNSName, meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) d.Set("file_system_arn", fsARN) d.Set(names.AttrFileSystemID, fsID) d.Set(names.AttrIPAddress, mt.IpAddress) diff --git a/internal/service/efs/mount_target_data_source.go b/internal/service/efs/mount_target_data_source.go index e2c0b0224e4..683b881b5aa 100644 --- a/internal/service/efs/mount_target_data_source.go +++ b/internal/service/efs/mount_target_data_source.go @@ -35,7 +35,7 @@ func DataSourceMountTarget() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -117,7 +117,7 @@ func dataSourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta }.String() d.Set("availability_zone_id", mt.AvailabilityZoneId) d.Set("availability_zone_name", mt.AvailabilityZoneName) - d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) + d.Set(names.AttrDNSName, meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) d.Set("file_system_arn", fsARN) d.Set(names.AttrFileSystemID, fsID) d.Set(names.AttrIPAddress, mt.IpAddress) diff --git a/internal/service/efs/mount_target_data_source_test.go b/internal/service/efs/mount_target_data_source_test.go index 1f508ff360c..4654b80084c 100644 --- a/internal/service/efs/mount_target_data_source_test.go +++ b/internal/service/efs/mount_target_data_source_test.go @@ -32,7 +32,7 @@ func TestAccEFSMountTargetDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, "mount_target_dns_name", resourceName, "mount_target_dns_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_name", resourceName, "availability_zone_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_id", resourceName, "availability_zone_id"), @@ -63,7 +63,7 @@ func TestAccEFSMountTargetDataSource_byAccessPointID(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, "mount_target_dns_name", resourceName, "mount_target_dns_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_name", resourceName, "availability_zone_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_id", resourceName, "availability_zone_id"), @@ -94,7 +94,7 @@ func TestAccEFSMountTargetDataSource_byFileSystemID(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, "mount_target_dns_name", resourceName, "mount_target_dns_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_name", resourceName, "availability_zone_name"), resource.TestCheckResourceAttrPair(dataSourceName, "availability_zone_id", resourceName, "availability_zone_id"), diff --git a/internal/service/efs/mount_target_test.go b/internal/service/efs/mount_target_test.go index 560fa635134..64bb869f384 100644 --- a/internal/service/efs/mount_target_test.go +++ b/internal/service/efs/mount_target_test.go @@ -39,7 +39,7 @@ func TestAccEFSMountTarget_basic(t *testing.T) { testAccCheckMountTargetExists(ctx, resourceName, &mount), resource.TestCheckResourceAttrSet(resourceName, "availability_zone_id"), resource.TestCheckResourceAttrSet(resourceName, "availability_zone_name"), - acctest.MatchResourceAttrRegionalHostname(resourceName, "dns_name", "efs", regexache.MustCompile(`fs-[^.]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, names.AttrDNSName, "efs", regexache.MustCompile(`fs-[^.]+`)), acctest.MatchResourceAttrRegionalARN(resourceName, "file_system_arn", "elasticfilesystem", regexache.MustCompile(`file-system/fs-.+`)), resource.TestMatchResourceAttr(resourceName, names.AttrIPAddress, regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), resource.TestCheckResourceAttrSet(resourceName, "mount_target_dns_name"), @@ -57,8 +57,8 @@ func TestAccEFSMountTarget_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMountTargetExists(ctx, resourceName, &mount), testAccCheckMountTargetExists(ctx, resourceName2, &mount), - acctest.MatchResourceAttrRegionalHostname(resourceName, "dns_name", "efs", regexache.MustCompile(`fs-[^.]+`)), - acctest.MatchResourceAttrRegionalHostname(resourceName2, "dns_name", "efs", regexache.MustCompile(`fs-[^.]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName, names.AttrDNSName, "efs", regexache.MustCompile(`fs-[^.]+`)), + acctest.MatchResourceAttrRegionalHostname(resourceName2, names.AttrDNSName, "efs", regexache.MustCompile(`fs-[^.]+`)), ), }, }, From 3fb5722c599b90303ac8647b073e7f90cb5d0554 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:58 -0400 Subject: [PATCH 32/78] elasticsearch: Use constants for strings --- internal/service/elasticsearch/domain.go | 2 +- internal/service/elasticsearch/domain_data_source.go | 2 +- internal/service/elasticsearch/domain_structure.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/elasticsearch/domain.go b/internal/service/elasticsearch/domain.go index 5bde0cd631e..e070a157b51 100644 --- a/internal/service/elasticsearch/domain.go +++ b/internal/service/elasticsearch/domain.go @@ -180,7 +180,7 @@ func ResourceDomain() *schema.Resource { Type: schema.TypeString, Required: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeList, Required: true, MaxItems: 1, diff --git a/internal/service/elasticsearch/domain_data_source.go b/internal/service/elasticsearch/domain_data_source.go index c5459d3470a..189ac58802d 100644 --- a/internal/service/elasticsearch/domain_data_source.go +++ b/internal/service/elasticsearch/domain_data_source.go @@ -71,7 +71,7 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ diff --git a/internal/service/elasticsearch/domain_structure.go b/internal/service/elasticsearch/domain_structure.go index a29026149e7..bfa99e8f12e 100644 --- a/internal/service/elasticsearch/domain_structure.go +++ b/internal/service/elasticsearch/domain_structure.go @@ -96,7 +96,7 @@ func expandAutoTuneMaintenanceSchedules(tfList []interface{}) []*elasticsearch.A startAt, _ := time.Parse(time.RFC3339, tfMap["start_at"].(string)) autoTuneMaintenanceSchedule.StartAt = aws.Time(startAt) - if v, ok := tfMap["duration"].([]interface{}); ok { + if v, ok := tfMap[names.AttrDuration].([]interface{}); ok { autoTuneMaintenanceSchedule.Duration = expandAutoTuneMaintenanceScheduleDuration(v[0].(map[string]interface{})) } @@ -216,7 +216,7 @@ func flattenAutoTuneMaintenanceSchedules(autoTuneMaintenanceSchedules []*elastic m["start_at"] = aws.TimeValue(autoTuneMaintenanceSchedule.StartAt).Format(time.RFC3339) - m["duration"] = []interface{}{flattenAutoTuneMaintenanceScheduleDuration(autoTuneMaintenanceSchedule.Duration)} + m[names.AttrDuration] = []interface{}{flattenAutoTuneMaintenanceScheduleDuration(autoTuneMaintenanceSchedule.Duration)} m["cron_expression_for_recurrence"] = aws.StringValue(autoTuneMaintenanceSchedule.CronExpressionForRecurrence) From 1b1f1c7c8d16321eebfdcf19e78db36487fd877b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:58 -0400 Subject: [PATCH 33/78] elb: Use constants for strings --- internal/service/elb/load_balancer.go | 16 ++++++++-------- .../service/elb/load_balancer_data_source.go | 8 ++++---- .../elb/load_balancer_data_source_test.go | 2 +- internal/service/elb/load_balancer_test.go | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/service/elb/load_balancer.go b/internal/service/elb/load_balancer.go index 16e783c0ec5..bfeac5d1ba2 100644 --- a/internal/service/elb/load_balancer.go +++ b/internal/service/elb/load_balancer.go @@ -49,7 +49,7 @@ func ResourceLoadBalancer() *schema.Resource { }, CustomizeDiff: customdiff.All( - customdiff.ForceNewIfChange("subnets", func(_ context.Context, o, n, meta interface{}) bool { + customdiff.ForceNewIfChange(names.AttrSubnets, func(_ context.Context, o, n, meta interface{}) bool { // Force new if removing all current subnets. os := o.(*schema.Set) ns := n.(*schema.Set) @@ -130,7 +130,7 @@ func ResourceLoadBalancer() *schema.Resource { "strictest", }, false), }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -252,7 +252,7 @@ func ResourceLoadBalancer() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Optional: true, Computed: true, @@ -300,7 +300,7 @@ func resourceLoadBalancerCreate(ctx context.Context, d *schema.ResourceData, met input.SecurityGroups = flex.ExpandStringSet(v.(*schema.Set)) } - if v, ok := d.GetOk("subnets"); ok && v.(*schema.Set).Len() > 0 { + if v, ok := d.GetOk(names.AttrSubnets); ok && v.(*schema.Set).Len() > 0 { input.Subnets = flex.ExpandStringSet(v.(*schema.Set)) } @@ -351,7 +351,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta d.Set("connection_draining", lbAttrs.ConnectionDraining.Enabled) d.Set("connection_draining_timeout", lbAttrs.ConnectionDraining.Timeout) d.Set("cross_zone_load_balancing", lbAttrs.CrossZoneLoadBalancing.Enabled) - d.Set("dns_name", lb.DNSName) + d.Set(names.AttrDNSName, lb.DNSName) if lbAttrs.ConnectionSettings != nil { d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) } @@ -365,7 +365,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrName, lb.LoadBalancerName) d.Set(names.AttrNamePrefix, create.NamePrefixFromName(aws.StringValue(lb.LoadBalancerName))) d.Set(names.AttrSecurityGroups, flex.FlattenStringList(lb.SecurityGroups)) - d.Set("subnets", flex.FlattenStringList(lb.Subnets)) + d.Set(names.AttrSubnets, flex.FlattenStringList(lb.Subnets)) d.Set("zone_id", lb.CanonicalHostedZoneNameID) if lb.SourceSecurityGroup != nil { @@ -683,8 +683,8 @@ func resourceLoadBalancerUpdate(ctx context.Context, d *schema.ResourceData, met } } - if d.HasChange("subnets") { - o, n := d.GetChange("subnets") + if d.HasChange(names.AttrSubnets) { + o, n := d.GetChange(names.AttrSubnets) os := o.(*schema.Set) ns := n.(*schema.Set) diff --git a/internal/service/elb/load_balancer_data_source.go b/internal/service/elb/load_balancer_data_source.go index 42d6b87af71..30aeb4c86de 100644 --- a/internal/service/elb/load_balancer_data_source.go +++ b/internal/service/elb/load_balancer_data_source.go @@ -81,7 +81,7 @@ func DataSourceLoadBalancer() *schema.Resource { Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -185,7 +185,7 @@ func DataSourceLoadBalancer() *schema.Resource { Computed: true, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Computed: true, @@ -242,7 +242,7 @@ func dataSourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, met } d.Set(names.AttrARN, arn.String()) d.Set(names.AttrName, lb.LoadBalancerName) - d.Set("dns_name", lb.DNSName) + d.Set(names.AttrDNSName, lb.DNSName) d.Set("zone_id", lb.CanonicalHostedZoneNameID) var scheme bool @@ -273,7 +273,7 @@ func dataSourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, met } } } - d.Set("subnets", flex.FlattenStringList(lb.Subnets)) + d.Set(names.AttrSubnets, flex.FlattenStringList(lb.Subnets)) if lbAttrs.ConnectionSettings != nil { d.Set("idle_timeout", lbAttrs.ConnectionSettings.IdleTimeout) } diff --git a/internal/service/elb/load_balancer_data_source_test.go b/internal/service/elb/load_balancer_data_source_test.go index e5e7c7985d3..8260db8c357 100644 --- a/internal/service/elb/load_balancer_data_source_test.go +++ b/internal/service/elb/load_balancer_data_source_test.go @@ -37,7 +37,7 @@ func TestAccELBLoadBalancerDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "tags.%", "2"), resource.TestCheckResourceAttr(dataSourceName, "tags.Name", rName), resource.TestCheckResourceAttr(dataSourceName, "tags.TestName", t.Name()), - resource.TestCheckResourceAttrSet(dataSourceName, "dns_name"), + resource.TestCheckResourceAttrSet(dataSourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(dataSourceName, "zone_id"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, "aws_elb.test", names.AttrARN), ), diff --git a/internal/service/elb/load_balancer_test.go b/internal/service/elb/load_balancer_test.go index 70516bbd73a..cb0e7a51d3c 100644 --- a/internal/service/elb/load_balancer_test.go +++ b/internal/service/elb/load_balancer_test.go @@ -264,7 +264,7 @@ func TestAccELBLoadBalancer_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "connection_draining_timeout", "300"), resource.TestCheckResourceAttr(resourceName, "cross_zone_load_balancing", "true"), resource.TestCheckResourceAttr(resourceName, "desync_mitigation_mode", "defensive"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "health_check.#", "1"), resource.TestCheckResourceAttr(resourceName, "idle_timeout", "60"), resource.TestCheckResourceAttr(resourceName, "instances.#", "0"), From 71ef9fa0db76a10403f88ed330a24efbbf821a15 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:59 -0400 Subject: [PATCH 34/78] elbv2: Use constants for strings --- internal/service/elbv2/listener.go | 16 ++++----- .../service/elbv2/listener_data_source.go | 4 +-- internal/service/elbv2/listener_rule.go | 4 +-- internal/service/elbv2/listener_rule_test.go | 2 +- internal/service/elbv2/load_balancer.go | 34 +++++++++---------- .../elbv2/load_balancer_data_source.go | 8 ++--- .../elbv2/load_balancer_data_source_test.go | 14 ++++---- internal/service/elbv2/load_balancer_test.go | 12 +++---- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index 14d17be5ad5..c24539c9392 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -235,7 +235,7 @@ func ResourceListener() *schema.Resource { Required: true, ValidateFunc: verify.ValidARN, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, ValidateFunc: validation.IntBetween(0, 999), Default: 1, @@ -251,7 +251,7 @@ func ResourceListener() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(1, 604800), @@ -930,7 +930,7 @@ func expandLbListenerActionForwardConfigTargetGroups(l []interface{}) []awstypes group := awstypes.TargetGroupTuple{ TargetGroupArn: aws.String(tfMap[names.AttrARN].(string)), - Weight: aws.Int32(int32(tfMap["weight"].(int))), + Weight: aws.Int32(int32(tfMap[names.AttrWeight].(int))), } groups = append(groups, group) @@ -951,7 +951,7 @@ func expandLbListenerActionForwardConfigTargetGroupStickinessConfig(l []interfac // The Plugin SDK stores a `nil` returned by the API as a `0` in the state. This is a invalid value. var duration *int32 - if v := tfMap["duration"].(int); v > 0 { + if v := tfMap[names.AttrDuration].(int); v > 0 { duration = aws.Int32(int32(v)) } @@ -1148,8 +1148,8 @@ func flattenLbListenerActionForwardConfigTargetGroups(groups []awstypes.TargetGr for _, group := range groups { m := map[string]interface{}{ - names.AttrARN: aws.ToString(group.TargetGroupArn), - "weight": aws.ToInt32(group.Weight), + names.AttrARN: aws.ToString(group.TargetGroupArn), + names.AttrWeight: aws.ToInt32(group.Weight), } vGroups = append(vGroups, m) @@ -1164,8 +1164,8 @@ func flattenLbListenerActionForwardConfigTargetGroupStickinessConfig(config *aws } m := map[string]interface{}{ - names.AttrEnabled: aws.ToBool(config.Enabled), - "duration": aws.ToInt32(config.DurationSeconds), + names.AttrEnabled: aws.ToBool(config.Enabled), + names.AttrDuration: aws.ToInt32(config.DurationSeconds), } return []interface{}{m} diff --git a/internal/service/elbv2/listener_data_source.go b/internal/service/elbv2/listener_data_source.go index d23e993c358..39602196a3b 100644 --- a/internal/service/elbv2/listener_data_source.go +++ b/internal/service/elbv2/listener_data_source.go @@ -178,7 +178,7 @@ func DataSourceListener() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Computed: true, }, @@ -198,7 +198,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Computed: true, }, diff --git a/internal/service/elbv2/listener_rule.go b/internal/service/elbv2/listener_rule.go index 5f294c46afa..84c75e6ad23 100644 --- a/internal/service/elbv2/listener_rule.go +++ b/internal/service/elbv2/listener_rule.go @@ -120,7 +120,7 @@ func ResourceListenerRule() *schema.Resource { Required: true, ValidateFunc: verify.ValidARN, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, ValidateFunc: validation.IntBetween(0, 999), Default: 1, @@ -141,7 +141,7 @@ func ResourceListenerRule() *schema.Resource { Optional: true, Default: false, }, - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Required: true, ValidateFunc: validation.IntBetween(1, 604800), diff --git a/internal/service/elbv2/listener_rule_test.go b/internal/service/elbv2/listener_rule_test.go index 627262d3833..db0cdc36a16 100644 --- a/internal/service/elbv2/listener_rule_test.go +++ b/internal/service/elbv2/listener_rule_test.go @@ -1276,7 +1276,7 @@ func TestAccELBV2ListenerRule_cognito(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action.0.type", "authenticate-cognito"), resource.TestCheckResourceAttrPair(resourceName, "action.0.authenticate_cognito.0.user_pool_arn", cognitoPoolResourceName, names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "action.0.authenticate_cognito.0.user_pool_client_id", cognitoPoolClientResourceName, names.AttrID), - resource.TestCheckResourceAttrPair(resourceName, "action.0.authenticate_cognito.0.user_pool_domain", cognitoPoolDomainResourceName, "domain"), + resource.TestCheckResourceAttrPair(resourceName, "action.0.authenticate_cognito.0.user_pool_domain", cognitoPoolDomainResourceName, names.AttrDomain), resource.TestCheckResourceAttr(resourceName, "action.0.authenticate_cognito.0.authentication_request_extra_params.%", "1"), resource.TestCheckResourceAttr(resourceName, "action.0.authenticate_cognito.0.authentication_request_extra_params.param", "test"), resource.TestCheckResourceAttr(resourceName, "action.1.order", "2"), diff --git a/internal/service/elbv2/load_balancer.go b/internal/service/elbv2/load_balancer.go index 60a1fb481a6..0ae7b3eb556 100644 --- a/internal/service/elbv2/load_balancer.go +++ b/internal/service/elbv2/load_balancer.go @@ -148,7 +148,7 @@ func ResourceLoadBalancer() *schema.Resource { ValidateFunc: validation.StringInSlice(httpDesyncMitigationMode_Values(), false), DiffSuppressFunc: suppressIfLBTypeNot(elbv2.LoadBalancerTypeEnumApplication), }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -290,14 +290,14 @@ func ResourceLoadBalancer() *schema.Resource { }, }, }, - ExactlyOneOf: []string{"subnet_mapping", "subnets"}, + ExactlyOneOf: []string{"subnet_mapping", names.AttrSubnets}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Optional: true, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, - ExactlyOneOf: []string{"subnet_mapping", "subnets"}, + ExactlyOneOf: []string{"subnet_mapping", names.AttrSubnets}, }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -382,7 +382,7 @@ func resourceLoadBalancerCreate(ctx context.Context, d *schema.ResourceData, met input.SubnetMappings = expandSubnetMappings(v.(*schema.Set).List()) } - if v, ok := d.GetOk("subnets"); ok { + if v, ok := d.GetOk(names.AttrSubnets); ok { input.Subnets = flex.ExpandStringSet(v.(*schema.Set)) } @@ -501,7 +501,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, lb.LoadBalancerArn) d.Set("arn_suffix", SuffixFromARN(lb.LoadBalancerArn)) d.Set("customer_owned_ipv4_pool", lb.CustomerOwnedIpv4Pool) - d.Set("dns_name", lb.DNSName) + d.Set(names.AttrDNSName, lb.DNSName) d.Set("enforce_security_group_inbound_rules_on_private_link_traffic", lb.EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic) d.Set("internal", aws.StringValue(lb.Scheme) == elbv2.LoadBalancerSchemeEnumInternal) d.Set("ip_address_type", lb.IpAddressType) @@ -513,7 +513,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta if err := d.Set("subnet_mapping", flattenSubnetMappingsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { return sdkdiag.AppendErrorf(diags, "setting subnet_mapping: %s", err) } - if err := d.Set("subnets", flattenSubnetsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { + if err := d.Set(names.AttrSubnets, flattenSubnetsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { return sdkdiag.AppendErrorf(diags, "setting subnets: %s", err) } d.Set(names.AttrVPCID, lb.VpcId) @@ -595,7 +595,7 @@ func resourceLoadBalancerUpdate(ctx context.Context, d *schema.ResourceData, met } } - if d.HasChanges("subnet_mapping", "subnets") { + if d.HasChanges("subnet_mapping", names.AttrSubnets) { input := &elbv2.SetSubnetsInput{ LoadBalancerArn: aws.String(d.Id()), } @@ -606,8 +606,8 @@ func resourceLoadBalancerUpdate(ctx context.Context, d *schema.ResourceData, met } } - if d.HasChange("subnets") { - if v, ok := d.GetOk("subnets"); ok { + if d.HasChange(names.AttrSubnets) { + if v, ok := d.GetOk(names.AttrSubnets); ok { input.Subnets = flex.ExpandStringSet(v.(*schema.Set)) } } @@ -1102,7 +1102,7 @@ func customizeDiffLoadBalancerNLB(_ context.Context, diff *schema.ResourceDiff, // Subnet diffs. // Check for changes here -- SetNewComputed will modify HasChange. - hasSubnetMappingChanges, hasSubnetsChanges := diff.HasChange("subnet_mapping"), diff.HasChange("subnets") + hasSubnetMappingChanges, hasSubnetsChanges := diff.HasChange("subnet_mapping"), diff.HasChange(names.AttrSubnets) if hasSubnetMappingChanges { if v := config.GetAttr("subnet_mapping"); v.IsWhollyKnown() { o, n := diff.GetChange("subnet_mapping") @@ -1128,18 +1128,18 @@ func customizeDiffLoadBalancerNLB(_ context.Context, diff *schema.ResourceDiff, } } - if err := diff.SetNewComputed("subnets"); err != nil { + if err := diff.SetNewComputed(names.AttrSubnets); err != nil { return err } } if hasSubnetsChanges { - if v := config.GetAttr("subnets"); v.IsWhollyKnown() { - o, n := diff.GetChange("subnets") + if v := config.GetAttr(names.AttrSubnets); v.IsWhollyKnown() { + o, n := diff.GetChange(names.AttrSubnets) os, ns := o.(*schema.Set), n.(*schema.Set) // In-place increase in number of subnets only. if deltaN := ns.Len() - os.Len(); deltaN <= 0 { - if err := diff.ForceNew("subnets"); err != nil { + if err := diff.ForceNew(names.AttrSubnets); err != nil { return err } } @@ -1180,7 +1180,7 @@ func customizeDiffLoadBalancerALB(_ context.Context, diff *schema.ResourceDiff, // Subnet diffs. // Check for changes here -- SetNewComputed will modify HasChange. - hasSubnetMappingChanges, hasSubnetsChanges := diff.HasChange("subnet_mapping"), diff.HasChange("subnets") + hasSubnetMappingChanges, hasSubnetsChanges := diff.HasChange("subnet_mapping"), diff.HasChange(names.AttrSubnets) if hasSubnetMappingChanges { if v := config.GetAttr("subnet_mapping"); v.IsWhollyKnown() { o, n := diff.GetChange("subnet_mapping") @@ -1210,7 +1210,7 @@ func customizeDiffLoadBalancerALB(_ context.Context, diff *schema.ResourceDiff, } } - if err := diff.SetNewComputed("subnets"); err != nil { + if err := diff.SetNewComputed(names.AttrSubnets); err != nil { return err } } diff --git a/internal/service/elbv2/load_balancer_data_source.go b/internal/service/elbv2/load_balancer_data_source.go index 437d32ce0e7..fb634d8f30f 100644 --- a/internal/service/elbv2/load_balancer_data_source.go +++ b/internal/service/elbv2/load_balancer_data_source.go @@ -94,7 +94,7 @@ func DataSourceLoadBalancer() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -192,7 +192,7 @@ func DataSourceLoadBalancer() *schema.Resource { }, }, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Elem: &schema.Schema{Type: schema.TypeString}, Computed: true, @@ -269,7 +269,7 @@ func dataSourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, met d.Set(names.AttrARN, lb.LoadBalancerArn) d.Set("arn_suffix", SuffixFromARN(lb.LoadBalancerArn)) d.Set("customer_owned_ipv4_pool", lb.CustomerOwnedIpv4Pool) - d.Set("dns_name", lb.DNSName) + d.Set(names.AttrDNSName, lb.DNSName) d.Set("enforce_security_group_inbound_rules_on_private_link_traffic", lb.EnforceSecurityGroupInboundRulesOnPrivateLinkTraffic) d.Set("ip_address_type", lb.IpAddressType) d.Set(names.AttrName, lb.LoadBalancerName) @@ -279,7 +279,7 @@ func dataSourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, met if err := d.Set("subnet_mapping", flattenSubnetMappingsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { return sdkdiag.AppendErrorf(diags, "setting subnet_mapping: %s", err) } - if err := d.Set("subnets", flattenSubnetsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { + if err := d.Set(names.AttrSubnets, flattenSubnetsFromAvailabilityZones(lb.AvailabilityZones)); err != nil { return sdkdiag.AppendErrorf(diags, "setting subnets: %s", err) } d.Set(names.AttrVPCID, lb.VpcId) diff --git a/internal/service/elbv2/load_balancer_data_source_test.go b/internal/service/elbv2/load_balancer_data_source_test.go index d4e202fe669..102ae703af1 100644 --- a/internal/service/elbv2/load_balancer_data_source_test.go +++ b/internal/service/elbv2/load_balancer_data_source_test.go @@ -40,7 +40,7 @@ func TestAccELBV2LoadBalancerDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -57,7 +57,7 @@ func TestAccELBV2LoadBalancerDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName2, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName2, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName2, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName2, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName2, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -74,7 +74,7 @@ func TestAccELBV2LoadBalancerDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName3, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName3, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName3, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName3, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName3, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -114,7 +114,7 @@ func TestAccELBV2LoadBalancerDataSource_outpost(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -152,7 +152,7 @@ func TestAccELBV2LoadBalancerDataSource_backwardsCompatibility(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName1, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName1, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName1, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName1, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName1, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName1, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName1, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName1, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -173,7 +173,7 @@ func TestAccELBV2LoadBalancerDataSource_backwardsCompatibility(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName2, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName2, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName2, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName2, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName2, "subnet_mapping.#", resourceName, "subnet_mapping.#"), @@ -194,7 +194,7 @@ func TestAccELBV2LoadBalancerDataSource_backwardsCompatibility(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName3, "idle_timeout", resourceName, "idle_timeout"), resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrVPCID, resourceName, names.AttrVPCID), resource.TestCheckResourceAttrPair(dataSourceName3, "zone_id", resourceName, "zone_id"), - resource.TestCheckResourceAttrPair(dataSourceName3, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName3, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(dataSourceName3, "ip_address_type", resourceName, "ip_address_type"), resource.TestCheckResourceAttrPair(dataSourceName3, "subnet_mapping.#", resourceName, "subnet_mapping.#"), diff --git a/internal/service/elbv2/load_balancer_test.go b/internal/service/elbv2/load_balancer_test.go index 3400d64ba00..3e984353df0 100644 --- a/internal/service/elbv2/load_balancer_test.go +++ b/internal/service/elbv2/load_balancer_test.go @@ -90,7 +90,7 @@ func TestAccELBV2LoadBalancer_ALB_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "connection_logs.#", "1"), resource.TestCheckResourceAttr(resourceName, "connection_logs.0.enabled", "false"), resource.TestCheckResourceAttr(resourceName, "desync_mitigation_mode", "defensive"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"), resource.TestCheckResourceAttr(resourceName, "enable_tls_version_and_cipher_suite_headers", "false"), resource.TestCheckResourceAttr(resourceName, "enable_xff_client_port", "false"), @@ -132,7 +132,7 @@ func TestAccELBV2LoadBalancer_NLB_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "access_logs.0.enabled", "false"), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "elasticloadbalancing", regexache.MustCompile(fmt.Sprintf("loadbalancer/net/%s/.+", rName))), resource.TestCheckNoResourceAttr(resourceName, "connection_logs.#"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "dns_record_client_routing_policy", "any_availability_zone"), resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"), resource.TestCheckResourceAttr(resourceName, "internal", "true"), @@ -581,7 +581,7 @@ func TestAccELBV2LoadBalancer_ALB_outpost(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "access_logs.#", "1"), resource.TestCheckResourceAttr(resourceName, "access_logs.0.enabled", "false"), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "elasticloadbalancing", regexache.MustCompile(fmt.Sprintf("loadbalancer/app/%s/.+", rName))), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"), resource.TestCheckResourceAttr(resourceName, "idle_timeout", "30"), resource.TestCheckResourceAttr(resourceName, "ip_address_type", "ipv4"), @@ -622,7 +622,7 @@ func TestAccELBV2LoadBalancer_networkLoadBalancerEIP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "internal", "false"), resource.TestCheckResourceAttr(resourceName, "ip_address_type", "ipv4"), resource.TestCheckResourceAttrSet(resourceName, "zone_id"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "load_balancer_type", "network"), resource.TestCheckResourceAttr(resourceName, "enable_deletion_protection", "false"), @@ -698,7 +698,7 @@ func TestAccELBV2LoadBalancer_backwardsCompatibility(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "load_balancer_type", "application"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVPCID), resource.TestCheckResourceAttrSet(resourceName, "zone_id"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), ), }, @@ -1244,7 +1244,7 @@ func TestAccELBV2LoadBalancer_ApplicationLoadBalancer_noSecurityGroup(t *testing resource.TestCheckResourceAttr(resourceName, "idle_timeout", "30"), resource.TestCheckResourceAttrSet(resourceName, names.AttrVPCID), resource.TestCheckResourceAttrSet(resourceName, "zone_id"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), ), }, }, From c7a4b8d00d642e458ae6dcb31ccfb2308ff62d8c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:59 -0400 Subject: [PATCH 35/78] events: Use constants for strings --- internal/service/events/target.go | 18 +++++++++--------- internal/service/events/target_migrate.go | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/events/target.go b/internal/service/events/target.go index 4923ef4836f..5ec2d116af2 100644 --- a/internal/service/events/target.go +++ b/internal/service/events/target.go @@ -134,7 +134,7 @@ func resourceTarget() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 1000), @@ -178,7 +178,7 @@ func resourceTarget() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -357,7 +357,7 @@ func resourceTarget() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 64), @@ -906,7 +906,7 @@ func expandTargetRedshiftParameters(config []interface{}) *types.RedshiftDataPar for _, c := range config { param := c.(map[string]interface{}) - redshiftParameters.Database = aws.String(param["database"].(string)) + redshiftParameters.Database = aws.String(param[names.AttrDatabase].(string)) redshiftParameters.Sql = aws.String(param["sql"].(string)) if val, ok := param["with_event"].(bool); ok { @@ -1021,7 +1021,7 @@ func expandTargetECSParametersNetworkConfiguration(nc []interface{}) *types.Netw if val, ok := raw[names.AttrSecurityGroups]; ok { awsVpcConfig.SecurityGroups = flex.ExpandStringValueSet(val.(*schema.Set)) } - awsVpcConfig.Subnets = flex.ExpandStringValueSet(raw["subnets"].(*schema.Set)) + awsVpcConfig.Subnets = flex.ExpandStringValueSet(raw[names.AttrSubnets].(*schema.Set)) if val, ok := raw["assign_public_ip"].(bool); ok { awsVpcConfig.AssignPublicIp = types.AssignPublicIpDisabled if val { @@ -1218,7 +1218,7 @@ func flattenTargetRedshiftParameters(redshiftParameters *types.RedshiftDataParam return []map[string]interface{}{config} } - config["database"] = aws.ToString(redshiftParameters.Database) + config[names.AttrDatabase] = aws.ToString(redshiftParameters.Database) config["db_user"] = aws.ToString(redshiftParameters.DbUser) config["secrets_manager_arn"] = aws.ToString(redshiftParameters.SecretManagerArn) config["sql"] = aws.ToString(redshiftParameters.Sql) @@ -1236,7 +1236,7 @@ func flattenTargetECSParametersNetworkConfiguration(nc *types.NetworkConfigurati result := make(map[string]interface{}) result[names.AttrSecurityGroups] = nc.AwsvpcConfiguration.SecurityGroups - result["subnets"] = nc.AwsvpcConfiguration.Subnets + result[names.AttrSubnets] = nc.AwsvpcConfiguration.Subnets result["assign_public_ip"] = nc.AwsvpcConfiguration.AssignPublicIp == types.AssignPublicIpEnabled return []interface{}{result} @@ -1422,7 +1422,7 @@ func expandTargetCapacityProviderStrategy(tfList []interface{}) []types.Capacity apiObject.Base = int32(val.(int)) } - if val, ok := cp["weight"]; ok { + if val, ok := cp[names.AttrWeight]; ok { apiObject.Weight = int32(val.(int)) } @@ -1478,7 +1478,7 @@ func flattenTargetCapacityProviderStrategy(cps []types.CapacityProviderStrategyI for _, cp := range cps { s := make(map[string]interface{}) s["capacity_provider"] = aws.ToString(cp.CapacityProvider) - s["weight"] = cp.Weight + s[names.AttrWeight] = cp.Weight s["base"] = cp.Base results = append(results, s) } diff --git a/internal/service/events/target_migrate.go b/internal/service/events/target_migrate.go index 430ecfdc053..40ac57e1aee 100644 --- a/internal/service/events/target_migrate.go +++ b/internal/service/events/target_migrate.go @@ -68,7 +68,7 @@ func resourceTargetV0() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, From 7a9e3ab9daa5187804baf7726fe3f51fc58cb870 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:59 -0400 Subject: [PATCH 36/78] finspace: Use constants for strings --- internal/service/finspace/kx_cluster.go | 16 ++++++++-------- internal/service/finspace/kx_cluster_test.go | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/service/finspace/kx_cluster.go b/internal/service/finspace/kx_cluster.go index f03469a55a4..34cd765b8de 100644 --- a/internal/service/finspace/kx_cluster.go +++ b/internal/service/finspace/kx_cluster.go @@ -158,7 +158,7 @@ func ResourceKxCluster() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(3, 255), @@ -189,7 +189,7 @@ func ResourceKxCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "database": { + names.AttrDatabase: { Type: schema.TypeList, Optional: true, Elem: &schema.Resource{ @@ -486,7 +486,7 @@ func resourceKxClusterCreate(ctx context.Context, d *schema.ResourceData, meta i in.AutoScalingConfiguration = expandAutoScalingConfiguration(v.([]interface{})) } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { in.Databases = expandDatabases(v.([]interface{})) } @@ -580,7 +580,7 @@ func resourceKxClusterRead(ctx context.Context, d *schema.ResourceData, meta int return create.AppendDiagError(diags, names.FinSpace, create.ErrActionSetting, ResNameKxCluster, d.Id(), err) } - if err := d.Set("database", flattenDatabases(out.Databases)); err != nil { + if err := d.Set(names.AttrDatabase, flattenDatabases(out.Databases)); err != nil { return create.AppendDiagError(diags, names.FinSpace, create.ErrActionSetting, ResNameKxCluster, d.Id(), err) } @@ -629,8 +629,8 @@ func resourceKxClusterUpdate(ctx context.Context, d *schema.ResourceData, meta i ClusterName: aws.String(d.Get(names.AttrName).(string)), } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && d.HasChanges("database") { - DatabaseConfigIn.Databases = expandDatabases(d.Get("database").([]interface{})) + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && d.HasChanges(names.AttrDatabase) { + DatabaseConfigIn.Databases = expandDatabases(d.Get(names.AttrDatabase).([]interface{})) updateDb = true } @@ -1114,7 +1114,7 @@ func expandCode(tfList []interface{}) *types.CodeConfiguration { a := &types.CodeConfiguration{} - if v, ok := tfMap["s3_bucket"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrS3Bucket].(string); ok && v != "" { a.S3Bucket = aws.String(v) } @@ -1313,7 +1313,7 @@ func flattenCode(apiObject *types.CodeConfiguration) []interface{} { m := map[string]interface{}{} if v := apiObject.S3Bucket; v != nil { - m["s3_bucket"] = aws.ToString(v) + m[names.AttrS3Bucket] = aws.ToString(v) } if v := apiObject.S3Key; v != nil { diff --git a/internal/service/finspace/kx_cluster_test.go b/internal/service/finspace/kx_cluster_test.go index f9f677d62f0..b0c83a88650 100644 --- a/internal/service/finspace/kx_cluster_test.go +++ b/internal/service/finspace/kx_cluster_test.go @@ -298,8 +298,8 @@ func TestAccFinSpaceKxCluster_code(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckKxClusterExists(ctx, resourceName, &kxcluster), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "code.*", map[string]string{ - "s3_bucket": rName, - "s3_key": codePath, + names.AttrS3Bucket: rName, + "s3_key": codePath, }), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(types.KxClusterStatusRunning)), ), @@ -309,8 +309,8 @@ func TestAccFinSpaceKxCluster_code(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckKxClusterExists(ctx, resourceName, &kxcluster), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "code.*", map[string]string{ - "s3_bucket": rName, - "s3_key": updatedCodePath, + names.AttrS3Bucket: rName, + "s3_key": updatedCodePath, }), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(types.KxClusterStatusRunning)), ), From b697f32e603b60f09cfba4c95d50d470301f406f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:59 -0400 Subject: [PATCH 37/78] firehose: Use constants for strings --- internal/service/firehose/delivery_stream.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/firehose/delivery_stream.go b/internal/service/firehose/delivery_stream.go index 4341e20b147..02c293f7c25 100644 --- a/internal/service/firehose/delivery_stream.go +++ b/internal/service/firehose/delivery_stream.go @@ -1001,7 +1001,7 @@ func resourceDeliveryStream() *schema.Resource { Default: types.SnowflakeDataLoadingOptionJsonMapping, ValidateDiagFunc: enum.Validate[types.SnowflakeDataLoadingOption](), }, - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -1041,7 +1041,7 @@ func resourceDeliveryStream() *schema.Resource { ValidateDiagFunc: enum.Validate[types.SnowflakeS3BackupMode](), }, "s3_configuration": s3ConfigurationSchema(), - "schema": { + names.AttrSchema: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -2650,12 +2650,12 @@ func expandSnowflakeDestinationConfiguration(tfMap map[string]interface{}) *type roleARN := tfMap[names.AttrRoleARN].(string) apiObject := &types.SnowflakeDestinationConfiguration{ AccountUrl: aws.String(tfMap["account_url"].(string)), - Database: aws.String(tfMap["database"].(string)), + Database: aws.String(tfMap[names.AttrDatabase].(string)), PrivateKey: aws.String(tfMap[names.AttrPrivateKey].(string)), RetryOptions: expandSnowflakeRetryOptions(tfMap), RoleARN: aws.String(roleARN), S3Configuration: expandS3DestinationConfiguration(tfMap["s3_configuration"].([]interface{})), - Schema: aws.String(tfMap["schema"].(string)), + Schema: aws.String(tfMap[names.AttrSchema].(string)), Table: aws.String(tfMap["table"].(string)), User: aws.String(tfMap["user"].(string)), } @@ -2703,12 +2703,12 @@ func expandSnowflakeDestinationUpdate(tfMap map[string]interface{}) *types.Snowf roleARN := tfMap[names.AttrRoleARN].(string) apiObject := &types.SnowflakeDestinationUpdate{ AccountUrl: aws.String(tfMap["account_url"].(string)), - Database: aws.String(tfMap["database"].(string)), + Database: aws.String(tfMap[names.AttrDatabase].(string)), PrivateKey: aws.String(tfMap[names.AttrPrivateKey].(string)), RetryOptions: expandSnowflakeRetryOptions(tfMap), RoleARN: aws.String(roleARN), S3Update: expandS3DestinationUpdate(tfMap["s3_configuration"].([]interface{})), - Schema: aws.String(tfMap["schema"].(string)), + Schema: aws.String(tfMap[names.AttrSchema].(string)), Table: aws.String(tfMap["table"].(string)), User: aws.String(tfMap["user"].(string)), } @@ -3414,7 +3414,7 @@ func flattenSnowflakeDestinationDescription(apiObject *types.SnowflakeDestinatio "cloudwatch_logging_options": flattenCloudWatchLoggingOptions(apiObject.CloudWatchLoggingOptions), "content_column_name": aws.ToString(apiObject.ContentColumnName), "data_loading_option": apiObject.DataLoadingOption, - "database": aws.ToString(apiObject.Database), + names.AttrDatabase: aws.ToString(apiObject.Database), "key_passphrase": configuredKeyPassphrase, "metadata_column_name": aws.ToString(apiObject.MetaDataColumnName), names.AttrPrivateKey: configuredPrivateKey, @@ -3422,7 +3422,7 @@ func flattenSnowflakeDestinationDescription(apiObject *types.SnowflakeDestinatio names.AttrRoleARN: roleARN, "s3_backup_mode": apiObject.S3BackupMode, "s3_configuration": flattenS3DestinationDescription(apiObject.S3DestinationDescription), - "schema": aws.ToString(apiObject.Schema), + names.AttrSchema: aws.ToString(apiObject.Schema), "snowflake_role_configuration": flattenSnowflakeRoleConfiguration(apiObject.SnowflakeRoleConfiguration), "snowflake_vpc_configuration": flattenSnowflakeVPCConfiguration(apiObject.SnowflakeVpcConfiguration), "table": aws.ToString(apiObject.Table), From 4b2cf42eb2ca3ba05ff8021a72e2a170350556a0 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:49:59 -0400 Subject: [PATCH 38/78] fis: Use constants for strings --- internal/service/fis/experiment_template_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/fis/experiment_template_test.go b/internal/service/fis/experiment_template_test.go index b1538296b1d..bb480992c1c 100644 --- a/internal/service/fis/experiment_template_test.go +++ b/internal/service/fis/experiment_template_test.go @@ -285,7 +285,7 @@ func TestAccFISExperimentTemplate_ebs(t *testing.T) { CheckDestroy: testAccCheckExperimentTemplateDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccExperimentTemplateConfig_ebsVolume(rName, "EBS Volume Pause I/O Experiment", "ebs-paused-io-action", "EBS Volume Pause I/O", "aws:ebs:pause-volume-io", "Volumes", "ebs-volume-to-pause-io", "duration", "PT6M", "aws:ec2:ebs-volume", "ALL", "env", "test"), + Config: testAccExperimentTemplateConfig_ebsVolume(rName, "EBS Volume Pause I/O Experiment", "ebs-paused-io-action", "EBS Volume Pause I/O", "aws:ebs:pause-volume-io", "Volumes", "ebs-volume-to-pause-io", names.AttrDuration, "PT6M", "aws:ec2:ebs-volume", "ALL", "env", "test"), Check: resource.ComposeTestCheckFunc( testAccExperimentTemplateExists(ctx, resourceName, &conf), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "EBS Volume Pause I/O Experiment"), @@ -297,7 +297,7 @@ func TestAccFISExperimentTemplate_ebs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action.0.description", "EBS Volume Pause I/O"), resource.TestCheckResourceAttr(resourceName, "action.0.action_id", "aws:ebs:pause-volume-io"), resource.TestCheckResourceAttr(resourceName, "action.0.parameter.#", "1"), - resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.key", "duration"), + resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.key", names.AttrDuration), resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.value", "PT6M"), resource.TestCheckResourceAttr(resourceName, "action.0.start_after.#", "0"), resource.TestCheckResourceAttr(resourceName, "action.0.target.0.key", "Volumes"), @@ -333,7 +333,7 @@ func TestAccFISExperimentTemplate_ebsParameters(t *testing.T) { CheckDestroy: testAccCheckExperimentTemplateDestroy(ctx), Steps: []resource.TestStep{ { - Config: testAccExperimentTemplateConfig_ebsVolumeParameters(rName, "EBS Volume Pause I/O Experiment", "ebs-paused-io-action", "EBS Volume Pause I/O", "aws:ebs:pause-volume-io", "Volumes", "ebs-volume-to-pause-io", "duration", "PT6M", "aws:ec2:ebs-volume", "ALL", "env", "test"), + Config: testAccExperimentTemplateConfig_ebsVolumeParameters(rName, "EBS Volume Pause I/O Experiment", "ebs-paused-io-action", "EBS Volume Pause I/O", "aws:ebs:pause-volume-io", "Volumes", "ebs-volume-to-pause-io", names.AttrDuration, "PT6M", "aws:ec2:ebs-volume", "ALL", "env", "test"), Check: resource.ComposeTestCheckFunc( testAccExperimentTemplateExists(ctx, resourceName, &conf), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "EBS Volume Pause I/O Experiment"), @@ -345,7 +345,7 @@ func TestAccFISExperimentTemplate_ebsParameters(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "action.0.description", "EBS Volume Pause I/O"), resource.TestCheckResourceAttr(resourceName, "action.0.action_id", "aws:ebs:pause-volume-io"), resource.TestCheckResourceAttr(resourceName, "action.0.parameter.#", "1"), - resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.key", "duration"), + resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.key", names.AttrDuration), resource.TestCheckResourceAttr(resourceName, "action.0.parameter.0.value", "PT6M"), resource.TestCheckResourceAttr(resourceName, "action.0.start_after.#", "0"), resource.TestCheckResourceAttr(resourceName, "action.0.target.0.key", "Volumes"), From 4834e63836c6c1326870721daf4e3af0718bfea2 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:00 -0400 Subject: [PATCH 39/78] fsx: Use constants for strings --- internal/service/fsx/file_cache.go | 4 ++-- internal/service/fsx/lustre_file_system.go | 4 ++-- internal/service/fsx/lustre_file_system_test.go | 2 +- internal/service/fsx/ontap_file_system.go | 10 +++++----- internal/service/fsx/ontap_file_system_data_source.go | 8 ++++---- .../service/fsx/ontap_file_system_data_source_test.go | 2 +- internal/service/fsx/ontap_storage_virtual_machine.go | 10 +++++----- .../fsx/ontap_storage_virtual_machine_data_source.go | 8 ++++---- .../fsx/ontap_storage_virtual_machine_migrate.go | 8 ++++---- internal/service/fsx/openzfs_file_system.go | 4 ++-- internal/service/fsx/openzfs_file_system_test.go | 4 ++-- internal/service/fsx/windows_file_system.go | 4 ++-- .../service/fsx/windows_file_system_data_source.go | 4 ++-- .../fsx/windows_file_system_data_source_test.go | 2 +- internal/service/fsx/windows_file_system_test.go | 6 +++--- 15 files changed, 40 insertions(+), 40 deletions(-) diff --git a/internal/service/fsx/file_cache.go b/internal/service/fsx/file_cache.go index ff41bf696cc..016da13be46 100644 --- a/internal/service/fsx/file_cache.go +++ b/internal/service/fsx/file_cache.go @@ -151,7 +151,7 @@ func resourceFileCache() *schema.Resource { Type: schema.TypeString, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -364,7 +364,7 @@ func resourceFileCacheRead(ctx context.Context, d *schema.ResourceData, meta int d.Set(names.AttrARN, filecache.ResourceARN) dataRepositoryAssociationIDs := aws.StringValueSlice(filecache.DataRepositoryAssociationIds) d.Set("data_repository_association_ids", dataRepositoryAssociationIDs) - d.Set("dns_name", filecache.DNSName) + d.Set(names.AttrDNSName, filecache.DNSName) d.Set("file_cache_id", filecache.FileCacheId) d.Set("file_cache_type", filecache.FileCacheType) d.Set("file_cache_type_version", filecache.FileCacheTypeVersion) diff --git a/internal/service/fsx/lustre_file_system.go b/internal/service/fsx/lustre_file_system.go index 55e9738a990..7fe2243ae59 100644 --- a/internal/service/fsx/lustre_file_system.go +++ b/internal/service/fsx/lustre_file_system.go @@ -101,7 +101,7 @@ func resourceLustreFileSystem() *schema.Resource { Default: fsx.LustreDeploymentTypeScratch1, ValidateFunc: validation.StringInSlice(fsx.LustreDeploymentType_Values(), false), }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -459,7 +459,7 @@ func resourceLustreFileSystemRead(ctx context.Context, d *schema.ResourceData, m d.Set("daily_automatic_backup_start_time", lustreConfig.DailyAutomaticBackupStartTime) d.Set("data_compression_type", lustreConfig.DataCompressionType) d.Set("deployment_type", lustreConfig.DeploymentType) - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set("drive_cache_type", lustreConfig.DriveCacheType) d.Set("export_path", lustreConfig.DataRepositoryConfiguration.ExportPath) d.Set("file_system_type_version", filesystem.FileSystemTypeVersion) diff --git a/internal/service/fsx/lustre_file_system_test.go b/internal/service/fsx/lustre_file_system_test.go index d5015417449..4ec3445ed19 100644 --- a/internal/service/fsx/lustre_file_system_test.go +++ b/internal/service/fsx/lustre_file_system_test.go @@ -47,7 +47,7 @@ func TestAccFSxLustreFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), resource.TestCheckResourceAttr(resourceName, "data_compression_type", fsx.DataCompressionTypeNone), resource.TestCheckResourceAttr(resourceName, "deployment_type", deploymentType), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexache.MustCompile(`fs-.+\.fsx\.`)), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, regexache.MustCompile(`fs-.+\.fsx\.`)), resource.TestCheckResourceAttr(resourceName, "export_path", ""), resource.TestCheckResourceAttr(resourceName, "import_path", ""), resource.TestCheckResourceAttr(resourceName, "imported_file_chunk_size", "0"), diff --git a/internal/service/fsx/ontap_file_system.go b/internal/service/fsx/ontap_file_system.go index 06cc41380f1..a632e9d3bf4 100644 --- a/internal/service/fsx/ontap_file_system.go +++ b/internal/service/fsx/ontap_file_system.go @@ -93,7 +93,7 @@ func resourceONTAPFileSystem() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -114,7 +114,7 @@ func resourceONTAPFileSystem() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -131,7 +131,7 @@ func resourceONTAPFileSystem() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -365,7 +365,7 @@ func resourceONTAPFileSystemRead(ctx context.Context, d *schema.ResourceData, me if err := d.Set("disk_iops_configuration", flattenOntapFileDiskIopsConfiguration(ontapConfig.DiskIopsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err) } - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set("endpoint_ip_address_range", ontapConfig.EndpointIpAddressRange) if err := d.Set(names.AttrEndpoints, flattenOntapFileSystemEndpoints(ontapConfig.Endpoints)); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoints: %s", err) @@ -550,7 +550,7 @@ func flattenOntapFileSystemEndpoint(rs *fsx.FileSystemEndpoint) []interface{} { m := make(map[string]interface{}) if rs.DNSName != nil { - m["dns_name"] = aws.StringValue(rs.DNSName) + m[names.AttrDNSName] = aws.StringValue(rs.DNSName) } if rs.IpAddresses != nil { m["ip_addresses"] = flex.FlattenStringSet(rs.IpAddresses) diff --git a/internal/service/fsx/ontap_file_system_data_source.go b/internal/service/fsx/ontap_file_system_data_source.go index 1fa075902f8..b50deb9b32a 100644 --- a/internal/service/fsx/ontap_file_system_data_source.go +++ b/internal/service/fsx/ontap_file_system_data_source.go @@ -55,7 +55,7 @@ func dataSourceONTAPFileSystem() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -73,7 +73,7 @@ func dataSourceONTAPFileSystem() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -90,7 +90,7 @@ func dataSourceONTAPFileSystem() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -192,7 +192,7 @@ func dataSourceONTAPFileSystemRead(ctx context.Context, d *schema.ResourceData, if err := d.Set("disk_iops_configuration", flattenOntapFileDiskIopsConfiguration(ontapConfig.DiskIopsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err) } - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set("endpoint_ip_address_range", ontapConfig.EndpointIpAddressRange) if err := d.Set(names.AttrEndpoints, flattenOntapFileSystemEndpoints(ontapConfig.Endpoints)); err != nil { return sdkdiag.AppendErrorf(diags, "setting endpoints: %s", err) diff --git a/internal/service/fsx/ontap_file_system_data_source_test.go b/internal/service/fsx/ontap_file_system_data_source_test.go index 047cf0df1e2..625e901edbf 100644 --- a/internal/service/fsx/ontap_file_system_data_source_test.go +++ b/internal/service/fsx/ontap_file_system_data_source_test.go @@ -35,7 +35,7 @@ func TestAccFSxONTAPFileSystemDataSource_Id(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "daily_automatic_backup_start_time", resourceName, "daily_automatic_backup_start_time"), resource.TestCheckResourceAttrPair(datasourceName, "deployment_type", resourceName, "deployment_type"), resource.TestCheckResourceAttrPair(datasourceName, "disk_iops_configuration.#", resourceName, "disk_iops_configuration.#"), - resource.TestCheckResourceAttrPair(datasourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(datasourceName, "endpoint_ip_address_range", resourceName, "endpoint_ip_address_range"), resource.TestCheckResourceAttrPair(datasourceName, "endpoints.#", resourceName, "endpoints.#"), resource.TestCheckResourceAttrPair(datasourceName, "ha_pairs", resourceName, "ha_pairs"), diff --git a/internal/service/fsx/ontap_storage_virtual_machine.go b/internal/service/fsx/ontap_storage_virtual_machine.go index 77c8add0dcd..a9e6c55cdd7 100644 --- a/internal/service/fsx/ontap_storage_virtual_machine.go +++ b/internal/service/fsx/ontap_storage_virtual_machine.go @@ -131,7 +131,7 @@ func resourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -148,7 +148,7 @@ func resourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -165,7 +165,7 @@ func resourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -182,7 +182,7 @@ func resourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -564,7 +564,7 @@ func flattenSvmEndpoint(rs *fsx.SvmEndpoint) []interface{} { m := make(map[string]interface{}) if rs.DNSName != nil { - m["dns_name"] = aws.StringValue(rs.DNSName) + m[names.AttrDNSName] = aws.StringValue(rs.DNSName) } if rs.IpAddresses != nil { m["ip_addresses"] = flex.FlattenStringSet(rs.IpAddresses) diff --git a/internal/service/fsx/ontap_storage_virtual_machine_data_source.go b/internal/service/fsx/ontap_storage_virtual_machine_data_source.go index 92da60a773c..4f29bfde530 100644 --- a/internal/service/fsx/ontap_storage_virtual_machine_data_source.go +++ b/internal/service/fsx/ontap_storage_virtual_machine_data_source.go @@ -84,7 +84,7 @@ func dataSourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -101,7 +101,7 @@ func dataSourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -118,7 +118,7 @@ func dataSourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -135,7 +135,7 @@ func dataSourceONTAPStorageVirtualMachine() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/fsx/ontap_storage_virtual_machine_migrate.go b/internal/service/fsx/ontap_storage_virtual_machine_migrate.go index 86d8ddf4679..7af906f43a1 100644 --- a/internal/service/fsx/ontap_storage_virtual_machine_migrate.go +++ b/internal/service/fsx/ontap_storage_virtual_machine_migrate.go @@ -107,7 +107,7 @@ func resourceONTAPStorageVirtualMachineV0() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -124,7 +124,7 @@ func resourceONTAPStorageVirtualMachineV0() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -141,7 +141,7 @@ func resourceONTAPStorageVirtualMachineV0() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -158,7 +158,7 @@ func resourceONTAPStorageVirtualMachineV0() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/fsx/openzfs_file_system.go b/internal/service/fsx/openzfs_file_system.go index f7f3c701405..afa316fe6e6 100644 --- a/internal/service/fsx/openzfs_file_system.go +++ b/internal/service/fsx/openzfs_file_system.go @@ -113,7 +113,7 @@ func resourceOpenZFSFileSystem() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -497,7 +497,7 @@ func resourceOpenZFSFileSystemRead(ctx context.Context, d *schema.ResourceData, if err := d.Set("disk_iops_configuration", flattenDiskIopsConfiguration(openZFSConfig.DiskIopsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err) } - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set("endpoint_ip_address", openZFSConfig.EndpointIpAddress) d.Set("endpoint_ip_address_range", openZFSConfig.EndpointIpAddressRange) d.Set(names.AttrKMSKeyID, filesystem.KmsKeyId) diff --git a/internal/service/fsx/openzfs_file_system_test.go b/internal/service/fsx/openzfs_file_system_test.go index b0dbef186f6..0461d59422a 100644 --- a/internal/service/fsx/openzfs_file_system_test.go +++ b/internal/service/fsx/openzfs_file_system_test.go @@ -57,7 +57,7 @@ func TestAccFSxOpenZFSFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.iops", "192"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.mode", "AUTOMATIC"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttr(resourceName, "endpoint_ip_address", ""), resource.TestCheckResourceAttr(resourceName, "endpoint_ip_address_range", ""), resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyID), @@ -870,7 +870,7 @@ func TestAccFSxOpenZFSFileSystem_multiAZ(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.iops", "192"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.mode", "AUTOMATIC"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), resource.TestCheckResourceAttrSet(resourceName, "endpoint_ip_address"), resource.TestCheckResourceAttrSet(resourceName, "endpoint_ip_address_range"), resource.TestCheckResourceAttrSet(resourceName, names.AttrKMSKeyID), diff --git a/internal/service/fsx/windows_file_system.go b/internal/service/fsx/windows_file_system.go index 5a2ab5cddc4..48b5b0f4373 100644 --- a/internal/service/fsx/windows_file_system.go +++ b/internal/service/fsx/windows_file_system.go @@ -161,7 +161,7 @@ func resourceWindowsFileSystem() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -445,7 +445,7 @@ func resourceWindowsFileSystemRead(ctx context.Context, d *schema.ResourceData, if err := d.Set("disk_iops_configuration", flattenWindowsDiskIopsConfiguration(windowsConfig.DiskIopsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err) } - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set(names.AttrKMSKeyID, filesystem.KmsKeyId) d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds)) d.Set(names.AttrOwnerID, filesystem.OwnerId) diff --git a/internal/service/fsx/windows_file_system_data_source.go b/internal/service/fsx/windows_file_system_data_source.go index 08d8474cde5..d8a00501544 100644 --- a/internal/service/fsx/windows_file_system_data_source.go +++ b/internal/service/fsx/windows_file_system_data_source.go @@ -92,7 +92,7 @@ func dataSourceWindowsFileSystem() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -193,7 +193,7 @@ func dataSourceWindowsFileSystemRead(ctx context.Context, d *schema.ResourceData if err := d.Set("disk_iops_configuration", flattenWindowsDiskIopsConfiguration(windowsConfig.DiskIopsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting disk_iops_configuration: %s", err) } - d.Set("dns_name", filesystem.DNSName) + d.Set(names.AttrDNSName, filesystem.DNSName) d.Set(names.AttrID, filesystem.FileSystemId) d.Set(names.AttrKMSKeyID, filesystem.KmsKeyId) d.Set("network_interface_ids", aws.StringValueSlice(filesystem.NetworkInterfaceIds)) diff --git a/internal/service/fsx/windows_file_system_data_source_test.go b/internal/service/fsx/windows_file_system_data_source_test.go index 975b620976a..46ec426aacc 100644 --- a/internal/service/fsx/windows_file_system_data_source_test.go +++ b/internal/service/fsx/windows_file_system_data_source_test.go @@ -40,7 +40,7 @@ func TestAccFSxWindowsFileSystemDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "daily_automatic_backup_start_time", resourceName, "daily_automatic_backup_start_time"), resource.TestCheckResourceAttrPair(datasourceName, "deployment_type", resourceName, "deployment_type"), resource.TestCheckResourceAttrPair(datasourceName, "disk_iops_configuration.#", resourceName, "disk_iops_configuration.#"), - resource.TestCheckResourceAttrPair(datasourceName, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrID, resourceName, names.AttrID), resource.TestCheckResourceAttrPair(datasourceName, names.AttrKMSKeyID, resourceName, names.AttrKMSKeyID), resource.TestCheckResourceAttrPair(datasourceName, "network_interface_ids.#", resourceName, "network_interface_ids.#"), diff --git a/internal/service/fsx/windows_file_system_test.go b/internal/service/fsx/windows_file_system_test.go index c0e73cf7496..daef7dcd536 100644 --- a/internal/service/fsx/windows_file_system_test.go +++ b/internal/service/fsx/windows_file_system_test.go @@ -50,7 +50,7 @@ func TestAccFSxWindowsFileSystem_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.#", "1"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.iops", "96"), resource.TestCheckResourceAttr(resourceName, "disk_iops_configuration.0.mode", "AUTOMATIC"), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexache.MustCompile(`fs-.+\..+`)), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, regexache.MustCompile(`fs-.+\..+`)), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrKMSKeyID, "kms", regexache.MustCompile(`key/.+`)), resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "1"), acctest.CheckResourceAttrAccountID(resourceName, names.AttrOwnerID), @@ -127,7 +127,7 @@ func TestAccFSxWindowsFileSystem_singleAz2(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexache.MustCompile(`^\d\d:\d\d$`)), resource.TestCheckResourceAttr(resourceName, "deployment_type", "SINGLE_AZ_2"), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexache.MustCompile(`^amznfsx\w{8}\.\w{8}\.test$`)), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, regexache.MustCompile(`^amznfsx\w{8}\.\w{8}\.test$`)), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrKMSKeyID, "kms", regexache.MustCompile(`key/.+`)), resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "1"), acctest.CheckResourceAttrAccountID(resourceName, names.AttrOwnerID), @@ -212,7 +212,7 @@ func TestAccFSxWindowsFileSystem_multiAz(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "copy_tags_to_backups", "false"), resource.TestMatchResourceAttr(resourceName, "daily_automatic_backup_start_time", regexache.MustCompile(`^\d\d:\d\d$`)), resource.TestCheckResourceAttr(resourceName, "deployment_type", "MULTI_AZ_1"), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexache.MustCompile(`^amznfsx\w{8}\.\w{8}\.test$`)), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, regexache.MustCompile(`^amznfsx\w{8}\.\w{8}\.test$`)), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrKMSKeyID, "kms", regexache.MustCompile(`key/.+`)), resource.TestCheckResourceAttr(resourceName, "network_interface_ids.#", "2"), acctest.CheckResourceAttrAccountID(resourceName, names.AttrOwnerID), From 8acb58a0abdf80636f76522314baf68a93f147a9 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:00 -0400 Subject: [PATCH 40/78] globalaccelerator: Use constants for strings --- internal/service/globalaccelerator/accelerator.go | 4 ++-- .../globalaccelerator/accelerator_data_source.go | 2 +- .../accelerator_data_source_test.go | 4 ++-- .../service/globalaccelerator/accelerator_test.go | 2 +- .../globalaccelerator/custom_routing_accelerator.go | 4 ++-- .../custom_routing_accelerator_data_source.go | 4 ++-- .../custom_routing_accelerator_data_source_test.go | 4 ++-- .../custom_routing_accelerator_test.go | 2 +- internal/service/globalaccelerator/endpoint_group.go | 6 +++--- .../service/globalaccelerator/endpoint_group_test.go | 12 ++++++------ 10 files changed, 22 insertions(+), 22 deletions(-) diff --git a/internal/service/globalaccelerator/accelerator.go b/internal/service/globalaccelerator/accelerator.go index 71f02796257..3a1b2519134 100644 --- a/internal/service/globalaccelerator/accelerator.go +++ b/internal/service/globalaccelerator/accelerator.go @@ -72,7 +72,7 @@ func resourceAccelerator() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -202,7 +202,7 @@ func resourceAcceleratorRead(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "reading Global Accelerator Accelerator (%s): %s", d.Id(), err) } - d.Set("dns_name", accelerator.DnsName) + d.Set(names.AttrDNSName, accelerator.DnsName) d.Set("dual_stack_dns_name", accelerator.DualStackDnsName) d.Set(names.AttrEnabled, accelerator.Enabled) d.Set(names.AttrHostedZoneID, meta.(*conns.AWSClient).GlobalAcceleratorHostedZoneID(ctx)) diff --git a/internal/service/globalaccelerator/accelerator_data_source.go b/internal/service/globalaccelerator/accelerator_data_source.go index 57ae310d8e9..ab5e6bfaa30 100644 --- a/internal/service/globalaccelerator/accelerator_data_source.go +++ b/internal/service/globalaccelerator/accelerator_data_source.go @@ -53,7 +53,7 @@ func (d *acceleratorDataSource) Schema(ctx context.Context, request datasource.S }, }, }, - "dns_name": schema.StringAttribute{ + names.AttrDNSName: schema.StringAttribute{ Computed: true, }, "dual_stack_dns_name": schema.StringAttribute{ diff --git a/internal/service/globalaccelerator/accelerator_data_source_test.go b/internal/service/globalaccelerator/accelerator_data_source_test.go index 0ac4f6989ca..170c8087e90 100644 --- a/internal/service/globalaccelerator/accelerator_data_source_test.go +++ b/internal/service/globalaccelerator/accelerator_data_source_test.go @@ -32,7 +32,7 @@ func TestAccGlobalAcceleratorAcceleratorDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSource1Name, "attributes.0.flow_logs_enabled", resourceName, "attributes.0.flow_logs_enabled"), resource.TestCheckResourceAttrPair(dataSource1Name, "attributes.0.flow_logs_s3_bucket", resourceName, "attributes.0.flow_logs_s3_bucket"), resource.TestCheckResourceAttrPair(dataSource1Name, "attributes.0.flow_logs_s3_prefix", resourceName, "attributes.0.flow_logs_s3_prefix"), - resource.TestCheckResourceAttrPair(dataSource1Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSource1Name, "dual_stack_dns_name", resourceName, "dual_stack_dns_name"), resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrEnabled, resourceName, names.AttrEnabled), resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrHostedZoneID, resourceName, names.AttrHostedZoneID), @@ -49,7 +49,7 @@ func TestAccGlobalAcceleratorAcceleratorDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSource2Name, "attributes.0.flow_logs_enabled", resourceName, "attributes.0.flow_logs_enabled"), resource.TestCheckResourceAttrPair(dataSource2Name, "attributes.0.flow_logs_s3_bucket", resourceName, "attributes.0.flow_logs_s3_bucket"), resource.TestCheckResourceAttrPair(dataSource2Name, "attributes.0.flow_logs_s3_prefix", resourceName, "attributes.0.flow_logs_s3_prefix"), - resource.TestCheckResourceAttrPair(dataSource2Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSource2Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSource2Name, "dual_stack_dns_name", resourceName, "dual_stack_dns_name"), resource.TestCheckResourceAttrPair(dataSource2Name, names.AttrEnabled, resourceName, names.AttrEnabled), resource.TestCheckResourceAttrPair(dataSource2Name, names.AttrHostedZoneID, resourceName, names.AttrHostedZoneID), diff --git a/internal/service/globalaccelerator/accelerator_test.go b/internal/service/globalaccelerator/accelerator_test.go index bbda1ffb4e0..20aaa0526e6 100644 --- a/internal/service/globalaccelerator/accelerator_test.go +++ b/internal/service/globalaccelerator/accelerator_test.go @@ -45,7 +45,7 @@ func TestAccGlobalAcceleratorAccelerator_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", ""), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_prefix", ""), - resource.TestMatchResourceAttr(resourceName, "dns_name", dnsNameRegex), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, dnsNameRegex), resource.TestCheckResourceAttr(resourceName, "dual_stack_dns_name", ""), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, names.AttrHostedZoneID, "Z2BJ6XQ5FK7U4H"), diff --git a/internal/service/globalaccelerator/custom_routing_accelerator.go b/internal/service/globalaccelerator/custom_routing_accelerator.go index d7f108a9f43..1fc35babbc0 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator.go @@ -72,7 +72,7 @@ func resourceCustomRoutingAccelerator() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -196,7 +196,7 @@ func resourceCustomRoutingAcceleratorRead(ctx context.Context, d *schema.Resourc return sdkdiag.AppendErrorf(diags, "reading Global Accelerator Custom Routing Accelerator (%s): %s", d.Id(), err) } - d.Set("dns_name", accelerator.DnsName) + d.Set(names.AttrDNSName, accelerator.DnsName) d.Set(names.AttrEnabled, accelerator.Enabled) d.Set(names.AttrHostedZoneID, meta.(*conns.AWSClient).GlobalAcceleratorHostedZoneID(ctx)) d.Set("ip_address_type", accelerator.IpAddressType) diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_data_source.go b/internal/service/globalaccelerator/custom_routing_accelerator_data_source.go index 1e6fe6612c8..302e4e90c48 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_data_source.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_data_source.go @@ -48,7 +48,7 @@ func dataSourceCustomRoutingAccelerator() *schema.Resource { }, }, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -125,7 +125,7 @@ func dataSourceCustomRoutingAcceleratorRead(ctx context.Context, d *schema.Resou accelerator := results[0] d.SetId(aws.ToString(accelerator.AcceleratorArn)) d.Set(names.AttrARN, accelerator.AcceleratorArn) - d.Set("dns_name", accelerator.DnsName) + d.Set(names.AttrDNSName, accelerator.DnsName) d.Set(names.AttrEnabled, accelerator.Enabled) d.Set(names.AttrHostedZoneID, meta.(*conns.AWSClient).GlobalAcceleratorHostedZoneID(ctx)) d.Set("ip_address_type", accelerator.IpAddressType) diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go b/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go index ba10dde45b8..0d66bf94b4c 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_data_source_test.go @@ -30,7 +30,7 @@ func TestAccGlobalAcceleratorCustomRoutingAcceleratorDataSource_basic(t *testing Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrEnabled, resourceName, names.AttrEnabled), - resource.TestCheckResourceAttrPair(dataSource1Name, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSource1Name, names.AttrHostedZoneID, resourceName, names.AttrHostedZoneID), resource.TestCheckResourceAttrPair(dataSource1Name, "ip_sets.#", resourceName, "ip_sets.#"), resource.TestCheckResourceAttrPair(dataSource1Name, "ip_sets.0.ip_addresses.#", resourceName, "ip_sets.0.ip_addresses.#"), @@ -40,7 +40,7 @@ func TestAccGlobalAcceleratorCustomRoutingAcceleratorDataSource_basic(t *testing resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrEnabled, resourceName, names.AttrEnabled), - resource.TestCheckResourceAttrPair(dataSourceName2, "dns_name", resourceName, "dns_name"), + resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrDNSName, resourceName, names.AttrDNSName), resource.TestCheckResourceAttrPair(dataSourceName2, names.AttrHostedZoneID, resourceName, names.AttrHostedZoneID), resource.TestCheckResourceAttrPair(dataSourceName2, "ip_sets.#", resourceName, "ip_sets.#"), resource.TestCheckResourceAttrPair(dataSourceName2, "ip_sets.0.ip_addresses.#", resourceName, "ip_sets.0.ip_addresses.#"), diff --git a/internal/service/globalaccelerator/custom_routing_accelerator_test.go b/internal/service/globalaccelerator/custom_routing_accelerator_test.go index e773810d863..76ce4f9b93a 100644 --- a/internal/service/globalaccelerator/custom_routing_accelerator_test.go +++ b/internal/service/globalaccelerator/custom_routing_accelerator_test.go @@ -40,7 +40,7 @@ func TestAccGlobalAcceleratorCustomRoutingAccelerator_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_bucket", ""), resource.TestCheckResourceAttr(resourceName, "attributes.0.flow_logs_s3_prefix", ""), - resource.TestMatchResourceAttr(resourceName, "dns_name", dnsNameRegex), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, dnsNameRegex), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, names.AttrHostedZoneID, "Z2BJ6XQ5FK7U4H"), resource.TestCheckResourceAttr(resourceName, "ip_address_type", "IPV4"), diff --git a/internal/service/globalaccelerator/endpoint_group.go b/internal/service/globalaccelerator/endpoint_group.go index 0e52e9a0652..754b8b76627 100644 --- a/internal/service/globalaccelerator/endpoint_group.go +++ b/internal/service/globalaccelerator/endpoint_group.go @@ -63,7 +63,7 @@ func resourceEndpointGroup() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 255), @@ -380,7 +380,7 @@ func expandEndpointConfiguration(tfMap map[string]interface{}) *awstypes.Endpoin apiObject.EndpointId = aws.String(v) } - if v, ok := tfMap["weight"].(int); ok { + if v, ok := tfMap[names.AttrWeight].(int); ok { apiObject.Weight = aws.Int32(int32(v)) } @@ -473,7 +473,7 @@ func flattenEndpointDescription(apiObject *awstypes.EndpointDescription) map[str } if v := apiObject.Weight; v != nil { - tfMap["weight"] = aws.ToInt32(v) + tfMap[names.AttrWeight] = aws.ToInt32(v) } return tfMap diff --git a/internal/service/globalaccelerator/endpoint_group_test.go b/internal/service/globalaccelerator/endpoint_group_test.go index f0d2ac0e59f..945273de803 100644 --- a/internal/service/globalaccelerator/endpoint_group_test.go +++ b/internal/service/globalaccelerator/endpoint_group_test.go @@ -108,7 +108,7 @@ func TestAccGlobalAcceleratorEndpointGroup_ALBEndpoint_clientIP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "false", - "weight": "20", + names.AttrWeight: "20", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", albResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), @@ -135,7 +135,7 @@ func TestAccGlobalAcceleratorEndpointGroup_ALBEndpoint_clientIP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "true", - "weight": "0", + names.AttrWeight: "0", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", albResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), @@ -183,7 +183,7 @@ func TestAccGlobalAcceleratorEndpointGroup_instanceEndpoint(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "true", - "weight": "20", + names.AttrWeight: "20", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", instanceResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), @@ -234,7 +234,7 @@ func TestAccGlobalAcceleratorEndpointGroup_multiRegion(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "false", - "weight": "20", + names.AttrWeight: "20", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", eipResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.AlternateRegion()), @@ -345,7 +345,7 @@ func TestAccGlobalAcceleratorEndpointGroup_tcpHealthCheckProtocol(t *testing.T) resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "false", - "weight": "10", + names.AttrWeight: "10", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", eipResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), @@ -406,7 +406,7 @@ func TestAccGlobalAcceleratorEndpointGroup_update(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "endpoint_configuration.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "endpoint_configuration.*", map[string]string{ "client_ip_preservation_enabled": "false", - "weight": "20", + names.AttrWeight: "20", }), resource.TestCheckTypeSetElemAttrPair(resourceName, "endpoint_configuration.*.endpoint_id", eipResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, "endpoint_group_region", acctest.Region()), From c473c57f350965380e238b2f0f7b992f98dd167a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:00 -0400 Subject: [PATCH 41/78] glue: Use constants for strings --- internal/service/glue/ml_transform.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/glue/ml_transform.go b/internal/service/glue/ml_transform.go index 56d18737725..60e827b35db 100644 --- a/internal/service/glue/ml_transform.go +++ b/internal/service/glue/ml_transform.go @@ -164,7 +164,7 @@ func ResourceMLTransform() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -287,7 +287,7 @@ func resourceMLTransformRead(ctx context.Context, d *schema.ResourceData, meta i return sdkdiag.AppendErrorf(diags, "setting parameters: %s", err) } - if err := d.Set("schema", flattenMLTransformSchemaColumns(output.Schema)); err != nil { + if err := d.Set(names.AttrSchema, flattenMLTransformSchemaColumns(output.Schema)); err != nil { return sdkdiag.AppendErrorf(diags, "setting schema: %s", err) } From 65b7ce622cff4a0ad9d9ce2958cf088cffa09b7a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:00 -0400 Subject: [PATCH 42/78] inspector: Use constants for strings --- internal/service/inspector/assessment_template.go | 6 +++--- internal/service/inspector/assessment_template_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/inspector/assessment_template.go b/internal/service/inspector/assessment_template.go index 2693975236c..ae52d3a7233 100644 --- a/internal/service/inspector/assessment_template.go +++ b/internal/service/inspector/assessment_template.go @@ -44,7 +44,7 @@ func ResourceAssessmentTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Required: true, ForceNew: true, @@ -99,7 +99,7 @@ func resourceAssessmentTemplateCreate(ctx context.Context, d *schema.ResourceDat input := &inspector.CreateAssessmentTemplateInput{ AssessmentTargetArn: aws.String(d.Get("target_arn").(string)), AssessmentTemplateName: aws.String(name), - DurationInSeconds: aws.Int64(int64(d.Get("duration").(int))), + DurationInSeconds: aws.Int64(int64(d.Get(names.AttrDuration).(int))), RulesPackageArns: flex.ExpandStringSet(d.Get("rules_package_arns").(*schema.Set)), } @@ -147,7 +147,7 @@ func resourceAssessmentTemplateRead(ctx context.Context, d *schema.ResourceData, arn := aws.StringValue(template.Arn) d.Set(names.AttrARN, arn) - d.Set("duration", template.DurationInSeconds) + d.Set(names.AttrDuration, template.DurationInSeconds) d.Set(names.AttrName, template.Name) d.Set("rules_package_arns", aws.StringValueSlice(template.RulesPackageArns)) d.Set("target_arn", template.AssessmentTargetArn) diff --git a/internal/service/inspector/assessment_template_test.go b/internal/service/inspector/assessment_template_test.go index 01dbd96de9d..8a77736e1d5 100644 --- a/internal/service/inspector/assessment_template_test.go +++ b/internal/service/inspector/assessment_template_test.go @@ -37,7 +37,7 @@ func TestAccInspectorAssessmentTemplate_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckTemplateExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "inspector", regexache.MustCompile(`target/.+/template/.+`)), - resource.TestCheckResourceAttr(resourceName, "duration", "3600"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "3600"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttrPair(resourceName, "rules_package_arns.#", "data.aws_inspector_rules_packages.available", "arns.#"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), From 49d4222c9f6f27ff9e062ef8cb9997bdc2683af3 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:00 -0400 Subject: [PATCH 43/78] kafkaconnect: Use constants for strings --- internal/service/kafkaconnect/connector.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/kafkaconnect/connector.go b/internal/service/kafkaconnect/connector.go index 170f6daf82f..cdb955ef96f 100644 --- a/internal/service/kafkaconnect/connector.go +++ b/internal/service/kafkaconnect/connector.go @@ -177,7 +177,7 @@ func ResourceConnector() *schema.Resource { ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, ForceNew: true, @@ -793,7 +793,7 @@ func expandVPC(tfMap map[string]interface{}) *kafkaconnect.Vpc { apiObject.SecurityGroups = flex.ExpandStringSet(v) } - if v, ok := tfMap["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { apiObject.Subnets = flex.ExpandStringSet(v) } @@ -1136,7 +1136,7 @@ func flattenVPCDescription(apiObject *kafkaconnect.VpcDescription) map[string]in } if v := apiObject.Subnets; v != nil { - tfMap["subnets"] = aws.StringValueSlice(v) + tfMap[names.AttrSubnets] = aws.StringValueSlice(v) } return tfMap From f887d6ba96efb1ca20b2b3fd4a632dc4fd87c7b7 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 44/78] kendra: Use constants for strings --- internal/service/kendra/data_source.go | 8 ++++---- internal/service/kendra/index.go | 6 +++--- internal/service/kendra/index_data_source.go | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/kendra/data_source.go b/internal/service/kendra/data_source.go index a1c2e39128c..5c660eb8926 100644 --- a/internal/service/kendra/data_source.go +++ b/internal/service/kendra/data_source.go @@ -497,7 +497,7 @@ func hookConfigurationSchema() *schema.Schema { Required: true, ValidateFunc: verify.ValidARN, }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -1278,7 +1278,7 @@ func expandHookConfiguration(tfList []interface{}) *types.HookConfiguration { result := &types.HookConfiguration{ LambdaArn: aws.String(tfMap["lambda_arn"].(string)), - S3Bucket: aws.String(tfMap["s3_bucket"].(string)), + S3Bucket: aws.String(tfMap[names.AttrS3Bucket].(string)), } if v, ok := tfMap["invocation_condition"].([]interface{}); ok && len(v) > 0 { @@ -1627,8 +1627,8 @@ func flattenHookConfiguration(apiObject *types.HookConfiguration) []interface{} } m := map[string]interface{}{ - "lambda_arn": aws.ToString(apiObject.LambdaArn), - "s3_bucket": aws.ToString(apiObject.S3Bucket), + "lambda_arn": aws.ToString(apiObject.LambdaArn), + names.AttrS3Bucket: aws.ToString(apiObject.S3Bucket), } if v := apiObject.InvocationCondition; v != nil { diff --git a/internal/service/kendra/index.go b/internal/service/kendra/index.go index 5b6c7efeb0a..89ab4617f73 100644 --- a/internal/service/kendra/index.go +++ b/internal/service/kendra/index.go @@ -112,7 +112,7 @@ func ResourceIndex() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "duration": { + names.AttrDuration: { Type: schema.TypeString, Computed: true, Optional: true, @@ -771,7 +771,7 @@ func expandRelevance(relevance []interface{}, documentAttributeValueType string) result := &types.Relevance{} - if v, ok := tfMap["duration"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrDuration].(string); ok && v != "" { result.Duration = aws.String(v) } @@ -986,7 +986,7 @@ func flattenRelevance(relevance *types.Relevance, documentAttributeValueType str } if v := relevance.Duration; v != nil { - values["duration"] = aws.ToString(v) + values[names.AttrDuration] = aws.ToString(v) } if v := relevance.Freshness; v != nil && documentAttributeValueType == string(types.DocumentAttributeValueTypeDateValue) { diff --git a/internal/service/kendra/index_data_source.go b/internal/service/kendra/index_data_source.go index a31b0decee7..42a9613e400 100644 --- a/internal/service/kendra/index_data_source.go +++ b/internal/service/kendra/index_data_source.go @@ -67,7 +67,7 @@ func DataSourceIndex() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "duration": { + names.AttrDuration: { Type: schema.TypeString, Computed: true, }, From 91a543b7792b5ba0e9a74f61b04917165c73b1c7 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 45/78] kinesisanalytics: Use constants for strings --- .../service/kinesisanalytics/application.go | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/service/kinesisanalytics/application.go b/internal/service/kinesisanalytics/application.go index f498b00ff79..9d23860344e 100644 --- a/internal/service/kinesisanalytics/application.go +++ b/internal/service/kinesisanalytics/application.go @@ -223,7 +223,7 @@ func ResourceApplication() *schema.Resource { }, }, - "schema": { + names.AttrSchema: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -434,7 +434,7 @@ func ResourceApplication() *schema.Resource { ), }, - "schema": { + names.AttrSchema: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -489,7 +489,7 @@ func ResourceApplication() *schema.Resource { }, }, - "schema": { + names.AttrSchema: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -1302,7 +1302,7 @@ func expandInput(vInput []interface{}) *kinesisanalytics.Input { input.InputProcessingConfiguration = expandInputProcessingConfiguration(vInputProcessingConfiguration) } - if vInputSchema, ok := mInput["schema"].([]interface{}); ok { + if vInputSchema, ok := mInput[names.AttrSchema].([]interface{}); ok { input.InputSchema = expandSourceSchema(vInputSchema) } @@ -1418,7 +1418,7 @@ func expandInputUpdate(vInput []interface{}) *kinesisanalytics.InputUpdate { inputUpdate.InputProcessingConfigurationUpdate = inputProcessingConfigurationUpdate } - if vInputSchema, ok := mInput["schema"].([]interface{}); ok && len(vInputSchema) > 0 && vInputSchema[0] != nil { + if vInputSchema, ok := mInput[names.AttrSchema].([]interface{}); ok && len(vInputSchema) > 0 && vInputSchema[0] != nil { inputSchemaUpdate := &kinesisanalytics.InputSchemaUpdate{} mInputSchema := vInputSchema[0].(map[string]interface{}) @@ -1484,7 +1484,7 @@ func expandOutput(vOutput interface{}) *kinesisanalytics.Output { mOutput := vOutput.(map[string]interface{}) - if vDestinationSchema, ok := mOutput["schema"].([]interface{}); ok && len(vDestinationSchema) > 0 && vDestinationSchema[0] != nil { + if vDestinationSchema, ok := mOutput[names.AttrSchema].([]interface{}); ok && len(vDestinationSchema) > 0 && vDestinationSchema[0] != nil { destinationSchema := &kinesisanalytics.DestinationSchema{} mDestinationSchema := vDestinationSchema[0].(map[string]interface{}) @@ -1650,7 +1650,7 @@ func expandReferenceDataSource(vReferenceDataSource []interface{}) *kinesisanaly mReferenceDataSource := vReferenceDataSource[0].(map[string]interface{}) - if vReferenceSchema, ok := mReferenceDataSource["schema"].([]interface{}); ok { + if vReferenceSchema, ok := mReferenceDataSource[names.AttrSchema].([]interface{}); ok { referenceDataSource.ReferenceSchema = expandSourceSchema(vReferenceSchema) } @@ -1692,7 +1692,7 @@ func expandReferenceDataSourceUpdate(vReferenceDataSource []interface{}) *kinesi referenceDataSourceUpdate.ReferenceId = aws.String(vReferenceId) } - if vReferenceSchema, ok := mReferenceDataSource["schema"].([]interface{}); ok { + if vReferenceSchema, ok := mReferenceDataSource[names.AttrSchema].([]interface{}); ok { referenceDataSourceUpdate.ReferenceSchemaUpdate = expandSourceSchema(vReferenceSchema) } @@ -1783,7 +1783,7 @@ func flattenInputDescriptions(inputDescriptions []*kinesisanalytics.InputDescrip } if inputSchema := inputDescription.InputSchema; inputSchema != nil { - mInput["schema"] = flattenSourceSchema(inputSchema) + mInput[names.AttrSchema] = flattenSourceSchema(inputSchema) } if inputProcessingConfigurationDescription := inputDescription.InputProcessingConfigurationDescription; inputProcessingConfigurationDescription != nil { @@ -1849,7 +1849,7 @@ func flattenOutputDescriptions(outputDescriptions []*kinesisanalytics.OutputDesc "record_format_type": aws.StringValue(destinationSchema.RecordFormatType), } - mOutput["schema"] = []interface{}{mDestinationSchema} + mOutput[names.AttrSchema] = []interface{}{mDestinationSchema} } if kinesisFirehoseOutputDescription := outputDescription.KinesisFirehoseOutputDescription; kinesisFirehoseOutputDescription != nil { @@ -1899,7 +1899,7 @@ func flattenReferenceDataSourceDescriptions(referenceDataSourceDescriptions []*k } if referenceSchema := referenceDataSourceDescription.ReferenceSchema; referenceSchema != nil { - mReferenceDataSource["schema"] = flattenSourceSchema(referenceSchema) + mReferenceDataSource[names.AttrSchema] = flattenSourceSchema(referenceSchema) } if s3ReferenceDataSource := referenceDataSourceDescription.S3ReferenceDataSourceDescription; s3ReferenceDataSource != nil { From 851c0b59a2975e704eca4c7286ba83d42560c820 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 46/78] lakeformation: Use constants for strings --- .../lakeformation/lakeformation_test.go | 6 ++-- internal/service/lakeformation/permissions.go | 28 +++++++++---------- .../lakeformation/permissions_data_source.go | 8 +++--- .../service/lakeformation/resource_lf_tag.go | 4 +-- .../lakeformation/resource_lf_tag_test.go | 2 +- .../service/lakeformation/resource_lf_tags.go | 12 ++++---- internal/service/lakeformation/sweep.go | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/internal/service/lakeformation/lakeformation_test.go b/internal/service/lakeformation/lakeformation_test.go index 9e1958932f4..5db27834caf 100644 --- a/internal/service/lakeformation/lakeformation_test.go +++ b/internal/service/lakeformation/lakeformation_test.go @@ -32,7 +32,7 @@ func TestAccLakeFormation_serial(t *testing.T) { }, "PermissionsBasic": { "basic": testAccPermissions_basic, - "database": testAccPermissions_database, + names.AttrDatabase: testAccPermissions_database, "databaseIAMAllowed": testAccPermissions_databaseIAMAllowed, "databaseMultiple": testAccPermissions_databaseMultiple, "dataCellsFilter": testAccPermissions_dataCellsFilter, @@ -45,7 +45,7 @@ func TestAccLakeFormation_serial(t *testing.T) { "PermissionsDataSource": { "basic": testAccPermissionsDataSource_basic, "dataCellsFilter": testAccPermissionsDataSource_dataCellsFilter, - "database": testAccPermissionsDataSource_database, + names.AttrDatabase: testAccPermissionsDataSource_database, "dataLocation": testAccPermissionsDataSource_dataLocation, "lfTag": testAccPermissionsDataSource_lfTag, "lfTagPolicy": testAccPermissionsDataSource_lfTagPolicy, @@ -85,7 +85,7 @@ func TestAccLakeFormation_serial(t *testing.T) { }, "ResourceLFTags": { "basic": testAccResourceLFTags_basic, - "database": testAccResourceLFTags_database, + names.AttrDatabase: testAccResourceLFTags_database, "databaseMultipleTags": testAccResourceLFTags_databaseMultipleTags, "disappears": testAccResourceLFTags_disappears, "hierarchy": testAccResourceLFTags_hierarchy, diff --git a/internal/service/lakeformation/permissions.go b/internal/service/lakeformation/permissions.go index 179e7a8610f..494ccbef277 100644 --- a/internal/service/lakeformation/permissions.go +++ b/internal/service/lakeformation/permissions.go @@ -50,7 +50,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -93,7 +93,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -118,7 +118,7 @@ func ResourcePermissions() *schema.Resource { }, }, }, - "database": { + names.AttrDatabase: { Type: schema.TypeList, Computed: true, ForceNew: true, @@ -127,7 +127,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -160,7 +160,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -203,7 +203,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -287,7 +287,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -340,7 +340,7 @@ func ResourcePermissions() *schema.Resource { ExactlyOneOf: []string{ "catalog_resource", "data_location", - "database", + names.AttrDatabase, "lf_tag", "lf_tag_policy", "table", @@ -448,7 +448,7 @@ func resourcePermissionsCreate(ctx context.Context, d *schema.ResourceData, meta input.Resource.DataLocation = ExpandDataLocationResource(v.([]interface{})[0].(map[string]interface{})) } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Resource.Database = ExpandDatabaseResource(v.([]interface{})[0].(map[string]interface{})) } @@ -538,7 +538,7 @@ func resourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta i input.Resource.DataLocation = ExpandDataLocationResource(v.([]interface{})[0].(map[string]interface{})) } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Resource.Database = ExpandDatabaseResource(v.([]interface{})[0].(map[string]interface{})) } @@ -620,7 +620,7 @@ func resourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta i log.Printf("[WARN] No Lake Formation permissions (%s) found", d.Id()) d.Set("catalog_resource", false) d.Set("data_location", nil) - d.Set("database", nil) + d.Set(names.AttrDatabase, nil) d.Set("lf_tag", nil) d.Set("lf_tag_policy", nil) d.Set("table_with_columns", nil) @@ -651,11 +651,11 @@ func resourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta i } if cleanPermissions[0].Resource.Database != nil { - if err := d.Set("database", []interface{}{flattenDatabaseResource(cleanPermissions[0].Resource.Database)}); err != nil { + if err := d.Set(names.AttrDatabase, []interface{}{flattenDatabaseResource(cleanPermissions[0].Resource.Database)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting database: %s", err) } } else { - d.Set("database", nil) + d.Set(names.AttrDatabase, nil) } if cleanPermissions[0].Resource.DataCellsFilter != nil { @@ -760,7 +760,7 @@ func resourcePermissionsDelete(ctx context.Context, d *schema.ResourceData, meta input.Resource.DataLocation = ExpandDataLocationResource(v.([]interface{})[0].(map[string]interface{})) } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Resource.Database = ExpandDatabaseResource(v.([]interface{})[0].(map[string]interface{})) } diff --git a/internal/service/lakeformation/permissions_data_source.go b/internal/service/lakeformation/permissions_data_source.go index eb66cef0376..2bee260574b 100644 --- a/internal/service/lakeformation/permissions_data_source.go +++ b/internal/service/lakeformation/permissions_data_source.go @@ -86,7 +86,7 @@ func DataSourcePermissions() *schema.Resource { }, }, }, - "database": { + names.AttrDatabase: { Type: schema.TypeList, Optional: true, Computed: true, @@ -303,7 +303,7 @@ func dataSourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta input.Resource.DataLocation = ExpandDataLocationResource(v.([]interface{})[0].(map[string]interface{})) } - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Resource.Database = ExpandDatabaseResource(v.([]interface{})[0].(map[string]interface{})) } @@ -394,11 +394,11 @@ func dataSourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta } if cleanPermissions[0].Resource.Database != nil { - if err := d.Set("database", []interface{}{flattenDatabaseResource(cleanPermissions[0].Resource.Database)}); err != nil { + if err := d.Set(names.AttrDatabase, []interface{}{flattenDatabaseResource(cleanPermissions[0].Resource.Database)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting database: %s", err) } } else { - d.Set("database", nil) + d.Set(names.AttrDatabase, nil) } if cleanPermissions[0].Resource.LFTag != nil { diff --git a/internal/service/lakeformation/resource_lf_tag.go b/internal/service/lakeformation/resource_lf_tag.go index df72d6bacb1..921b760e36c 100644 --- a/internal/service/lakeformation/resource_lf_tag.go +++ b/internal/service/lakeformation/resource_lf_tag.go @@ -70,7 +70,7 @@ func (r *resourceResourceLFTag) Schema(ctx context.Context, req resource.SchemaR names.AttrID: framework.IDAttribute(), }, Blocks: map[string]schema.Block{ - "database": schema.ListNestedBlock{ + names.AttrDatabase: schema.ListNestedBlock{ CustomType: fwtypes.NewListNestedObjectTypeOf[Database](ctx), Validators: []validator.List{ listvalidator.SizeAtMost(1), @@ -510,7 +510,7 @@ func (r *resourceResourceLFTag) Delete(ctx context.Context, req resource.DeleteR func (r *resourceResourceLFTag) ConfigValidators(_ context.Context) []resource.ConfigValidator { return []resource.ConfigValidator{ resourcevalidator.ExactlyOneOf( - path.MatchRoot("database"), + path.MatchRoot(names.AttrDatabase), path.MatchRoot("table"), path.MatchRoot("table_with_columns"), ), diff --git a/internal/service/lakeformation/resource_lf_tag_test.go b/internal/service/lakeformation/resource_lf_tag_test.go index 1b6f4ef63c9..274147c3361 100644 --- a/internal/service/lakeformation/resource_lf_tag_test.go +++ b/internal/service/lakeformation/resource_lf_tag_test.go @@ -184,7 +184,7 @@ func lfTagsDisappearsStateFunc(ctx context.Context, state *tfsdk.State, is *terr log.Printf("[WARN] %s", err) } - if err := fwdiag.DiagnosticsError(state.SetAttribute(ctx, path.Root("database"), lfdata.Database)); err != nil { + if err := fwdiag.DiagnosticsError(state.SetAttribute(ctx, path.Root(names.AttrDatabase), lfdata.Database)); err != nil { log.Printf("[WARN] %s", err) } diff --git a/internal/service/lakeformation/resource_lf_tags.go b/internal/service/lakeformation/resource_lf_tags.go index 28fc1df2465..dd01fb504b4 100644 --- a/internal/service/lakeformation/resource_lf_tags.go +++ b/internal/service/lakeformation/resource_lf_tags.go @@ -49,14 +49,14 @@ func ResourceResourceLFTags() *schema.Resource { Optional: true, ValidateFunc: verify.ValidAccountID, }, - "database": { + names.AttrDatabase: { Type: schema.TypeList, Computed: true, ForceNew: true, MaxItems: 1, Optional: true, ExactlyOneOf: []string{ - "database", + names.AttrDatabase, "table", "table_with_columns", }, @@ -112,7 +112,7 @@ func ResourceResourceLFTags() *schema.Resource { MaxItems: 1, Optional: true, ExactlyOneOf: []string{ - "database", + names.AttrDatabase, "table", "table_with_columns", }, @@ -160,7 +160,7 @@ func ResourceResourceLFTags() *schema.Resource { MaxItems: 1, Optional: true, ExactlyOneOf: []string{ - "database", + names.AttrDatabase, "table", "table_with_columns", }, @@ -384,7 +384,7 @@ func resourceResourceLFTagsDelete(ctx context.Context, d *schema.ResourceData, m func lfTagsTagger(d *schema.ResourceData) (tagger, diag.Diagnostics) { var diags diag.Diagnostics - if v, ok := d.GetOk("database"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrDatabase); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { return &databaseTagger{}, diags } else if v, ok := d.GetOk("table"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { return &tableTagger{}, diags @@ -410,7 +410,7 @@ type tagger interface { type databaseTagger struct{} func (t *databaseTagger) ExpandResource(d *schema.ResourceData) *awstypes.Resource { - v := d.Get("database").([]any)[0].(map[string]any) + v := d.Get(names.AttrDatabase).([]any)[0].(map[string]any) return &awstypes.Resource{ Database: ExpandDatabaseResource(v), } diff --git a/internal/service/lakeformation/sweep.go b/internal/service/lakeformation/sweep.go index 9ef7aa9c7d8..bf319d3403c 100644 --- a/internal/service/lakeformation/sweep.go +++ b/internal/service/lakeformation/sweep.go @@ -56,7 +56,7 @@ func sweepPermissions(ctx context.Context, client *conns.AWSClient) ([]sweep.Swe } if v.Resource.Database != nil { - d.Set("database", []any{flattenDatabaseResource(v.Resource.Database)}) + d.Set(names.AttrDatabase, []any{flattenDatabaseResource(v.Resource.Database)}) } if v.Resource.DataCellsFilter != nil { From 547bd8c05c717a9d1f20366a37a13ad71ab56474 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 47/78] lambda: Use constants for strings --- internal/service/lambda/function.go | 18 +++++++++--------- internal/service/lambda/function_test.go | 6 +++--- internal/service/lambda/layer_version.go | 6 +++--- internal/service/lambda/layer_version_test.go | 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index d77d9fa8fe2..e638af27e88 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -167,7 +167,7 @@ func resourceFunction() *schema.Resource { "filename": { Type: schema.TypeString, Optional: true, - ExactlyOneOf: []string{"filename", "image_uri", "s3_bucket"}, + ExactlyOneOf: []string{"filename", "image_uri", names.AttrS3Bucket}, }, "function_name": { Type: schema.TypeString, @@ -206,7 +206,7 @@ func resourceFunction() *schema.Resource { "image_uri": { Type: schema.TypeString, Optional: true, - ExactlyOneOf: []string{"filename", "image_uri", "s3_bucket"}, + ExactlyOneOf: []string{"filename", "image_uri", names.AttrS3Bucket}, }, "invoke_arn": { Type: schema.TypeString, @@ -321,16 +321,16 @@ func resourceFunction() *schema.Resource { Optional: true, ValidateDiagFunc: enum.Validate[awstypes.Runtime](), }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Optional: true, - ExactlyOneOf: []string{"filename", "image_uri", "s3_bucket"}, + ExactlyOneOf: []string{"filename", "image_uri", names.AttrS3Bucket}, RequiredWith: []string{"s3_key"}, }, "s3_key": { Type: schema.TypeString, Optional: true, - RequiredWith: []string{"s3_bucket"}, + RequiredWith: []string{names.AttrS3Bucket}, }, "s3_object_version": { Type: schema.TypeString, @@ -496,7 +496,7 @@ func resourceFunctionCreate(ctx context.Context, d *schema.ResourceData, meta in } else if v, ok := d.GetOk("image_uri"); ok { input.Code.ImageUri = aws.String(v.(string)) } else { - input.Code.S3Bucket = aws.String(d.Get("s3_bucket").(string)) + input.Code.S3Bucket = aws.String(d.Get(names.AttrS3Bucket).(string)) input.Code.S3Key = aws.String(d.Get("s3_key").(string)) if v, ok := d.GetOk("s3_object_version"); ok { input.Code.S3ObjectVersion = aws.String(v.(string)) @@ -961,7 +961,7 @@ func resourceFunctionUpdate(ctx context.Context, d *schema.ResourceData, meta in } else if v, ok := d.GetOk("image_uri"); ok { input.ImageUri = aws.String(v.(string)) } else { - input.S3Bucket = aws.String(d.Get("s3_bucket").(string)) + input.S3Bucket = aws.String(d.Get(names.AttrS3Bucket).(string)) input.S3Key = aws.String(d.Get("s3_key").(string)) if v, ok := d.GetOk("s3_object_version"); ok { input.S3ObjectVersion = aws.String(v.(string)) @@ -973,7 +973,7 @@ func resourceFunctionUpdate(ctx context.Context, d *schema.ResourceData, meta in if err != nil { if errs.IsAErrorMessageContains[*awstypes.InvalidParameterValueException](err, "Error occurred while GetObject.") { // As s3_bucket, s3_key and s3_object_version aren't set in resourceFunctionRead(), don't ovewrite the last known good values. - for _, key := range []string{"s3_bucket", "s3_key", "s3_object_version"} { + for _, key := range []string{names.AttrS3Bucket, "s3_key", "s3_object_version"} { old, _ := d.GetChange(key) d.Set(key, old) } @@ -1283,7 +1283,7 @@ func updateComputedAttributesOnPublish(_ context.Context, d *schema.ResourceDiff func needsFunctionCodeUpdate(d sdkv2.ResourceDiffer) bool { return d.HasChange("filename") || d.HasChange("source_code_hash") || - d.HasChange("s3_bucket") || + d.HasChange(names.AttrS3Bucket) || d.HasChange("s3_key") || d.HasChange("s3_object_version") || d.HasChange("image_uri") || diff --git a/internal/service/lambda/function_test.go b/internal/service/lambda/function_test.go index dd508085dc2..f98b2369bb1 100644 --- a/internal/service/lambda/function_test.go +++ b/internal/service/lambda/function_test.go @@ -1852,7 +1852,7 @@ func TestAccLambdaFunction_s3(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"publish", "s3_bucket", "s3_key"}, + ImportStateVerifyIgnore: []string{"publish", names.AttrS3Bucket, "s3_key"}, }, }, }) @@ -2019,7 +2019,7 @@ func TestAccLambdaFunction_S3Update_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"filename", "publish", "s3_bucket", "s3_key", "s3_object_version"}, + ImportStateVerifyIgnore: []string{"filename", "publish", names.AttrS3Bucket, "s3_key", "s3_object_version"}, }, { PreConfig: func() { @@ -2075,7 +2075,7 @@ func TestAccLambdaFunction_S3Update_unversioned(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"filename", "publish", "s3_bucket", "s3_key"}, + ImportStateVerifyIgnore: []string{"filename", "publish", names.AttrS3Bucket, "s3_key"}, }, { PreConfig: func() { diff --git a/internal/service/lambda/layer_version.go b/internal/service/lambda/layer_version.go index d74643925d4..700ddaaee21 100644 --- a/internal/service/lambda/layer_version.go +++ b/internal/service/lambda/layer_version.go @@ -79,7 +79,7 @@ func resourceLayerVersion() *schema.Resource { Type: schema.TypeString, Optional: true, ForceNew: true, - ConflictsWith: []string{"s3_bucket", "s3_key", "s3_object_version"}, + ConflictsWith: []string{names.AttrS3Bucket, "s3_key", "s3_object_version"}, }, "layer_arn": { Type: schema.TypeString, @@ -96,7 +96,7 @@ func resourceLayerVersion() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(0, 512), }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -152,7 +152,7 @@ func resourceLayerVersionCreate(ctx context.Context, d *schema.ResourceData, met layerName := d.Get("layer_name").(string) filename, hasFilename := d.GetOk("filename") - s3Bucket, bucketOk := d.GetOk("s3_bucket") + s3Bucket, bucketOk := d.GetOk(names.AttrS3Bucket) s3Key, keyOk := d.GetOk("s3_key") s3ObjectVersion, versionOk := d.GetOk("s3_object_version") diff --git a/internal/service/lambda/layer_version_test.go b/internal/service/lambda/layer_version_test.go index f845b7a360b..7b7526fb06b 100644 --- a/internal/service/lambda/layer_version_test.go +++ b/internal/service/lambda/layer_version_test.go @@ -170,7 +170,7 @@ func TestAccLambdaLayerVersion_s3(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"s3_bucket", "s3_key", "skip_destroy"}, + ImportStateVerifyIgnore: []string{names.AttrS3Bucket, "s3_key", "skip_destroy"}, }, }, }) From 54c31618b6b7bfd04036b6adbac8e28c4bda07b9 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 48/78] lexmodels: Use constants for strings --- internal/service/lexmodels/intent.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/lexmodels/intent.go b/internal/service/lexmodels/intent.go index 90083f8aeee..e144479a3f2 100644 --- a/internal/service/lexmodels/intent.go +++ b/internal/service/lexmodels/intent.go @@ -562,7 +562,7 @@ var codeHookResource = &schema.Resource{ var messageResource = &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 1000), @@ -685,7 +685,7 @@ func expandFulfilmentActivity(rawObject interface{}) (activity *lexmodelbuilding func flattenMessages(messages []*lexmodelbuildingservice.Message) (flattenedMessages []map[string]interface{}) { for _, message := range messages { flattenedMessages = append(flattenedMessages, map[string]interface{}{ - "content": aws.StringValue(message.Content), + names.AttrContent: aws.StringValue(message.Content), names.AttrContentType: aws.StringValue(message.ContentType), "group_number": aws.Int64Value(message.GroupNumber), }) @@ -707,7 +707,7 @@ func expandMessages(rawValues []interface{}) []*lexmodelbuildingservice.Message } message := &lexmodelbuildingservice.Message{ - Content: aws.String(value["content"].(string)), + Content: aws.String(value[names.AttrContent].(string)), ContentType: aws.String(value[names.AttrContentType].(string)), } From 717c749943cb1061b955e8f44835f2e93a640db8 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:01 -0400 Subject: [PATCH 49/78] lightsail: Use constants for strings --- internal/service/lightsail/lb.go | 4 ++-- internal/service/lightsail/lb_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/lightsail/lb.go b/internal/service/lightsail/lb.go index dd77e69e9be..79b791355e7 100644 --- a/internal/service/lightsail/lb.go +++ b/internal/service/lightsail/lb.go @@ -45,7 +45,7 @@ func ResourceLoadBalancer() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -151,7 +151,7 @@ func resourceLoadBalancerRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, lb.Arn) d.Set(names.AttrCreatedAt, lb.CreatedAt.Format(time.RFC3339)) - d.Set("dns_name", lb.DnsName) + d.Set(names.AttrDNSName, lb.DnsName) d.Set("health_check_path", lb.HealthCheckPath) d.Set("instance_port", lb.InstancePort) d.Set("ip_address_type", lb.IpAddressType) diff --git a/internal/service/lightsail/lb_test.go b/internal/service/lightsail/lb_test.go index 5384c498b43..74145b5e392 100644 --- a/internal/service/lightsail/lb_test.go +++ b/internal/service/lightsail/lb_test.go @@ -85,7 +85,7 @@ func testAccLoadBalancer_basic(t *testing.T) { testAccCheckLoadBalancerExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "health_check_path", "/"), resource.TestCheckResourceAttr(resourceName, "instance_port", "80"), - resource.TestCheckResourceAttrSet(resourceName, "dns_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDNSName), ), }, { From aebeaa313a7eed5e04295fb144b95f7f9234929b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 50/78] m2: Use constants for strings --- internal/service/m2/application.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/m2/application.go b/internal/service/m2/application.go index e9b1dc04948..10ed533b452 100644 --- a/internal/service/m2/application.go +++ b/internal/service/m2/application.go @@ -114,12 +114,12 @@ func (r *applicationResource) Schema(ctx context.Context, request resource.Schem }, NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "content": schema.StringAttribute{ + names.AttrContent: schema.StringAttribute{ Optional: true, Validators: []validator.String{ stringvalidator.LengthBetween(1, 65000), stringvalidator.ExactlyOneOf( - path.MatchRelative().AtParent().AtName("content"), + path.MatchRelative().AtParent().AtName(names.AttrContent), path.MatchRelative().AtParent().AtName("s3_location"), ), }, From e3611b73cca78c3bc6a1da2801288206489580fd Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 51/78] meta: Use constants for strings --- internal/service/meta/service_data_source.go | 2 +- internal/service/meta/service_data_source_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/meta/service_data_source.go b/internal/service/meta/service_data_source.go index 12f9f077173..c1582c415f6 100644 --- a/internal/service/meta/service_data_source.go +++ b/internal/service/meta/service_data_source.go @@ -38,7 +38,7 @@ func (d *dataSourceService) Metadata(_ context.Context, request datasource.Metad func (d *dataSourceService) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ Attributes: map[string]schema.Attribute{ - "dns_name": schema.StringAttribute{ + names.AttrDNSName: schema.StringAttribute{ Optional: true, Computed: true, }, diff --git a/internal/service/meta/service_data_source_test.go b/internal/service/meta/service_data_source_test.go index fbb5e72327d..896cec37016 100644 --- a/internal/service/meta/service_data_source_test.go +++ b/internal/service/meta/service_data_source_test.go @@ -30,7 +30,7 @@ func TestAccMetaService_basic(t *testing.T) { { Config: testAccServiceDataSourceConfig_basic(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "dns_name", fmt.Sprintf("%s.%s.%s", ec2.EndpointsID, acctest.Region(), "amazonaws.com")), + resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", ec2.EndpointsID, acctest.Region(), "amazonaws.com")), resource.TestCheckResourceAttr(dataSourceName, "partition", acctest.Partition()), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "com.amazonaws"), resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, acctest.Region()), @@ -101,7 +101,7 @@ func TestAccMetaService_byParts(t *testing.T) { { Config: testAccServiceDataSourceConfig_byPart(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "dns_name", fmt.Sprintf("%s.%s.%s", s3.EndpointsID, acctest.Region(), "amazonaws.com")), + resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", s3.EndpointsID, acctest.Region(), "amazonaws.com")), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_name", fmt.Sprintf("%s.%s.%s", "com.amazonaws", acctest.Region(), s3.EndpointsID)), resource.TestCheckResourceAttr(dataSourceName, "supported", "true"), ), @@ -122,7 +122,7 @@ func TestAccMetaService_unsupported(t *testing.T) { { Config: testAccServiceDataSourceConfig_unsupported(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "dns_name", fmt.Sprintf("%s.%s.%s", waf.EndpointsID, endpoints.UsGovWest1RegionID, "amazonaws.com")), + resource.TestCheckResourceAttr(dataSourceName, names.AttrDNSName, fmt.Sprintf("%s.%s.%s", waf.EndpointsID, endpoints.UsGovWest1RegionID, "amazonaws.com")), resource.TestCheckResourceAttr(dataSourceName, "partition", endpoints.AwsUsGovPartitionID), resource.TestCheckResourceAttr(dataSourceName, "reverse_dns_prefix", "com.amazonaws"), resource.TestCheckResourceAttr(dataSourceName, names.AttrRegion, endpoints.UsGovWest1RegionID), From 191064f38a360133a04a6aeb0fe246e72f123fe6 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 52/78] mwaa: Use constants for strings --- internal/service/mwaa/environment.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/mwaa/environment.go b/internal/service/mwaa/environment.go index dfb685dab04..a088ccf1595 100644 --- a/internal/service/mwaa/environment.go +++ b/internal/service/mwaa/environment.go @@ -135,7 +135,7 @@ func ResourceEnvironment() *schema.Resource { }, }, }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, Optional: true, Computed: true, @@ -344,7 +344,7 @@ func resourceEnvironmentCreate(ctx context.Context, d *schema.ResourceData, meta input.KmsKey = aws.String(v.(string)) } - if v, ok := d.GetOk("logging_configuration"); ok { + if v, ok := d.GetOk(names.AttrLoggingConfiguration); ok { input.LoggingConfiguration = expandEnvironmentLoggingConfiguration(v.([]interface{})) } @@ -446,7 +446,7 @@ func resourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta i if err := d.Set("last_updated", flattenLastUpdate(environment.LastUpdate)); err != nil { return sdkdiag.AppendErrorf(diags, "setting last_updated: %s", err) } - if err := d.Set("logging_configuration", flattenLoggingConfiguration(environment.LoggingConfiguration)); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, flattenLoggingConfiguration(environment.LoggingConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting logging_configuration: %s", err) } d.Set("max_workers", environment.MaxWorkers) @@ -510,8 +510,8 @@ func resourceEnvironmentUpdate(ctx context.Context, d *schema.ResourceData, meta input.ExecutionRoleArn = aws.String(d.Get(names.AttrExecutionRoleARN).(string)) } - if d.HasChange("logging_configuration") { - input.LoggingConfiguration = expandEnvironmentLoggingConfiguration(d.Get("logging_configuration").([]interface{})) + if d.HasChange(names.AttrLoggingConfiguration) { + input.LoggingConfiguration = expandEnvironmentLoggingConfiguration(d.Get(names.AttrLoggingConfiguration).([]interface{})) } if d.HasChange("max_workers") { From c2f0f0fc88cb746d263c8b71a0bbd4c12308ac8d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 53/78] networkfirewall: Use constants for strings --- .../service/networkfirewall/logging_configuration.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/service/networkfirewall/logging_configuration.go b/internal/service/networkfirewall/logging_configuration.go index c3287f18ef0..5844aa053ff 100644 --- a/internal/service/networkfirewall/logging_configuration.go +++ b/internal/service/networkfirewall/logging_configuration.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_networkfirewall_logging_configuration") @@ -37,7 +38,7 @@ func ResourceLoggingConfiguration() *schema.Resource { Required: true, ForceNew: true, }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -84,7 +85,7 @@ func resourceLoggingConfigurationCreate(ctx context.Context, d *schema.ResourceD log.Printf("[DEBUG] Adding Logging Configuration to NetworkFirewall Firewall: %s", firewallArn) - loggingConfigs := expandLoggingConfiguration(d.Get("logging_configuration").([]interface{})) + loggingConfigs := expandLoggingConfiguration(d.Get(names.AttrLoggingConfiguration).([]interface{})) // cumulatively add the configured "log_destination_config" in "logging_configuration" err := putLoggingConfiguration(ctx, conn, firewallArn, loggingConfigs) if err != nil { @@ -120,7 +121,7 @@ func resourceLoggingConfigurationRead(ctx context.Context, d *schema.ResourceDat d.Set("firewall_arn", output.FirewallArn) - if err := d.Set("logging_configuration", flattenLoggingConfiguration(output.LoggingConfiguration)); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, flattenLoggingConfiguration(output.LoggingConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting logging_configuration: %s", err) } @@ -134,7 +135,7 @@ func resourceLoggingConfigurationUpdate(ctx context.Context, d *schema.ResourceD log.Printf("[DEBUG] Updating Logging Configuration for NetworkFirewall Firewall: %s", d.Id()) - o, n := d.GetChange("logging_configuration") + o, n := d.GetChange(names.AttrLoggingConfiguration) // Remove destination configs one by one, if any if oldConfig := o.([]interface{}); len(oldConfig) != 0 && oldConfig[0] != nil { loggingConfig := expandLoggingConfigurationOnUpdate(oldConfig) @@ -147,7 +148,7 @@ func resourceLoggingConfigurationUpdate(ctx context.Context, d *schema.ResourceD } // Only send new LoggingConfiguration with content if newConfig := n.([]interface{}); len(newConfig) != 0 && newConfig[0] != nil { - loggingConfigs := expandLoggingConfiguration(d.Get("logging_configuration").([]interface{})) + loggingConfigs := expandLoggingConfiguration(d.Get(names.AttrLoggingConfiguration).([]interface{})) // cumulatively add the configured "log_destination_config" in "logging_configuration" err := putLoggingConfiguration(ctx, conn, d.Id(), loggingConfigs) if err != nil { From 112c77a44a1f2071f3dd4b0c38c4ecf24159ac5f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 54/78] opensearch: Use constants for strings --- internal/service/opensearch/domain.go | 2 +- internal/service/opensearch/domain_data_source.go | 2 +- internal/service/opensearch/domain_structure.go | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/opensearch/domain.go b/internal/service/opensearch/domain.go index ceb96499bf4..badc1b4ab08 100644 --- a/internal/service/opensearch/domain.go +++ b/internal/service/opensearch/domain.go @@ -189,7 +189,7 @@ func ResourceDomain() *schema.Resource { Type: schema.TypeString, Required: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeList, Required: true, MaxItems: 1, diff --git a/internal/service/opensearch/domain_data_source.go b/internal/service/opensearch/domain_data_source.go index 069f1348b8a..1b77c8818b2 100644 --- a/internal/service/opensearch/domain_data_source.go +++ b/internal/service/opensearch/domain_data_source.go @@ -75,7 +75,7 @@ func DataSourceDomain() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ diff --git a/internal/service/opensearch/domain_structure.go b/internal/service/opensearch/domain_structure.go index d7630622bf5..61f9820c1c3 100644 --- a/internal/service/opensearch/domain_structure.go +++ b/internal/service/opensearch/domain_structure.go @@ -103,7 +103,7 @@ func expandAutoTuneMaintenanceSchedules(tfList []interface{}) []*opensearchservi startAt, _ := time.Parse(time.RFC3339, tfMap["start_at"].(string)) autoTuneMaintenanceSchedule.StartAt = aws.Time(startAt) - if v, ok := tfMap["duration"].([]interface{}); ok { + if v, ok := tfMap[names.AttrDuration].([]interface{}); ok { autoTuneMaintenanceSchedule.Duration = expandAutoTuneMaintenanceScheduleDuration(v[0].(map[string]interface{})) } @@ -280,7 +280,7 @@ func flattenAutoTuneMaintenanceSchedules(autoTuneMaintenanceSchedules []*opensea m["start_at"] = aws.TimeValue(autoTuneMaintenanceSchedule.StartAt).Format(time.RFC3339) - m["duration"] = []interface{}{flattenAutoTuneMaintenanceScheduleDuration(autoTuneMaintenanceSchedule.Duration)} + m[names.AttrDuration] = []interface{}{flattenAutoTuneMaintenanceScheduleDuration(autoTuneMaintenanceSchedule.Duration)} m["cron_expression_for_recurrence"] = aws.StringValue(autoTuneMaintenanceSchedule.CronExpressionForRecurrence) From db79983ece76b408557ee90b2bbef365600935f9 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:02 -0400 Subject: [PATCH 55/78] organizations: Use constants for strings --- internal/service/organizations/policy.go | 10 +++++----- internal/service/organizations/policy_data_source.go | 4 ++-- .../service/organizations/policy_data_source_test.go | 2 +- internal/service/organizations/policy_test.go | 6 +++--- internal/service/organizations/resource_policy.go | 10 +++++----- internal/service/organizations/resource_policy_test.go | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/service/organizations/policy.go b/internal/service/organizations/policy.go index 718dc0832cd..2a7bca0d268 100644 --- a/internal/service/organizations/policy.go +++ b/internal/service/organizations/policy.go @@ -41,7 +41,7 @@ func ResourcePolicy() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs, @@ -79,7 +79,7 @@ func resourcePolicyCreate(ctx context.Context, d *schema.ResourceData, meta inte name := d.Get(names.AttrName).(string) input := &organizations.CreatePolicyInput{ - Content: aws.String(d.Get("content").(string)), + Content: aws.String(d.Get(names.AttrContent).(string)), Description: aws.String(d.Get(names.AttrDescription).(string)), Name: aws.String(name), Type: aws.String(d.Get(names.AttrType).(string)), @@ -116,7 +116,7 @@ func resourcePolicyRead(ctx context.Context, d *schema.ResourceData, meta interf policySummary := policy.PolicySummary d.Set(names.AttrARN, policySummary.Arn) - d.Set("content", policy.Content) + d.Set(names.AttrContent, policy.Content) d.Set(names.AttrDescription, policySummary.Description) d.Set(names.AttrName, policySummary.Name) d.Set(names.AttrType, policySummary.Type) @@ -142,8 +142,8 @@ func resourcePolicyUpdate(ctx context.Context, d *schema.ResourceData, meta inte PolicyId: aws.String(d.Id()), } - if d.HasChange("content") { - input.Content = aws.String(d.Get("content").(string)) + if d.HasChange(names.AttrContent) { + input.Content = aws.String(d.Get(names.AttrContent).(string)) } if d.HasChange(names.AttrDescription) { diff --git a/internal/service/organizations/policy_data_source.go b/internal/service/organizations/policy_data_source.go index df58d974151..7bed6258ba3 100644 --- a/internal/service/organizations/policy_data_source.go +++ b/internal/service/organizations/policy_data_source.go @@ -28,7 +28,7 @@ func DataSourcePolicy() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -67,7 +67,7 @@ func dataSourcePolicyRead(ctx context.Context, d *schema.ResourceData, meta inte d.SetId(aws.StringValue(policySummary.Id)) d.Set(names.AttrARN, policySummary.Arn) d.Set("aws_managed", policySummary.AwsManaged) - d.Set("content", policy.Content) + d.Set(names.AttrContent, policy.Content) d.Set(names.AttrDescription, policySummary.Description) d.Set(names.AttrName, policySummary.Name) d.Set(names.AttrType, policySummary.Type) diff --git a/internal/service/organizations/policy_data_source_test.go b/internal/service/organizations/policy_data_source_test.go index efe32e99355..7f0bf487acb 100644 --- a/internal/service/organizations/policy_data_source_test.go +++ b/internal/service/organizations/policy_data_source_test.go @@ -32,7 +32,7 @@ func testAccPolicyDataSource_UnattachedPolicy(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(resourceName, names.AttrID, dataSourceName, "policy_id"), resource.TestCheckResourceAttrPair(resourceName, names.AttrARN, dataSourceName, names.AttrARN), - resource.TestCheckResourceAttrPair(resourceName, "content", dataSourceName, "content"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrContent, dataSourceName, names.AttrContent), resource.TestCheckResourceAttrPair(resourceName, names.AttrType, dataSourceName, names.AttrType), resource.TestCheckResourceAttrPair(resourceName, names.AttrName, dataSourceName, names.AttrName), ), diff --git a/internal/service/organizations/policy_test.go b/internal/service/organizations/policy_test.go index c5b9caaf2ff..1606be38833 100644 --- a/internal/service/organizations/policy_test.go +++ b/internal/service/organizations/policy_test.go @@ -42,7 +42,7 @@ func testAccPolicy_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPolicyExists(ctx, resourceName, &policy), acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "organizations", regexache.MustCompile("policy/o-.+/service_control_policy/p-.+$")), - resource.TestCheckResourceAttr(resourceName, "content", content1), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content1), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrType, organizations.PolicyTypeServiceControlPolicy), @@ -52,7 +52,7 @@ func testAccPolicy_basic(t *testing.T) { Config: testAccPolicyConfig_required(rName, content2), Check: resource.ComposeTestCheckFunc( testAccCheckPolicyExists(ctx, resourceName, &policy), - resource.TestCheckResourceAttr(resourceName, "content", content2), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content2), ), }, { @@ -197,7 +197,7 @@ func testAccPolicy_skipDestroy(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPolicyExists(ctx, resourceName, &policy), acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "organizations", regexache.MustCompile("policy/o-.+/service_control_policy/p-.+$")), - resource.TestCheckResourceAttr(resourceName, "content", content), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "skip_destroy", "true"), diff --git a/internal/service/organizations/resource_policy.go b/internal/service/organizations/resource_policy.go index b132623c06e..e0e20b49cfe 100644 --- a/internal/service/organizations/resource_policy.go +++ b/internal/service/organizations/resource_policy.go @@ -42,7 +42,7 @@ func ResourceResourcePolicy() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringIsJSON, @@ -65,7 +65,7 @@ func resourceResourcePolicyCreate(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).OrganizationsConn(ctx) - policy, err := structure.NormalizeJsonString(d.Get("content").(string)) + policy, err := structure.NormalizeJsonString(d.Get(names.AttrContent).(string)) if err != nil { return sdkdiag.AppendFromErr(diags, err) } @@ -105,10 +105,10 @@ func resourceResourcePolicyRead(ctx context.Context, d *schema.ResourceData, met } d.Set(names.AttrARN, policy.ResourcePolicySummary.Arn) - if policyToSet, err := verify.PolicyToSet(d.Get("content").(string), aws.StringValue(policy.Content)); err != nil { + if policyToSet, err := verify.PolicyToSet(d.Get(names.AttrContent).(string), aws.StringValue(policy.Content)); err != nil { return sdkdiag.AppendFromErr(diags, err) } else { - d.Set("content", policyToSet) + d.Set(names.AttrContent, policyToSet) } return diags @@ -119,7 +119,7 @@ func resourceResourcePolicyUpdate(ctx context.Context, d *schema.ResourceData, m conn := meta.(*conns.AWSClient).OrganizationsConn(ctx) if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { - policy, err := structure.NormalizeJsonString(d.Get("content").(string)) + policy, err := structure.NormalizeJsonString(d.Get(names.AttrContent).(string)) if err != nil { return sdkdiag.AppendFromErr(diags, err) } diff --git a/internal/service/organizations/resource_policy_test.go b/internal/service/organizations/resource_policy_test.go index 8ca879fccad..1e730ab015a 100644 --- a/internal/service/organizations/resource_policy_test.go +++ b/internal/service/organizations/resource_policy_test.go @@ -39,7 +39,7 @@ func testAccResourcePolicy_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckResourcePolicyExists(ctx, resourceName, &policy), acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "organizations", regexache.MustCompile("resourcepolicy/o-.+/rp-.+$")), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, From badb13ee5ee46a24d621d29f8eb8bff473c613cf Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:03 -0400 Subject: [PATCH 56/78] pipes: Use constants for strings --- internal/service/pipes/source_parameters.go | 6 +++--- internal/service/pipes/target_parameters.go | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/service/pipes/source_parameters.go b/internal/service/pipes/source_parameters.go index a0cd18ef05c..46b51d7fbbe 100644 --- a/internal/service/pipes/source_parameters.go +++ b/internal/service/pipes/source_parameters.go @@ -510,7 +510,7 @@ func sourceParametersSchema() *schema.Schema { ), }, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Optional: true, MaxItems: 16, @@ -1212,7 +1212,7 @@ func expandSelfManagedKafkaAccessConfigurationVPC(tfMap map[string]interface{}) apiObject.SecurityGroup = flex.ExpandStringValueSet(v) } - if v, ok := tfMap["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { apiObject.Subnets = flex.ExpandStringValueSet(v) } @@ -1643,7 +1643,7 @@ func flattenSelfManagedKafkaAccessConfigurationVPC(apiObject *types.SelfManagedK } if v := apiObject.Subnets; v != nil { - tfMap["subnets"] = v + tfMap[names.AttrSubnets] = v } return tfMap diff --git a/internal/service/pipes/target_parameters.go b/internal/service/pipes/target_parameters.go index 549f1c76a08..e022052fb16 100644 --- a/internal/service/pipes/target_parameters.go +++ b/internal/service/pipes/target_parameters.go @@ -225,7 +225,7 @@ func targetParametersSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(0, 1000), @@ -280,7 +280,7 @@ func targetParametersSchema() *schema.Schema { ), }, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Optional: true, MaxItems: 16, @@ -674,7 +674,7 @@ func targetParametersSchema() *schema.Schema { }, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 64), @@ -1201,7 +1201,7 @@ func expandCapacityProviderStrategyItem(tfMap map[string]interface{}) *types.Cap apiObject.CapacityProvider = aws.String(v) } - if v, ok := tfMap["weight"].(int); ok { + if v, ok := tfMap[names.AttrWeight].(int); ok { apiObject.Weight = int32(v) } @@ -1263,7 +1263,7 @@ func expandVPCConfiguration(tfMap map[string]interface{}) *types.AwsVpcConfigura apiObject.SecurityGroups = flex.ExpandStringValueSet(v) } - if v, ok := tfMap["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { apiObject.Subnets = flex.ExpandStringValueSet(v) } @@ -1741,7 +1741,7 @@ func expandPipeTargetRedshiftDataParameters(tfMap map[string]interface{}) *types apiObject := &types.PipeTargetRedshiftDataParameters{} - if v, ok := tfMap["database"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrDatabase].(string); ok && v != "" { apiObject.Database = aws.String(v) } @@ -2183,8 +2183,8 @@ func flattenPipeTargetECSTaskParameters(apiObject *types.PipeTargetEcsTaskParame func flattenCapacityProviderStrategyItem(apiObject types.CapacityProviderStrategyItem) map[string]interface{} { tfMap := map[string]interface{}{ - "base": apiObject.Base, - "weight": apiObject.Weight, + "base": apiObject.Base, + names.AttrWeight: apiObject.Weight, } if v := apiObject.CapacityProvider; v != nil { @@ -2452,7 +2452,7 @@ func flattenVPCConfiguration(apiObject *types.AwsVpcConfiguration) map[string]in } if v := apiObject.Subnets; v != nil { - tfMap["subnets"] = v + tfMap[names.AttrSubnets] = v } return tfMap @@ -2604,7 +2604,7 @@ func flattenPipeTargetRedshiftDataParameters(apiObject *types.PipeTargetRedshift } if v := apiObject.Database; v != nil { - tfMap["database"] = aws.ToString(v) + tfMap[names.AttrDatabase] = aws.ToString(v) } if v := apiObject.DbUser; v != nil { From 4756751acacaec409493e6878842c7efe02ec18e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:03 -0400 Subject: [PATCH 57/78] quicksight: Use constants for strings --- internal/service/quicksight/data_set.go | 6 +- .../quicksight/data_set_data_source.go | 2 +- internal/service/quicksight/data_source.go | 114 +++++++++--------- .../service/quicksight/schema/analysis.go | 2 +- .../service/quicksight/schema/dashboard.go | 2 +- .../service/quicksight/schema/template.go | 4 +- .../quicksight/schema/template_sheet.go | 10 +- .../schema/visual_sankey_diagram.go | 6 +- .../service/quicksight/schema/visual_table.go | 6 +- 9 files changed, 76 insertions(+), 76 deletions(-) diff --git a/internal/service/quicksight/data_set.go b/internal/service/quicksight/data_set.go index 51383720e65..6a3c2ccb2c4 100644 --- a/internal/service/quicksight/data_set.go +++ b/internal/service/quicksight/data_set.go @@ -753,7 +753,7 @@ func physicalTableMapSchema() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 64), }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Optional: true, }, @@ -1760,7 +1760,7 @@ func expandDataSetRelationalTable(tfMap map[string]interface{}) *quicksight.Rela if v, ok := tfMap[names.AttrName].(string); ok { relationalTable.Name = aws.String(v) } - if v, ok := tfMap["schema"].(string); ok { + if v, ok := tfMap[names.AttrSchema].(string); ok { relationalTable.Schema = aws.String(v) } @@ -2517,7 +2517,7 @@ func flattenRelationalTable(apiObject *quicksight.RelationalTable) []interface{} tfMap[names.AttrName] = aws.StringValue(apiObject.Name) } if apiObject.Schema != nil { - tfMap["schema"] = aws.StringValue(apiObject.Schema) + tfMap[names.AttrSchema] = aws.StringValue(apiObject.Schema) } return []interface{}{tfMap} diff --git a/internal/service/quicksight/data_set_data_source.go b/internal/service/quicksight/data_set_data_source.go index dec3736cdde..e4163b53e33 100644 --- a/internal/service/quicksight/data_set_data_source.go +++ b/internal/service/quicksight/data_set_data_source.go @@ -543,7 +543,7 @@ func physicalTableMapDataSourceSchema() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "schema": { + names.AttrSchema: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/quicksight/data_source.go b/internal/service/quicksight/data_source.go index b6e8483f024..f64c078a97e 100644 --- a/internal/service/quicksight/data_source.go +++ b/internal/service/quicksight/data_source.go @@ -121,7 +121,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -149,7 +149,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -173,7 +173,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -225,7 +225,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -249,7 +249,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -273,7 +273,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -297,7 +297,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -345,7 +345,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -369,7 +369,7 @@ func ResourceDataSource() *schema.Resource { Optional: true, ValidateFunc: validation.NoZeroValues, }, - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -433,7 +433,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -476,7 +476,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -500,7 +500,7 @@ func ResourceDataSource() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ValidateFunc: validation.NoZeroValues, @@ -894,7 +894,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.AmazonElasticsearchParameters{} - if v, ok := m["domain"].(string); ok && v != "" { + if v, ok := m[names.AttrDomain].(string); ok && v != "" { ps.Domain = aws.String(v) } @@ -920,7 +920,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.AuroraParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -939,7 +939,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.AuroraPostgreSqlParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -984,7 +984,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.MariaDbParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1003,7 +1003,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.MySqlParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1022,7 +1022,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.OracleParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1041,7 +1041,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.PostgreSqlParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1079,7 +1079,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.RdsParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m[names.AttrInstanceID].(string); ok && v != "" { @@ -1098,7 +1098,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if v, ok := m["cluster_id"].(string); ok && v != "" { ps.ClusterId = aws.String(v) } - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1157,7 +1157,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.SnowflakeParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1194,7 +1194,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.SqlServerParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1214,7 +1214,7 @@ func expandDataSourceParameters(tfList []interface{}) *quicksight.DataSourcePara if ok { ps := &quicksight.TeradataParameters{} - if v, ok := m["database"].(string); ok && v != "" { + if v, ok := m[names.AttrDatabase].(string); ok && v != "" { ps.Database = aws.String(v) } if v, ok := m["host"].(string); ok && v != "" { @@ -1298,7 +1298,7 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "amazon_elasticsearch": []interface{}{ map[string]interface{}{ - "domain": parameters.AmazonElasticsearchParameters.Domain, + names.AttrDomain: parameters.AmazonElasticsearchParameters.Domain, }, }, }) @@ -1318,9 +1318,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "aurora": []interface{}{ map[string]interface{}{ - "database": parameters.AuroraParameters.Database, - "host": parameters.AuroraParameters.Host, - names.AttrPort: parameters.AuroraParameters.Port, + names.AttrDatabase: parameters.AuroraParameters.Database, + "host": parameters.AuroraParameters.Host, + names.AttrPort: parameters.AuroraParameters.Port, }, }, }) @@ -1330,9 +1330,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "aurora_postgresql": []interface{}{ map[string]interface{}{ - "database": parameters.AuroraPostgreSqlParameters.Database, - "host": parameters.AuroraPostgreSqlParameters.Host, - names.AttrPort: parameters.AuroraPostgreSqlParameters.Port, + names.AttrDatabase: parameters.AuroraPostgreSqlParameters.Database, + "host": parameters.AuroraPostgreSqlParameters.Host, + names.AttrPort: parameters.AuroraPostgreSqlParameters.Port, }, }, }) @@ -1362,9 +1362,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "maria_db": []interface{}{ map[string]interface{}{ - "database": parameters.MariaDbParameters.Database, - "host": parameters.MariaDbParameters.Host, - names.AttrPort: parameters.MariaDbParameters.Port, + names.AttrDatabase: parameters.MariaDbParameters.Database, + "host": parameters.MariaDbParameters.Host, + names.AttrPort: parameters.MariaDbParameters.Port, }, }, }) @@ -1374,9 +1374,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "mysql": []interface{}{ map[string]interface{}{ - "database": parameters.MySqlParameters.Database, - "host": parameters.MySqlParameters.Host, - names.AttrPort: parameters.MySqlParameters.Port, + names.AttrDatabase: parameters.MySqlParameters.Database, + "host": parameters.MySqlParameters.Host, + names.AttrPort: parameters.MySqlParameters.Port, }, }, }) @@ -1386,9 +1386,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "oracle": []interface{}{ map[string]interface{}{ - "database": parameters.OracleParameters.Database, - "host": parameters.OracleParameters.Host, - names.AttrPort: parameters.OracleParameters.Port, + names.AttrDatabase: parameters.OracleParameters.Database, + "host": parameters.OracleParameters.Host, + names.AttrPort: parameters.OracleParameters.Port, }, }, }) @@ -1398,9 +1398,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "postgresql": []interface{}{ map[string]interface{}{ - "database": parameters.PostgreSqlParameters.Database, - "host": parameters.PostgreSqlParameters.Host, - names.AttrPort: parameters.PostgreSqlParameters.Port, + names.AttrDatabase: parameters.PostgreSqlParameters.Database, + "host": parameters.PostgreSqlParameters.Host, + names.AttrPort: parameters.PostgreSqlParameters.Port, }, }, }) @@ -1422,7 +1422,7 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "rds": []interface{}{ map[string]interface{}{ - "database": parameters.RdsParameters.Database, + names.AttrDatabase: parameters.RdsParameters.Database, names.AttrInstanceID: parameters.RdsParameters.InstanceId, }, }, @@ -1433,10 +1433,10 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "redshift": []interface{}{ map[string]interface{}{ - "cluster_id": parameters.RedshiftParameters.ClusterId, - "database": parameters.RedshiftParameters.Database, - "host": parameters.RedshiftParameters.Host, - names.AttrPort: parameters.RedshiftParameters.Port, + "cluster_id": parameters.RedshiftParameters.ClusterId, + names.AttrDatabase: parameters.RedshiftParameters.Database, + "host": parameters.RedshiftParameters.Host, + names.AttrPort: parameters.RedshiftParameters.Port, }, }, }) @@ -1471,9 +1471,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "snowflake": []interface{}{ map[string]interface{}{ - "database": parameters.SnowflakeParameters.Database, - "host": parameters.SnowflakeParameters.Host, - "warehouse": parameters.SnowflakeParameters.Warehouse, + names.AttrDatabase: parameters.SnowflakeParameters.Database, + "host": parameters.SnowflakeParameters.Host, + "warehouse": parameters.SnowflakeParameters.Warehouse, }, }, }) @@ -1494,9 +1494,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "sql_server": []interface{}{ map[string]interface{}{ - "database": parameters.SqlServerParameters.Database, - "host": parameters.SqlServerParameters.Host, - names.AttrPort: parameters.SqlServerParameters.Port, + names.AttrDatabase: parameters.SqlServerParameters.Database, + "host": parameters.SqlServerParameters.Host, + names.AttrPort: parameters.SqlServerParameters.Port, }, }, }) @@ -1506,9 +1506,9 @@ func flattenParameters(parameters *quicksight.DataSourceParameters) []interface{ params = append(params, map[string]interface{}{ "teradata": []interface{}{ map[string]interface{}{ - "database": parameters.TeradataParameters.Database, - "host": parameters.TeradataParameters.Host, - names.AttrPort: parameters.TeradataParameters.Port, + names.AttrDatabase: parameters.TeradataParameters.Database, + "host": parameters.TeradataParameters.Host, + names.AttrPort: parameters.TeradataParameters.Port, }, }, }) diff --git a/internal/service/quicksight/schema/analysis.go b/internal/service/quicksight/schema/analysis.go index fbbaa249c28..3c4c35526c1 100644 --- a/internal/service/quicksight/schema/analysis.go +++ b/internal/service/quicksight/schema/analysis.go @@ -97,7 +97,7 @@ func AnalysisDefinitionSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "sheet_text_box_id": idSchema(), - "content": stringSchema(false, validation.StringLenBetween(1, 150000)), + names.AttrContent: stringSchema(false, validation.StringLenBetween(1, 150000)), }, }, }, diff --git a/internal/service/quicksight/schema/dashboard.go b/internal/service/quicksight/schema/dashboard.go index c34d743a6e5..972f5af6a5d 100644 --- a/internal/service/quicksight/schema/dashboard.go +++ b/internal/service/quicksight/schema/dashboard.go @@ -97,7 +97,7 @@ func DashboardDefinitionSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "sheet_text_box_id": idSchema(), - "content": stringSchema(false, validation.StringLenBetween(1, 150000)), + names.AttrContent: stringSchema(false, validation.StringLenBetween(1, 150000)), }, }, }, diff --git a/internal/service/quicksight/schema/template.go b/internal/service/quicksight/schema/template.go index d530bf66e51..69afe8e81d4 100644 --- a/internal/service/quicksight/schema/template.go +++ b/internal/service/quicksight/schema/template.go @@ -98,7 +98,7 @@ func TemplateDefinitionSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "sheet_text_box_id": idSchema(), - "content": stringSchema(false, validation.StringLenBetween(1, 150000)), + names.AttrContent: stringSchema(false, validation.StringLenBetween(1, 150000)), }, }, }, @@ -1431,7 +1431,7 @@ func flattenTextBoxes(apiObject []*quicksight.SheetTextBox) []interface{} { "sheet_text_box_id": aws.StringValue(config.SheetTextBoxId), } if config.Content != nil { - tfMap["content"] = aws.StringValue(config.Content) + tfMap[names.AttrContent] = aws.StringValue(config.Content) } tfList = append(tfList, tfMap) } diff --git a/internal/service/quicksight/schema/template_sheet.go b/internal/service/quicksight/schema/template_sheet.go index 9e011263318..213c7ec3fef 100644 --- a/internal/service/quicksight/schema/template_sheet.go +++ b/internal/service/quicksight/schema/template_sheet.go @@ -262,7 +262,7 @@ func layoutSchema() *schema.Schema { MaxItems: 28, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BodySectionContent.html + names.AttrContent: { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_BodySectionContent.html Type: schema.TypeList, Required: true, MinItems: 1, @@ -1360,7 +1360,7 @@ func expandBodySectionConfiguration(tfMap map[string]interface{}) *quicksight.Bo if v, ok := tfMap["section_id"].(string); ok && v != "" { config.SectionId = aws.String(v) } - if v, ok := tfMap["content"].([]interface{}); ok && len(v) > 0 { + if v, ok := tfMap[names.AttrContent].([]interface{}); ok && len(v) > 0 { config.Content = expandBodySectionContent(v) } if v, ok := tfMap["page_break_configuration"].([]interface{}); ok && len(v) > 0 { @@ -1646,7 +1646,7 @@ func expandSheetTextBox(tfMap map[string]interface{}) *quicksight.SheetTextBox { if v, ok := tfMap["sheet_text_box_id"].(string); ok && v != "" { box.SheetTextBoxId = aws.String(v) } - if v, ok := tfMap["content"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrContent].(string); ok && v != "" { box.Content = aws.String(v) } @@ -2147,8 +2147,8 @@ func flattenBodySectionConfiguration(apiObject []*quicksight.BodySectionConfigur } tfMap := map[string]interface{}{ - "content": flattenBodySectionContent(config.Content), - "section_id": aws.StringValue(config.SectionId), + names.AttrContent: flattenBodySectionContent(config.Content), + "section_id": aws.StringValue(config.SectionId), } if config.PageBreakConfiguration != nil { tfMap["page_break_configuration"] = flattenSectionPageBreakConfiguration(config.PageBreakConfiguration) diff --git a/internal/service/quicksight/schema/visual_sankey_diagram.go b/internal/service/quicksight/schema/visual_sankey_diagram.go index 65969cb43ca..3ae87f115ce 100644 --- a/internal/service/quicksight/schema/visual_sankey_diagram.go +++ b/internal/service/quicksight/schema/visual_sankey_diagram.go @@ -45,7 +45,7 @@ func sankeyDiagramVisualSchema() *schema.Schema { Schema: map[string]*schema.Schema{ names.AttrDestination: dimensionFieldSchema(dimensionsFieldMaxItems200), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DimensionField.html names.AttrSource: dimensionFieldSchema(dimensionsFieldMaxItems200), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_DimensionField.html - "weight": measureFieldSchema(measureFieldsMaxItems200), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MeasureField.html + names.AttrWeight: measureFieldSchema(measureFieldsMaxItems200), // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_MeasureField.html }, }, }, @@ -169,7 +169,7 @@ func expandSankeyDiagramAggregatedFieldWells(tfList []interface{}) *quicksight.S if v, ok := tfMap[names.AttrSource].([]interface{}); ok && len(v) > 0 { config.Source = expandDimensionFields(v) } - if v, ok := tfMap["weight"].([]interface{}); ok && len(v) > 0 { + if v, ok := tfMap[names.AttrWeight].([]interface{}); ok && len(v) > 0 { config.Weight = expandMeasureFields(v) } @@ -270,7 +270,7 @@ func flattenSankeyDiagramAggregatedFieldWells(apiObject *quicksight.SankeyDiagra tfMap[names.AttrSource] = flattenDimensionFields(apiObject.Source) } if apiObject.Weight != nil { - tfMap["weight"] = flattenMeasureFields(apiObject.Weight) + tfMap[names.AttrWeight] = flattenMeasureFields(apiObject.Weight) } return []interface{}{tfMap} diff --git a/internal/service/quicksight/schema/visual_table.go b/internal/service/quicksight/schema/visual_table.go index 29552e67eab..b86757cc172 100644 --- a/internal/service/quicksight/schema/visual_table.go +++ b/internal/service/quicksight/schema/visual_table.go @@ -89,7 +89,7 @@ func tableVisualSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TableFieldLinkContentConfiguration.html + names.AttrContent: { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_TableFieldLinkContentConfiguration.html Type: schema.TypeList, Optional: true, MinItems: 1, @@ -681,7 +681,7 @@ func expandTableFieldLinkConfiguration(tfList []interface{}) *quicksight.TableFi if v, ok := tfMap[names.AttrTarget].(string); ok && v != "" { options.Target = aws.String(v) } - if v, ok := tfMap["content"].([]interface{}); ok && len(v) > 0 { + if v, ok := tfMap[names.AttrContent].([]interface{}); ok && len(v) > 0 { options.Content = expandTableFieldLinkContentConfiguration(v) } @@ -1153,7 +1153,7 @@ func flattenTableFieldLinkConfiguration(apiObject *quicksight.TableFieldLinkConf tfMap := map[string]interface{}{} if apiObject.Content != nil { - tfMap["content"] = flattenTableFieldLinkContentConfiguration(apiObject.Content) + tfMap[names.AttrContent] = flattenTableFieldLinkContentConfiguration(apiObject.Content) } if apiObject.Target != nil { tfMap[names.AttrTarget] = aws.StringValue(apiObject.Target) From d178d4ea544f8750bfe7c289044278f16f2f64e8 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:03 -0400 Subject: [PATCH 58/78] rds: Use constants for strings --- internal/service/rds/cluster.go | 18 +++++++------- internal/service/rds/cluster_test.go | 4 ++-- internal/service/rds/export_task_test.go | 2 +- internal/service/rds/instance.go | 24 +++++++++---------- internal/service/rds/instance_migrate.go | 4 ++-- internal/service/rds/instance_test.go | 6 ++--- internal/service/rds/reserved_instance.go | 4 ++-- .../reserved_instance_offering_data_source.go | 6 ++--- ...rved_instance_offering_data_source_test.go | 2 +- .../service/rds/reserved_instance_test.go | 2 +- 10 files changed, 36 insertions(+), 36 deletions(-) diff --git a/internal/service/rds/cluster.go b/internal/service/rds/cluster.go index e727d09cb6a..5ee17cd16a6 100644 --- a/internal/service/rds/cluster.go +++ b/internal/service/rds/cluster.go @@ -175,7 +175,7 @@ func ResourceCluster() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, }, @@ -627,7 +627,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int input.DBSubnetGroupName = aws.String(v.(string)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -753,7 +753,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int input.DBSubnetGroupName = aws.String(v.(string)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -877,7 +877,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int input.DBSubnetGroupName = aws.String(v.(string)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -1003,7 +1003,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int input.DBSystemId = aws.String(v.(string)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -1195,10 +1195,10 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("deletion_protection", dbc.DeletionProtection) if len(dbc.DomainMemberships) > 0 && dbc.DomainMemberships[0] != nil { domainMembership := dbc.DomainMemberships[0] - d.Set("domain", domainMembership.Domain) + d.Set(names.AttrDomain, domainMembership.Domain) d.Set("domain_iam_role_name", domainMembership.IAMRoleName) } else { - d.Set("domain", nil) + d.Set(names.AttrDomain, nil) d.Set("domain_iam_role_name", nil) } d.Set("enabled_cloudwatch_logs_exports", aws.StringValueSlice(dbc.EnabledCloudwatchLogsExports)) @@ -1343,8 +1343,8 @@ func resourceClusterUpdate(ctx context.Context, d *schema.ResourceData, meta int input.DeletionProtection = aws.Bool(d.Get("deletion_protection").(bool)) } - if d.HasChanges("domain", "domain_iam_role_name") { - input.Domain = aws.String(d.Get("domain").(string)) + if d.HasChanges(names.AttrDomain, "domain_iam_role_name") { + input.Domain = aws.String(d.Get(names.AttrDomain).(string)) input.DomainIAMRoleName = aws.String(d.Get("domain_iam_role_name").(string)) } diff --git a/internal/service/rds/cluster_test.go b/internal/service/rds/cluster_test.go index 1bc60288945..12ad4373c93 100644 --- a/internal/service/rds/cluster_test.go +++ b/internal/service/rds/cluster_test.go @@ -84,7 +84,7 @@ func TestAccRDSCluster_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "db_cluster_parameter_group_name"), resource.TestCheckResourceAttr(resourceName, "db_system_id", ""), resource.TestCheckResourceAttr(resourceName, "delete_automated_backups", "true"), - resource.TestCheckResourceAttr(resourceName, "domain", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, ""), resource.TestCheckResourceAttr(resourceName, "domain_iam_role_name", ""), resource.TestCheckResourceAttr(resourceName, "enabled_cloudwatch_logs_exports.#", "0"), resource.TestCheckResourceAttr(resourceName, "engine", tfrds.ClusterEngineAuroraMySQL), @@ -930,7 +930,7 @@ func TestAccRDSCluster_domain(t *testing.T) { Config: testAccClusterConfig_domain(rName, domain), Check: resource.ComposeTestCheckFunc( testAccCheckClusterExists(ctx, resourceName, &dbCluster), - resource.TestCheckResourceAttrSet(resourceName, "domain"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDomain), resource.TestCheckResourceAttrSet(resourceName, "domain_iam_role_name"), ), }, diff --git a/internal/service/rds/export_task_test.go b/internal/service/rds/export_task_test.go index 6da8363b80b..ecb94c5d71e 100644 --- a/internal/service/rds/export_task_test.go +++ b/internal/service/rds/export_task_test.go @@ -86,7 +86,7 @@ func TestAccRDSExportTask_optional(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "iam_role_arn", "aws_iam_role.test", names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, names.AttrKMSKeyID, "aws_kms_key.test", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "export_only.#", "1"), - resource.TestCheckResourceAttr(resourceName, "export_only.0", "database"), + resource.TestCheckResourceAttr(resourceName, "export_only.0", names.AttrDatabase), resource.TestCheckResourceAttr(resourceName, "s3_prefix", s3Prefix), ), }, diff --git a/internal/service/rds/instance.go b/internal/service/rds/instance.go index 096153d4176..8bc2b1e72a4 100644 --- a/internal/service/rds/instance.go +++ b/internal/service/rds/instance.go @@ -246,7 +246,7 @@ func ResourceInstance() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"domain_fqdn", "domain_ou", "domain_auth_secret_arn", "domain_dns_ips"}, @@ -255,7 +255,7 @@ func ResourceInstance() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateFunc: verify.ValidARN, - ConflictsWith: []string{"domain", "domain_iam_role_name"}, + ConflictsWith: []string{names.AttrDomain, "domain_iam_role_name"}, }, "domain_dns_ips": { Type: schema.TypeSet, @@ -266,13 +266,13 @@ func ResourceInstance() *schema.Resource { Type: schema.TypeString, ValidateFunc: validation.IsIPAddress, }, - ConflictsWith: []string{"domain", "domain_iam_role_name"}, + ConflictsWith: []string{names.AttrDomain, "domain_iam_role_name"}, }, "domain_fqdn": { Type: schema.TypeString, Optional: true, Computed: true, - ConflictsWith: []string{"domain", "domain_iam_role_name"}, + ConflictsWith: []string{names.AttrDomain, "domain_iam_role_name"}, }, "domain_iam_role_name": { Type: schema.TypeString, @@ -282,7 +282,7 @@ func ResourceInstance() *schema.Resource { "domain_ou": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"domain", "domain_iam_role_name"}, + ConflictsWith: []string{names.AttrDomain, "domain_iam_role_name"}, }, "enabled_cloudwatch_logs_exports": { Type: schema.TypeSet, @@ -1177,7 +1177,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in input.DedicatedLogVolume = aws.Bool(v.(bool)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -1422,7 +1422,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in input.DedicatedLogVolume = aws.Bool(v.(bool)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -1610,7 +1610,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in input.DedicatedLogVolume = aws.Bool(v.(bool)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -1853,14 +1853,14 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("deletion_protection", v.DeletionProtection) if len(v.DomainMemberships) > 0 && v.DomainMemberships[0] != nil { v := v.DomainMemberships[0] - d.Set("domain", v.Domain) + d.Set(names.AttrDomain, v.Domain) d.Set("domain_auth_secret_arn", v.AuthSecretArn) d.Set("domain_dns_ips", aws.StringValueSlice(v.DnsIps)) d.Set("domain_fqdn", v.FQDN) d.Set("domain_iam_role_name", v.IAMRoleName) d.Set("domain_ou", v.OU) } else { - d.Set("domain", nil) + d.Set(names.AttrDomain, nil) d.Set("domain_auth_secret_arn", nil) d.Set("domain_dns_ips", nil) d.Set("domain_fqdn", nil) @@ -2247,9 +2247,9 @@ func dbInstancePopulateModify(input *rds_sdkv2.ModifyDBInstanceInput, d *schema. input.DeletionProtection = aws.Bool(d.Get("deletion_protection").(bool)) // "InvalidParameterCombination: Specify the parameters for either AWS Managed Active Directory or self-managed Active Directory". - if d.HasChanges("domain", "domain_iam_role_name") { + if d.HasChanges(names.AttrDomain, "domain_iam_role_name") { needsModify = true - input.Domain = aws.String(d.Get("domain").(string)) + input.Domain = aws.String(d.Get(names.AttrDomain).(string)) input.DomainIAMRoleName = aws.String(d.Get("domain_iam_role_name").(string)) } else if d.HasChanges("domain_auth_secret_arn", "domain_dns_ips", "domain_fqdn", "domain_ou") { needsModify = true diff --git a/internal/service/rds/instance_migrate.go b/internal/service/rds/instance_migrate.go index cd46f0edb18..16e727a2c9a 100644 --- a/internal/service/rds/instance_migrate.go +++ b/internal/service/rds/instance_migrate.go @@ -358,7 +358,7 @@ func resourceInstanceResourceV0() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, }, @@ -535,7 +535,7 @@ func resourceInstanceResourceV1() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, }, diff --git a/internal/service/rds/instance_test.go b/internal/service/rds/instance_test.go index f39ed04218b..d00e1f968c9 100644 --- a/internal/service/rds/instance_test.go +++ b/internal/service/rds/instance_test.go @@ -3793,7 +3793,7 @@ func TestAccRDSInstance_MSSQL_domain(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &vBefore), testAccCheckInstanceDomainAttributes(domain1, &vBefore), - resource.TestCheckResourceAttrSet(resourceName, "domain"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDomain), resource.TestCheckResourceAttrSet(resourceName, "domain_iam_role_name"), ), }, @@ -3802,7 +3802,7 @@ func TestAccRDSInstance_MSSQL_domain(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckInstanceExists(ctx, resourceName, &vAfter), testAccCheckInstanceDomainAttributes(domain2, &vAfter), - resource.TestCheckResourceAttrSet(resourceName, "domain"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDomain), resource.TestCheckResourceAttrSet(resourceName, "domain_iam_role_name"), ), }, @@ -3834,7 +3834,7 @@ func TestAccRDSInstance_MSSQL_domainSnapshotRestore(t *testing.T) { testAccCheckInstanceExists(ctx, resourceName, &vRestoredInstance), testAccCheckInstanceExists(ctx, originResourceName, &v), testAccCheckInstanceDomainAttributes(domain, &vRestoredInstance), - resource.TestCheckResourceAttrSet(resourceName, "domain"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrDomain), resource.TestCheckResourceAttrSet(resourceName, "domain_iam_role_name"), ), }, diff --git a/internal/service/rds/reserved_instance.go b/internal/service/rds/reserved_instance.go index 20c1c791271..fecdc435d24 100644 --- a/internal/service/rds/reserved_instance.go +++ b/internal/service/rds/reserved_instance.go @@ -55,7 +55,7 @@ func ResourceReservedInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Computed: true, }, @@ -179,7 +179,7 @@ func resourceReservedInstanceRead(ctx context.Context, d *schema.ResourceData, m d.Set(names.AttrARN, reservation.ReservedDBInstanceArn) d.Set("currency_code", reservation.CurrencyCode) d.Set("db_instance_class", reservation.DBInstanceClass) - d.Set("duration", reservation.Duration) + d.Set(names.AttrDuration, reservation.Duration) d.Set("fixed_price", reservation.FixedPrice) d.Set("instance_count", reservation.DBInstanceCount) d.Set("lease_id", reservation.LeaseId) diff --git a/internal/service/rds/reserved_instance_offering_data_source.go b/internal/service/rds/reserved_instance_offering_data_source.go index 8d78380f774..d002939c321 100644 --- a/internal/service/rds/reserved_instance_offering_data_source.go +++ b/internal/service/rds/reserved_instance_offering_data_source.go @@ -34,7 +34,7 @@ func DataSourceReservedOffering() *schema.Resource { Type: schema.TypeString, Required: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Required: true, }, @@ -72,7 +72,7 @@ func dataSourceReservedOfferingRead(ctx context.Context, d *schema.ResourceData, input := &rds.DescribeReservedDBInstancesOfferingsInput{ DBInstanceClass: aws.String(d.Get("db_instance_class").(string)), - Duration: aws.String(fmt.Sprint(d.Get("duration").(int))), + Duration: aws.String(fmt.Sprint(d.Get(names.AttrDuration).(int))), MultiAZ: aws.Bool(d.Get("multi_az").(bool)), OfferingType: aws.String(d.Get("offering_type").(string)), ProductDescription: aws.String(d.Get("product_description").(string)), @@ -96,7 +96,7 @@ func dataSourceReservedOfferingRead(ctx context.Context, d *schema.ResourceData, d.SetId(aws.ToString(offering.ReservedDBInstancesOfferingId)) d.Set("currency_code", offering.CurrencyCode) d.Set("db_instance_class", offering.DBInstanceClass) - d.Set("duration", offering.Duration) + d.Set(names.AttrDuration, offering.Duration) d.Set("fixed_price", offering.FixedPrice) d.Set("multi_az", offering.MultiAZ) d.Set("offering_type", offering.OfferingType) diff --git a/internal/service/rds/reserved_instance_offering_data_source_test.go b/internal/service/rds/reserved_instance_offering_data_source_test.go index 3381859ff33..71cfc832253 100644 --- a/internal/service/rds/reserved_instance_offering_data_source_test.go +++ b/internal/service/rds/reserved_instance_offering_data_source_test.go @@ -26,7 +26,7 @@ func TestAccRDSInstanceOffering_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet(dataSourceName, "currency_code"), resource.TestCheckResourceAttr(dataSourceName, "db_instance_class", "db.t2.micro"), - resource.TestCheckResourceAttr(dataSourceName, "duration", "31536000"), + resource.TestCheckResourceAttr(dataSourceName, names.AttrDuration, "31536000"), resource.TestCheckResourceAttrSet(dataSourceName, "fixed_price"), resource.TestCheckResourceAttr(dataSourceName, "multi_az", "false"), resource.TestCheckResourceAttrSet(dataSourceName, "offering_id"), diff --git a/internal/service/rds/reserved_instance_test.go b/internal/service/rds/reserved_instance_test.go index 4213ec97d4a..27dce4c6a12 100644 --- a/internal/service/rds/reserved_instance_test.go +++ b/internal/service/rds/reserved_instance_test.go @@ -47,7 +47,7 @@ func TestAccRDSReservedInstance_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "rds", regexache.MustCompile(`ri:.+`)), resource.TestCheckResourceAttrPair(dataSourceName, "currency_code", resourceName, "currency_code"), resource.TestCheckResourceAttrPair(dataSourceName, "db_instance_class", resourceName, "db_instance_class"), - resource.TestCheckResourceAttrPair(dataSourceName, "duration", resourceName, "duration"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDuration, resourceName, names.AttrDuration), resource.TestCheckResourceAttrPair(dataSourceName, "fixed_price", resourceName, "fixed_price"), resource.TestCheckResourceAttr(resourceName, "instance_count", instanceCount), resource.TestCheckResourceAttrSet(resourceName, "lease_id"), From 45cb7da7de2a45d614ff01102adcc3da7f61bf23 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 59/78] redshift: Use constants for strings --- internal/service/redshift/cluster.go | 6 +++--- internal/service/redshift/cluster_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/redshift/cluster.go b/internal/service/redshift/cluster.go index 0805b4e46e2..3ed62a51317 100644 --- a/internal/service/redshift/cluster.go +++ b/internal/service/redshift/cluster.go @@ -172,7 +172,7 @@ func resourceCluster() *schema.Resource { Computed: true, ValidateFunc: verify.ValidARN, }, - "dns_name": { + names.AttrDNSName: { Type: schema.TypeString, Computed: true, }, @@ -719,12 +719,12 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter return aws.StringValue(v.VpcSecurityGroupId) })) - d.Set("dns_name", nil) + d.Set(names.AttrDNSName, nil) d.Set(names.AttrEndpoint, nil) d.Set(names.AttrPort, nil) if endpoint := rsc.Endpoint; endpoint != nil { if address := aws.StringValue(endpoint.Address); address != "" { - d.Set("dns_name", address) + d.Set(names.AttrDNSName, address) if port := aws.Int64Value(endpoint.Port); port != 0 { d.Set(names.AttrEndpoint, fmt.Sprintf("%s:%d", address, port)) d.Set(names.AttrPort, port) diff --git a/internal/service/redshift/cluster_test.go b/internal/service/redshift/cluster_test.go index e013d1a9f9a..775a538b6b9 100644 --- a/internal/service/redshift/cluster_test.go +++ b/internal/service/redshift/cluster_test.go @@ -43,7 +43,7 @@ func TestAccRedshiftCluster_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "cluster_nodes.0.public_ip_address"), resource.TestCheckResourceAttr(resourceName, "cluster_type", "single-node"), resource.TestCheckResourceAttr(resourceName, names.AttrPubliclyAccessible, "true"), - resource.TestMatchResourceAttr(resourceName, "dns_name", regexache.MustCompile(fmt.Sprintf("^%s.*\\.redshift\\..*", rName))), + resource.TestMatchResourceAttr(resourceName, names.AttrDNSName, regexache.MustCompile(fmt.Sprintf("^%s.*\\.redshift\\..*", rName))), resource.TestCheckResourceAttr(resourceName, "availability_zone_relocation_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "aqua_configuration_status", "auto"), resource.TestCheckResourceAttr(resourceName, "maintenance_track_name", "current"), From 183ce0a12fc14f0ff6a9a020925988a6f53bea77 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 60/78] redshiftdata: Use constants for strings --- internal/service/redshiftdata/statement.go | 6 +++--- internal/service/redshiftdata/statement_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/redshiftdata/statement.go b/internal/service/redshiftdata/statement.go index 0b91645ab59..e5d805fbeea 100644 --- a/internal/service/redshiftdata/statement.go +++ b/internal/service/redshiftdata/statement.go @@ -45,7 +45,7 @@ func resourceStatement() *schema.Resource { Optional: true, ForceNew: true, }, - "database": { + names.AttrDatabase: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -110,7 +110,7 @@ func resourceStatementCreate(ctx context.Context, d *schema.ResourceData, meta i conn := meta.(*conns.AWSClient).RedshiftDataClient(ctx) input := &redshiftdata.ExecuteStatementInput{ - Database: aws.String(d.Get("database").(string)), + Database: aws.String(d.Get(names.AttrDatabase).(string)), Sql: aws.String(d.Get("sql").(string)), WithEvent: aws.Bool(d.Get("with_event").(bool)), } @@ -171,7 +171,7 @@ func resourceStatementRead(ctx context.Context, d *schema.ResourceData, meta int } d.Set(names.AttrClusterIdentifier, sub.ClusterIdentifier) - d.Set("database", d.Get("database").(string)) + d.Set(names.AttrDatabase, d.Get(names.AttrDatabase).(string)) d.Set("db_user", d.Get("db_user").(string)) if err := d.Set(names.AttrParameters, flattenParameters(sub.QueryParameters)); err != nil { return sdkdiag.AppendErrorf(diags, "setting parameters: %s", err) diff --git a/internal/service/redshiftdata/statement_test.go b/internal/service/redshiftdata/statement_test.go index 62ace718b7d..76972bb908e 100644 --- a/internal/service/redshiftdata/statement_test.go +++ b/internal/service/redshiftdata/statement_test.go @@ -44,7 +44,7 @@ func TestAccRedshiftDataStatement_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"database", "db_user"}, + ImportStateVerifyIgnore: []string{names.AttrDatabase, "db_user"}, }, }, }) @@ -76,7 +76,7 @@ func TestAccRedshiftDataStatement_workgroup(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"database", "db_user"}, + ImportStateVerifyIgnore: []string{names.AttrDatabase, "db_user"}, }, }, }) From 7b97ba6f12fab447844df9fe54eef021f4f0f3dc Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 61/78] route53: Use constants for strings --- internal/service/route53/record.go | 8 +-- internal/service/route53/record_migrate.go | 6 +- .../service/route53/record_migrate_test.go | 6 +- internal/service/route53/record_test.go | 66 +++++++++---------- 4 files changed, 43 insertions(+), 43 deletions(-) diff --git a/internal/service/route53/record.go b/internal/service/route53/record.go index c46f2480be2..275d06ab073 100644 --- a/internal/service/route53/record.go +++ b/internal/service/route53/record.go @@ -307,7 +307,7 @@ func ResourceRecord() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, }, @@ -490,7 +490,7 @@ func resourceRecordRead(ctx context.Context, d *schema.ResourceData, meta interf if record.Weight != nil { v := []map[string]interface{}{{ - "weight": aws.Int64Value((record.Weight)), + names.AttrWeight: aws.Int64Value((record.Weight)), }} if err := d.Set("weighted_routing_policy", v); err != nil { return sdkdiag.AppendErrorf(diags, "setting weighted_routing_policy: %s", err) @@ -617,7 +617,7 @@ func resourceRecordUpdate(ctx context.Context, d *schema.ResourceData, meta inte if o, ok := v.([]interface{}); ok { if len(o) == 1 { if v, ok := o[0].(map[string]interface{}); ok { - oldRec.Weight = aws.Int64(int64(v["weight"].(int))) + oldRec.Weight = aws.Int64(int64(v[names.AttrWeight].(int))) } } } @@ -968,7 +968,7 @@ func expandResourceRecordSet(d *schema.ResourceData, zoneName string) *route53.R records := v.([]interface{}) weight := records[0].(map[string]interface{}) - rec.Weight = aws.Int64(int64(weight["weight"].(int))) + rec.Weight = aws.Int64(int64(weight[names.AttrWeight].(int))) } return rec diff --git a/internal/service/route53/record_migrate.go b/internal/service/route53/record_migrate.go index 1ac5f8497a9..3446ccbf494 100644 --- a/internal/service/route53/record_migrate.go +++ b/internal/service/route53/record_migrate.go @@ -46,17 +46,17 @@ func migrateRecordStateV1toV2(is *terraform.InstanceState) (*terraform.InstanceS return is, nil } log.Printf("[DEBUG] Attributes before migration: %#v", is.Attributes) - if is.Attributes["weight"] != "" && is.Attributes["weight"] != "-1" { + if is.Attributes[names.AttrWeight] != "" && is.Attributes[names.AttrWeight] != "-1" { is.Attributes["weighted_routing_policy.#"] = "1" key := "weighted_routing_policy.0.weight" - is.Attributes[key] = is.Attributes["weight"] + is.Attributes[key] = is.Attributes[names.AttrWeight] } if is.Attributes["failover"] != "" { is.Attributes["failover_routing_policy.#"] = "1" key := "failover_routing_policy.0.type" is.Attributes[key] = is.Attributes["failover"] } - delete(is.Attributes, "weight") + delete(is.Attributes, names.AttrWeight) delete(is.Attributes, "failover") log.Printf("[DEBUG] Attributes after migration: %#v", is.Attributes) return is, nil diff --git a/internal/service/route53/record_migrate_test.go b/internal/service/route53/record_migrate_test.go index cfd5172242b..21178ecf95d 100644 --- a/internal/service/route53/record_migrate_test.go +++ b/internal/service/route53/record_migrate_test.go @@ -77,8 +77,8 @@ func TestRecordMigrateStateV1toV2(t *testing.T) { "v0_1": { StateVersion: 1, Attributes: map[string]string{ - "weight": "0", - "failover": "PRIMARY", + names.AttrWeight: "0", + "failover": "PRIMARY", }, Expected: map[string]string{ "weighted_routing_policy.#": "1", @@ -90,7 +90,7 @@ func TestRecordMigrateStateV1toV2(t *testing.T) { "v0_2": { StateVersion: 0, Attributes: map[string]string{ - "weight": "-1", + names.AttrWeight: "-1", }, Expected: map[string]string{}, }, diff --git a/internal/service/route53/record_test.go b/internal/service/route53/record_test.go index 46be320ffe4..9247c7d93da 100644 --- a/internal/service/route53/record_test.go +++ b/internal/service/route53/record_test.go @@ -181,7 +181,7 @@ func TestAccRoute53Record_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -260,7 +260,7 @@ func TestAccRoute53Record_underscored(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -287,7 +287,7 @@ func TestAccRoute53Record_fqdn(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Ensure that changing the name to include a trailing "dot" results in @@ -329,7 +329,7 @@ func TestAccRoute53Record_trailingPeriodAndZoneID(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -356,7 +356,7 @@ func TestAccRoute53Record_Support_txt(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight", "zone_id"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight, "zone_id"}, }, }, }) @@ -384,7 +384,7 @@ func TestAccRoute53Record_Support_spf(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -412,7 +412,7 @@ func TestAccRoute53Record_Support_caa(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -439,7 +439,7 @@ func TestAccRoute53Record_Support_ds(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -466,7 +466,7 @@ func TestAccRoute53Record_generatesSuffix(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -493,7 +493,7 @@ func TestAccRoute53Record_wildcard(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh @@ -529,7 +529,7 @@ func TestAccRoute53Record_failover(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -558,7 +558,7 @@ func TestAccRoute53Record_Weighted_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -585,7 +585,7 @@ func TestAccRoute53Record_WeightedToSimple_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, { Config: testAccRecordConfig_simpleRoutingPolicy, @@ -620,7 +620,7 @@ func TestAccRoute53Record_Alias_elb(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -648,7 +648,7 @@ func TestAccRoute53Record_Alias_s3(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -680,7 +680,7 @@ func TestAccRoute53Record_Alias_vpcEndpoint(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -709,7 +709,7 @@ func TestAccRoute53Record_Alias_uppercase(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -737,7 +737,7 @@ func TestAccRoute53Record_Weighted_alias(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, { @@ -798,7 +798,7 @@ func TestAccRoute53Record_cidr(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, { Config: testAccRecordConfig_cidr(rName, locationName, zoneName.String(), recordName.String(), "cidr-location-2"), @@ -848,7 +848,7 @@ func TestAccRoute53Record_Geolocation_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -877,7 +877,7 @@ func TestAccRoute53Record_Geoproximity_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -904,7 +904,7 @@ func TestAccRoute53Record_HealthCheckID_setIdentifierChange(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, { Config: testAccRecordConfig_healthCheckIdSetIdentifier("test2"), @@ -937,7 +937,7 @@ func TestAccRoute53Record_HealthCheckID_typeChange(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, { Config: testAccRecordConfig_healthCheckIdTypeA(), @@ -972,7 +972,7 @@ func TestAccRoute53Record_Latency_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -999,7 +999,7 @@ func TestAccRoute53Record_typeChange(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh @@ -1034,7 +1034,7 @@ func TestAccRoute53Record_nameChange(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh @@ -1070,7 +1070,7 @@ func TestAccRoute53Record_setIdentifierChangeBasicToWeighted(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh @@ -1469,7 +1469,7 @@ func TestAccRoute53Record_Alias_change(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh @@ -1506,7 +1506,7 @@ func TestAccRoute53Record_Alias_changeDualstack(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, // Cause a change, which will trigger a refresh { @@ -1541,7 +1541,7 @@ func TestAccRoute53Record_empty(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -1569,7 +1569,7 @@ func TestAccRoute53Record_longTXTrecord(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -1597,7 +1597,7 @@ func TestAccRoute53Record_MultiValueAnswer_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) @@ -1637,7 +1637,7 @@ func TestAccRoute53Record_Allow_overwrite(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"allow_overwrite", "weight"}, + ImportStateVerifyIgnore: []string{"allow_overwrite", names.AttrWeight}, }, }, }) From d45b663a058af2b705ec65e2cb9f4e3d6693b29f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 62/78] rum: Use constants for strings --- internal/service/rum/app_monitor.go | 10 +++++----- internal/service/rum/app_monitor_test.go | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/rum/app_monitor.go b/internal/service/rum/app_monitor.go index cc331970641..5face412c10 100644 --- a/internal/service/rum/app_monitor.go +++ b/internal/service/rum/app_monitor.go @@ -130,7 +130,7 @@ func ResourceAppMonitor() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 253), @@ -155,7 +155,7 @@ func resourceAppMonitorCreate(ctx context.Context, d *schema.ResourceData, meta input := &cloudwatchrum.CreateAppMonitorInput{ Name: aws.String(name), CwLogEnabled: aws.Bool(d.Get("cw_log_enabled").(bool)), - Domain: aws.String(d.Get("domain").(string)), + Domain: aws.String(d.Get(names.AttrDomain).(string)), Tags: getTagsIn(ctx), } @@ -212,7 +212,7 @@ func resourceAppMonitorRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrARN, arn) d.Set("cw_log_enabled", appMon.DataStorage.CwLog.CwLogEnabled) d.Set("cw_log_group", appMon.DataStorage.CwLog.CwLogGroup) - d.Set("domain", appMon.Domain) + d.Set(names.AttrDomain, appMon.Domain) d.Set(names.AttrName, appMon.Name) setTagsOut(ctx, appMon.Tags) @@ -240,8 +240,8 @@ func resourceAppMonitorUpdate(ctx context.Context, d *schema.ResourceData, meta input.CwLogEnabled = aws.Bool(d.Get("cw_log_enabled").(bool)) } - if d.HasChange("domain") { - input.Domain = aws.String(d.Get("domain").(string)) + if d.HasChange(names.AttrDomain) { + input.Domain = aws.String(d.Get(names.AttrDomain).(string)) } _, err := conn.UpdateAppMonitorWithContext(ctx, input) diff --git a/internal/service/rum/app_monitor_test.go b/internal/service/rum/app_monitor_test.go index 027ed04957c..720574be95a 100644 --- a/internal/service/rum/app_monitor_test.go +++ b/internal/service/rum/app_monitor_test.go @@ -41,7 +41,7 @@ func TestAccRUMAppMonitor_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "app_monitor_id"), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "rum", fmt.Sprintf("appmonitor/%s", rName)), resource.TestCheckResourceAttr(resourceName, "cw_log_enabled", "false"), - resource.TestCheckResourceAttr(resourceName, "domain", "localhost"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "localhost"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "custom_events.#", "1"), ), @@ -62,7 +62,7 @@ func TestAccRUMAppMonitor_basic(t *testing.T) { acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "rum", fmt.Sprintf("appmonitor/%s", rName)), resource.TestCheckResourceAttr(resourceName, "cw_log_enabled", "true"), resource.TestCheckResourceAttrSet(resourceName, "cw_log_group"), - resource.TestCheckResourceAttr(resourceName, "domain", "localhost"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "localhost"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "custom_events.#", "1"), ), From d9406a0ae78f6d769a2c9f32d071f29d0128fb02 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 63/78] s3: Use constants for strings --- internal/service/s3/bucket_object.go | 10 +++++----- internal/service/s3/bucket_object_test.go | 14 +++++++------- internal/service/s3/object.go | 10 +++++----- internal/service/s3/object_test.go | 18 +++++++++--------- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/internal/service/s3/bucket_object.go b/internal/service/s3/bucket_object.go index 9ec7cde4491..506fe1cc266 100644 --- a/internal/service/s3/bucket_object.go +++ b/internal/service/s3/bucket_object.go @@ -83,7 +83,7 @@ func resourceBucketObject() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{names.AttrSource, "content_base64"}, @@ -91,7 +91,7 @@ func resourceBucketObject() *schema.Resource { "content_base64": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{names.AttrSource, "content"}, + ConflictsWith: []string{names.AttrSource, names.AttrContent}, }, "content_disposition": { Type: schema.TypeString, @@ -174,7 +174,7 @@ func resourceBucketObject() *schema.Resource { names.AttrSource: { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"content", "content_base64"}, + ConflictsWith: []string{names.AttrContent, "content_base64"}, }, "source_hash": { Type: schema.TypeString, @@ -396,7 +396,7 @@ func resourceBucketObjectUpload(ctx context.Context, d *schema.ResourceData, met log.Printf("[WARN] Error closing S3 object source (%s): %s", path, err) } }() - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { content := v.(string) body = bytes.NewReader([]byte(content)) } else if v, ok := d.GetOk("content_base64"); ok { @@ -545,7 +545,7 @@ func hasBucketObjectContentChanges(d sdkv2.ResourceDiffer) bool { "content_encoding", "content_language", names.AttrContentType, - "content", + names.AttrContent, "etag", names.AttrKMSKeyID, "metadata", diff --git a/internal/service/s3/bucket_object_test.go b/internal/service/s3/bucket_object_test.go index 50d13a1b872..24a8b6a8723 100644 --- a/internal/service/s3/bucket_object_test.go +++ b/internal/service/s3/bucket_object_test.go @@ -77,7 +77,7 @@ func TestAccS3BucketObject_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrBucket, rName), resource.TestCheckResourceAttr(resourceName, "bucket_key_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "cache_control", ""), - resource.TestCheckNoResourceAttr(resourceName, "content"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrContent), resource.TestCheckNoResourceAttr(resourceName, "content_base64"), resource.TestCheckResourceAttr(resourceName, "content_disposition", ""), resource.TestCheckResourceAttr(resourceName, "content_encoding", ""), @@ -168,7 +168,7 @@ func TestAccS3BucketObject_content(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", "content_base64", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{"acl", names.AttrContent, "content_base64", names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -283,7 +283,7 @@ func TestAccS3BucketObject_sourceHashTrigger(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", "content_base64", names.AttrForceDestroy, names.AttrSource, "source_hash"}, + ImportStateVerifyIgnore: []string{"acl", names.AttrContent, "content_base64", names.AttrForceDestroy, names.AttrSource, "source_hash"}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -649,7 +649,7 @@ func TestAccS3BucketObject_acl(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{"acl", names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -761,7 +761,7 @@ func TestAccS3BucketObject_storageClass(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, "acl", names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -834,7 +834,7 @@ func TestAccS3BucketObject_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, "acl", names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, @@ -907,7 +907,7 @@ func TestAccS3BucketObject_tagsLeadingSingleSlash(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "acl", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, "acl", names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, diff --git a/internal/service/s3/object.go b/internal/service/s3/object.go index a781c7a88a1..14bb093aaa9 100644 --- a/internal/service/s3/object.go +++ b/internal/service/s3/object.go @@ -110,7 +110,7 @@ func resourceObject() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{names.AttrSource, "content_base64"}, @@ -118,7 +118,7 @@ func resourceObject() *schema.Resource { "content_base64": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{names.AttrSource, "content"}, + ConflictsWith: []string{names.AttrSource, names.AttrContent}, }, "content_disposition": { Type: schema.TypeString, @@ -224,7 +224,7 @@ func resourceObject() *schema.Resource { names.AttrSource: { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"content", "content_base64"}, + ConflictsWith: []string{names.AttrContent, "content_base64"}, }, "source_hash": { Type: schema.TypeString, @@ -481,7 +481,7 @@ func resourceObjectUpload(ctx context.Context, d *schema.ResourceData, meta inte log.Printf("[WARN] Error closing S3 object source (%s): %s", path, err) } }() - } else if v, ok := d.GetOk("content"); ok { + } else if v, ok := d.GetOk(names.AttrContent); ok { body = strings.NewReader(v.(string)) } else if v, ok := d.GetOk("content_base64"); ok { // We can't do streaming decoding here (with base64.NewDecoder) because @@ -652,7 +652,7 @@ func hasObjectContentChanges(d sdkv2.ResourceDiffer) bool { "content_encoding", "content_language", names.AttrContentType, - "content", + names.AttrContent, "etag", names.AttrKMSKeyID, "metadata", diff --git a/internal/service/s3/object_test.go b/internal/service/s3/object_test.go index 90af16cea23..84028bc1ce7 100644 --- a/internal/service/s3/object_test.go +++ b/internal/service/s3/object_test.go @@ -134,7 +134,7 @@ func TestAccS3Object_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "checksum_crc32c", ""), resource.TestCheckResourceAttr(resourceName, "checksum_sha1", ""), resource.TestCheckResourceAttr(resourceName, "checksum_sha256", ""), - resource.TestCheckNoResourceAttr(resourceName, "content"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrContent), resource.TestCheckNoResourceAttr(resourceName, "content_base64"), resource.TestCheckResourceAttr(resourceName, "content_disposition", ""), resource.TestCheckResourceAttr(resourceName, "content_encoding", ""), @@ -304,7 +304,7 @@ func TestAccS3Object_content(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "content_base64", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, "content_base64", names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -415,7 +415,7 @@ func TestAccS3Object_sourceHashTrigger(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", "content_base64", names.AttrForceDestroy, names.AttrSource, "source_hash"}, + ImportStateVerifyIgnore: []string{names.AttrContent, "content_base64", names.AttrForceDestroy, names.AttrSource, "source_hash"}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -780,7 +780,7 @@ func TestAccS3Object_acl(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"acl", "content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{"acl", names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -891,7 +891,7 @@ func TestAccS3Object_storageClass(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, }, @@ -960,7 +960,7 @@ func TestAccS3Object_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, @@ -1029,7 +1029,7 @@ func TestAccS3Object_tagsLeadingSingleSlash(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/%s", rName, key), }, }, @@ -1925,7 +1925,7 @@ func TestAccS3Object_checksumAlgorithm(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"checksum_algorithm", "checksum_crc32", "content", names.AttrForceDestroy}, + ImportStateVerifyIgnore: []string{"checksum_algorithm", "checksum_crc32", names.AttrContent, names.AttrForceDestroy}, ImportStateId: fmt.Sprintf("s3://%s/test-key", rName), }, { @@ -2006,7 +2006,7 @@ func TestAccS3Object_directoryBucket(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "checksum_crc32c", ""), resource.TestCheckResourceAttr(resourceName, "checksum_sha1", ""), resource.TestCheckResourceAttr(resourceName, "checksum_sha256", ""), - resource.TestCheckNoResourceAttr(resourceName, "content"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrContent), resource.TestCheckNoResourceAttr(resourceName, "content_base64"), resource.TestCheckResourceAttr(resourceName, "content_disposition", ""), resource.TestCheckResourceAttr(resourceName, "content_encoding", ""), From 61006a94553af6e23a7c18ddfea6d7511b77d03b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:04 -0400 Subject: [PATCH 64/78] sagemaker: Use constants for strings --- .../service/sagemaker/data_quality_job_definition.go | 6 +++--- internal/service/sagemaker/feature_group.go | 6 +++--- internal/service/sagemaker/human_task_ui.go | 10 +++++----- internal/service/sagemaker/model.go | 6 +++--- internal/service/sagemaker/workforce.go | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/internal/service/sagemaker/data_quality_job_definition.go b/internal/service/sagemaker/data_quality_job_definition.go index ac50b0a0d02..99e8e29281d 100644 --- a/internal/service/sagemaker/data_quality_job_definition.go +++ b/internal/service/sagemaker/data_quality_job_definition.go @@ -410,7 +410,7 @@ func ResourceDataQualityJobDefinition() *schema.Resource { ForceNew: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, MinItems: 1, MaxItems: 16, @@ -926,7 +926,7 @@ func flattenVPCConfig(config *sagemaker.VpcConfig) []map[string]interface{} { } if config.Subnets != nil { - m["subnets"] = flex.FlattenStringSet(config.Subnets) + m[names.AttrSubnets] = flex.FlattenStringSet(config.Subnets) } return []map[string]interface{}{m} @@ -1304,7 +1304,7 @@ func expandVPCConfig(configured []interface{}) *sagemaker.VpcConfig { c.SecurityGroupIds = flex.ExpandStringSet(v) } - if v, ok := m["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := m[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { c.Subnets = flex.ExpandStringSet(v) } diff --git a/internal/service/sagemaker/feature_group.go b/internal/service/sagemaker/feature_group.go index 447349e3f4b..c7afd76b40e 100644 --- a/internal/service/sagemaker/feature_group.go +++ b/internal/service/sagemaker/feature_group.go @@ -116,7 +116,7 @@ func ResourceFeatureGroup() *schema.Resource { Computed: true, ForceNew: true, }, - "database": { + names.AttrDatabase: { Type: schema.TypeString, Optional: true, Computed: true, @@ -634,7 +634,7 @@ func expandFeatureGroupOfflineStoreConfigDataCatalogConfig(l []interface{}) *sag config := &sagemaker.DataCatalogConfig{ Catalog: aws.String(m["catalog"].(string)), - Database: aws.String(m["database"].(string)), + Database: aws.String(m[names.AttrDatabase].(string)), TableName: aws.String(m[names.AttrTableName].(string)), } @@ -648,7 +648,7 @@ func flattenFeatureGroupOfflineStoreConfigDataCatalogConfig(config *sagemaker.Da m := map[string]interface{}{ "catalog": aws.StringValue(config.Catalog), - "database": aws.StringValue(config.Database), + names.AttrDatabase: aws.StringValue(config.Database), names.AttrTableName: aws.StringValue(config.TableName), } diff --git a/internal/service/sagemaker/human_task_ui.go b/internal/service/sagemaker/human_task_ui.go index f90ee88cee6..44e4e2dfa68 100644 --- a/internal/service/sagemaker/human_task_ui.go +++ b/internal/service/sagemaker/human_task_ui.go @@ -46,7 +46,7 @@ func ResourceHumanTaskUI() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "content": { + names.AttrContent: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -165,7 +165,7 @@ func expandHumanTaskUiUiTemplate(l []interface{}) *sagemaker.UiTemplate { m := l[0].(map[string]interface{}) config := &sagemaker.UiTemplate{ - Content: aws.String(m["content"].(string)), + Content: aws.String(m[names.AttrContent].(string)), } return config @@ -177,9 +177,9 @@ func flattenHumanTaskUiUiTemplate(config *sagemaker.UiTemplateInfo, content stri } m := map[string]interface{}{ - "content_sha256": aws.StringValue(config.ContentSha256), - names.AttrURL: aws.StringValue(config.Url), - "content": content, + "content_sha256": aws.StringValue(config.ContentSha256), + names.AttrURL: aws.StringValue(config.Url), + names.AttrContent: content, } return []map[string]interface{}{m} diff --git a/internal/service/sagemaker/model.go b/internal/service/sagemaker/model.go index f512f94c99d..304347d2c95 100644 --- a/internal/service/sagemaker/model.go +++ b/internal/service/sagemaker/model.go @@ -310,7 +310,7 @@ func ResourceModel() *schema.Resource { ForceNew: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, MaxItems: 16, @@ -393,7 +393,7 @@ func expandVPCConfigRequest(l []interface{}) *sagemaker.VpcConfig { return &sagemaker.VpcConfig{ SecurityGroupIds: flex.ExpandStringSet(m[names.AttrSecurityGroupIDs].(*schema.Set)), - Subnets: flex.ExpandStringSet(m["subnets"].(*schema.Set)), + Subnets: flex.ExpandStringSet(m[names.AttrSubnets].(*schema.Set)), } } @@ -447,7 +447,7 @@ func flattenVPCConfigResponse(vpcConfig *sagemaker.VpcConfig) []map[string]inter m := map[string]interface{}{ names.AttrSecurityGroupIDs: flex.FlattenStringSet(vpcConfig.SecurityGroupIds), - "subnets": flex.FlattenStringSet(vpcConfig.Subnets), + names.AttrSubnets: flex.FlattenStringSet(vpcConfig.Subnets), } return []map[string]interface{}{m} diff --git a/internal/service/sagemaker/workforce.go b/internal/service/sagemaker/workforce.go index 08f6ff8ab19..69f7521ba85 100644 --- a/internal/service/sagemaker/workforce.go +++ b/internal/service/sagemaker/workforce.go @@ -165,7 +165,7 @@ func ResourceWorkforce() *schema.Resource { MaxItems: 5, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Optional: true, MaxItems: 16, @@ -427,7 +427,7 @@ func expandWorkforceVPCConfig(l []interface{}) *sagemaker.WorkforceVpcConfigRequ config := &sagemaker.WorkforceVpcConfigRequest{ SecurityGroupIds: flex.ExpandStringSet(m[names.AttrSecurityGroupIDs].(*schema.Set)), - Subnets: flex.ExpandStringSet(m["subnets"].(*schema.Set)), + Subnets: flex.ExpandStringSet(m[names.AttrSubnets].(*schema.Set)), VpcId: aws.String(m[names.AttrVPCID].(string)), } @@ -441,7 +441,7 @@ func flattenWorkforceVPCConfig(config *sagemaker.WorkforceVpcConfigResponse) []m m := map[string]interface{}{ names.AttrSecurityGroupIDs: flex.FlattenStringSet(config.SecurityGroupIds), - "subnets": flex.FlattenStringSet(config.Subnets), + names.AttrSubnets: flex.FlattenStringSet(config.Subnets), "vpc_endpoint_id": aws.StringValue(config.VpcEndpointId), names.AttrVPCID: aws.StringValue(config.VpcId), } From c81cc4e56a6977532dc2e279e528addce6637be6 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:05 -0400 Subject: [PATCH 65/78] scheduler: Use constants for strings --- internal/service/scheduler/flex.go | 8 ++++---- internal/service/scheduler/schedule.go | 6 +++--- internal/service/scheduler/schedule_test.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/scheduler/flex.go b/internal/service/scheduler/flex.go index a1fb92eaea5..898b9be0c21 100644 --- a/internal/service/scheduler/flex.go +++ b/internal/service/scheduler/flex.go @@ -29,7 +29,7 @@ func expandCapacityProviderStrategyItem(tfMap map[string]interface{}) types.Capa a.CapacityProvider = aws.String(v) } - if v, ok := tfMap["weight"].(int); ok { + if v, ok := tfMap[names.AttrWeight].(int); ok { a.Weight = int32(v) } @@ -45,7 +45,7 @@ func flattenCapacityProviderStrategyItem(apiObject types.CapacityProviderStrateg m["capacity_provider"] = aws.ToString(v) } - m["weight"] = apiObject.Weight + m[names.AttrWeight] = apiObject.Weight return m } @@ -374,7 +374,7 @@ func expandNetworkConfiguration(tfMap map[string]interface{}) *types.NetworkConf awsvpcConfig.SecurityGroups = flex.ExpandStringValueSet(v) } - if v, ok := tfMap["subnets"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrSubnets].(*schema.Set); ok && v.Len() > 0 { awsvpcConfig.Subnets = flex.ExpandStringValueSet(v) } @@ -402,7 +402,7 @@ func flattenNetworkConfiguration(apiObject *types.NetworkConfiguration) map[stri } if v := apiObject.AwsvpcConfiguration.Subnets; v != nil { - m["subnets"] = flex.FlattenStringValueSet(v) + m[names.AttrSubnets] = flex.FlattenStringValueSet(v) } return m diff --git a/internal/service/scheduler/schedule.go b/internal/service/scheduler/schedule.go index 930f135c854..3f32b7215d0 100644 --- a/internal/service/scheduler/schedule.go +++ b/internal/service/scheduler/schedule.go @@ -184,7 +184,7 @@ func resourceSchedule() *schema.Resource { Required: true, ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 255)), }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Optional: true, ValidateDiagFunc: validation.ToDiagFunc(validation.IntBetween(0, 1000)), @@ -226,7 +226,7 @@ func resourceSchedule() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "subnets": { + names.AttrSubnets: { Type: schema.TypeSet, Required: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -713,7 +713,7 @@ func capacityProviderHash(v interface{}) int { buf.WriteString(fmt.Sprintf("%s-", v)) } - if v, ok := m["weight"].(int); ok { + if v, ok := m[names.AttrWeight].(int); ok { buf.WriteString(fmt.Sprintf("%d-", v)) } diff --git a/internal/service/scheduler/schedule_test.go b/internal/service/scheduler/schedule_test.go index 0877a7af6f1..35add7146d4 100644 --- a/internal/service/scheduler/schedule_test.go +++ b/internal/service/scheduler/schedule_test.go @@ -1009,12 +1009,12 @@ func TestAccSchedulerSchedule_targetECSParameters(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "target.0.ecs_parameters.0.capacity_provider_strategy.*", map[string]string{ "base": "2", "capacity_provider": "test1", - "weight": "50", + names.AttrWeight: "50", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "target.0.ecs_parameters.0.capacity_provider_strategy.*", map[string]string{ "base": "0", "capacity_provider": "test2", - "weight": "50", + names.AttrWeight: "50", }), resource.TestCheckResourceAttr(resourceName, "target.0.ecs_parameters.0.enable_ecs_managed_tags", "true"), resource.TestCheckResourceAttr(resourceName, "target.0.ecs_parameters.0.enable_execute_command", "false"), @@ -1056,7 +1056,7 @@ func TestAccSchedulerSchedule_targetECSParameters(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "target.0.ecs_parameters.0.capacity_provider_strategy.*", map[string]string{ "base": "3", "capacity_provider": "test3", - "weight": "100", + names.AttrWeight: "100", }), resource.TestCheckResourceAttr(resourceName, "target.0.ecs_parameters.0.enable_ecs_managed_tags", "false"), resource.TestCheckResourceAttr(resourceName, "target.0.ecs_parameters.0.enable_execute_command", "true"), From d12a0eadcbee9fe982af25e9715bf074ab64e392 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:05 -0400 Subject: [PATCH 66/78] schemas: Use constants for strings --- internal/service/schemas/schema.go | 12 ++++++------ internal/service/schemas/schema_test.go | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/schemas/schema.go b/internal/service/schemas/schema.go index 0817cbf8789..d848ed289b8 100644 --- a/internal/service/schemas/schema.go +++ b/internal/service/schemas/schema.go @@ -42,7 +42,7 @@ func ResourceSchema() *schema.Resource { Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs, @@ -105,7 +105,7 @@ func resourceSchemaCreate(ctx context.Context, d *schema.ResourceData, meta inte name := d.Get(names.AttrName).(string) registryName := d.Get("registry_name").(string) input := &schemas.CreateSchemaInput{ - Content: aws.String(d.Get("content").(string)), + Content: aws.String(d.Get(names.AttrContent).(string)), RegistryName: aws.String(registryName), SchemaName: aws.String(name), Tags: getTagsIn(ctx), @@ -153,7 +153,7 @@ func resourceSchemaRead(ctx context.Context, d *schema.ResourceData, meta interf } d.Set(names.AttrARN, output.SchemaArn) - d.Set("content", output.Content) + d.Set(names.AttrContent, output.Content) d.Set(names.AttrDescription, output.Description) if output.LastModified != nil { d.Set("last_modified", aws.TimeValue(output.LastModified).Format(time.RFC3339)) @@ -177,7 +177,7 @@ func resourceSchemaUpdate(ctx context.Context, d *schema.ResourceData, meta inte var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SchemasConn(ctx) - if d.HasChanges("content", names.AttrDescription, names.AttrType) { + if d.HasChanges(names.AttrContent, names.AttrDescription, names.AttrType) { name, registryName, err := SchemaParseResourceID(d.Id()) if err != nil { @@ -189,8 +189,8 @@ func resourceSchemaUpdate(ctx context.Context, d *schema.ResourceData, meta inte SchemaName: aws.String(name), } - if d.HasChanges("content", names.AttrType) { - input.Content = aws.String(d.Get("content").(string)) + if d.HasChanges(names.AttrContent, names.AttrType) { + input.Content = aws.String(d.Get(names.AttrContent).(string)) input.Type = aws.String(d.Get(names.AttrType).(string)) } diff --git a/internal/service/schemas/schema_test.go b/internal/service/schemas/schema_test.go index 0a0f9f96b96..a6e35e50bac 100644 --- a/internal/service/schemas/schema_test.go +++ b/internal/service/schemas/schema_test.go @@ -110,7 +110,7 @@ func TestAccSchemasSchema_openAPI3(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckSchemaExists(ctx, resourceName, &v), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "schemas", fmt.Sprintf("schema/%s/%s", rName, rName)), - resource.TestCheckResourceAttrSet(resourceName, "content"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrContent), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), resource.TestCheckResourceAttrSet(resourceName, "last_modified"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), @@ -148,7 +148,7 @@ func TestAccSchemasSchema_jsonSchemaDraftv4(t *testing.T) { testAccCheckSchemaExists(ctx, resourceName, &v), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "schemas", fmt.Sprintf("schema/%s/%s", rName, rName)), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), - resource.TestCheckResourceAttr(resourceName, "content", testAccJSONSchemaContent), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, testAccJSONSchemaContent), resource.TestCheckResourceAttrSet(resourceName, "last_modified"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "registry_name", rName), @@ -207,7 +207,7 @@ func TestAccSchemasSchema_contentDescription(t *testing.T) { Config: testAccSchemaConfig_contentDescription(rName, testAccSchemaContent, "description1"), Check: resource.ComposeTestCheckFunc( testAccCheckSchemaExists(ctx, resourceName, &v), - resource.TestCheckResourceAttr(resourceName, "content", testAccSchemaContent), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, testAccSchemaContent), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "description1"), resource.TestCheckResourceAttr(resourceName, names.AttrVersion, "1"), ), @@ -221,7 +221,7 @@ func TestAccSchemasSchema_contentDescription(t *testing.T) { Config: testAccSchemaConfig_contentDescription(rName, testAccSchemaContentUpdated, "description2"), Check: resource.ComposeTestCheckFunc( testAccCheckSchemaExists(ctx, resourceName, &v), - resource.TestCheckResourceAttr(resourceName, "content", testAccSchemaContentUpdated), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, testAccSchemaContentUpdated), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "description2"), resource.TestCheckResourceAttr(resourceName, names.AttrVersion, "2"), ), From 5431ad555f757021cde992df2881d988923afc97 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:05 -0400 Subject: [PATCH 67/78] secretsmanager: Use constants for strings --- internal/service/secretsmanager/secret_rotation.go | 6 +++--- .../service/secretsmanager/secret_rotation_data_source.go | 2 +- internal/service/secretsmanager/secret_rotation_migrate.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/secretsmanager/secret_rotation.go b/internal/service/secretsmanager/secret_rotation.go index 3164c4d41a2..936aeafdfe3 100644 --- a/internal/service/secretsmanager/secret_rotation.go +++ b/internal/service/secretsmanager/secret_rotation.go @@ -72,7 +72,7 @@ func resourceSecretRotation() *schema.Resource { ExactlyOneOf: []string{"rotation_rules.0.automatically_after_days", "rotation_rules.0.schedule_expression"}, ValidateFunc: validation.IntBetween(1, 1000), }, - "duration": { + names.AttrDuration: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`[0-9h]+`), ""), @@ -216,7 +216,7 @@ func expandRotationRules(l []interface{}) *types.RotationRulesType { rules.AutomaticallyAfterDays = aws.Int64(int64(v)) } - if v, ok := tfMap["duration"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrDuration].(string); ok && v != "" { rules.Duration = aws.String(v) } @@ -240,7 +240,7 @@ func flattenRotationRules(rules *types.RotationRulesType) []interface{} { } if v := rules.Duration; v != nil { - m["duration"] = aws.ToString(v) + m[names.AttrDuration] = aws.ToString(v) } if v := rules.ScheduleExpression; v != nil { diff --git a/internal/service/secretsmanager/secret_rotation_data_source.go b/internal/service/secretsmanager/secret_rotation_data_source.go index a0046413932..92b30ee4b68 100644 --- a/internal/service/secretsmanager/secret_rotation_data_source.go +++ b/internal/service/secretsmanager/secret_rotation_data_source.go @@ -37,7 +37,7 @@ func dataSourceSecretRotation() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/secretsmanager/secret_rotation_migrate.go b/internal/service/secretsmanager/secret_rotation_migrate.go index 1d081d1915b..cb8c2b61e54 100644 --- a/internal/service/secretsmanager/secret_rotation_migrate.go +++ b/internal/service/secretsmanager/secret_rotation_migrate.go @@ -39,7 +39,7 @@ func secretRotationResourceV0() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeString, Optional: true, }, From 02d251faca12732c6f3c4afab6c68d713c78b3aa Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:05 -0400 Subject: [PATCH 68/78] ses: Use constants for strings --- internal/service/ses/domain_dkim.go | 7 ++++--- internal/service/ses/domain_identity.go | 8 ++++---- internal/service/ses/domain_identity_data_source.go | 6 +++--- internal/service/ses/domain_identity_verification.go | 6 +++--- internal/service/ses/domain_mail_from.go | 7 ++++--- internal/service/ses/domain_mail_from_test.go | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/internal/service/ses/domain_dkim.go b/internal/service/ses/domain_dkim.go index 81099ff17bf..9fe2fc705a1 100644 --- a/internal/service/ses/domain_dkim.go +++ b/internal/service/ses/domain_dkim.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_ses_domain_dkim") @@ -26,7 +27,7 @@ func ResourceDomainDKIM() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -44,7 +45,7 @@ func resourceDomainDKIMCreate(ctx context.Context, d *schema.ResourceData, meta var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESConn(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) createOpts := &ses.VerifyDomainDkimInput{ Domain: aws.String(domainName), @@ -65,7 +66,7 @@ func resourceDomainDKIMRead(ctx context.Context, d *schema.ResourceData, meta in conn := meta.(*conns.AWSClient).SESConn(ctx) domainName := d.Id() - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) readOpts := &ses.GetIdentityDkimAttributesInput{ Identities: []*string{ diff --git a/internal/service/ses/domain_identity.go b/internal/service/ses/domain_identity.go index 7454f2f831c..0415b479b3c 100644 --- a/internal/service/ses/domain_identity.go +++ b/internal/service/ses/domain_identity.go @@ -35,7 +35,7 @@ func ResourceDomainIdentity() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -53,7 +53,7 @@ func resourceDomainIdentityCreate(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESConn(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) createOpts := &ses.VerifyDomainIdentityInput{ Domain: aws.String(domainName), @@ -74,7 +74,7 @@ func resourceDomainIdentityRead(ctx context.Context, d *schema.ResourceData, met conn := meta.(*conns.AWSClient).SESConn(ctx) domainName := d.Id() - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) readOpts := &ses.GetIdentityVerificationAttributesInput{ Identities: []*string{ @@ -110,7 +110,7 @@ func resourceDomainIdentityDelete(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESConn(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) deleteOpts := &ses.DeleteIdentityInput{ Identity: aws.String(domainName), diff --git a/internal/service/ses/domain_identity_data_source.go b/internal/service/ses/domain_identity_data_source.go index fbd79d45240..02345b2fdf2 100644 --- a/internal/service/ses/domain_identity_data_source.go +++ b/internal/service/ses/domain_identity_data_source.go @@ -28,7 +28,7 @@ func DataSourceDomainIdentity() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringDoesNotMatch(regexache.MustCompile(`\.$`), "cannot end with a period"), @@ -45,9 +45,9 @@ func dataSourceDomainIdentityRead(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESConn(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) d.SetId(domainName) - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) readOpts := &ses.GetIdentityVerificationAttributesInput{ Identities: []*string{ diff --git a/internal/service/ses/domain_identity_verification.go b/internal/service/ses/domain_identity_verification.go index acf00a0405b..33db7bc70cf 100644 --- a/internal/service/ses/domain_identity_verification.go +++ b/internal/service/ses/domain_identity_verification.go @@ -35,7 +35,7 @@ func ResourceDomainIdentityVerification() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -66,7 +66,7 @@ func getIdentityVerificationAttributes(ctx context.Context, conn *ses.SES, domai func resourceDomainIdentityVerificationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics conn := meta.(*conns.AWSClient).SESConn(ctx) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) err := retry.RetryContext(ctx, d.Timeout(schema.TimeoutCreate), func() *retry.RetryError { att, err := getIdentityVerificationAttributes(ctx, conn, domainName) if err != nil { @@ -105,7 +105,7 @@ func resourceDomainIdentityVerificationRead(ctx context.Context, d *schema.Resou conn := meta.(*conns.AWSClient).SESConn(ctx) domainName := d.Id() - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) att, err := getIdentityVerificationAttributes(ctx, conn, domainName) if err != nil { diff --git a/internal/service/ses/domain_mail_from.go b/internal/service/ses/domain_mail_from.go index f7e44a0acfb..b1fdc61c9ef 100644 --- a/internal/service/ses/domain_mail_from.go +++ b/internal/service/ses/domain_mail_from.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_ses_domain_mail_from") @@ -27,7 +28,7 @@ func ResourceDomainMailFrom() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "domain": { + names.AttrDomain: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -50,7 +51,7 @@ func resourceDomainMailFromSet(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).SESConn(ctx) behaviorOnMxFailure := d.Get("behavior_on_mx_failure").(string) - domainName := d.Get("domain").(string) + domainName := d.Get(names.AttrDomain).(string) mailFromDomain := d.Get("mail_from_domain").(string) input := &ses.SetIdentityMailFromDomainInput{ @@ -100,7 +101,7 @@ func resourceDomainMailFromRead(ctx context.Context, d *schema.ResourceData, met } d.Set("behavior_on_mx_failure", attributes.BehaviorOnMXFailure) - d.Set("domain", domainName) + d.Set(names.AttrDomain, domainName) d.Set("mail_from_domain", attributes.MailFromDomain) return diags diff --git a/internal/service/ses/domain_mail_from_test.go b/internal/service/ses/domain_mail_from_test.go index 0090eecc333..d5d50da399f 100644 --- a/internal/service/ses/domain_mail_from_test.go +++ b/internal/service/ses/domain_mail_from_test.go @@ -36,7 +36,7 @@ func TestAccSESDomainMailFrom_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainMailFromExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "behavior_on_mx_failure", ses.BehaviorOnMXFailureUseDefaultValue), - resource.TestCheckResourceAttr(resourceName, "domain", domain), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, domain), resource.TestCheckResourceAttr(resourceName, "mail_from_domain", mailFromDomain1), ), }, @@ -45,7 +45,7 @@ func TestAccSESDomainMailFrom_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckDomainMailFromExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "behavior_on_mx_failure", ses.BehaviorOnMXFailureUseDefaultValue), - resource.TestCheckResourceAttr(resourceName, "domain", domain), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, domain), resource.TestCheckResourceAttr(resourceName, "mail_from_domain", mailFromDomain2), ), }, From b2ec5be2d607e1e400ea6d692a91950a38a70c3e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:05 -0400 Subject: [PATCH 69/78] sfn: Use constants for strings --- internal/service/sfn/alias.go | 6 +++--- internal/service/sfn/alias_data_source.go | 2 +- internal/service/sfn/state_machine.go | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/sfn/alias.go b/internal/service/sfn/alias.go index 631794e03e5..606ffc77fce 100644 --- a/internal/service/sfn/alias.go +++ b/internal/service/sfn/alias.go @@ -66,7 +66,7 @@ func ResourceAlias() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, }, @@ -216,7 +216,7 @@ func flattenAliasRoutingConfigurationItem(apiObject *sfn.RoutingConfigurationLis } if v := apiObject.Weight; v != nil { - tfMap["weight"] = aws.Int64Value(v) + tfMap[names.AttrWeight] = aws.Int64Value(v) } return tfMap @@ -275,7 +275,7 @@ func expandAliasRoutingConfigurationItem(tfMap map[string]interface{}) *sfn.Rout apiObject.StateMachineVersionArn = aws.String(v) } - if v, ok := tfMap["weight"].(int); ok && v != 0 { + if v, ok := tfMap[names.AttrWeight].(int); ok && v != 0 { apiObject.Weight = aws.Int64(int64(v)) } diff --git a/internal/service/sfn/alias_data_source.go b/internal/service/sfn/alias_data_source.go index 214331c703e..81784c445fb 100644 --- a/internal/service/sfn/alias_data_source.go +++ b/internal/service/sfn/alias_data_source.go @@ -48,7 +48,7 @@ func DataSourceAlias() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Required: true, }, diff --git a/internal/service/sfn/state_machine.go b/internal/service/sfn/state_machine.go index a97cfbc096c..9dcd2c9cd64 100644 --- a/internal/service/sfn/state_machine.go +++ b/internal/service/sfn/state_machine.go @@ -63,7 +63,7 @@ func ResourceStateMachine() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, Optional: true, Computed: true, @@ -178,7 +178,7 @@ func resourceStateMachineCreate(ctx context.Context, d *schema.ResourceData, met Type: aws.String(d.Get(names.AttrType).(string)), } - if v, ok := d.GetOk("logging_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrLoggingConfiguration); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.LoggingConfiguration = expandLoggingConfiguration(v.([]interface{})[0].(map[string]interface{})) } @@ -228,11 +228,11 @@ func resourceStateMachineRead(ctx context.Context, d *schema.ResourceData, meta d.Set("definition", output.Definition) d.Set(names.AttrDescription, output.Description) if output.LoggingConfiguration != nil { - if err := d.Set("logging_configuration", []interface{}{flattenLoggingConfiguration(output.LoggingConfiguration)}); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, []interface{}{flattenLoggingConfiguration(output.LoggingConfiguration)}); err != nil { return diag.Errorf("setting logging_configuration: %s", err) } } else { - d.Set("logging_configuration", nil) + d.Set(names.AttrLoggingConfiguration, nil) } d.Set(names.AttrName, output.Name) d.Set(names.AttrNamePrefix, create.NamePrefixFromName(aws.StringValue(output.Name))) @@ -285,8 +285,8 @@ func resourceStateMachineUpdate(ctx context.Context, d *schema.ResourceData, met input.VersionDescription = aws.String(d.Get("version_description").(string)) } - if d.HasChange("logging_configuration") { - if v, ok := d.GetOk("logging_configuration"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if d.HasChange(names.AttrLoggingConfiguration) { + if v, ok := d.GetOk(names.AttrLoggingConfiguration); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.LoggingConfiguration = expandLoggingConfiguration(v.([]interface{})[0].(map[string]interface{})) } } From f40e8ba40ee5a13ba5f961c74467279632079a43 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 70/78] ssm: Use constants for strings --- internal/service/ssm/document.go | 12 ++++++------ internal/service/ssm/document_data_source.go | 4 ++-- internal/service/ssm/document_data_source_test.go | 4 ++-- internal/service/ssm/document_test.go | 4 ++-- internal/service/ssm/maintenance_window.go | 8 ++++---- internal/service/ssm/maintenance_window_test.go | 10 +++++----- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/service/ssm/document.go b/internal/service/ssm/document.go index c55e31ced19..91563a2ebe6 100644 --- a/internal/service/ssm/document.go +++ b/internal/service/ssm/document.go @@ -85,7 +85,7 @@ func ResourceDocument() *schema.Resource { }, }, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, }, @@ -226,7 +226,7 @@ func ResourceDocument() *schema.Resource { } } - if d.HasChange("content") { + if d.HasChange(names.AttrContent) { if err := d.SetNewComputed("default_version"); err != nil { return err } @@ -256,7 +256,7 @@ func resourceDocumentCreate(ctx context.Context, d *schema.ResourceData, meta in name := d.Get(names.AttrName).(string) input := &ssm.CreateDocumentInput{ - Content: aws.String(d.Get("content").(string)), + Content: aws.String(d.Get(names.AttrContent).(string)), DocumentFormat: aws.String(d.Get("document_format").(string)), DocumentType: aws.String(d.Get("document_type").(string)), Name: aws.String(name), @@ -369,7 +369,7 @@ func resourceDocumentRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading SSM Document (%s) content: %s", d.Id(), err) } - d.Set("content", output.Content) + d.Set(names.AttrContent, output.Content) } { @@ -456,9 +456,9 @@ func resourceDocumentUpdate(ctx context.Context, d *schema.ResourceData, meta in // Update for schema version 1.x is not allowed. isSchemaVersion1, _ := regexp.MatchString(`^1[.][0-9]$`, d.Get("schema_version").(string)) - if d.HasChange("content") || !isSchemaVersion1 { + if d.HasChange(names.AttrContent) || !isSchemaVersion1 { input := &ssm.UpdateDocumentInput{ - Content: aws.String(d.Get("content").(string)), + Content: aws.String(d.Get(names.AttrContent).(string)), DocumentFormat: aws.String(d.Get("document_format").(string)), DocumentVersion: aws.String(d.Get("default_version").(string)), Name: aws.String(d.Id()), diff --git a/internal/service/ssm/document_data_source.go b/internal/service/ssm/document_data_source.go index 35bf8baa68c..cefa8837bcb 100644 --- a/internal/service/ssm/document_data_source.go +++ b/internal/service/ssm/document_data_source.go @@ -29,7 +29,7 @@ func DataSourceDocument() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "content": { + names.AttrContent: { Type: schema.TypeString, Computed: true, }, @@ -89,7 +89,7 @@ func dataDocumentRead(ctx context.Context, d *schema.ResourceData, meta interfac } else { d.Set(names.AttrARN, name) } - d.Set("content", output.Content) + d.Set(names.AttrContent, output.Content) d.Set("document_format", output.DocumentFormat) d.Set("document_type", output.DocumentType) d.Set("document_version", output.DocumentVersion) diff --git a/internal/service/ssm/document_data_source_test.go b/internal/service/ssm/document_data_source_test.go index 2267e20aef7..88779a4d7df 100644 --- a/internal/service/ssm/document_data_source_test.go +++ b/internal/service/ssm/document_data_source_test.go @@ -32,7 +32,7 @@ func TestAccSSMDocumentDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, "document_format", resourceName, "document_format"), resource.TestCheckResourceAttr(dataSourceName, "document_version", "1"), resource.TestCheckResourceAttrPair(dataSourceName, "document_type", resourceName, "document_type"), - resource.TestCheckResourceAttrPair(dataSourceName, "content", resourceName, "content"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrContent, resourceName, names.AttrContent), ), }, { @@ -43,7 +43,7 @@ func TestAccSSMDocumentDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "document_format", "YAML"), resource.TestCheckResourceAttr(dataSourceName, "document_version", "1"), resource.TestCheckResourceAttrPair(dataSourceName, "document_type", resourceName, "document_type"), - resource.TestCheckResourceAttrSet(dataSourceName, "content"), + resource.TestCheckResourceAttrSet(dataSourceName, names.AttrContent), ), }, }, diff --git a/internal/service/ssm/document_test.go b/internal/service/ssm/document_test.go index 2e0733b0824..18ecd357964 100644 --- a/internal/service/ssm/document_test.go +++ b/internal/service/ssm/document_test.go @@ -526,7 +526,7 @@ mainSteps: Config: testAccDocumentConfig_formatYAML(rName, content1), Check: resource.ComposeTestCheckFunc( testAccCheckDocumentExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "content", content1+"\n"), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content1+"\n"), resource.TestCheckResourceAttr(resourceName, "document_format", "YAML"), ), }, @@ -539,7 +539,7 @@ mainSteps: Config: testAccDocumentConfig_formatYAML(rName, content2), Check: resource.ComposeTestCheckFunc( testAccCheckDocumentExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "content", content2+"\n"), + resource.TestCheckResourceAttr(resourceName, names.AttrContent, content2+"\n"), resource.TestCheckResourceAttr(resourceName, "document_format", "YAML"), ), }, diff --git a/internal/service/ssm/maintenance_window.go b/internal/service/ssm/maintenance_window.go index 9f615db0ce7..687304c3949 100644 --- a/internal/service/ssm/maintenance_window.go +++ b/internal/service/ssm/maintenance_window.go @@ -49,7 +49,7 @@ func ResourceMaintenanceWindow() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "duration": { + names.AttrDuration: { Type: schema.TypeInt, Required: true, }, @@ -99,7 +99,7 @@ func resourceMaintenanceWindowCreate(ctx context.Context, d *schema.ResourceData input := &ssm.CreateMaintenanceWindowInput{ AllowUnassociatedTargets: aws.Bool(d.Get("allow_unassociated_targets").(bool)), Cutoff: aws.Int64(int64(d.Get("cutoff").(int))), - Duration: aws.Int64(int64(d.Get("duration").(int))), + Duration: aws.Int64(int64(d.Get(names.AttrDuration).(int))), Name: aws.String(name), Schedule: aws.String(d.Get(names.AttrSchedule).(string)), Tags: getTagsIn(ctx), @@ -168,7 +168,7 @@ func resourceMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData, d.Set("allow_unassociated_targets", output.AllowUnassociatedTargets) d.Set("cutoff", output.Cutoff) d.Set(names.AttrDescription, output.Description) - d.Set("duration", output.Duration) + d.Set(names.AttrDuration, output.Duration) d.Set(names.AttrEnabled, output.Enabled) d.Set("end_date", output.EndDate) d.Set(names.AttrName, output.Name) @@ -190,7 +190,7 @@ func resourceMaintenanceWindowUpdate(ctx context.Context, d *schema.ResourceData input := &ssm.UpdateMaintenanceWindowInput{ AllowUnassociatedTargets: aws.Bool(d.Get("allow_unassociated_targets").(bool)), Cutoff: aws.Int64(int64(d.Get("cutoff").(int))), - Duration: aws.Int64(int64(d.Get("duration").(int))), + Duration: aws.Int64(int64(d.Get(names.AttrDuration).(int))), Enabled: aws.Bool(d.Get(names.AttrEnabled).(bool)), Name: aws.String(d.Get(names.AttrName).(string)), Replace: aws.Bool(true), diff --git a/internal/service/ssm/maintenance_window_test.go b/internal/service/ssm/maintenance_window_test.go index 029b725a229..6827efbb70c 100644 --- a/internal/service/ssm/maintenance_window_test.go +++ b/internal/service/ssm/maintenance_window_test.go @@ -37,7 +37,7 @@ func TestAccSSMMaintenanceWindow_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &winId), resource.TestCheckResourceAttr(resourceName, "cutoff", "1"), - resource.TestCheckResourceAttr(resourceName, "duration", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "3"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, "end_date", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), @@ -182,7 +182,7 @@ func TestAccSSMMaintenanceWindow_multipleUpdates(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow1), resource.TestCheckResourceAttr(resourceName, "cutoff", "1"), - resource.TestCheckResourceAttr(resourceName, "duration", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "3"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName1), resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * TUE *)"), @@ -193,7 +193,7 @@ func TestAccSSMMaintenanceWindow_multipleUpdates(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow2), resource.TestCheckResourceAttr(resourceName, "cutoff", "8"), - resource.TestCheckResourceAttr(resourceName, "duration", "10"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "10"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "false"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName2), resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * WED *)"), @@ -254,7 +254,7 @@ func TestAccSSMMaintenanceWindow_duration(t *testing.T) { Config: testAccMaintenanceWindowConfig_duration(rName, 3), Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow1), - resource.TestCheckResourceAttr(resourceName, "duration", "3"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "3"), ), }, { @@ -266,7 +266,7 @@ func TestAccSSMMaintenanceWindow_duration(t *testing.T) { Config: testAccMaintenanceWindowConfig_duration(rName, 10), Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow2), - resource.TestCheckResourceAttr(resourceName, "duration", "10"), + resource.TestCheckResourceAttr(resourceName, names.AttrDuration, "10"), ), }, }, From fee8eb995686e7b66a6688252b17120000b897b1 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 71/78] synthetics: Use constants for strings --- internal/service/synthetics/canary.go | 10 +++++----- internal/service/synthetics/canary_test.go | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/synthetics/canary.go b/internal/service/synthetics/canary.go index 73e767e9104..7604c4178a5 100644 --- a/internal/service/synthetics/canary.go +++ b/internal/service/synthetics/canary.go @@ -156,7 +156,7 @@ func ResourceCanary() *schema.Resource { Type: schema.TypeString, Required: true, }, - "s3_bucket": { + names.AttrS3Bucket: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"zip_file"}, @@ -166,7 +166,7 @@ func ResourceCanary() *schema.Resource { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"zip_file"}, - RequiredWith: []string{"s3_bucket"}, + RequiredWith: []string{names.AttrS3Bucket}, }, "s3_version": { Type: schema.TypeString, @@ -264,7 +264,7 @@ func ResourceCanary() *schema.Resource { "zip_file": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"s3_bucket", "s3_key", "s3_version"}, + ConflictsWith: []string{names.AttrS3Bucket, "s3_key", "s3_version"}, }, }, @@ -445,7 +445,7 @@ func resourceCanaryUpdate(ctx context.Context, d *schema.ResourceData, meta inte input.RuntimeVersion = aws.String(d.Get("runtime_version").(string)) } - if d.HasChanges("handler", "zip_file", "s3_bucket", "s3_key", "s3_version") { + if d.HasChanges("handler", "zip_file", names.AttrS3Bucket, "s3_key", "s3_version") { if code, err := expandCanaryCode(d); err != nil { return sdkdiag.AppendErrorf(diags, "updating Synthetics Canary (%s): %s", d.Id(), err) } else { @@ -577,7 +577,7 @@ func expandCanaryCode(d *schema.ResourceData) (*awstypes.CanaryCodeInput, error) } codeConfig.ZipFile = file } else { - codeConfig.S3Bucket = aws.String(d.Get("s3_bucket").(string)) + codeConfig.S3Bucket = aws.String(d.Get(names.AttrS3Bucket).(string)) codeConfig.S3Key = aws.String(d.Get("s3_key").(string)) if v, ok := d.GetOk("s3_version"); ok { diff --git a/internal/service/synthetics/canary_test.go b/internal/service/synthetics/canary_test.go index cfc22ca0014..af7f1b3da76 100644 --- a/internal/service/synthetics/canary_test.go +++ b/internal/service/synthetics/canary_test.go @@ -302,7 +302,7 @@ func TestAccSyntheticsCanary_s3(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"s3_bucket", "s3_key", "s3_version", "start_canary", "delete_lambda"}, + ImportStateVerifyIgnore: []string{names.AttrS3Bucket, "s3_key", "s3_version", "start_canary", "delete_lambda"}, }, }, }) From 8966c05d6d8a385977bbb92ed460d55a648d574a Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 72/78] timestreamwrite: Use constants for strings --- internal/service/timestreamwrite/table.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/timestreamwrite/table.go b/internal/service/timestreamwrite/table.go index 224eedf7d89..6523f2cea1c 100644 --- a/internal/service/timestreamwrite/table.go +++ b/internal/service/timestreamwrite/table.go @@ -124,7 +124,7 @@ func resourceTable() *schema.Resource { }, }, }, - "schema": { + names.AttrSchema: { Type: schema.TypeList, Optional: true, Computed: true, @@ -199,7 +199,7 @@ func resourceTableCreate(ctx context.Context, d *schema.ResourceData, meta inter input.RetentionProperties = expandRetentionProperties(v.([]interface{})) } - if v, ok := d.GetOk("schema"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrSchema); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Schema = expandSchema(v.([]interface{})[0].(map[string]interface{})) } @@ -239,11 +239,11 @@ func resourceTableRead(ctx context.Context, d *schema.ResourceData, meta interfa return diag.Errorf("setting retention_properties: %s", err) } if table.Schema != nil { - if err := d.Set("schema", []interface{}{flattenSchema(table.Schema)}); err != nil { + if err := d.Set(names.AttrSchema, []interface{}{flattenSchema(table.Schema)}); err != nil { return diag.Errorf("setting schema: %s", err) } } else { - d.Set("schema", nil) + d.Set(names.AttrSchema, nil) } d.Set(names.AttrTableName, table.TableName) @@ -272,8 +272,8 @@ func resourceTableUpdate(ctx context.Context, d *schema.ResourceData, meta inter input.RetentionProperties = expandRetentionProperties(d.Get("retention_properties").([]interface{})) } - if d.HasChange("schema") { - if v, ok := d.GetOk("schema"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if d.HasChange(names.AttrSchema) { + if v, ok := d.GetOk(names.AttrSchema); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Schema = expandSchema(v.([]interface{})[0].(map[string]interface{})) } } From d56bc1ac9439a3fda30fd83a4f55e2cc282fb52f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 73/78] transfer: Use constants for strings --- internal/service/transfer/server.go | 6 +++--- internal/service/transfer/server_data_source.go | 4 ++-- internal/service/transfer/server_data_source_test.go | 2 +- internal/service/transfer/server_test.go | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/transfer/server.go b/internal/service/transfer/server.go index 235bdc01291..ebecd12cd56 100644 --- a/internal/service/transfer/server.go +++ b/internal/service/transfer/server.go @@ -67,7 +67,7 @@ func resourceServer() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -335,7 +335,7 @@ func resourceServerCreate(ctx context.Context, d *schema.ResourceData, meta inte input.IdentityProviderDetails.DirectoryId = aws.String(v.(string)) } - if v, ok := d.GetOk("domain"); ok { + if v, ok := d.GetOk(names.AttrDomain); ok { input.Domain = aws.String(v.(string)) } @@ -490,7 +490,7 @@ func resourceServerRead(ctx context.Context, d *schema.ResourceData, meta interf } else { d.Set("directory_id", "") } - d.Set("domain", output.Domain) + d.Set(names.AttrDomain, output.Domain) d.Set(names.AttrEndpoint, meta.(*conns.AWSClient).RegionalHostname(ctx, fmt.Sprintf("%s.server.transfer", d.Id()))) if output.EndpointDetails != nil { securityGroupIDs := make([]*string, 0) diff --git a/internal/service/transfer/server_data_source.go b/internal/service/transfer/server_data_source.go index afdc2782a4d..27a16993e5d 100644 --- a/internal/service/transfer/server_data_source.go +++ b/internal/service/transfer/server_data_source.go @@ -27,7 +27,7 @@ func DataSourceServer() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "domain": { + names.AttrDomain: { Type: schema.TypeString, Computed: true, }, @@ -98,7 +98,7 @@ func dataSourceServerRead(ctx context.Context, d *schema.ResourceData, meta inte d.SetId(aws.StringValue(output.ServerId)) d.Set(names.AttrARN, output.Arn) d.Set(names.AttrCertificate, output.Certificate) - d.Set("domain", output.Domain) + d.Set(names.AttrDomain, output.Domain) d.Set(names.AttrEndpoint, meta.(*conns.AWSClient).RegionalHostname(ctx, fmt.Sprintf("%s.server.transfer", serverID))) d.Set(names.AttrEndpointType, output.EndpointType) d.Set("identity_provider_type", output.IdentityProviderType) diff --git a/internal/service/transfer/server_data_source_test.go b/internal/service/transfer/server_data_source_test.go index 07ba8b00b90..a6117bfe8fe 100644 --- a/internal/service/transfer/server_data_source_test.go +++ b/internal/service/transfer/server_data_source_test.go @@ -27,7 +27,7 @@ func testAccServerDataSource_basic(t *testing.T) { Config: testAccServerDataSourceConfig_basic, Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(datasourceName, names.AttrARN, resourceName, names.AttrARN), - resource.TestCheckResourceAttrPair(datasourceName, "domain", resourceName, "domain"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrDomain, resourceName, names.AttrDomain), resource.TestCheckResourceAttrPair(datasourceName, names.AttrEndpoint, resourceName, names.AttrEndpoint), resource.TestCheckResourceAttrPair(datasourceName, "identity_provider_type", resourceName, "identity_provider_type"), resource.TestCheckResourceAttrPair(datasourceName, "logging_role", resourceName, "logging_role"), diff --git a/internal/service/transfer/server_test.go b/internal/service/transfer/server_test.go index ba2aef680fe..84dcc9815fa 100644 --- a/internal/service/transfer/server_test.go +++ b/internal/service/transfer/server_test.go @@ -93,7 +93,7 @@ func testAccServer_basic(t *testing.T) { testAccCheckServerExists(ctx, resourceName, &conf), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "transfer", regexache.MustCompile(`server/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrCertificate, ""), - resource.TestCheckResourceAttr(resourceName, "domain", "S3"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "S3"), acctest.MatchResourceAttrRegionalHostname(resourceName, names.AttrEndpoint, "server.transfer", regexache.MustCompile(`s-[0-9a-z]+`)), resource.TestCheckResourceAttr(resourceName, "endpoint_details.#", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrEndpointType, "PUBLIC"), @@ -200,7 +200,7 @@ func testAccServer_domain(t *testing.T) { Config: testAccServerConfig_domain(rName, "EFS"), Check: resource.ComposeTestCheckFunc( testAccCheckServerExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "domain", "EFS"), + resource.TestCheckResourceAttr(resourceName, names.AttrDomain, "EFS"), ), }, { From f3cbd84ae8f9b345328fb72f3ae83b388d38a44f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 74/78] vpclattice: Use constants for strings --- internal/service/vpclattice/listener.go | 6 +++--- internal/service/vpclattice/listener_data_source.go | 4 ++-- internal/service/vpclattice/listener_rule.go | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/service/vpclattice/listener.go b/internal/service/vpclattice/listener.go index 3d687eb7e78..a10a7500be1 100644 --- a/internal/service/vpclattice/listener.go +++ b/internal/service/vpclattice/listener.go @@ -101,7 +101,7 @@ func ResourceListener() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Default: 100, Optional: true, @@ -381,7 +381,7 @@ func flattenDefaultActionForwardTargetGroups(groups []types.WeightedTargetGroup) for _, targetGroup := range groups { m := map[string]interface{}{ "target_group_identifier": aws.ToString(targetGroup.TargetGroupIdentifier), - "weight": aws.ToInt32(targetGroup.Weight), + names.AttrWeight: aws.ToInt32(targetGroup.Weight), } targetGroups = append(targetGroups, m) } @@ -434,7 +434,7 @@ func expandForwardTargetGroupList(tfList []interface{}) []types.WeightedTargetGr targetGroup := &types.WeightedTargetGroup{ TargetGroupIdentifier: aws.String((tfMap["target_group_identifier"].(string))), - Weight: aws.Int32(int32(tfMap["weight"].(int))), + Weight: aws.Int32(int32(tfMap[names.AttrWeight].(int))), } targetGroups = append(targetGroups, *targetGroup) diff --git a/internal/service/vpclattice/listener_data_source.go b/internal/service/vpclattice/listener_data_source.go index 8bc27b2ae59..0c47a69d081 100644 --- a/internal/service/vpclattice/listener_data_source.go +++ b/internal/service/vpclattice/listener_data_source.go @@ -66,7 +66,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, Computed: true, }, @@ -246,7 +246,7 @@ func flattenDefaultActionForwardTargetGroupsDataSource(groups []types.WeightedTa for _, targetGroup := range groups { m := map[string]interface{}{ "target_group_identifier": aws.ToString(targetGroup.TargetGroupIdentifier), - "weight": aws.ToInt32(targetGroup.Weight), + names.AttrWeight: aws.ToInt32(targetGroup.Weight), } targetGroups = append(targetGroups, m) } diff --git a/internal/service/vpclattice/listener_rule.go b/internal/service/vpclattice/listener_rule.go index 3aa760eac1e..c6b3fdb7dee 100644 --- a/internal/service/vpclattice/listener_rule.go +++ b/internal/service/vpclattice/listener_rule.go @@ -96,7 +96,7 @@ func ResourceListenerRule() *schema.Resource { Type: schema.TypeString, Required: true, }, - "weight": { + names.AttrWeight: { Type: schema.TypeInt, ValidateFunc: validation.IntBetween(0, 999), Default: 100, @@ -484,7 +484,7 @@ func flattenWeightedTargetGroup(apiObject *types.WeightedTargetGroup) map[string } if v := apiObject.Weight; v != nil { - tfMap["weight"] = aws.ToInt32(v) + tfMap[names.AttrWeight] = aws.ToInt32(v) } return tfMap @@ -734,7 +734,7 @@ func expandWeightedTargetGroup(tfMap map[string]interface{}) types.WeightedTarge apiObject.TargetGroupIdentifier = aws.String(v) } - if v, ok := tfMap["weight"].(int); ok && v != 0 { + if v, ok := tfMap[names.AttrWeight].(int); ok && v != 0 { apiObject.Weight = aws.Int32(int32(v)) } From 5670811d47620ff0d5b5e76ecc3b2f4d685a1fae Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 75/78] waf: Use constants for strings --- internal/service/waf/web_acl.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/waf/web_acl.go b/internal/service/waf/web_acl.go index da954fced6b..8d011378cb6 100644 --- a/internal/service/waf/web_acl.go +++ b/internal/service/waf/web_acl.go @@ -64,7 +64,7 @@ func ResourceWebACL() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z]+$`), "must contain only alphanumeric characters"), }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -189,7 +189,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte Resource: fmt.Sprintf("webacl/%s", d.Id()), }.String() - loggingConfiguration := d.Get("logging_configuration").([]interface{}) + loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}) if len(loggingConfiguration) == 1 { input := &waf.PutLoggingConfigurationInput{ LoggingConfiguration: expandLoggingConfiguration(loggingConfiguration, arn), @@ -277,7 +277,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf loggingConfiguration = flattenLoggingConfiguration(getLoggingConfigurationOutput.LoggingConfiguration) } - if err := d.Set("logging_configuration", loggingConfiguration); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, loggingConfiguration); err != nil { return sdkdiag.AppendErrorf(diags, "setting logging_configuration: %s", err) } @@ -307,8 +307,8 @@ func resourceWebACLUpdate(ctx context.Context, d *schema.ResourceData, meta inte } } - if d.HasChange("logging_configuration") { - loggingConfiguration := d.Get("logging_configuration").([]interface{}) + if d.HasChange(names.AttrLoggingConfiguration) { + loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}) if len(loggingConfiguration) == 1 { input := &waf.PutLoggingConfigurationInput{ From fe0099c4df1b2dad0c88c64df2f6cf6a86c1c231 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:06 -0400 Subject: [PATCH 76/78] wafregional: Use constants for strings --- internal/service/wafregional/web_acl.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/wafregional/web_acl.go b/internal/service/wafregional/web_acl.go index 363efcc9c22..1df56aa2bde 100644 --- a/internal/service/wafregional/web_acl.go +++ b/internal/service/wafregional/web_acl.go @@ -65,7 +65,7 @@ func resourceWebACL() *schema.Resource { }, }, }, - "logging_configuration": { + names.AttrLoggingConfiguration: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -214,7 +214,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte }.String() } - loggingConfiguration := d.Get("logging_configuration").([]interface{}) + loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}) if len(loggingConfiguration) == 1 { input := &waf.PutLoggingConfigurationInput{ @@ -310,7 +310,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf loggingConfiguration = flattenLoggingConfiguration(getLoggingConfigurationOutput.LoggingConfiguration) } - if err := d.Set("logging_configuration", loggingConfiguration); err != nil { + if err := d.Set(names.AttrLoggingConfiguration, loggingConfiguration); err != nil { return sdkdiag.AppendErrorf(diags, "setting logging_configuration: %s", err) } @@ -341,8 +341,8 @@ func resourceWebACLUpdate(ctx context.Context, d *schema.ResourceData, meta inte } } - if d.HasChange("logging_configuration") { - loggingConfiguration := d.Get("logging_configuration").([]interface{}) + if d.HasChange(names.AttrLoggingConfiguration) { + loggingConfiguration := d.Get(names.AttrLoggingConfiguration).([]interface{}) if len(loggingConfiguration) == 1 { input := &waf.PutLoggingConfigurationInput{ From 27747ea5bf6e9cf4afbeb2e9fe15f72228a0b522 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:07 -0400 Subject: [PATCH 77/78] wafv2: Use constants for strings --- internal/service/wafv2/flex.go | 4 ++-- internal/service/wafv2/rule_group_test.go | 8 ++++---- internal/service/wafv2/schemas.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/wafv2/flex.go b/internal/service/wafv2/flex.go index 8d276f77027..370858284ff 100644 --- a/internal/service/wafv2/flex.go +++ b/internal/service/wafv2/flex.go @@ -319,7 +319,7 @@ func expandCustomResponseBodies(m []interface{}) map[string]awstypes.CustomRespo vm := v.(map[string]interface{}) key := vm[names.AttrKey].(string) customResponseBodies[key] = awstypes.CustomResponseBody{ - Content: aws.String(vm["content"].(string)), + Content: aws.String(vm[names.AttrContent].(string)), ContentType: awstypes.ResponseContentType(vm[names.AttrContentType].(string)), } } @@ -1814,7 +1814,7 @@ func flattenCustomResponseBodies(b map[string]awstypes.CustomResponseBody) inter for key, body := range b { out[i] = map[string]interface{}{ names.AttrKey: key, - "content": aws.ToString(body.Content), + names.AttrContent: aws.ToString(body.Content), names.AttrContentType: string(body.ContentType), } i += 1 diff --git a/internal/service/wafv2/rule_group_test.go b/internal/service/wafv2/rule_group_test.go index eb063308846..b9078f6c12d 100644 --- a/internal/service/wafv2/rule_group_test.go +++ b/internal/service/wafv2/rule_group_test.go @@ -1729,12 +1729,12 @@ func TestAccWAFV2RuleGroup_RuleAction_customResponse(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "visibility_config.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "custom_response_body.*", map[string]string{ names.AttrKey: "test_body_1", - "content": "test response 1", + names.AttrContent: "test response 1", names.AttrContentType: "TEXT_PLAIN", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "custom_response_body.*", map[string]string{ names.AttrKey: "test_body_2", - "content": "test response 2", + names.AttrContent: "test response 2", names.AttrContentType: "TEXT_HTML", }), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), @@ -1764,12 +1764,12 @@ func TestAccWAFV2RuleGroup_RuleAction_customResponse(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "custom_response_body.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "custom_response_body.*", map[string]string{ names.AttrKey: "test_body_1", - "content": "test response 1", + names.AttrContent: "test response 1", names.AttrContentType: "TEXT_PLAIN", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "custom_response_body.*", map[string]string{ names.AttrKey: "test_body_2", - "content": "test response 2", + names.AttrContent: "test response 2", names.AttrContentType: "TEXT_HTML", }), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), diff --git a/internal/service/wafv2/schemas.go b/internal/service/wafv2/schemas.go index 1fb6ef0b01f..5c1ea211d48 100644 --- a/internal/service/wafv2/schemas.go +++ b/internal/service/wafv2/schemas.go @@ -766,7 +766,7 @@ func customResponseBodySchema() *schema.Schema { validation.StringMatch(regexache.MustCompile(`^[\w\-]+$`), "must contain only alphanumeric, hyphen, and underscore characters"), ), }, - "content": { + names.AttrContent: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 10240), From 179469604b1c411067b1abcdb0950263b9e7878c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Sat, 11 May 2024 10:50:07 -0400 Subject: [PATCH 78/78] names: Use constants for strings --- names/attr_constants.csv | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/names/attr_constants.csv b/names/attr_constants.csv index cfb7e91ad30..e795e1e7763 100644 --- a/names/attr_constants.csv +++ b/names/attr_constants.csv @@ -17,11 +17,13 @@ certificate_arn,CertificateARN client_id,ClientID cluster_identifier,ClusterIdentifier configuration,Configuration +content,Content content_type,ContentType created_at,CreatedAt created_date,CreatedDate creation_date,CreationDate creation_time,CreationTime +database,Database database_name,DatabaseName delete_on_termination,DeleteOnTermination description,Description @@ -29,7 +31,10 @@ destination,Destination destination_arn,DestinationARN device_name,DeviceName display_name,DisplayName +dns_name,DNSName +domain,Domain domain_name,DomainName +duration,Duration enabled,Enabled encrypted,Encrypted encryption_configuration,EncryptionConfiguration @@ -55,6 +60,7 @@ kms_key_arn,KMSKeyARN kms_key_id,KMSKeyID last_updated_date,LastUpdatedDate log_group_name,LogGroupName +logging_configuration,LoggingConfiguration max,Max metric_name,MetricName min,Min @@ -84,9 +90,11 @@ region,Region resource_arn,ResourceARN resource_type,ResourceType role_arn,RoleARN +s3_bucket,S3Bucket s3_bucket_name,S3BucketName schedule,Schedule schedule_expression,ScheduleExpression +schema,Schema secret_key,SecretKey security_group_ids,SecurityGroupIDs security_groups,SecurityGroups @@ -101,6 +109,7 @@ state,State status,Status subnet_id,SubnetID subnet_ids,SubnetIDs +subnets,Subnets table_name,TableName tags,Tags tags_all,TagsAll @@ -119,3 +128,4 @@ version,Version vpc_config,VPCConfig vpc_id,VPCID vpc_security_group_ids,VPCSecurityGroupIDs +weight,Weight