From 5bf78692ba202d03cbe5594679192eb849058d17 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:55 -0400 Subject: [PATCH 01/62] ci: Prefer constant for string literals --- .ci/.semgrep-constants.yml | 110 +++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/.ci/.semgrep-constants.yml b/.ci/.semgrep-constants.yml index 2e0f4a06aa1..a6549fe4910 100644 --- a/.ci/.semgrep-constants.yml +++ b/.ci/.semgrep-constants.yml @@ -370,6 +370,16 @@ rules: - pattern: '"database_name"' severity: ERROR fix: "names.AttrDatabaseName" + - id: literal-default_action-string-constant + languages: [go] + message: Use the constant `names.AttrDefaultAction` for the string literal "default_action" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"default_action"' + severity: ERROR + fix: "names.AttrDefaultAction" - id: literal-default_value-string-constant languages: [go] message: Use the constant `names.AttrDefaultValue` for the string literal "default_value" @@ -580,6 +590,16 @@ rules: - pattern: '"expression"' severity: ERROR fix: "names.AttrExpression" + - id: literal-external_id-string-constant + languages: [go] + message: Use the constant `names.AttrExternalID` for the string literal "external_id" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"external_id"' + severity: ERROR + fix: "names.AttrExternalID" - id: literal-family-string-constant languages: [go] message: Use the constant `names.AttrFamily` for the string literal "family" @@ -620,6 +640,16 @@ rules: - pattern: '"filter"' severity: ERROR fix: "names.AttrFilter" + - id: literal-force_delete-string-constant + languages: [go] + message: Use the constant `names.AttrForceDelete` for the string literal "force_delete" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"force_delete"' + severity: ERROR + fix: "names.AttrForceDelete" - id: literal-force_destroy-string-constant languages: [go] message: Use the constant `names.AttrForceDestroy` for the string literal "force_destroy" @@ -870,6 +900,16 @@ rules: - pattern: '"key_id"' severity: ERROR fix: "names.AttrKeyID" + - id: literal-language_code-string-constant + languages: [go] + message: Use the constant `names.AttrLanguageCode` for the string literal "language_code" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"language_code"' + severity: ERROR + fix: "names.AttrLanguageCode" - id: literal-last_updated_date-string-constant languages: [go] message: Use the constant `names.AttrLastUpdatedDate` for the string literal "last_updated_date" @@ -920,6 +960,16 @@ rules: - pattern: '"max"' severity: ERROR fix: "names.AttrMax" + - id: literal-max_capacity-string-constant + languages: [go] + message: Use the constant `names.AttrMaxCapacity` for the string literal "max_capacity" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"max_capacity"' + severity: ERROR + fix: "names.AttrMaxCapacity" - id: literal-message-string-constant languages: [go] message: Use the constant `names.AttrMessage` for the string literal "message" @@ -1180,6 +1230,16 @@ rules: - pattern: '"profile"' severity: ERROR fix: "names.AttrProfile" + - id: literal-propagate_tags-string-constant + languages: [go] + message: Use the constant `names.AttrPropagateTags` for the string literal "propagate_tags" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"propagate_tags"' + severity: ERROR + fix: "names.AttrPropagateTags" - id: literal-properties-string-constant languages: [go] message: Use the constant `names.AttrProperties` for the string literal "properties" @@ -1200,6 +1260,16 @@ rules: - pattern: '"protocol"' severity: ERROR fix: "names.AttrProtocol" + - id: literal-provider_name-string-constant + languages: [go] + message: Use the constant `names.AttrProviderName` for the string literal "provider_name" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"provider_name"' + severity: ERROR + fix: "names.AttrProviderName" - id: literal-public_key-string-constant languages: [go] message: Use the constant `names.AttrPublicKey` for the string literal "public_key" @@ -1450,6 +1520,16 @@ rules: - pattern: '"service_name"' severity: ERROR fix: "names.AttrServiceName" + - id: literal-service_role-string-constant + languages: [go] + message: Use the constant `names.AttrServiceRole` for the string literal "service_role" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"service_role"' + severity: ERROR + fix: "names.AttrServiceRole" - id: literal-service_role_arn-string-constant languages: [go] message: Use the constant `names.AttrServiceRoleARN` for the string literal "service_role_arn" @@ -1520,6 +1600,16 @@ rules: - pattern: '"skip_requesting_account_id"' severity: ERROR fix: "names.AttrSkipRequestingAccountID" + - id: literal-snapshot_id-string-constant + languages: [go] + message: Use the constant `names.AttrSnapshotID` for the string literal "snapshot_id" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"snapshot_id"' + severity: ERROR + fix: "names.AttrSnapshotID" - id: literal-source-string-constant languages: [go] message: Use the constant `names.AttrSource` for the string literal "source" @@ -1580,6 +1670,16 @@ rules: - pattern: '"status"' severity: ERROR fix: "names.AttrStatus" + - id: literal-status_code-string-constant + languages: [go] + message: Use the constant `names.AttrStatusCode` for the string literal "status_code" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"status_code"' + severity: ERROR + fix: "names.AttrStatusCode" - id: literal-status_message-string-constant languages: [go] message: Use the constant `names.AttrStatusMessage` for the string literal "status_message" @@ -1590,6 +1690,16 @@ rules: - pattern: '"status_message"' severity: ERROR fix: "names.AttrStatusMessage" + - id: literal-status_reason-string-constant + languages: [go] + message: Use the constant `names.AttrStatusReason` for the string literal "status_reason" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"status_reason"' + severity: ERROR + fix: "names.AttrStatusReason" - id: literal-storage_type-string-constant languages: [go] message: Use the constant `names.AttrStorageType` for the string literal "storage_type" From e50b00201d5360300970e5eb502cf22bf9c37e34 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:55 -0400 Subject: [PATCH 02/62] names: Add constant for string literals --- names/attr_consts_gen.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/names/attr_consts_gen.go b/names/attr_consts_gen.go index 7532912a58e..3c410a78173 100644 --- a/names/attr_consts_gen.go +++ b/names/attr_consts_gen.go @@ -46,6 +46,7 @@ const ( AttrDNSName = "dns_name" AttrDatabase = "database" AttrDatabaseName = "database_name" + AttrDefaultAction = "default_action" AttrDefaultValue = "default_value" AttrDeleteOnTermination = "delete_on_termination" AttrDescription = "description" @@ -67,10 +68,12 @@ const ( AttrEnvironment = "environment" AttrExecutionRoleARN = "execution_role_arn" AttrExpression = "expression" + AttrExternalID = "external_id" AttrFamily = "family" AttrField = "field" AttrFileSystemID = "file_system_id" AttrFilter = "filter" + AttrForceDelete = "force_delete" AttrForceDestroy = "force_destroy" AttrFormat = "format" AttrFunctionARN = "function_arn" @@ -96,11 +99,13 @@ const ( AttrKMSKeyID = "kms_key_id" AttrKey = "key" AttrKeyID = "key_id" + AttrLanguageCode = "language_code" AttrLastUpdatedDate = "last_updated_date" AttrLaunchTemplate = "launch_template" AttrLogGroupName = "log_group_name" AttrLoggingConfiguration = "logging_configuration" AttrMax = "max" + AttrMaxCapacity = "max_capacity" AttrMessage = "message" AttrMetricName = "metric_name" AttrMin = "min" @@ -127,8 +132,10 @@ const ( AttrPriority = "priority" AttrPrivateKey = "private_key" AttrProfile = "profile" + AttrPropagateTags = "propagate_tags" AttrProperties = "properties" AttrProtocol = "protocol" + AttrProviderName = "provider_name" AttrPublicKey = "public_key" AttrPubliclyAccessible = "publicly_accessible" AttrRegion = "region" @@ -154,6 +161,7 @@ const ( AttrSecurityGroupIDs = "security_group_ids" AttrSecurityGroups = "security_groups" AttrServiceName = "service_name" + AttrServiceRole = "service_role" AttrServiceRoleARN = "service_role_arn" AttrSession = "session" AttrSharedConfigFiles = "shared_config_files" @@ -161,13 +169,16 @@ const ( AttrSkipCredentialsValidation = "skip_credentials_validation" AttrSkipDestroy = "skip_destroy" AttrSkipRequestingAccountID = "skip_requesting_account_id" + AttrSnapshotID = "snapshot_id" AttrSource = "source" AttrSourceType = "source_type" AttrStage = "stage" AttrStartTime = "start_time" AttrState = "state" AttrStatus = "status" + AttrStatusCode = "status_code" AttrStatusMessage = "status_message" + AttrStatusReason = "status_reason" AttrStorageType = "storage_type" AttrStreamARN = "stream_arn" AttrSubnetID = "subnet_id" @@ -245,6 +256,7 @@ func ConstOrQuote(constant string) string { "dns_name": "AttrDNSName", "database": "AttrDatabase", "database_name": "AttrDatabaseName", + "default_action": "AttrDefaultAction", "default_value": "AttrDefaultValue", "delete_on_termination": "AttrDeleteOnTermination", "description": "AttrDescription", @@ -266,10 +278,12 @@ func ConstOrQuote(constant string) string { "environment": "AttrEnvironment", "execution_role_arn": "AttrExecutionRoleARN", "expression": "AttrExpression", + "external_id": "AttrExternalID", "family": "AttrFamily", "field": "AttrField", "file_system_id": "AttrFileSystemID", "filter": "AttrFilter", + "force_delete": "AttrForceDelete", "force_destroy": "AttrForceDestroy", "format": "AttrFormat", "function_arn": "AttrFunctionARN", @@ -295,11 +309,13 @@ func ConstOrQuote(constant string) string { "kms_key_id": "AttrKMSKeyID", "key": "AttrKey", "key_id": "AttrKeyID", + "language_code": "AttrLanguageCode", "last_updated_date": "AttrLastUpdatedDate", "launch_template": "AttrLaunchTemplate", "log_group_name": "AttrLogGroupName", "logging_configuration": "AttrLoggingConfiguration", "max": "AttrMax", + "max_capacity": "AttrMaxCapacity", "message": "AttrMessage", "metric_name": "AttrMetricName", "min": "AttrMin", @@ -326,8 +342,10 @@ func ConstOrQuote(constant string) string { "priority": "AttrPriority", "private_key": "AttrPrivateKey", "profile": "AttrProfile", + "propagate_tags": "AttrPropagateTags", "properties": "AttrProperties", "protocol": "AttrProtocol", + "provider_name": "AttrProviderName", "public_key": "AttrPublicKey", "publicly_accessible": "AttrPubliclyAccessible", "region": "AttrRegion", @@ -353,6 +371,7 @@ func ConstOrQuote(constant string) string { "security_group_ids": "AttrSecurityGroupIDs", "security_groups": "AttrSecurityGroups", "service_name": "AttrServiceName", + "service_role": "AttrServiceRole", "service_role_arn": "AttrServiceRoleARN", "session": "AttrSession", "shared_config_files": "AttrSharedConfigFiles", @@ -360,13 +379,16 @@ func ConstOrQuote(constant string) string { "skip_credentials_validation": "AttrSkipCredentialsValidation", "skip_destroy": "AttrSkipDestroy", "skip_requesting_account_id": "AttrSkipRequestingAccountID", + "snapshot_id": "AttrSnapshotID", "source": "AttrSource", "source_type": "AttrSourceType", "stage": "AttrStage", "start_time": "AttrStartTime", "state": "AttrState", "status": "AttrStatus", + "status_code": "AttrStatusCode", "status_message": "AttrStatusMessage", + "status_reason": "AttrStatusReason", "storage_type": "AttrStorageType", "stream_arn": "AttrStreamARN", "subnet_id": "AttrSubnetID", From 4269ca6359a1fb3c2cde21eeb0a1c536cc14d527 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:55 -0400 Subject: [PATCH 03/62] apigateway: Use constants for strings --- internal/service/apigateway/documentation_part.go | 6 +++--- internal/service/apigateway/gateway_response.go | 6 +++--- .../service/apigateway/gateway_response_test.go | 4 ++-- .../service/apigateway/integration_response.go | 12 ++++++------ .../apigateway/integration_response_test.go | 10 +++++----- internal/service/apigateway/method_response.go | 14 +++++++------- .../service/apigateway/method_response_test.go | 10 +++++----- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/internal/service/apigateway/documentation_part.go b/internal/service/apigateway/documentation_part.go index bdabcea7a7f..ea8552c0dd3 100644 --- a/internal/service/apigateway/documentation_part.go +++ b/internal/service/apigateway/documentation_part.go @@ -61,7 +61,7 @@ func resourceDocumentationPart() *schema.Resource { Optional: true, ForceNew: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -260,7 +260,7 @@ func expandDocumentationPartLocation(l []interface{}) *types.DocumentationPartLo if v, ok := loc[names.AttrPath]; ok { out.Path = aws.String(v.(string)) } - if v, ok := loc["status_code"]; ok { + if v, ok := loc[names.AttrStatusCode]; ok { out.StatusCode = aws.String(v.(string)) } return out @@ -286,7 +286,7 @@ func flattenDocumentationPartLocation(l *types.DocumentationPartLocation) []inte } if v := l.StatusCode; v != nil { - m["status_code"] = aws.ToString(v) + m[names.AttrStatusCode] = aws.ToString(v) } m[names.AttrType] = string(l.Type) diff --git a/internal/service/apigateway/gateway_response.go b/internal/service/apigateway/gateway_response.go index 127b6f88495..a6d4427ab99 100644 --- a/internal/service/apigateway/gateway_response.go +++ b/internal/service/apigateway/gateway_response.go @@ -66,7 +66,7 @@ func resourceGatewayResponse() *schema.Resource { Required: true, ForceNew: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Optional: true, }, @@ -91,7 +91,7 @@ func resourceGatewayResponsePut(ctx context.Context, d *schema.ResourceData, met input.ResponseTemplates = flex.ExpandStringValueMap(v.(map[string]interface{})) } - if v, ok := d.GetOk("status_code"); ok { + if v, ok := d.GetOk(names.AttrStatusCode); ok { input.StatusCode = aws.String(v.(string)) } @@ -127,7 +127,7 @@ func resourceGatewayResponseRead(ctx context.Context, d *schema.ResourceData, me d.Set("response_parameters", gatewayResponse.ResponseParameters) d.Set("response_templates", gatewayResponse.ResponseTemplates) d.Set("response_type", gatewayResponse.ResponseType) - d.Set("status_code", gatewayResponse.StatusCode) + d.Set(names.AttrStatusCode, gatewayResponse.StatusCode) return diags } diff --git a/internal/service/apigateway/gateway_response_test.go b/internal/service/apigateway/gateway_response_test.go index 226288becf5..3e2c9d1992c 100644 --- a/internal/service/apigateway/gateway_response_test.go +++ b/internal/service/apigateway/gateway_response_test.go @@ -35,7 +35,7 @@ func TestAccAPIGatewayGatewayResponse_basic(t *testing.T) { Config: testAccGatewayResponseConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGatewayResponseExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "status_code", "401"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "401"), resource.TestCheckResourceAttr(resourceName, "response_parameters.gatewayresponse.header.Authorization", "'Basic'"), resource.TestCheckResourceAttr(resourceName, "response_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"), resource.TestCheckNoResourceAttr(resourceName, "response_templates.application/json"), @@ -51,7 +51,7 @@ func TestAccAPIGatewayGatewayResponse_basic(t *testing.T) { Config: testAccGatewayResponseConfig_update(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGatewayResponseExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "status_code", "477"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "477"), resource.TestCheckResourceAttr(resourceName, "response_templates.application/json", "{'message':$context.error.messageString}"), resource.TestCheckNoResourceAttr(resourceName, "response_templates.application/xml"), resource.TestCheckNoResourceAttr(resourceName, "response_parameters.gatewayresponse.header.Authorization"), diff --git a/internal/service/apigateway/integration_response.go b/internal/service/apigateway/integration_response.go index f958b8bfc4e..89d08731a76 100644 --- a/internal/service/apigateway/integration_response.go +++ b/internal/service/apigateway/integration_response.go @@ -42,7 +42,7 @@ func resourceIntegrationResponse() *schema.Resource { httpMethod := idParts[2] statusCode := idParts[3] d.Set("http_method", httpMethod) - d.Set("status_code", statusCode) + d.Set(names.AttrStatusCode, statusCode) d.Set(names.AttrResourceID, resourceID) d.Set("rest_api_id", restApiID) d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", restApiID, resourceID, httpMethod, statusCode)) @@ -86,7 +86,7 @@ func resourceIntegrationResponse() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Required: true, }, @@ -102,7 +102,7 @@ func resourceIntegrationResponsePut(ctx context.Context, d *schema.ResourceData, HttpMethod: aws.String(d.Get("http_method").(string)), ResourceId: aws.String(d.Get(names.AttrResourceID).(string)), RestApiId: aws.String(d.Get("rest_api_id").(string)), - StatusCode: aws.String(d.Get("status_code").(string)), + StatusCode: aws.String(d.Get(names.AttrStatusCode).(string)), } if v, ok := d.GetOk("content_handling"); ok { @@ -128,7 +128,7 @@ func resourceIntegrationResponsePut(ctx context.Context, d *schema.ResourceData, } if d.IsNewResource() { - d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get(names.AttrResourceID).(string), d.Get("http_method").(string), d.Get("status_code").(string))) + d.SetId(fmt.Sprintf("agir-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get(names.AttrResourceID).(string), d.Get("http_method").(string), d.Get(names.AttrStatusCode).(string))) } return append(diags, resourceIntegrationResponseRead(ctx, d, meta)...) @@ -138,7 +138,7 @@ func resourceIntegrationResponseRead(ctx context.Context, d *schema.ResourceData var diags diag.Diagnostics conn := meta.(*conns.AWSClient).APIGatewayClient(ctx) - integrationResponse, err := findIntegrationResponseByFourPartKey(ctx, conn, d.Get("http_method").(string), d.Get(names.AttrResourceID).(string), d.Get("rest_api_id").(string), d.Get("status_code").(string)) + integrationResponse, err := findIntegrationResponseByFourPartKey(ctx, conn, d.Get("http_method").(string), d.Get(names.AttrResourceID).(string), d.Get("rest_api_id").(string), d.Get(names.AttrStatusCode).(string)) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] API Gateway Integration Response (%s) not found, removing from state", d.Id()) @@ -172,7 +172,7 @@ func resourceIntegrationResponseDelete(ctx context.Context, d *schema.ResourceDa HttpMethod: aws.String(d.Get("http_method").(string)), ResourceId: aws.String(d.Get(names.AttrResourceID).(string)), RestApiId: aws.String(d.Get("rest_api_id").(string)), - StatusCode: aws.String(d.Get("status_code").(string)), + StatusCode: aws.String(d.Get(names.AttrStatusCode).(string)), }) if errs.IsA[*types.NotFoundException](err) { diff --git a/internal/service/apigateway/integration_response_test.go b/internal/service/apigateway/integration_response_test.go index d2ef3f724c3..2d93b8d5f8d 100644 --- a/internal/service/apigateway/integration_response_test.go +++ b/internal/service/apigateway/integration_response_test.go @@ -42,7 +42,7 @@ func TestAccAPIGatewayIntegrationResponse_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "response_templates.application/json", ""), resource.TestCheckResourceAttr(resourceName, "response_templates.application/xml", "#set($inputRoot = $input.path('$'))\n{ }"), resource.TestCheckResourceAttr(resourceName, "selection_pattern", ".*"), - resource.TestCheckResourceAttr(resourceName, "status_code", "400"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "400"), ), }, { @@ -61,7 +61,7 @@ func TestAccAPIGatewayIntegrationResponse_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "response_templates.application/json", "$input.path('$')"), resource.TestCheckResourceAttr(resourceName, "response_templates.application/xml", ""), resource.TestCheckResourceAttr(resourceName, "selection_pattern", ""), - resource.TestCheckResourceAttr(resourceName, "status_code", "400"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "400"), ), }, }, @@ -101,7 +101,7 @@ func testAccCheckIntegrationResponseExists(ctx context.Context, n string, v *api conn := acctest.Provider.Meta().(*conns.AWSClient).APIGatewayClient(ctx) - output, err := tfapigateway.FindIntegrationResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes["status_code"]) + output, err := tfapigateway.FindIntegrationResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrStatusCode]) if err != nil { return err @@ -122,7 +122,7 @@ func testAccCheckIntegrationResponseDestroy(ctx context.Context) resource.TestCh continue } - _, err := tfapigateway.FindIntegrationResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes["status_code"]) + _, err := tfapigateway.FindIntegrationResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrStatusCode]) if tfresource.NotFound(err) { continue @@ -146,7 +146,7 @@ func testAccIntegrationResponseImportStateIdFunc(resourceName string) resource.I return "", fmt.Errorf("Not found: %s", resourceName) } - return fmt.Sprintf("%s/%s/%s/%s", rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["http_method"], rs.Primary.Attributes["status_code"]), nil + return fmt.Sprintf("%s/%s/%s/%s", rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrStatusCode]), nil } } diff --git a/internal/service/apigateway/method_response.go b/internal/service/apigateway/method_response.go index cad0364e7f1..a9b431dec1c 100644 --- a/internal/service/apigateway/method_response.go +++ b/internal/service/apigateway/method_response.go @@ -43,7 +43,7 @@ func resourceMethodResponse() *schema.Resource { httpMethod := idParts[2] statusCode := idParts[3] d.Set("http_method", httpMethod) - d.Set("status_code", statusCode) + d.Set(names.AttrStatusCode, statusCode) d.Set(names.AttrResourceID, resourceID) d.Set("rest_api_id", restApiID) d.SetId(fmt.Sprintf("agmr-%s-%s-%s-%s", restApiID, resourceID, httpMethod, statusCode)) @@ -78,7 +78,7 @@ func resourceMethodResponse() *schema.Resource { Required: true, ForceNew: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Required: true, }, @@ -94,7 +94,7 @@ func resourceMethodResponseCreate(ctx context.Context, d *schema.ResourceData, m HttpMethod: aws.String(d.Get("http_method").(string)), ResourceId: aws.String(d.Get(names.AttrResourceID).(string)), RestApiId: aws.String(d.Get("rest_api_id").(string)), - StatusCode: aws.String(d.Get("status_code").(string)), + StatusCode: aws.String(d.Get(names.AttrStatusCode).(string)), } if v, ok := d.GetOk("response_models"); ok && len(v.(map[string]interface{})) > 0 { @@ -120,7 +120,7 @@ func resourceMethodResponseCreate(ctx context.Context, d *schema.ResourceData, m return sdkdiag.AppendErrorf(diags, "creating API Gateway Method Response: %s", err) } - d.SetId(fmt.Sprintf("agmr-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get(names.AttrResourceID).(string), d.Get("http_method").(string), d.Get("status_code").(string))) + d.SetId(fmt.Sprintf("agmr-%s-%s-%s-%s", d.Get("rest_api_id").(string), d.Get(names.AttrResourceID).(string), d.Get("http_method").(string), d.Get(names.AttrStatusCode).(string))) return diags } @@ -129,7 +129,7 @@ func resourceMethodResponseRead(ctx context.Context, d *schema.ResourceData, met var diags diag.Diagnostics conn := meta.(*conns.AWSClient).APIGatewayClient(ctx) - methodResponse, err := findMethodResponseByFourPartKey(ctx, conn, d.Get("http_method").(string), d.Get(names.AttrResourceID).(string), d.Get("rest_api_id").(string), d.Get("status_code").(string)) + methodResponse, err := findMethodResponseByFourPartKey(ctx, conn, d.Get("http_method").(string), d.Get(names.AttrResourceID).(string), d.Get("rest_api_id").(string), d.Get(names.AttrStatusCode).(string)) if !d.IsNewResource() && tfresource.NotFound(err) { log.Printf("[WARN] API Gateway Method Response (%s) not found, removing from state", d.Id()) @@ -170,7 +170,7 @@ func resourceMethodResponseUpdate(ctx context.Context, d *schema.ResourceData, m PatchOperations: operations, ResourceId: aws.String(d.Get(names.AttrResourceID).(string)), RestApiId: aws.String(d.Get("rest_api_id").(string)), - StatusCode: aws.String(d.Get("status_code").(string)), + StatusCode: aws.String(d.Get(names.AttrStatusCode).(string)), } _, err := conn.UpdateMethodResponse(ctx, input) @@ -191,7 +191,7 @@ func resourceMethodResponseDelete(ctx context.Context, d *schema.ResourceData, m HttpMethod: aws.String(d.Get("http_method").(string)), ResourceId: aws.String(d.Get(names.AttrResourceID).(string)), RestApiId: aws.String(d.Get("rest_api_id").(string)), - StatusCode: aws.String(d.Get("status_code").(string)), + StatusCode: aws.String(d.Get(names.AttrStatusCode).(string)), }) if errs.IsA[*types.NotFoundException](err) { diff --git a/internal/service/apigateway/method_response_test.go b/internal/service/apigateway/method_response_test.go index 24a2bac491e..32c9b20c5b1 100644 --- a/internal/service/apigateway/method_response_test.go +++ b/internal/service/apigateway/method_response_test.go @@ -40,7 +40,7 @@ func TestAccAPIGatewayMethodResponse_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "response_models.application/json", "Error"), resource.TestCheckResourceAttr(resourceName, "response_parameters.%", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "response_parameters.method.response.header.Content-Type", "true"), - resource.TestCheckResourceAttr(resourceName, "status_code", "400"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "400"), ), }, { @@ -58,7 +58,7 @@ func TestAccAPIGatewayMethodResponse_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "response_models.application/json", "Empty"), resource.TestCheckResourceAttr(resourceName, "response_parameters.%", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "response_parameters.method.response.header.Host", "false"), - resource.TestCheckResourceAttr(resourceName, "status_code", "400"), + resource.TestCheckResourceAttr(resourceName, names.AttrStatusCode, "400"), ), }, }, @@ -98,7 +98,7 @@ func testAccCheckMethodResponseExists(ctx context.Context, n string, v *apigatew conn := acctest.Provider.Meta().(*conns.AWSClient).APIGatewayClient(ctx) - output, err := tfapigateway.FindMethodResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes["status_code"]) + output, err := tfapigateway.FindMethodResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrStatusCode]) if err != nil { return err @@ -119,7 +119,7 @@ func testAccCheckMethodResponseDestroy(ctx context.Context) resource.TestCheckFu continue } - _, err := tfapigateway.FindMethodResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes["status_code"]) + _, err := tfapigateway.FindMethodResponseByFourPartKey(ctx, conn, rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrStatusCode]) if tfresource.NotFound(err) { continue @@ -143,7 +143,7 @@ func testAccMethodResponseImportStateIdFunc(resourceName string) resource.Import return "", fmt.Errorf("Not found: %s", resourceName) } - return fmt.Sprintf("%s/%s/%s/%s", rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["http_method"], rs.Primary.Attributes["status_code"]), nil + return fmt.Sprintf("%s/%s/%s/%s", rs.Primary.Attributes["rest_api_id"], rs.Primary.Attributes[names.AttrResourceID], rs.Primary.Attributes["http_method"], rs.Primary.Attributes[names.AttrStatusCode]), nil } } From 80d380700fabd211734cd86a2cb5d4f41ffee807 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:56 -0400 Subject: [PATCH 04/62] apigatewayv2: Use constants for strings --- internal/service/apigatewayv2/integration.go | 8 ++++---- internal/service/apigatewayv2/integration_test.go | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/apigatewayv2/integration.go b/internal/service/apigatewayv2/integration.go index d4c8c0565f6..21f9c60b5e8 100644 --- a/internal/service/apigatewayv2/integration.go +++ b/internal/service/apigatewayv2/integration.go @@ -148,7 +148,7 @@ func resourceIntegration() *schema.Resource { // Length between [1-512]. Elem: &schema.Schema{Type: schema.TypeString}, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Required: true, }, @@ -401,7 +401,7 @@ func resourceIntegrationUpdate(ctx context.Context, d *schema.ResourceData, meta continue } - if v, ok := tfMap["status_code"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrStatusCode].(string); ok && v != "" { if input.ResponseParameters == nil { input.ResponseParameters = map[string]map[string]string{} } @@ -548,7 +548,7 @@ func expandIntegrationResponseParameters(tfList []interface{}) map[string]map[st continue } - if vStatusCode, ok := tfMap["status_code"].(string); ok && vStatusCode != "" { + if vStatusCode, ok := tfMap[names.AttrStatusCode].(string); ok && vStatusCode != "" { if v, ok := tfMap["mappings"].(map[string]interface{}); ok && len(v) > 0 { responseParameters[vStatusCode] = flex.ExpandStringValueMap(v) } @@ -572,7 +572,7 @@ func flattenIntegrationResponseParameters(responseParameters map[string]map[stri tfMap := map[string]interface{}{} - tfMap["status_code"] = statusCode + tfMap[names.AttrStatusCode] = statusCode tfMap["mappings"] = mappings tfList = append(tfList, tfMap) diff --git a/internal/service/apigatewayv2/integration_test.go b/internal/service/apigatewayv2/integration_test.go index 301a1f92141..4cab7382dcb 100644 --- a/internal/service/apigatewayv2/integration_test.go +++ b/internal/service/apigatewayv2/integration_test.go @@ -173,13 +173,13 @@ func TestAccAPIGatewayV2Integration_dataMappingHTTP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "request_templates.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "response_parameters.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - "status_code": "500", + names.AttrStatusCode: "500", "mappings.%": acctest.CtTwo, "mappings.append:header.header1": "$context.requestId", "mappings.overwrite:statuscode": "403", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - "status_code": "404", + names.AttrStatusCode: "404", "mappings.%": acctest.CtOne, "mappings.append:header.error": "$stageVariables.environmentId", }), @@ -210,7 +210,7 @@ func TestAccAPIGatewayV2Integration_dataMappingHTTP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "request_templates.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "response_parameters.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - "status_code": "500", + names.AttrStatusCode: "500", "mappings.%": acctest.CtTwo, "mappings.append:header.header1": "$context.requestId", "mappings.overwrite:statuscode": "403", From 998bf83e2d39e1990d778bf0fd172a2535903c1f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:56 -0400 Subject: [PATCH 05/62] appautoscaling: Use constants for strings --- internal/service/appautoscaling/scheduled_action.go | 6 +++--- internal/service/appautoscaling/target.go | 8 ++++---- internal/service/appautoscaling/target_test.go | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/service/appautoscaling/scheduled_action.go b/internal/service/appautoscaling/scheduled_action.go index cb567a84533..1fd44922f40 100644 --- a/internal/service/appautoscaling/scheduled_action.go +++ b/internal/service/appautoscaling/scheduled_action.go @@ -65,7 +65,7 @@ func resourceScheduledAction() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "max_capacity": { + names.AttrMaxCapacity: { Type: nullable.TypeNullableInt, Optional: true, ValidateFunc: nullable.ValidateTypeStringNullableIntAtLeast(0), @@ -284,7 +284,7 @@ func expandScalableTargetAction(l []interface{}) *awstypes.ScalableTargetAction result := &awstypes.ScalableTargetAction{} - if v, ok := m["max_capacity"]; ok { + if v, ok := m[names.AttrMaxCapacity]; ok { if v, null, _ := nullable.Int(v.(string)).ValueInt32(); !null { result.MaxCapacity = aws.Int32(v) } @@ -305,7 +305,7 @@ func flattenScalableTargetAction(cfg *awstypes.ScalableTargetAction) []interface m := make(map[string]interface{}) if cfg.MaxCapacity != nil { - m["max_capacity"] = strconv.FormatInt(int64(aws.ToInt32(cfg.MaxCapacity)), 10) + m[names.AttrMaxCapacity] = strconv.FormatInt(int64(aws.ToInt32(cfg.MaxCapacity)), 10) } if cfg.MinCapacity != nil { m["min_capacity"] = strconv.FormatInt(int64(aws.ToInt32(cfg.MinCapacity)), 10) diff --git a/internal/service/appautoscaling/target.go b/internal/service/appautoscaling/target.go index ccec8dc71d8..e655cf2ddbd 100644 --- a/internal/service/appautoscaling/target.go +++ b/internal/service/appautoscaling/target.go @@ -43,7 +43,7 @@ func resourceTarget() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeInt, Required: true, }, @@ -85,7 +85,7 @@ func resourceTargetCreate(ctx context.Context, d *schema.ResourceData, meta inte resourceID := d.Get(names.AttrResourceID).(string) input := &applicationautoscaling.RegisterScalableTargetInput{ - MaxCapacity: aws.Int32(int32(d.Get("max_capacity").(int))), + MaxCapacity: aws.Int32(int32(d.Get(names.AttrMaxCapacity).(int))), MinCapacity: aws.Int32(int32(d.Get("min_capacity").(int))), ResourceId: aws.String(resourceID), ScalableDimension: awstypes.ScalableDimension(d.Get("scalable_dimension").(string)), @@ -132,7 +132,7 @@ func resourceTargetRead(ctx context.Context, d *schema.ResourceData, meta interf t := outputRaw.(*awstypes.ScalableTarget) d.Set(names.AttrARN, t.ScalableTargetARN) - d.Set("max_capacity", t.MaxCapacity) + d.Set(names.AttrMaxCapacity, t.MaxCapacity) d.Set("min_capacity", t.MinCapacity) d.Set(names.AttrResourceID, t.ResourceId) d.Set(names.AttrRoleARN, t.RoleARN) @@ -148,7 +148,7 @@ func resourceTargetUpdate(ctx context.Context, d *schema.ResourceData, meta inte if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { input := &applicationautoscaling.RegisterScalableTargetInput{ - MaxCapacity: aws.Int32(int32(d.Get("max_capacity").(int))), + MaxCapacity: aws.Int32(int32(d.Get(names.AttrMaxCapacity).(int))), MinCapacity: aws.Int32(int32(d.Get("min_capacity").(int))), ResourceId: aws.String(d.Id()), ScalableDimension: awstypes.ScalableDimension(d.Get("scalable_dimension").(string)), diff --git a/internal/service/appautoscaling/target_test.go b/internal/service/appautoscaling/target_test.go index 6981ff4cf4c..81da481206e 100644 --- a/internal/service/appautoscaling/target_test.go +++ b/internal/service/appautoscaling/target_test.go @@ -37,7 +37,7 @@ func TestAccAppAutoScalingTarget_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckTargetExists(ctx, resourceName, &target), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "max_capacity", acctest.CtThree), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, acctest.CtThree), resource.TestCheckResourceAttr(resourceName, "min_capacity", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "scalable_dimension", "ecs:service:DesiredCount"), resource.TestCheckResourceAttr(resourceName, "service_namespace", "ecs"), @@ -49,7 +49,7 @@ func TestAccAppAutoScalingTarget_basic(t *testing.T) { Config: testAccTargetConfig_update(rName), Check: resource.ComposeTestCheckFunc( testAccCheckTargetExists(ctx, resourceName, &target), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "8"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "8"), resource.TestCheckResourceAttr(resourceName, "min_capacity", acctest.CtTwo), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), @@ -218,14 +218,14 @@ func TestAccAppAutoScalingTarget_multipleTargets(t *testing.T) { resource.TestCheckResourceAttr(writeResourceName, names.AttrResourceID, "table/"+rName), resource.TestCheckResourceAttr(writeResourceName, "scalable_dimension", "dynamodb:table:WriteCapacityUnits"), resource.TestCheckResourceAttr(writeResourceName, "min_capacity", acctest.CtOne), - resource.TestCheckResourceAttr(writeResourceName, "max_capacity", "10"), + resource.TestCheckResourceAttr(writeResourceName, names.AttrMaxCapacity, "10"), testAccCheckTargetExists(ctx, readResourceName, &readTarget), resource.TestCheckResourceAttr(readResourceName, "service_namespace", "dynamodb"), resource.TestCheckResourceAttr(readResourceName, names.AttrResourceID, "table/"+rName), resource.TestCheckResourceAttr(readResourceName, "scalable_dimension", "dynamodb:table:ReadCapacityUnits"), resource.TestCheckResourceAttr(readResourceName, "min_capacity", acctest.CtTwo), - resource.TestCheckResourceAttr(readResourceName, "max_capacity", "15"), + resource.TestCheckResourceAttr(readResourceName, names.AttrMaxCapacity, "15"), ), }, }, From fd98d5e0645fcd25c4b989660f96a39587b59862 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:56 -0400 Subject: [PATCH 06/62] appsync: Use constants for strings --- internal/service/appsync/graphql_api.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/appsync/graphql_api.go b/internal/service/appsync/graphql_api.go index 63c8e062bc2..8e3b628accf 100644 --- a/internal/service/appsync/graphql_api.go +++ b/internal/service/appsync/graphql_api.go @@ -263,7 +263,7 @@ func ResourceGraphQLAPI() *schema.Resource { Optional: true, Computed: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringInSlice(appsync.DefaultAction_Values(), false), @@ -646,7 +646,7 @@ func expandGraphQLAPIUserPoolConfig(l []interface{}, currentRegion string) *apps userPoolConfig := &appsync.UserPoolConfig{ AwsRegion: aws.String(currentRegion), - DefaultAction: aws.String(m["default_action"].(string)), + DefaultAction: aws.String(m[names.AttrDefaultAction].(string)), UserPoolId: aws.String(m["user_pool_id"].(string)), } @@ -773,7 +773,7 @@ func flattenGraphQLAPIUserPoolConfig(userPoolConfig *appsync.UserPoolConfig) []i m := map[string]interface{}{ "aws_region": aws.StringValue(userPoolConfig.AwsRegion), - "default_action": aws.StringValue(userPoolConfig.DefaultAction), + names.AttrDefaultAction: aws.StringValue(userPoolConfig.DefaultAction), "user_pool_id": aws.StringValue(userPoolConfig.UserPoolId), } From 96dd449a62040dda5c91beb877a5028623a4291e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:56 -0400 Subject: [PATCH 07/62] autoscaling: Use constants for strings --- internal/service/autoscaling/group.go | 6 +++--- internal/service/autoscaling/group_migrate.go | 2 +- internal/service/autoscaling/group_test.go | 14 +++++++------- .../service/autoscaling/launch_configuration.go | 6 +++--- .../launch_configuration_data_source.go | 2 +- internal/service/autoscaling/sweep.go | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/service/autoscaling/group.go b/internal/service/autoscaling/group.go index 92ff1a99e66..f209abfecc9 100644 --- a/internal/service/autoscaling/group.go +++ b/internal/service/autoscaling/group.go @@ -110,7 +110,7 @@ func resourceGroup() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, Default: false, @@ -1664,7 +1664,7 @@ func resourceGroupUpdate(ctx context.Context, d *schema.ResourceData, meta inter // No warm pool exists in new config. Delete it. if len(w) == 0 || w[0] == nil { - forceDeleteWarmPool := d.Get("force_delete").(bool) || d.Get("force_delete_warm_pool").(bool) + forceDeleteWarmPool := d.Get(names.AttrForceDelete).(bool) || d.Get("force_delete_warm_pool").(bool) if err := deleteWarmPool(ctx, conn, d.Id(), forceDeleteWarmPool, d.Timeout(schema.TimeoutUpdate)); err != nil { return sdkdiag.AppendFromErr(diags, err) @@ -1792,7 +1792,7 @@ func resourceGroupDelete(ctx context.Context, d *schema.ResourceData, meta inter var diags diag.Diagnostics conn := meta.(*conns.AWSClient).AutoScalingClient(ctx) - forceDeleteGroup := d.Get("force_delete").(bool) + forceDeleteGroup := d.Get(names.AttrForceDelete).(bool) forceDeleteWarmPool := forceDeleteGroup || d.Get("force_delete_warm_pool").(bool) group, err := findGroupByName(ctx, conn, d.Id()) diff --git a/internal/service/autoscaling/group_migrate.go b/internal/service/autoscaling/group_migrate.go index 099a7c0e808..1be42424e9e 100644 --- a/internal/service/autoscaling/group_migrate.go +++ b/internal/service/autoscaling/group_migrate.go @@ -57,7 +57,7 @@ func resourceGroupV0() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, Default: false, diff --git a/internal/service/autoscaling/group_test.go b/internal/service/autoscaling/group_test.go index 59f9fabeeb0..b17917d38e3 100644 --- a/internal/service/autoscaling/group_test.go +++ b/internal/service/autoscaling/group_test.go @@ -42,7 +42,7 @@ func testAccGroupImportStep(n string) resource.TestStep { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "force_delete", + names.AttrForceDelete, "ignore_failed_scaling_activities", "initial_lifecycle_hook", "load_balancers", @@ -82,7 +82,7 @@ func TestAccAutoScalingGroup_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "desired_capacity", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "desired_capacity_type", ""), resource.TestCheckResourceAttr(resourceName, "enabled_metrics.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "force_delete", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "false"), resource.TestCheckResourceAttr(resourceName, "force_delete_warm_pool", "false"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "300"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "EC2"), @@ -308,7 +308,7 @@ func TestAccAutoScalingGroup_simple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "desired_capacity", "4"), resource.TestCheckResourceAttr(resourceName, "desired_capacity_type", ""), resource.TestCheckResourceAttr(resourceName, "enabled_metrics.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), resource.TestCheckResourceAttr(resourceName, "force_delete_warm_pool", "false"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "300"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "ELB"), @@ -359,7 +359,7 @@ func TestAccAutoScalingGroup_simple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "desired_capacity", "4"), resource.TestCheckResourceAttr(resourceName, "desired_capacity_type", ""), resource.TestCheckResourceAttr(resourceName, "enabled_metrics.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), resource.TestCheckResourceAttr(resourceName, "force_delete_warm_pool", "false"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "400"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "ELB"), @@ -640,7 +640,7 @@ func TestAccAutoScalingGroup_withLoadBalancer(t *testing.T) { Config: testAccGroupConfig_loadBalancer(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &group), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "300"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "ELB"), resource.TestCheckResourceAttr(resourceName, "load_balancers.#", acctest.CtOne), @@ -716,7 +716,7 @@ func TestAccAutoScalingGroup_withTrafficSourceELB(t *testing.T) { Config: testAccGroupConfig_trafficSourceELB(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &group), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "300"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "ELB"), resource.TestCheckResourceAttr(resourceName, "traffic_source.#", acctest.CtOne), @@ -859,7 +859,7 @@ func TestAccAutoScalingGroup_withTrafficSourceVPCLatticeTargetGroup(t *testing.T Config: testAccGroupConfig_trafficSourceVPCLatticeTargetGroup(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &group), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), resource.TestCheckResourceAttr(resourceName, "health_check_grace_period", "300"), resource.TestCheckResourceAttr(resourceName, "health_check_type", "ELB"), resource.TestCheckResourceAttr(resourceName, "traffic_source.#", acctest.CtOne), diff --git a/internal/service/autoscaling/launch_configuration.go b/internal/service/autoscaling/launch_configuration.go index f760974f80a..a5f4e2b0e5a 100644 --- a/internal/service/autoscaling/launch_configuration.go +++ b/internal/service/autoscaling/launch_configuration.go @@ -88,7 +88,7 @@ func resourceLaunchConfiguration() *schema.Resource { Optional: true, ForceNew: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, Computed: true, @@ -558,7 +558,7 @@ func expandBlockDeviceMappingForEBSBlockDevice(tfMap map[string]interface{}) aws apiObject.Ebs.Iops = aws.Int32(int32(v)) } - if v, ok := tfMap["snapshot_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrSnapshotID].(string); ok && v != "" { apiObject.Ebs.SnapshotId = aws.String(v) } @@ -717,7 +717,7 @@ func flattenBlockDeviceMappings(apiObjects []awstypes.BlockDeviceMapping, rootDe if v := apiObject.Ebs; v != nil { if v := v.SnapshotId; v != nil { - tfMap["snapshot_id"] = aws.ToString(v) + tfMap[names.AttrSnapshotID] = aws.ToString(v) } } diff --git a/internal/service/autoscaling/launch_configuration_data_source.go b/internal/service/autoscaling/launch_configuration_data_source.go index 945599e2354..224733994c1 100644 --- a/internal/service/autoscaling/launch_configuration_data_source.go +++ b/internal/service/autoscaling/launch_configuration_data_source.go @@ -52,7 +52,7 @@ func dataSourceLaunchConfiguration() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/autoscaling/sweep.go b/internal/service/autoscaling/sweep.go index e84d852477a..f7f0d09fd14 100644 --- a/internal/service/autoscaling/sweep.go +++ b/internal/service/autoscaling/sweep.go @@ -55,7 +55,7 @@ func sweepGroups(region string) error { r := resourceGroup() d := r.Data(nil) d.SetId(aws.ToString(v.AutoScalingGroupName)) - d.Set("force_delete", true) + d.Set(names.AttrForceDelete, true) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } From b0376e5d7693f69d626b34623ef2a7335e65df23 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:57 -0400 Subject: [PATCH 08/62] autoscalingplans: Use constants for strings --- internal/service/autoscalingplans/scaling_plan.go | 6 +++--- .../service/autoscalingplans/scaling_plan_test.go | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/autoscalingplans/scaling_plan.go b/internal/service/autoscalingplans/scaling_plan.go index c3c89e75cf2..2eadb0198e3 100644 --- a/internal/service/autoscalingplans/scaling_plan.go +++ b/internal/service/autoscalingplans/scaling_plan.go @@ -137,7 +137,7 @@ func ResourceScalingPlan() *schema.Resource { Default: false, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeInt, Required: true, }, @@ -561,7 +561,7 @@ func expandScalingInstructions(vScalingInstructions *schema.Set) []awstypes.Scal if v, ok := mScalingInstruction["disable_dynamic_scaling"].(bool); ok { scalingInstruction.DisableDynamicScaling = aws.Bool(v) } - if v, ok := mScalingInstruction["max_capacity"].(int); ok { + if v, ok := mScalingInstruction[names.AttrMaxCapacity].(int); ok { scalingInstruction.MaxCapacity = aws.Int32(int32(v)) } if v, ok := mScalingInstruction["min_capacity"].(int); ok { @@ -731,7 +731,7 @@ func flattenScalingInstructions(scalingInstructions []awstypes.ScalingInstructio for _, scalingInstruction := range scalingInstructions { mScalingInstruction := map[string]interface{}{ "disable_dynamic_scaling": aws.ToBool(scalingInstruction.DisableDynamicScaling), - "max_capacity": int(aws.ToInt32(scalingInstruction.MaxCapacity)), + names.AttrMaxCapacity: int(aws.ToInt32(scalingInstruction.MaxCapacity)), "min_capacity": int(aws.ToInt32(scalingInstruction.MinCapacity)), "predictive_scaling_max_capacity_behavior": scalingInstruction.PredictiveScalingMaxCapacityBehavior, "predictive_scaling_max_capacity_buffer": int(aws.ToInt32(scalingInstruction.PredictiveScalingMaxCapacityBuffer)), diff --git a/internal/service/autoscalingplans/scaling_plan_test.go b/internal/service/autoscalingplans/scaling_plan_test.go index 1d5486b1c38..f8660ac3449 100644 --- a/internal/service/autoscalingplans/scaling_plan_test.go +++ b/internal/service/autoscalingplans/scaling_plan_test.go @@ -50,7 +50,7 @@ func TestAccAutoScalingPlansScalingPlan_basicDynamicScaling(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -110,7 +110,7 @@ func TestAccAutoScalingPlansScalingPlan_basicPredictiveScaling(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "true", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtOne, "predefined_load_metric_specification.0.predefined_load_metric_type": "ASGTotalCPUUtilization", @@ -174,7 +174,7 @@ func TestAccAutoScalingPlansScalingPlan_basicUpdate(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -207,7 +207,7 @@ func TestAccAutoScalingPlansScalingPlan_basicUpdate(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "true", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtOne, "predefined_load_metric_specification.0.predefined_load_metric_type": "ASGTotalCPUUtilization", @@ -291,7 +291,7 @@ func TestAccAutoScalingPlansScalingPlan_DynamicScaling_customizedScalingMetricSp resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -330,7 +330,7 @@ func TestAccAutoScalingPlansScalingPlan_DynamicScaling_customizedScalingMetricSp resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - "max_capacity": acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), From b0cf048c6bdf3f6f5c1bdb7f228151b78821003b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:57 -0400 Subject: [PATCH 09/62] batch: Use constants for strings --- internal/service/batch/compute_environment.go | 20 ++-- .../batch/compute_environment_data_source.go | 8 +- .../compute_environment_data_source_test.go | 2 +- .../service/batch/compute_environment_test.go | 106 +++++++++--------- internal/service/batch/job_definition.go | 10 +- internal/service/batch/job_definition_test.go | 16 +-- .../service/batch/job_queue_data_source.go | 4 +- 7 files changed, 83 insertions(+), 83 deletions(-) diff --git a/internal/service/batch/compute_environment.go b/internal/service/batch/compute_environment.go index 5ad2f3e9711..eb6be3a58aa 100644 --- a/internal/service/batch/compute_environment.go +++ b/internal/service/batch/compute_environment.go @@ -226,7 +226,7 @@ func ResourceComputeEnvironment() *schema.Resource { }, }, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Optional: true, Computed: true, @@ -245,7 +245,7 @@ func ResourceComputeEnvironment() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -289,7 +289,7 @@ func resourceComputeEnvironmentCreate(ctx context.Context, d *schema.ResourceDat computeEnvironmentType := d.Get(names.AttrType).(string) input := &batch.CreateComputeEnvironmentInput{ ComputeEnvironmentName: aws.String(computeEnvironmentName), - ServiceRole: aws.String(d.Get("service_role").(string)), + ServiceRole: aws.String(d.Get(names.AttrServiceRole).(string)), Tags: getTagsIn(ctx), Type: aws.String(computeEnvironmentType), } @@ -374,10 +374,10 @@ func resourceComputeEnvironmentRead(ctx context.Context, d *schema.ResourceData, } else { d.Set("eks_configuration", nil) } - d.Set("service_role", computeEnvironment.ServiceRole) + d.Set(names.AttrServiceRole, computeEnvironment.ServiceRole) d.Set(names.AttrState, computeEnvironment.State) d.Set(names.AttrStatus, computeEnvironment.Status) - d.Set("status_reason", computeEnvironment.StatusReason) + d.Set(names.AttrStatusReason, computeEnvironment.StatusReason) d.Set(names.AttrType, computeEnvironmentType) if err := d.Set("update_policy", flattenComputeEnvironmentUpdatePolicy(computeEnvironment.UpdatePolicy)); err != nil { @@ -398,8 +398,8 @@ func resourceComputeEnvironmentUpdate(ctx context.Context, d *schema.ResourceDat ComputeEnvironment: aws.String(d.Id()), } - if d.HasChange("service_role") { - input.ServiceRole = aws.String(d.Get("service_role").(string)) + if d.HasChange(names.AttrServiceRole) { + input.ServiceRole = aws.String(d.Get(names.AttrServiceRole).(string)) } if d.HasChange(names.AttrState) { @@ -833,13 +833,13 @@ func isUpdatableComputeEnvironment(diff *schema.ResourceDiff) bool { func isServiceLinkedRoleDiff(diff *schema.ResourceDiff) bool { var before, after string - if diff.HasChange("service_role") { - beforeRaw, afterRaw := diff.GetChange("service_role") + if diff.HasChange(names.AttrServiceRole) { + beforeRaw, afterRaw := diff.GetChange(names.AttrServiceRole) before, _ = beforeRaw.(string) after, _ := afterRaw.(string) return isServiceLinkedRole(before) && isServiceLinkedRole(after) } - afterRaw, _ := diff.GetOk("service_role") + afterRaw, _ := diff.GetOk(names.AttrServiceRole) after, _ = afterRaw.(string) return isServiceLinkedRole(after) } diff --git a/internal/service/batch/compute_environment_data_source.go b/internal/service/batch/compute_environment_data_source.go index 9935dd20a10..6a20f0e1af6 100644 --- a/internal/service/batch/compute_environment_data_source.go +++ b/internal/service/batch/compute_environment_data_source.go @@ -37,7 +37,7 @@ func DataSourceComputeEnvironment() *schema.Resource { Computed: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Computed: true, }, @@ -54,7 +54,7 @@ func DataSourceComputeEnvironment() *schema.Resource { Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -108,10 +108,10 @@ func dataSourceComputeEnvironmentRead(ctx context.Context, d *schema.ResourceDat d.Set(names.AttrARN, computeEnvironment.ComputeEnvironmentArn) d.Set("compute_environment_name", computeEnvironment.ComputeEnvironmentName) d.Set("ecs_cluster_arn", computeEnvironment.EcsClusterArn) - d.Set("service_role", computeEnvironment.ServiceRole) + d.Set(names.AttrServiceRole, computeEnvironment.ServiceRole) d.Set(names.AttrType, computeEnvironment.Type) d.Set(names.AttrStatus, computeEnvironment.Status) - d.Set("status_reason", computeEnvironment.StatusReason) + d.Set(names.AttrStatusReason, computeEnvironment.StatusReason) d.Set(names.AttrState, computeEnvironment.State) if err := d.Set("update_policy", flattenComputeEnvironmentUpdatePolicy(computeEnvironment.UpdatePolicy)); err != nil { diff --git a/internal/service/batch/compute_environment_data_source_test.go b/internal/service/batch/compute_environment_data_source_test.go index 4534ffdd5b9..1299f9e9fdd 100644 --- a/internal/service/batch/compute_environment_data_source_test.go +++ b/internal/service/batch/compute_environment_data_source_test.go @@ -30,7 +30,7 @@ func TestAccBatchComputeEnvironmentDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttrPair(datasourceName, "compute_environment_name", resourceName, "compute_environment_name"), resource.TestCheckResourceAttrPair(datasourceName, "ecs_cluster_arn", resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(datasourceName, "service_role", resourceName, "service_role"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrServiceRole, resourceName, names.AttrServiceRole), resource.TestCheckResourceAttrPair(datasourceName, names.AttrState, resourceName, names.AttrState), resource.TestCheckResourceAttrPair(datasourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent), resource.TestCheckResourceAttrPair(datasourceName, names.AttrType, resourceName, names.AttrType), diff --git a/internal/service/batch/compute_environment_test.go b/internal/service/batch/compute_environment_test.go index 2457dd782cb..093247c7fbf 100644 --- a/internal/service/batch/compute_environment_test.go +++ b/internal/service/batch/compute_environment_test.go @@ -178,10 +178,10 @@ func TestAccBatchComputeEnvironment_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.#", acctest.CtZero), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), resource.TestCheckResourceAttr(resourceName, "eks_configuration.#", acctest.CtZero), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "UNMANAGED"), ), @@ -350,10 +350,10 @@ func TestAccBatchComputeEnvironment_createEC2(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -513,10 +513,10 @@ func TestAccBatchComputeEnvironment_CreateEC2DesiredVCPUsEC2KeyPairImageID_compu resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.key1", acctest.CtValue1), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -574,10 +574,10 @@ func TestAccBatchComputeEnvironment_createSpot(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -635,10 +635,10 @@ func TestAccBatchComputeEnvironment_CreateSpotAllocationStrategy_bidPercentage(t resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -693,10 +693,10 @@ func TestAccBatchComputeEnvironment_createFargate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -751,10 +751,10 @@ func TestAccBatchComputeEnvironment_createFargateSpot(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE_SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -790,10 +790,10 @@ func TestAccBatchComputeEnvironment_updateState(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_environment_name_prefix", ""), resource.TestCheckResourceAttr(resourceName, "compute_resources.#", acctest.CtZero), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "UNMANAGED"), ), @@ -807,10 +807,10 @@ func TestAccBatchComputeEnvironment_updateState(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_environment_name_prefix", ""), resource.TestCheckResourceAttr(resourceName, "compute_resources.#", acctest.CtZero), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "DISABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "UNMANAGED"), ), @@ -866,10 +866,10 @@ func TestAccBatchComputeEnvironment_updateServiceRole(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName1, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName1, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -900,10 +900,10 @@ func TestAccBatchComputeEnvironment_updateServiceRole(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName2, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName2, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -961,10 +961,10 @@ func TestAccBatchComputeEnvironment_defaultServiceRole(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - acctest.MatchResourceAttrGlobalARN(resourceName, "service_role", "iam", regexache.MustCompile(`role/aws-service-role/batch`)), + acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", regexache.MustCompile(`role/aws-service-role/batch`)), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1021,10 +1021,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_minVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1056,10 +1056,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_minVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1091,10 +1091,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_minVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1151,10 +1151,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_maxVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1186,10 +1186,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_maxVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1221,10 +1221,10 @@ func TestAccBatchComputeEnvironment_ComputeResources_maxVCPUs(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "EC2"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1286,10 +1286,10 @@ func TestAccBatchComputeEnvironment_ec2Configuration(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1352,10 +1352,10 @@ func TestAccBatchComputeEnvironment_ec2ConfigurationPlacementGroup(t *testing.T) resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1415,10 +1415,10 @@ func TestAccBatchComputeEnvironment_launchTemplate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1480,10 +1480,10 @@ func TestAccBatchComputeEnvironment_updateLaunchTemplate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1518,10 +1518,10 @@ func TestAccBatchComputeEnvironment_updateLaunchTemplate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "SPOT"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1579,10 +1579,10 @@ func TestAccBatchComputeEnvironment_UpdateSecurityGroupsAndSubnets_fargate(t *te resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1614,10 +1614,10 @@ func TestAccBatchComputeEnvironment_UpdateSecurityGroupsAndSubnets_fargate(t *te resource.TestCheckResourceAttr(resourceName, "compute_resources.0.tags.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "compute_resources.0.type", "FARGATE"), resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", serviceRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, serviceRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1705,7 +1705,7 @@ func TestAccBatchComputeEnvironment_updateEC2(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1745,7 +1745,7 @@ func TestAccBatchComputeEnvironment_updateEC2(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), @@ -1781,7 +1781,7 @@ func TestAccBatchComputeEnvironment_updateEC2(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "ecs_cluster_arn"), resource.TestCheckResourceAttr(resourceName, names.AttrState, "ENABLED"), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), - resource.TestCheckResourceAttrSet(resourceName, "status_reason"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrStatusReason), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, "MANAGED"), ), diff --git a/internal/service/batch/job_definition.go b/internal/service/batch/job_definition.go index 203100acea4..b9ca6438358 100644 --- a/internal/service/batch/job_definition.go +++ b/internal/service/batch/job_definition.go @@ -342,7 +342,7 @@ func ResourceJobDefinition() *schema.Resource { }, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeBool, Optional: true, Default: false, @@ -562,7 +562,7 @@ func needsJobDefUpdate(d *schema.ResourceDiff) bool { } if d.HasChanges( - "propagate_tags", + names.AttrPropagateTags, names.AttrParameters, "platform_capabilities", "scheduling_priority", @@ -582,7 +582,7 @@ func resourceJobDefinitionCreate(ctx context.Context, d *schema.ResourceData, me jobDefinitionType := d.Get(names.AttrType).(string) input := &batch.RegisterJobDefinitionInput{ JobDefinitionName: aws.String(name), - PropagateTags: aws.Bool(d.Get("propagate_tags").(bool)), + PropagateTags: aws.Bool(d.Get(names.AttrPropagateTags).(bool)), Tags: getTagsIn(ctx), Type: aws.String(jobDefinitionType), } @@ -717,7 +717,7 @@ func resourceJobDefinitionRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrParameters, aws.StringValueMap(jobDefinition.Parameters)) d.Set("platform_capabilities", aws.StringValueSlice(jobDefinition.PlatformCapabilities)) - d.Set("propagate_tags", jobDefinition.PropagateTags) + d.Set(names.AttrPropagateTags, jobDefinition.PropagateTags) if jobDefinition.RetryStrategy != nil { if err := d.Set("retry_strategy", []interface{}{flattenRetryStrategy(jobDefinition.RetryStrategy)}); err != nil { @@ -790,7 +790,7 @@ func resourceJobDefinitionUpdate(ctx context.Context, d *schema.ResourceData, me input.NodeProperties = props } - if v, ok := d.GetOk("propagate_tags"); ok { + if v, ok := d.GetOk(names.AttrPropagateTags); ok { input.PropagateTags = aws.Bool(v.(bool)) } diff --git a/internal/service/batch/job_definition_test.go b/internal/service/batch/job_definition_test.go index 03a0b4676ae..58dddfe8e42 100644 --- a/internal/service/batch/job_definition_test.go +++ b/internal/service/batch/job_definition_test.go @@ -56,7 +56,7 @@ func TestAccBatchJobDefinition_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "scheduling_priority", acctest.CtZero), @@ -98,7 +98,7 @@ func TestAccBatchJobDefinition_attributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtOne), resource.TestCheckTypeSetElemAttr(resourceName, "platform_capabilities.*", "EC2"), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "true"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "retry_strategy.0.attempts", acctest.CtThree), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), @@ -154,7 +154,7 @@ func TestAccBatchJobDefinition_attributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtOne), resource.TestCheckTypeSetElemAttr(resourceName, "platform_capabilities.*", "EC2"), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "retry_strategy.0.attempts", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "revision", "4"), @@ -226,7 +226,7 @@ func TestAccBatchJobDefinition_PlatformCapabilities_ec2(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtOne), resource.TestCheckTypeSetElemAttr(resourceName, "platform_capabilities.*", "EC2"), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), @@ -273,7 +273,7 @@ func TestAccBatchJobDefinition_PlatformCapabilitiesFargate_containerPropertiesDe resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtOne), resource.TestCheckTypeSetElemAttr(resourceName, "platform_capabilities.*", "FARGATE"), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), @@ -320,7 +320,7 @@ func TestAccBatchJobDefinition_PlatformCapabilities_fargate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtOne), resource.TestCheckTypeSetElemAttr(resourceName, "platform_capabilities.*", "FARGATE"), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), @@ -526,7 +526,7 @@ func TestAccBatchJobDefinition_propagateTags(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "true"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), @@ -631,7 +631,7 @@ func TestAccBatchJobDefinition_NodeProperties_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "parameters.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "platform_capabilities.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", "false"), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, "false"), resource.TestCheckResourceAttr(resourceName, "retry_strategy.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "revision", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), diff --git a/internal/service/batch/job_queue_data_source.go b/internal/service/batch/job_queue_data_source.go index 8c42ca387d7..0ca86232a84 100644 --- a/internal/service/batch/job_queue_data_source.go +++ b/internal/service/batch/job_queue_data_source.go @@ -43,7 +43,7 @@ func DataSourceJobQueue() *schema.Resource { Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -107,7 +107,7 @@ func dataSourceJobQueueRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrName, jobQueue.JobQueueName) d.Set("scheduling_policy_arn", jobQueue.SchedulingPolicyArn) d.Set(names.AttrStatus, jobQueue.Status) - d.Set("status_reason", jobQueue.StatusReason) + d.Set(names.AttrStatusReason, jobQueue.StatusReason) d.Set(names.AttrState, jobQueue.State) d.Set(names.AttrPriority, jobQueue.Priority) From d0c895d7e706a65c8e71944864f7d97feda89082 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:57 -0400 Subject: [PATCH 10/62] bedrock: Use constants for strings --- internal/service/bedrock/foundation_model_data_source.go | 2 +- internal/service/bedrock/foundation_model_data_source_test.go | 2 +- internal/service/bedrock/foundation_models_data_source.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/bedrock/foundation_model_data_source.go b/internal/service/bedrock/foundation_model_data_source.go index 4a74e287649..aa5b2a78595 100644 --- a/internal/service/bedrock/foundation_model_data_source.go +++ b/internal/service/bedrock/foundation_model_data_source.go @@ -63,7 +63,7 @@ func (d *foundationModelDataSource) Schema(ctx context.Context, request datasour ElementType: types.StringType, Computed: true, }, - "provider_name": schema.StringAttribute{ + names.AttrProviderName: schema.StringAttribute{ Computed: true, }, "response_streaming_supported": schema.BoolAttribute{ diff --git a/internal/service/bedrock/foundation_model_data_source_test.go b/internal/service/bedrock/foundation_model_data_source_test.go index 14fac10527a..ca87cc9e14b 100644 --- a/internal/service/bedrock/foundation_model_data_source_test.go +++ b/internal/service/bedrock/foundation_model_data_source_test.go @@ -30,7 +30,7 @@ func TestAccBedrockFoundationModelDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrSet(datasourceName, "model_arn"), resource.TestCheckResourceAttrSet(datasourceName, "model_name"), resource.TestCheckResourceAttrSet(datasourceName, "output_modalities.#"), - resource.TestCheckResourceAttrSet(datasourceName, "provider_name"), + resource.TestCheckResourceAttrSet(datasourceName, names.AttrProviderName), resource.TestCheckResourceAttrSet(datasourceName, "response_streaming_supported"), ), }, diff --git a/internal/service/bedrock/foundation_models_data_source.go b/internal/service/bedrock/foundation_models_data_source.go index 6ae812dc3b2..ce071eae625 100644 --- a/internal/service/bedrock/foundation_models_data_source.go +++ b/internal/service/bedrock/foundation_models_data_source.go @@ -68,7 +68,7 @@ func (d *foundationModelsDataSource) Schema(ctx context.Context, request datasou "model_id": types.StringType, "model_name": types.StringType, "output_modalities": types.SetType{ElemType: types.StringType}, - "provider_name": types.StringType, + names.AttrProviderName: types.StringType, "response_streaming_supported": types.BoolType, }, }, From 4da15d7155d79413e95f7a85fff18492a6ab9fe6 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:58 -0400 Subject: [PATCH 11/62] chimesdkmediapipelines: Use constants for strings --- .../media_insights_pipeline_configuration.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go index e0dc8c4e971..7c0975622f9 100644 --- a/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go +++ b/internal/service/chimesdkmediapipelines/media_insights_pipeline_configuration.go @@ -148,7 +148,7 @@ func AmazonTranscribeCallAnalyticsProcessorConfigurationSchema() *schema.Schema Type: schema.TypeBool, Optional: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[awstypes.CallAnalyticsLanguageCode](), @@ -259,7 +259,7 @@ func AmazonTranscribeProcessorConfigurationSchema() *schema.Schema { Type: schema.TypeBool, Optional: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[awstypes.CallAnalyticsLanguageCode](), @@ -691,7 +691,7 @@ func expandElement(inputElement interface{}) (awstypes.MediaInsightsPipelineConf rawConfiguration := configuration[0].(map[string]interface{}) element.AmazonTranscribeCallAnalyticsProcessorConfiguration = &awstypes.AmazonTranscribeCallAnalyticsProcessorConfiguration{ - LanguageCode: awstypes.CallAnalyticsLanguageCode(rawConfiguration["language_code"].(string)), + LanguageCode: awstypes.CallAnalyticsLanguageCode(rawConfiguration[names.AttrLanguageCode].(string)), } if callAnalyticsStreamCategories, ok := rawConfiguration["call_analytics_stream_categories"].([]interface{}); ok && len(callAnalyticsStreamCategories) > 0 { @@ -761,7 +761,7 @@ func expandElement(inputElement interface{}) (awstypes.MediaInsightsPipelineConf rawConfiguration := configuration[0].(map[string]interface{}) element.AmazonTranscribeProcessorConfiguration = &awstypes.AmazonTranscribeProcessorConfiguration{ - LanguageCode: awstypes.CallAnalyticsLanguageCode(rawConfiguration["language_code"].(string)), + LanguageCode: awstypes.CallAnalyticsLanguageCode(rawConfiguration[names.AttrLanguageCode].(string)), } if contentIdentificationType, ok := rawConfiguration["content_identification_type"].(string); ok && contentIdentificationType != "" { @@ -979,7 +979,7 @@ func flattenElement(apiElement awstypes.MediaInsightsPipelineConfigurationElemen configuration["content_redaction_type"] = processorConfiguration.ContentRedactionType configuration["enable_partial_results_stabilization"] = processorConfiguration.EnablePartialResultsStabilization configuration["filter_partial_results"] = processorConfiguration.FilterPartialResults - configuration["language_code"] = processorConfiguration.LanguageCode + configuration[names.AttrLanguageCode] = processorConfiguration.LanguageCode configuration["language_model_name"] = processorConfiguration.LanguageModelName configuration["partial_results_stability"] = processorConfiguration.PartialResultsStability configuration["pii_entity_types"] = processorConfiguration.PiiEntityTypes @@ -1003,7 +1003,7 @@ func flattenElement(apiElement awstypes.MediaInsightsPipelineConfigurationElemen configuration["content_redaction_type"] = processorConfiguration.ContentRedactionType configuration["enable_partial_results_stabilization"] = processorConfiguration.EnablePartialResultsStabilization configuration["filter_partial_results"] = processorConfiguration.FilterPartialResults - configuration["language_code"] = processorConfiguration.LanguageCode + configuration[names.AttrLanguageCode] = processorConfiguration.LanguageCode configuration["language_model_name"] = processorConfiguration.LanguageModelName configuration["partial_results_stability"] = processorConfiguration.PartialResultsStability configuration["pii_entity_types"] = processorConfiguration.PiiEntityTypes From 3933ee6303c11f44667c43b1f67a3123adb9cce1 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:58 -0400 Subject: [PATCH 12/62] codebuild: Use constants for strings --- internal/service/codebuild/project.go | 16 ++++++++-------- internal/service/codebuild/project_test.go | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/codebuild/project.go b/internal/service/codebuild/project.go index 833a15dcb2f..5eb0f6edb64 100644 --- a/internal/service/codebuild/project.go +++ b/internal/service/codebuild/project.go @@ -164,7 +164,7 @@ func resourceProject() *schema.Resource { }, }, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidARN, @@ -588,7 +588,7 @@ func resourceProject() *schema.Resource { }, }, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidARN, @@ -791,7 +791,7 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, meta int input.SecondarySourceVersions = expandProjectSecondarySourceVersions(v.(*schema.Set).List()) } - if v, ok := d.GetOk("service_role"); ok { + if v, ok := d.GetOk(names.AttrServiceRole); ok { input.ServiceRole = aws.String(v.(string)) } @@ -905,7 +905,7 @@ func resourceProjectRead(ctx context.Context, d *schema.ResourceData, meta inter if err := d.Set("secondary_source_version", flattenProjectSecondarySourceVersions(project.SecondarySourceVersions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting secondary_source_version: %s", err) } - d.Set("service_role", project.ServiceRole) + d.Set(names.AttrServiceRole, project.ServiceRole) if project.Source != nil { if err := d.Set(names.AttrSource, []interface{}{flattenProjectSource(project.Source)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting source: %s", err) @@ -1033,8 +1033,8 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, meta int } } - if d.HasChange("service_role") { - input.ServiceRole = aws.String(d.Get("service_role").(string)) + if d.HasChange(names.AttrServiceRole) { + input.ServiceRole = aws.String(d.Get(names.AttrServiceRole).(string)) } if d.HasChange(names.AttrSource) { @@ -1467,7 +1467,7 @@ func expandProjectBuildBatchConfig(tfMap map[string]interface{}) *types.ProjectB } apiObject := &types.ProjectBuildBatchConfig{ - ServiceRole: aws.String(tfMap["service_role"].(string)), + ServiceRole: aws.String(tfMap[names.AttrServiceRole].(string)), } if v, ok := tfMap["combine_artifacts"].(bool); ok { @@ -1926,7 +1926,7 @@ func flattenBuildBatchConfig(apiObject *types.ProjectBuildBatchConfig) []interfa tfMap := map[string]interface{}{} - tfMap["service_role"] = aws.ToString(apiObject.ServiceRole) + tfMap[names.AttrServiceRole] = aws.ToString(apiObject.ServiceRole) if apiObject.CombineArtifacts != nil { tfMap["combine_artifacts"] = aws.ToBool(apiObject.CombineArtifacts) diff --git a/internal/service/codebuild/project_test.go b/internal/service/codebuild/project_test.go index a6d6aa86ed9..277cb2e0425 100644 --- a/internal/service/codebuild/project_test.go +++ b/internal/service/codebuild/project_test.go @@ -124,7 +124,7 @@ func TestAccCodeBuildProject_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "secondary_artifacts.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "secondary_sources.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "secondary_source_version.#", acctest.CtZero), - resource.TestCheckResourceAttrPair(resourceName, "service_role", roleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, roleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "source.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "source.0.git_clone_depth", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "source.0.insecure_ssl", "false"), From d89a67bf546430b71268e13133075afef34004b7 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:58 -0400 Subject: [PATCH 13/62] codecatalyst: Use constants for strings --- internal/service/codecatalyst/dev_environment_data_source.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/codecatalyst/dev_environment_data_source.go b/internal/service/codecatalyst/dev_environment_data_source.go index 2bd0e1f3007..e448645c2a7 100644 --- a/internal/service/codecatalyst/dev_environment_data_source.go +++ b/internal/service/codecatalyst/dev_environment_data_source.go @@ -104,7 +104,7 @@ func DataSourceDevEnvironment() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -142,7 +142,7 @@ func dataSourceDevEnvironmentRead(ctx context.Context, d *schema.ResourceData, m d.Set("inactivity_timeout_minutes", out.InactivityTimeoutMinutes) d.Set("persistent_storage", flattenPersistentStorage(out.PersistentStorage)) d.Set(names.AttrStatus, out.Status) - d.Set("status_reason", out.StatusReason) + d.Set(names.AttrStatusReason, out.StatusReason) if err := d.Set("ides", flattenIdes(out.Ides)); err != nil { return create.AppendDiagError(diags, names.CodeCatalyst, create.ErrActionSetting, ResNameDevEnvironment, d.Id(), err) From 0fde3795ea0372fb8521a3ed44a819e88a5ce7cc Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:58 -0400 Subject: [PATCH 14/62] codepipeline: Use constants for strings --- internal/service/codepipeline/custom_action_type.go | 6 +++--- internal/service/codepipeline/custom_action_type_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/service/codepipeline/custom_action_type.go b/internal/service/codepipeline/custom_action_type.go index 6707c03ec2e..992d709eda3 100644 --- a/internal/service/codepipeline/custom_action_type.go +++ b/internal/service/codepipeline/custom_action_type.go @@ -136,7 +136,7 @@ func resourceCustomActionType() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, ForceNew: true, Required: true, @@ -188,7 +188,7 @@ func resourceCustomActionTypeCreate(ctx context.Context, d *schema.ResourceData, conn := meta.(*conns.AWSClient).CodePipelineClient(ctx) category := d.Get("category").(string) - provider := d.Get("provider_name").(string) + provider := d.Get(names.AttrProviderName).(string) version := d.Get(names.AttrVersion).(string) id := CustomActionTypeCreateResourceID(category, provider, version) input := &codepipeline.CreateCustomActionTypeInput{ @@ -273,7 +273,7 @@ func resourceCustomActionTypeRead(ctx context.Context, d *schema.ResourceData, m d.Set("output_artifact_details", nil) } d.Set(names.AttrOwner, actionType.Id.Owner) - d.Set("provider_name", actionType.Id.Provider) + d.Set(names.AttrProviderName, actionType.Id.Provider) if actionType.Settings != nil && // Service can return empty ({}) Settings. (actionType.Settings.EntityUrlTemplate != nil || actionType.Settings.ExecutionUrlTemplate != nil || actionType.Settings.RevisionUrlTemplate != nil || actionType.Settings.ThirdPartyConfigurationUrl != nil) { diff --git a/internal/service/codepipeline/custom_action_type_test.go b/internal/service/codepipeline/custom_action_type_test.go index 4add7b1b7a0..2f8ba2b14b6 100644 --- a/internal/service/codepipeline/custom_action_type_test.go +++ b/internal/service/codepipeline/custom_action_type_test.go @@ -48,7 +48,7 @@ func TestAccCodePipelineCustomActionType_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "output_artifact_details.0.maximum_count", "4"), resource.TestCheckResourceAttr(resourceName, "output_artifact_details.0.minimum_count", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "Custom"), - resource.TestCheckResourceAttr(resourceName, "provider_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, rName), resource.TestCheckResourceAttr(resourceName, "settings.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrVersion, acctest.CtOne), @@ -182,7 +182,7 @@ func TestAccCodePipelineCustomActionType_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "output_artifact_details.0.maximum_count", "5"), resource.TestCheckResourceAttr(resourceName, "output_artifact_details.0.minimum_count", "4"), resource.TestCheckResourceAttr(resourceName, names.AttrOwner, "Custom"), - resource.TestCheckResourceAttr(resourceName, "provider_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, rName), resource.TestCheckResourceAttr(resourceName, "settings.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "settings.0.entity_url_template", "https://example.com/entity"), resource.TestCheckResourceAttr(resourceName, "settings.0.execution_url_template", ""), From 841fca2fee6e4f0dee9470a032d8117178ea8a64 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:59 -0400 Subject: [PATCH 15/62] cognitoidentity: Use constants for strings --- internal/service/cognitoidentity/flex.go | 4 ++-- internal/service/cognitoidentity/pool.go | 2 +- internal/service/cognitoidentity/pool_data_source.go | 2 +- internal/service/cognitoidentity/pool_test.go | 6 +++--- internal/service/cognitoidentity/validate_test.go | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/cognitoidentity/flex.go b/internal/service/cognitoidentity/flex.go index 90be9bfc07b..e46ae609c3d 100644 --- a/internal/service/cognitoidentity/flex.go +++ b/internal/service/cognitoidentity/flex.go @@ -76,7 +76,7 @@ func expandIdentityProviders(s *schema.Set) []awstypes.CognitoIdentityProvider { ip.ClientId = aws.String(sv) } - if sv, ok := s["provider_name"].(string); ok { + if sv, ok := s[names.AttrProviderName].(string); ok { ip.ProviderName = aws.String(sv) } @@ -155,7 +155,7 @@ func flattenIdentityProviders(ips []awstypes.CognitoIdentityProvider) []map[stri } if v.ProviderName != nil { - ip["provider_name"] = aws.ToString(v.ProviderName) + ip[names.AttrProviderName] = aws.ToString(v.ProviderName) } if v.ServerSideTokenCheck != nil { diff --git a/internal/service/cognitoidentity/pool.go b/internal/service/cognitoidentity/pool.go index b510daf4d55..18ae5b5cb40 100644 --- a/internal/service/cognitoidentity/pool.go +++ b/internal/service/cognitoidentity/pool.go @@ -59,7 +59,7 @@ func resourcePool() *schema.Resource { Optional: true, ValidateFunc: validIdentityProvidersClientID, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, ValidateFunc: validIdentityProvidersProviderName, diff --git a/internal/service/cognitoidentity/pool_data_source.go b/internal/service/cognitoidentity/pool_data_source.go index 2b9c46dbd8e..ff7d13cb0d1 100644 --- a/internal/service/cognitoidentity/pool_data_source.go +++ b/internal/service/cognitoidentity/pool_data_source.go @@ -47,7 +47,7 @@ func dataSourcePool() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/cognitoidentity/pool_test.go b/internal/service/cognitoidentity/pool_test.go index 0b4020a5c69..b758352c862 100644 --- a/internal/service/cognitoidentity/pool_test.go +++ b/internal/service/cognitoidentity/pool_test.go @@ -271,12 +271,12 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", - "provider_name": fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", - "provider_name": fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Ab129faBb", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Ab129faBb", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), ), @@ -295,7 +295,7 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "6lhlkkfbfb4q5kpp90urffae", - "provider_name": fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), ), diff --git a/internal/service/cognitoidentity/validate_test.go b/internal/service/cognitoidentity/validate_test.go index e7a2128fc4e..e80c9568642 100644 --- a/internal/service/cognitoidentity/validate_test.go +++ b/internal/service/cognitoidentity/validate_test.go @@ -97,7 +97,7 @@ func TestValidIdentityProvidersProviderName(t *testing.T) { } for _, s := range validValues { - _, errors := tfcognitoidentity.ValidIdentityProvidersProviderName(s, "provider_name") + _, errors := tfcognitoidentity.ValidIdentityProvidersProviderName(s, names.AttrProviderName) if len(errors) > 0 { t.Fatalf("%q should be a valid Cognito Identity Provider Name: %v", s, errors) } @@ -112,7 +112,7 @@ func TestValidIdentityProvidersProviderName(t *testing.T) { } for _, s := range invalidValues { - _, errors := tfcognitoidentity.ValidIdentityProvidersProviderName(s, "provider_name") + _, errors := tfcognitoidentity.ValidIdentityProvidersProviderName(s, names.AttrProviderName) if len(errors) == 0 { t.Fatalf("%q should not be a valid Cognito Identity Provider Name: %v", s, errors) } From 35cac1adb075bd8597e46b259fbabd69b173b114 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:59 -0400 Subject: [PATCH 16/62] cognitoidp: Use constants for strings --- internal/service/cognitoidp/identity_provider.go | 6 +++--- .../service/cognitoidp/identity_provider_test.go | 12 ++++++------ .../service/cognitoidp/managed_user_pool_client.go | 6 +++--- internal/service/cognitoidp/user_pool.go | 6 +++--- internal/service/cognitoidp/user_pool_client.go | 8 ++++---- .../cognitoidp/user_pool_client_data_source.go | 4 ++-- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/service/cognitoidp/identity_provider.go b/internal/service/cognitoidp/identity_provider.go index 19ddaed8aa9..499e02214d4 100644 --- a/internal/service/cognitoidp/identity_provider.go +++ b/internal/service/cognitoidp/identity_provider.go @@ -61,7 +61,7 @@ func resourceIdentityProvider() *schema.Resource { Required: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -89,7 +89,7 @@ func resourceIdentityProviderCreate(ctx context.Context, d *schema.ResourceData, var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - providerName := d.Get("provider_name").(string) + providerName := d.Get(names.AttrProviderName).(string) userPoolID := d.Get("user_pool_id").(string) id := identityProviderCreateResourceID(userPoolID, providerName) input := &cognitoidentityprovider.CreateIdentityProviderInput{ @@ -145,7 +145,7 @@ func resourceIdentityProviderRead(ctx context.Context, d *schema.ResourceData, m d.Set("attribute_mapping", aws.StringValueMap(idp.AttributeMapping)) d.Set("idp_identifiers", aws.StringValueSlice(idp.IdpIdentifiers)) d.Set("provider_details", aws.StringValueMap(idp.ProviderDetails)) - d.Set("provider_name", idp.ProviderName) + d.Set(names.AttrProviderName, idp.ProviderName) d.Set("provider_type", idp.ProviderType) d.Set("user_pool_id", idp.UserPoolId) diff --git a/internal/service/cognitoidp/identity_provider_test.go b/internal/service/cognitoidp/identity_provider_test.go index 42af93f7bce..c672be3625d 100644 --- a/internal/service/cognitoidp/identity_provider_test.go +++ b/internal/service/cognitoidp/identity_provider_test.go @@ -47,7 +47,7 @@ func TestAccCognitoIDPIdentityProvider_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "provider_details.token_request_method", "POST"), resource.TestCheckResourceAttr(resourceName, "provider_details.token_url", "https://www.googleapis.com/oauth2/v4/token"), resource.TestCheckResourceAttr(resourceName, "provider_details.oidc_issuer", "https://accounts.google.com"), - resource.TestCheckResourceAttr(resourceName, "provider_name", "Google"), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, "Google"), resource.TestCheckResourceAttr(resourceName, "provider_type", "Google"), ), }, @@ -68,7 +68,7 @@ func TestAccCognitoIDPIdentityProvider_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "provider_details.token_request_method", "POST"), resource.TestCheckResourceAttr(resourceName, "provider_details.token_url", "https://www.googleapis.com/oauth2/v4/token"), resource.TestCheckResourceAttr(resourceName, "provider_details.oidc_issuer", "https://accounts.google.com"), - resource.TestCheckResourceAttr(resourceName, "provider_name", "Google"), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, "Google"), resource.TestCheckResourceAttr(resourceName, "provider_type", "Google"), ), }, @@ -142,7 +142,7 @@ func TestAccCognitoIDPIdentityProvider_saml(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "provider_details.EncryptedResponses", "false"), resource.TestCheckResourceAttrSet(resourceName, "provider_details.MetadataFile"), resource.TestCheckResourceAttr(resourceName, "provider_details.SSORedirectBindingURI", "https://terraform-dev-ed.my.salesforce.com/idp/endpoint/HttpRedirect"), - resource.TestCheckResourceAttr(resourceName, "provider_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, rName), resource.TestCheckResourceAttr(resourceName, "provider_type", "SAML"), ), }, @@ -163,7 +163,7 @@ func TestAccCognitoIDPIdentityProvider_saml(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "provider_details.EncryptedResponses", "true"), resource.TestCheckResourceAttrSet(resourceName, "provider_details.MetadataFile"), resource.TestCheckResourceAttr(resourceName, "provider_details.SSORedirectBindingURI", "https://terraform-dev-ed.my.salesforce.com/idp/endpoint/HttpRedirect"), - resource.TestCheckResourceAttr(resourceName, "provider_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, rName), resource.TestCheckResourceAttr(resourceName, "provider_type", "SAML"), ), }, @@ -228,7 +228,7 @@ func testAccCheckIdentityProviderDestroy(ctx context.Context) resource.TestCheck continue } - _, err := tfcognitoidp.FindIdentityProviderByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes["provider_name"]) + _, err := tfcognitoidp.FindIdentityProviderByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes[names.AttrProviderName]) if tfresource.NotFound(err) { continue @@ -254,7 +254,7 @@ func testAccCheckIdentityProviderExists(ctx context.Context, n string, v *cognit conn := acctest.Provider.Meta().(*conns.AWSClient).CognitoIDPConn(ctx) - output, err := tfcognitoidp.FindIdentityProviderByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes["provider_name"]) + output, err := tfcognitoidp.FindIdentityProviderByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes[names.AttrProviderName]) if err != nil { return err diff --git a/internal/service/cognitoidp/managed_user_pool_client.go b/internal/service/cognitoidp/managed_user_pool_client.go index 28110242fc5..79e28fa0ca2 100644 --- a/internal/service/cognitoidp/managed_user_pool_client.go +++ b/internal/service/cognitoidp/managed_user_pool_client.go @@ -270,7 +270,7 @@ func (r *managedUserPoolClientResource) Schema(ctx context.Context, request reso path.MatchRelative().AtParent().AtName("application_id"), ), stringvalidator.ConflictsWith( - path.MatchRelative().AtParent().AtName("external_id"), + path.MatchRelative().AtParent().AtName(names.AttrExternalID), path.MatchRelative().AtParent().AtName(names.AttrRoleARN), ), }, @@ -279,12 +279,12 @@ func (r *managedUserPoolClientResource) Schema(ctx context.Context, request reso Optional: true, Validators: []validator.String{ stringvalidator.AlsoRequires( - path.MatchRelative().AtParent().AtName("external_id"), + path.MatchRelative().AtParent().AtName(names.AttrExternalID), path.MatchRelative().AtParent().AtName(names.AttrRoleARN), ), }, }, - "external_id": schema.StringAttribute{ + names.AttrExternalID: schema.StringAttribute{ Optional: true, }, names.AttrRoleARN: schema.StringAttribute{ diff --git a/internal/service/cognitoidp/user_pool.go b/internal/service/cognitoidp/user_pool.go index 23385896f15..e21b61deec5 100644 --- a/internal/service/cognitoidp/user_pool.go +++ b/internal/service/cognitoidp/user_pool.go @@ -486,7 +486,7 @@ func resourceUserPool() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "external_id": { + names.AttrExternalID: { Type: schema.TypeString, Required: true, }, @@ -1232,7 +1232,7 @@ func expandSMSConfiguration(tfList []interface{}) *cognitoidentityprovider.SmsCo apiObject := &cognitoidentityprovider.SmsConfigurationType{} - if v, ok := tfMap["external_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExternalID].(string); ok && v != "" { apiObject.ExternalId = aws.String(v) } @@ -1271,7 +1271,7 @@ func flattenSMSConfiguration(apiObject *cognitoidentityprovider.SmsConfiguration tfMap := map[string]interface{}{} if v := apiObject.ExternalId; v != nil { - tfMap["external_id"] = aws.StringValue(v) + tfMap[names.AttrExternalID] = aws.StringValue(v) } if v := apiObject.SnsCallerArn; v != nil { diff --git a/internal/service/cognitoidp/user_pool_client.go b/internal/service/cognitoidp/user_pool_client.go index e5e9c90601c..331a176cd52 100644 --- a/internal/service/cognitoidp/user_pool_client.go +++ b/internal/service/cognitoidp/user_pool_client.go @@ -264,7 +264,7 @@ func (r *userPoolClientResource) Schema(ctx context.Context, request resource.Sc path.MatchRelative().AtParent().AtName("application_id"), ), stringvalidator.ConflictsWith( - path.MatchRelative().AtParent().AtName("external_id"), + path.MatchRelative().AtParent().AtName(names.AttrExternalID), path.MatchRelative().AtParent().AtName(names.AttrRoleARN), ), }, @@ -273,12 +273,12 @@ func (r *userPoolClientResource) Schema(ctx context.Context, request resource.Sc Optional: true, Validators: []validator.String{ stringvalidator.AlsoRequires( - path.MatchRelative().AtParent().AtName("external_id"), + path.MatchRelative().AtParent().AtName(names.AttrExternalID), path.MatchRelative().AtParent().AtName(names.AttrRoleARN), ), }, }, - "external_id": schema.StringAttribute{ + names.AttrExternalID: schema.StringAttribute{ Optional: true, }, names.AttrRoleARN: schema.StringAttribute{ @@ -737,7 +737,7 @@ func flattenAnaylticsConfiguration(ctx context.Context, ac *cognitoidentityprovi attrs := map[string]attr.Value{} attrs["application_arn"] = flex.StringToFrameworkARN(ctx, ac.ApplicationArn) attrs["application_id"] = flex.StringToFramework(ctx, ac.ApplicationId) - attrs["external_id"] = flex.StringToFramework(ctx, ac.ExternalId) + attrs[names.AttrExternalID] = flex.StringToFramework(ctx, ac.ExternalId) attrs[names.AttrRoleARN] = flex.StringToFrameworkARN(ctx, ac.RoleArn) attrs["user_data_shared"] = flex.BoolToFramework(ctx, ac.UserDataShared) diff --git a/internal/service/cognitoidp/user_pool_client_data_source.go b/internal/service/cognitoidp/user_pool_client_data_source.go index 560d5aa03e0..47e9064bdc0 100644 --- a/internal/service/cognitoidp/user_pool_client_data_source.go +++ b/internal/service/cognitoidp/user_pool_client_data_source.go @@ -57,7 +57,7 @@ func dataSourceUserPoolClient() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "external_id": { + names.AttrExternalID: { Type: schema.TypeString, Computed: true, }, @@ -237,7 +237,7 @@ func flattenUserPoolClientAnalyticsConfig(analyticsConfig *cognitoidentityprovid } if analyticsConfig.ExternalId != nil { - m["external_id"] = aws.StringValue(analyticsConfig.ExternalId) + m[names.AttrExternalID] = aws.StringValue(analyticsConfig.ExternalId) } if analyticsConfig.RoleArn != nil { From 37a6bcd8c656c2779f289f48f2b52166322919ef Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:59 -0400 Subject: [PATCH 17/62] comprehend: Use constants for strings --- internal/service/comprehend/document_classifier.go | 6 +++--- internal/service/comprehend/document_classifier_test.go | 8 ++++---- internal/service/comprehend/entity_recognizer.go | 6 +++--- internal/service/comprehend/entity_recognizer_test.go | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/internal/service/comprehend/document_classifier.go b/internal/service/comprehend/document_classifier.go index eae53c1244d..8e9541985fb 100644 --- a/internal/service/comprehend/document_classifier.go +++ b/internal/service/comprehend/document_classifier.go @@ -139,7 +139,7 @@ func ResourceDocumentClassifier() *schema.Resource { }, }, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[types.SyntaxLanguageCode](), @@ -311,7 +311,7 @@ func resourceDocumentClassifierRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrARN, out.DocumentClassifierArn) d.Set("data_access_role_arn", out.DataAccessRoleArn) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) d.Set(names.AttrMode, out.Mode) d.Set("model_kms_key_id", out.ModelKmsKeyId) d.Set("version_name", out.VersionName) @@ -470,7 +470,7 @@ func documentClassifierPublishVersion(ctx context.Context, conn *comprehend.Clie in := &comprehend.CreateDocumentClassifierInput{ DataAccessRoleArn: aws.String(d.Get("data_access_role_arn").(string)), InputDataConfig: expandDocumentClassifierInputDataConfig(d), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), DocumentClassifierName: aws.String(d.Get(names.AttrName).(string)), Mode: types.DocumentClassifierMode(d.Get(names.AttrMode).(string)), OutputDataConfig: expandDocumentClassifierOutputDataConfig(d.Get("output_data_config").([]interface{})), diff --git a/internal/service/comprehend/document_classifier_test.go b/internal/service/comprehend/document_classifier_test.go index 8973145ddf1..5ddab0fd4dc 100644 --- a/internal/service/comprehend/document_classifier_test.go +++ b/internal/service/comprehend/document_classifier_test.go @@ -56,7 +56,7 @@ func TestAccComprehendDocumentClassifier_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.label_delimiter", ""), resource.TestCheckResourceAttrSet(resourceName, "input_data_config.0.s3_uri"), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.test_s3_uri", ""), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrMode, string(types.DocumentClassifierModeMultiClass)), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, "output_data_config.#", acctest.CtZero), @@ -324,7 +324,7 @@ func TestAccComprehendDocumentClassifier_testDocuments(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.augmented_manifests.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.data_format", string(types.DocumentClassifierDataFormatComprehendCsv)), resource.TestCheckResourceAttrSet(resourceName, "input_data_config.0.test_s3_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.CtZero), @@ -413,7 +413,7 @@ func TestAccComprehendDocumentClassifier_multiLabel_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.augmented_manifests.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.data_format", string(types.DocumentClassifierDataFormatComprehendCsv)), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.label_delimiter", tfcomprehend.DocumentClassifierLabelSeparatorDefault), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrMode, string(types.DocumentClassifierModeMultiLabel)), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), @@ -823,7 +823,7 @@ func TestAccComprehendDocumentClassifier_multiLabel_labelDelimiter(t *testing.T) resource.TestCheckResourceAttr(resourceName, "input_data_config.0.augmented_manifests.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.data_format", string(types.DocumentClassifierDataFormatComprehendCsv)), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.label_delimiter", delimiter), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrMode, string(types.DocumentClassifierModeMultiLabel)), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), diff --git a/internal/service/comprehend/entity_recognizer.go b/internal/service/comprehend/entity_recognizer.go index 0b6e8689d21..05d609dbad9 100644 --- a/internal/service/comprehend/entity_recognizer.go +++ b/internal/service/comprehend/entity_recognizer.go @@ -196,7 +196,7 @@ func ResourceEntityRecognizer() *schema.Resource { }, }, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[types.SyntaxLanguageCode](), @@ -346,7 +346,7 @@ func resourceEntityRecognizerRead(ctx context.Context, d *schema.ResourceData, m d.Set(names.AttrARN, out.EntityRecognizerArn) d.Set("data_access_role_arn", out.DataAccessRoleArn) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) d.Set("model_kms_key_id", out.ModelKmsKeyId) d.Set("version_name", out.VersionName) d.Set("version_name_prefix", create.NamePrefixFromName(aws.ToString(out.VersionName))) @@ -500,7 +500,7 @@ func entityRecognizerPublishVersion(ctx context.Context, conn *comprehend.Client in := &comprehend.CreateEntityRecognizerInput{ DataAccessRoleArn: aws.String(d.Get("data_access_role_arn").(string)), InputDataConfig: expandEntityRecognizerInputDataConfig(getEntityRecognizerInputDataConfig(d)), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), RecognizerName: aws.String(d.Get(names.AttrName).(string)), VersionName: versionName, VpcConfig: expandVPCConfig(d.Get(names.AttrVPCConfig).([]interface{})), diff --git a/internal/service/comprehend/entity_recognizer_test.go b/internal/service/comprehend/entity_recognizer_test.go index 1a13e883d68..6e705df938f 100644 --- a/internal/service/comprehend/entity_recognizer_test.go +++ b/internal/service/comprehend/entity_recognizer_test.go @@ -59,7 +59,7 @@ func TestAccComprehendEntityRecognizer_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.0.input_format", string(types.InputFormatOneDocPerLine)), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.0.test_s3_uri", ""), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.entity_list.#", acctest.CtOne), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.CtZero), @@ -325,7 +325,7 @@ func TestAccComprehendEntityRecognizer_documents_testDocuments(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.#", acctest.CtOne), resource.TestCheckResourceAttrSet(resourceName, "input_data_config.0.documents.0.test_s3_uri"), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.entity_list.#", acctest.CtOne), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.CtZero), @@ -381,7 +381,7 @@ func TestAccComprehendEntityRecognizer_annotations_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.0.input_format", string(types.InputFormatOneDocPerLine)), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.0.test_s3_uri", ""), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.entity_list.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.CtZero), @@ -437,7 +437,7 @@ func TestAccComprehendEntityRecognizer_annotations_testDocuments(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "input_data_config.0.documents.0.input_format", string(types.InputFormatOneDocPerLine)), resource.TestCheckResourceAttrSet(resourceName, "input_data_config.0.documents.0.test_s3_uri"), resource.TestCheckResourceAttr(resourceName, "input_data_config.0.entity_list.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, "model_kms_key_id", ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsAllPercent, acctest.CtZero), From 9f7920c188c78fd5620866052a3ed21eeae1d005 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:52:59 -0400 Subject: [PATCH 18/62] connect: Use constants for strings --- internal/service/connect/instance.go | 4 ++-- internal/service/connect/instance_data_source.go | 4 ++-- internal/service/connect/instance_data_source_test.go | 4 ++-- internal/service/connect/instance_test.go | 2 +- internal/service/connect/vocabulary.go | 6 +++--- internal/service/connect/vocabulary_data_source.go | 4 ++-- internal/service/connect/vocabulary_data_source_test.go | 4 ++-- internal/service/connect/vocabulary_test.go | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/service/connect/instance.go b/internal/service/connect/instance.go index 2541c8fefc5..90fe517e8a5 100644 --- a/internal/service/connect/instance.go +++ b/internal/service/connect/instance.go @@ -109,7 +109,7 @@ func ResourceInstance() *schema.Resource { Type: schema.TypeBool, Required: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Computed: true, }, @@ -194,7 +194,7 @@ func resourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("inbound_calls_enabled", instance.InboundCallsEnabled) d.Set("instance_alias", instance.InstanceAlias) d.Set("outbound_calls_enabled", instance.OutboundCallsEnabled) - d.Set("service_role", instance.ServiceRole) + d.Set(names.AttrServiceRole, instance.ServiceRole) d.Set(names.AttrStatus, instance.InstanceStatus) for attributeType, key := range InstanceAttributeMapping() { diff --git a/internal/service/connect/instance_data_source.go b/internal/service/connect/instance_data_source.go index f0b173737de..b5cc11973da 100644 --- a/internal/service/connect/instance_data_source.go +++ b/internal/service/connect/instance_data_source.go @@ -78,7 +78,7 @@ func DataSourceInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Computed: true, }, @@ -145,7 +145,7 @@ func dataSourceInstanceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("inbound_calls_enabled", matchedInstance.InboundCallsEnabled) d.Set("instance_alias", matchedInstance.InstanceAlias) d.Set("outbound_calls_enabled", matchedInstance.OutboundCallsEnabled) - d.Set("service_role", matchedInstance.ServiceRole) + d.Set(names.AttrServiceRole, matchedInstance.ServiceRole) d.Set(names.AttrStatus, matchedInstance.InstanceStatus) for att := range InstanceAttributeMapping() { diff --git a/internal/service/connect/instance_data_source_test.go b/internal/service/connect/instance_data_source_test.go index ad72627fdf8..e4751a2f4ad 100644 --- a/internal/service/connect/instance_data_source_test.go +++ b/internal/service/connect/instance_data_source_test.go @@ -38,7 +38,7 @@ func testAccInstanceDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "early_media_enabled", dataSourceName, "early_media_enabled"), resource.TestCheckResourceAttrPair(resourceName, "multi_party_conference_enabled", dataSourceName, "multi_party_conference_enabled"), resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceName, names.AttrStatus), - resource.TestCheckResourceAttrPair(resourceName, "service_role", dataSourceName, "service_role"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, dataSourceName, names.AttrServiceRole), ), }, { @@ -56,7 +56,7 @@ func testAccInstanceDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "early_media_enabled", dataSourceName, "early_media_enabled"), resource.TestCheckResourceAttrPair(resourceName, "multi_party_conference_enabled", dataSourceName, "multi_party_conference_enabled"), resource.TestCheckResourceAttrPair(resourceName, names.AttrStatus, dataSourceName, names.AttrStatus), - resource.TestCheckResourceAttrPair(resourceName, "service_role", dataSourceName, "service_role"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, dataSourceName, names.AttrServiceRole), ), }, }, diff --git a/internal/service/connect/instance_test.go b/internal/service/connect/instance_test.go index a6586485a0e..a882f173f1c 100644 --- a/internal/service/connect/instance_test.go +++ b/internal/service/connect/instance_test.go @@ -47,7 +47,7 @@ func testAccInstance_basic(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "instance_alias", regexache.MustCompile(rName)), resource.TestCheckResourceAttr(resourceName, "multi_party_conference_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outbound_calls_enabled", "true"), - acctest.MatchResourceAttrGlobalARN(resourceName, "service_role", "iam", regexache.MustCompile(`role/aws-service-role/connect.amazonaws.com/.+`)), + acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", regexache.MustCompile(`role/aws-service-role/connect.amazonaws.com/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, connect.InstanceStatusActive), ), }, diff --git a/internal/service/connect/vocabulary.go b/internal/service/connect/vocabulary.go index 0d97cd77109..5824c0d2e7f 100644 --- a/internal/service/connect/vocabulary.go +++ b/internal/service/connect/vocabulary.go @@ -66,7 +66,7 @@ func ResourceVocabulary() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 100), }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -110,7 +110,7 @@ func resourceVocabularyCreate(ctx context.Context, d *schema.ResourceData, meta ClientToken: aws.String(id.UniqueId()), InstanceId: aws.String(instanceID), Content: aws.String(d.Get(names.AttrContent).(string)), - LanguageCode: aws.String(d.Get("language_code").(string)), + LanguageCode: aws.String(d.Get(names.AttrLanguageCode).(string)), Tags: getTagsIn(ctx), VocabularyName: aws.String(vocabularyName), } @@ -174,7 +174,7 @@ func resourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrContent, vocabulary.Content) d.Set("failure_reason", vocabulary.FailureReason) d.Set(names.AttrInstanceID, instanceID) - d.Set("language_code", vocabulary.LanguageCode) + d.Set(names.AttrLanguageCode, vocabulary.LanguageCode) d.Set("last_modified_time", vocabulary.LastModifiedTime.Format(time.RFC3339)) d.Set(names.AttrName, vocabulary.Name) d.Set(names.AttrState, vocabulary.State) diff --git a/internal/service/connect/vocabulary_data_source.go b/internal/service/connect/vocabulary_data_source.go index 16665bdc5c5..79cd6b18b23 100644 --- a/internal/service/connect/vocabulary_data_source.go +++ b/internal/service/connect/vocabulary_data_source.go @@ -42,7 +42,7 @@ func DataSourceVocabulary() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 100), }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Computed: true, }, @@ -116,7 +116,7 @@ func dataSourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrContent, vocabulary.Content) d.Set("failure_reason", vocabulary.FailureReason) d.Set(names.AttrInstanceID, instanceID) - d.Set("language_code", vocabulary.LanguageCode) + d.Set(names.AttrLanguageCode, vocabulary.LanguageCode) d.Set("last_modified_time", vocabulary.LastModifiedTime.Format(time.RFC3339)) d.Set(names.AttrName, vocabulary.Name) d.Set(names.AttrState, vocabulary.State) diff --git a/internal/service/connect/vocabulary_data_source_test.go b/internal/service/connect/vocabulary_data_source_test.go index 604974e8c51..669663a2abf 100644 --- a/internal/service/connect/vocabulary_data_source_test.go +++ b/internal/service/connect/vocabulary_data_source_test.go @@ -35,7 +35,7 @@ func testAccVocabularyDataSource_vocabularyID(t *testing.T) { 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"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrLanguageCode, resourceName, names.AttrLanguageCode), resource.TestCheckResourceAttrPair(datasourceName, "last_modified_time", resourceName, "last_modified_time"), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrState, resourceName, names.AttrState), @@ -70,7 +70,7 @@ func testAccVocabularyDataSource_name(t *testing.T) { 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"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrLanguageCode, resourceName, names.AttrLanguageCode), resource.TestCheckResourceAttrPair(datasourceName, "last_modified_time", resourceName, "last_modified_time"), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrState, resourceName, names.AttrState), diff --git a/internal/service/connect/vocabulary_test.go b/internal/service/connect/vocabulary_test.go index 1cd530568c8..b44030816ba 100644 --- a/internal/service/connect/vocabulary_test.go +++ b/internal/service/connect/vocabulary_test.go @@ -47,7 +47,7 @@ func testAccVocabulary_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, names.AttrContent, content), resource.TestCheckResourceAttrPair(resourceName, names.AttrInstanceID, "aws_connect_instance.test", names.AttrID), - resource.TestCheckResourceAttr(resourceName, "language_code", languageCode), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, languageCode), resource.TestCheckResourceAttrSet(resourceName, "last_modified_time"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName2), resource.TestCheckResourceAttrSet(resourceName, names.AttrState), From b2728fc029aec2f452df26e2cb7552d713ed199c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:00 -0400 Subject: [PATCH 19/62] directconnect: Use constants for strings --- internal/service/directconnect/connection.go | 8 ++++---- internal/service/directconnect/connection_data_source.go | 4 ++-- .../service/directconnect/connection_data_source_test.go | 2 +- internal/service/directconnect/connection_test.go | 6 +++--- internal/service/directconnect/hosted_connection.go | 4 ++-- internal/service/directconnect/lag.go | 6 +++--- internal/service/directconnect/lag_test.go | 8 ++++---- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/service/directconnect/connection.go b/internal/service/directconnect/connection.go index da50d73d874..34df7df6e1c 100644 --- a/internal/service/directconnect/connection.go +++ b/internal/service/directconnect/connection.go @@ -93,7 +93,7 @@ func ResourceConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, Computed: true, @@ -213,7 +213,7 @@ func ResourceConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, Computed: true, @@ -249,7 +249,7 @@ func resourceConnectionCreate(ctx context.Context, d *schema.ResourceData, meta Tags: getTagsIn(ctx), } - if v, ok := d.GetOk("provider_name"); ok { + if v, ok := d.GetOk(names.AttrProviderName); ok { input.ProviderName = aws.String(v.(string)) } @@ -299,7 +299,7 @@ func resourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("owner_account_id", connection.OwnerAccount) d.Set("partner_name", connection.PartnerName) d.Set("port_encryption_status", connection.PortEncryptionStatus) - d.Set("provider_name", connection.ProviderName) + d.Set(names.AttrProviderName, connection.ProviderName) d.Set("vlan_id", connection.Vlan) // d.Set("request_macsec", d.Get("request_macsec").(bool)) diff --git a/internal/service/directconnect/connection_data_source.go b/internal/service/directconnect/connection_data_source.go index 872adf82304..2b1436e6cf0 100644 --- a/internal/service/directconnect/connection_data_source.go +++ b/internal/service/directconnect/connection_data_source.go @@ -52,7 +52,7 @@ func DataSourceConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, @@ -113,7 +113,7 @@ func dataSourceConnectionRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrName, connection.ConnectionName) d.Set("owner_account_id", connection.OwnerAccount) d.Set("partner_name", connection.PartnerName) - d.Set("provider_name", connection.ProviderName) + d.Set(names.AttrProviderName, connection.ProviderName) d.Set("vlan_id", connection.Vlan) tags, err := listTags(ctx, conn, arn) diff --git a/internal/service/directconnect/connection_data_source_test.go b/internal/service/directconnect/connection_data_source_test.go index edd54793b43..185f6a4eec6 100644 --- a/internal/service/directconnect/connection_data_source_test.go +++ b/internal/service/directconnect/connection_data_source_test.go @@ -35,7 +35,7 @@ func TestAccDirectConnectConnectionDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, "owner_account_id", resourceName, "owner_account_id"), resource.TestCheckResourceAttrPair(datasourceName, "partner_name", resourceName, "partner_name"), - resource.TestCheckResourceAttrPair(datasourceName, "provider_name", resourceName, "provider_name"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrProviderName, resourceName, names.AttrProviderName), resource.TestCheckResourceAttrPair(datasourceName, "vlan_id", resourceName, "vlan_id"), ), }, diff --git a/internal/service/directconnect/connection_test.go b/internal/service/directconnect/connection_test.go index 158440f0544..a3e46d68f99 100644 --- a/internal/service/directconnect/connection_test.go +++ b/internal/service/directconnect/connection_test.go @@ -43,7 +43,7 @@ func TestAccDirectConnectConnection_basic(t *testing.T) { acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "partner_name", ""), - resource.TestCheckResourceAttr(resourceName, "provider_name", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "vlan_id", acctest.CtZero), ), @@ -163,7 +163,7 @@ func TestAccDirectConnectConnection_macsecRequested(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "request_macsec", "true"), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttrSet(resourceName, "provider_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrProviderName), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, @@ -198,7 +198,7 @@ func TestAccDirectConnectConnection_providerName(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "location"), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttrSet(resourceName, "provider_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrProviderName), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, diff --git a/internal/service/directconnect/hosted_connection.go b/internal/service/directconnect/hosted_connection.go index 7866e2c20d9..67a82e22df0 100644 --- a/internal/service/directconnect/hosted_connection.go +++ b/internal/service/directconnect/hosted_connection.go @@ -78,7 +78,7 @@ func ResourceHostedConnection() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, @@ -153,7 +153,7 @@ func resourceHostedConnectionRead(ctx context.Context, d *schema.ResourceData, m d.Set(names.AttrName, connection.ConnectionName) d.Set("owner_account_id", connection.OwnerAccount) d.Set("partner_name", connection.PartnerName) - d.Set("provider_name", connection.ProviderName) + d.Set(names.AttrProviderName, connection.ProviderName) d.Set(names.AttrRegion, connection.Region) d.Set(names.AttrState, connection.ConnectionState) d.Set("vlan", connection.Vlan) diff --git a/internal/service/directconnect/lag.go b/internal/service/directconnect/lag.go index 4e78b864337..4c00b1085a2 100644 --- a/internal/service/directconnect/lag.go +++ b/internal/service/directconnect/lag.go @@ -76,7 +76,7 @@ func ResourceLag() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, Computed: true, @@ -111,7 +111,7 @@ func resourceLagCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.NumberOfConnections = aws.Int64(1) } - if v, ok := d.GetOk("provider_name"); ok { + if v, ok := d.GetOk(names.AttrProviderName); ok { input.ProviderName = aws.String(v.(string)) } @@ -164,7 +164,7 @@ func resourceLagRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("location", lag.Location) d.Set(names.AttrName, lag.LagName) d.Set("owner_account_id", lag.OwnerAccount) - d.Set("provider_name", lag.ProviderName) + d.Set(names.AttrProviderName, lag.ProviderName) return diags } diff --git a/internal/service/directconnect/lag_test.go b/internal/service/directconnect/lag_test.go index 2e13438f2d4..cbc50a4d5ae 100644 --- a/internal/service/directconnect/lag_test.go +++ b/internal/service/directconnect/lag_test.go @@ -46,7 +46,7 @@ func TestAccDirectConnectLag_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "location"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName1), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), - resource.TestCheckResourceAttr(resourceName, "provider_name", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, @@ -63,7 +63,7 @@ func TestAccDirectConnectLag_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "location"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName2), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), - resource.TestCheckResourceAttr(resourceName, "provider_name", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, @@ -127,7 +127,7 @@ func TestAccDirectConnectLag_connectionID(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "location"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), - resource.TestCheckResourceAttr(resourceName, "provider_name", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, @@ -166,7 +166,7 @@ func TestAccDirectConnectLag_providerName(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "location"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), acctest.CheckResourceAttrAccountID(resourceName, "owner_account_id"), - resource.TestCheckResourceAttrSet(resourceName, "provider_name"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrProviderName), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, From 183ffb7358dc9f57bf29e6f491e68245fc15f536 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:00 -0400 Subject: [PATCH 20/62] dms: Use constants for strings --- internal/service/dms/s3_endpoint.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/dms/s3_endpoint.go b/internal/service/dms/s3_endpoint.go index caa5c0f1e53..f79584d3d26 100644 --- a/internal/service/dms/s3_endpoint.go +++ b/internal/service/dms/s3_endpoint.go @@ -71,7 +71,7 @@ func ResourceS3Endpoint() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "external_id": { + names.AttrExternalID: { Type: schema.TypeString, Computed: true, }, @@ -419,7 +419,7 @@ func resourceS3EndpointRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("endpoint_id", endpoint.EndpointIdentifier) d.Set(names.AttrEndpointType, strings.ToLower(*endpoint.EndpointType)) // For some reason the AWS API only accepts lowercase type but returns it as uppercase d.Set("engine_display_name", endpoint.EngineDisplayName) - d.Set("external_id", endpoint.ExternalId) + d.Set(names.AttrExternalID, endpoint.ExternalId) // d.Set("external_table_definition", endpoint.ExternalTableDefinition) // set from s3 settings d.Set(names.AttrKMSKeyARN, endpoint.KmsKeyId) // d.Set("service_access_role_arn", endpoint.ServiceAccessRoleArn) // set from s3 settings From 61624bb7ad25fce7fbd3ea393ae7686d060eea8b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:00 -0400 Subject: [PATCH 21/62] dynamodb: Use constants for strings --- internal/service/dynamodb/table.go | 8 ++--- internal/service/dynamodb/table_test.go | 40 ++++++++++++------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/service/dynamodb/table.go b/internal/service/dynamodb/table.go index 8db6bd4e9aa..f43c6044f75 100644 --- a/internal/service/dynamodb/table.go +++ b/internal/service/dynamodb/table.go @@ -282,7 +282,7 @@ func resourceTable() *schema.Resource { Optional: true, Default: false, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeBool, Optional: true, Default: false, @@ -1343,7 +1343,7 @@ func updateReplicaTags(ctx context.Context, conn *dynamodb.Client, rn string, re continue } - if v, ok := tfMap["propagate_tags"].(bool); ok && v { + if v, ok := tfMap[names.AttrPropagateTags].(bool); ok && v { optFn := func(o *dynamodb.Options) { o.Region = region } @@ -1850,12 +1850,12 @@ func addReplicaTagPropagates(configReplicas *schema.Set, replicas []interface{}) continue } - if v, ok := configReplica["propagate_tags"].(bool); ok && v { + if v, ok := configReplica[names.AttrPropagateTags].(bool); ok && v { prop = true break } } - replica["propagate_tags"] = prop + replica[names.AttrPropagateTags] = prop replicas[i] = replica } diff --git a/internal/service/dynamodb/table_test.go b/internal/service/dynamodb/table_test.go index 8105d97dff7..dd99b7380fc 100644 --- a/internal/service/dynamodb/table_test.go +++ b/internal/service/dynamodb/table_test.go @@ -2078,11 +2078,11 @@ func TestAccDynamoDBTable_Replica_tagsOneOfTwo(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "false", + names.AttrPropagateTags: "false", }), ), }, @@ -2118,11 +2118,11 @@ func TestAccDynamoDBTable_Replica_tagsTwoOfTwo(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2157,7 +2157,7 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2170,11 +2170,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2186,7 +2186,7 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2199,11 +2199,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "false", + names.AttrPropagateTags: "false", }), ), }, @@ -2216,11 +2216,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "false", + names.AttrPropagateTags: "false", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "false", + names.AttrPropagateTags: "false", }), ), }, @@ -2255,7 +2255,7 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2267,7 +2267,7 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2280,11 +2280,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2297,11 +2297,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, @@ -2314,11 +2314,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.AlternateRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ "region_name": acctest.ThirdRegion(), - "propagate_tags": "true", + names.AttrPropagateTags: "true", }), ), }, From 659df2b2e85939652abd72ef352f1d819c900816 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:00 -0400 Subject: [PATCH 22/62] ec2: Use constants for strings --- .../service/ec2/ebs_fast_snapshot_restore.go | 2 +- .../ec2/ebs_fast_snapshot_restore_test.go | 6 ++--- .../ebs_snapshot_create_volume_permission.go | 6 ++--- ..._snapshot_create_volume_permission_test.go | 2 +- .../service/ec2/ebs_snapshot_data_source.go | 4 ++-- internal/service/ec2/ebs_volume.go | 10 ++++----- .../service/ec2/ebs_volume_data_source.go | 4 ++-- internal/service/ec2/ebs_volume_test.go | 22 +++++++++---------- internal/service/ec2/ec2_ami.go | 12 +++++----- internal/service/ec2/ec2_ami_copy.go | 4 ++-- internal/service/ec2/ec2_ami_data_source.go | 4 ++-- internal/service/ec2/ec2_ami_from_instance.go | 4 ++-- internal/service/ec2/ec2_instance.go | 14 ++++++------ .../service/ec2/ec2_instance_data_source.go | 4 ++-- internal/service/ec2/ec2_instance_migrate.go | 2 +- internal/service/ec2/ec2_launch_template.go | 6 ++--- .../ec2/ec2_launch_template_data_source.go | 2 +- .../service/ec2/ec2_spot_fleet_request.go | 8 +++---- 18 files changed, 58 insertions(+), 58 deletions(-) diff --git a/internal/service/ec2/ebs_fast_snapshot_restore.go b/internal/service/ec2/ebs_fast_snapshot_restore.go index 767ab4d2a8a..2c84ac69090 100644 --- a/internal/service/ec2/ebs_fast_snapshot_restore.go +++ b/internal/service/ec2/ebs_fast_snapshot_restore.go @@ -55,7 +55,7 @@ func (r *ebsFastSnapshotRestoreResource) Schema(ctx context.Context, request res }, }, names.AttrID: framework.IDAttribute(), - "snapshot_id": schema.StringAttribute{ + names.AttrSnapshotID: schema.StringAttribute{ Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/service/ec2/ebs_fast_snapshot_restore_test.go b/internal/service/ec2/ebs_fast_snapshot_restore_test.go index 32814798a26..7ef4c892dd8 100644 --- a/internal/service/ec2/ebs_fast_snapshot_restore_test.go +++ b/internal/service/ec2/ebs_fast_snapshot_restore_test.go @@ -37,7 +37,7 @@ func TestAccEC2EBSFastSnapshotRestore_basic(t *testing.T) { Config: testAccEBSFastSnapshotRestoreConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckEBSFastSnapshotRestoreExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "snapshot_id", snapshotResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrSnapshotID, snapshotResourceName, names.AttrID), ), }, { @@ -111,7 +111,7 @@ func testAccCheckEBSFastSnapshotRestoreDestroy(ctx context.Context) resource.Tes continue } - _, err := tfec2.FindFastSnapshotRestoreByTwoPartKey(ctx, conn, rs.Primary.Attributes[names.AttrAvailabilityZone], rs.Primary.Attributes["snapshot_id"]) + _, err := tfec2.FindFastSnapshotRestoreByTwoPartKey(ctx, conn, rs.Primary.Attributes[names.AttrAvailabilityZone], rs.Primary.Attributes[names.AttrSnapshotID]) if tfresource.NotFound(err) { continue @@ -137,7 +137,7 @@ func testAccCheckEBSFastSnapshotRestoreExists(ctx context.Context, n string) res conn := acctest.Provider.Meta().(*conns.AWSClient).EC2Client(ctx) - _, err := tfec2.FindFastSnapshotRestoreByTwoPartKey(ctx, conn, rs.Primary.Attributes[names.AttrAvailabilityZone], rs.Primary.Attributes["snapshot_id"]) + _, err := tfec2.FindFastSnapshotRestoreByTwoPartKey(ctx, conn, rs.Primary.Attributes[names.AttrAvailabilityZone], rs.Primary.Attributes[names.AttrSnapshotID]) return err } diff --git a/internal/service/ec2/ebs_snapshot_create_volume_permission.go b/internal/service/ec2/ebs_snapshot_create_volume_permission.go index 5a6e7a4ebe9..ce8487eaf94 100644 --- a/internal/service/ec2/ebs_snapshot_create_volume_permission.go +++ b/internal/service/ec2/ebs_snapshot_create_volume_permission.go @@ -42,7 +42,7 @@ func ResourceSnapshotCreateVolumePermission() *schema.Resource { Required: true, ForceNew: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -55,7 +55,7 @@ func resourceSnapshotCreateVolumePermissionCreate(ctx context.Context, d *schema var diags diag.Diagnostics conn := meta.(*conns.AWSClient).EC2Client(ctx) - snapshotID := d.Get("snapshot_id").(string) + snapshotID := d.Get(names.AttrSnapshotID).(string) accountID := d.Get(names.AttrAccountID).(string) id := EBSSnapshotCreateVolumePermissionCreateResourceID(snapshotID, accountID) input := &ec2.ModifySnapshotAttributeInput{ @@ -154,7 +154,7 @@ func resourceSnapshotCreateVolumePermissionDelete(ctx context.Context, d *schema func resourceSnapshotCreateVolumePermissionCustomizeDiff(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) error { if diff.Id() == "" { - if snapshotID := diff.Get("snapshot_id").(string); snapshotID != "" { + if snapshotID := diff.Get(names.AttrSnapshotID).(string); snapshotID != "" { conn := meta.(*conns.AWSClient).EC2Client(ctx) snapshot, err := FindSnapshotByID(ctx, conn, snapshotID) diff --git a/internal/service/ec2/ebs_snapshot_create_volume_permission_test.go b/internal/service/ec2/ebs_snapshot_create_volume_permission_test.go index 6677b128d8e..e45105ba0ef 100644 --- a/internal/service/ec2/ebs_snapshot_create_volume_permission_test.go +++ b/internal/service/ec2/ebs_snapshot_create_volume_permission_test.go @@ -38,7 +38,7 @@ func TestAccEC2EBSSnapshotCreateVolumePermission_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccSnapshotCreateVolumePermissionExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrAccountID), - resource.TestCheckResourceAttrSet(resourceName, "snapshot_id"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrSnapshotID), ), }, }, diff --git a/internal/service/ec2/ebs_snapshot_data_source.go b/internal/service/ec2/ebs_snapshot_data_source.go index 28615c7923f..0e1f73841c0 100644 --- a/internal/service/ec2/ebs_snapshot_data_source.go +++ b/internal/service/ec2/ebs_snapshot_data_source.go @@ -79,7 +79,7 @@ func DataSourceEBSSnapshot() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -174,7 +174,7 @@ func dataSourceEBSSnapshotRead(ctx context.Context, d *schema.ResourceData, meta d.Set("outpost_arn", snapshot.OutpostArn) d.Set("owner_alias", snapshot.OwnerAlias) d.Set(names.AttrOwnerID, snapshot.OwnerId) - d.Set("snapshot_id", snapshot.SnapshotId) + d.Set(names.AttrSnapshotID, snapshot.SnapshotId) d.Set(names.AttrState, snapshot.State) d.Set("storage_tier", snapshot.StorageTier) d.Set("volume_id", snapshot.VolumeId) diff --git a/internal/service/ec2/ebs_volume.go b/internal/service/ec2/ebs_volume.go index 52ae4801355..2cc71ab1052 100644 --- a/internal/service/ec2/ebs_volume.go +++ b/internal/service/ec2/ebs_volume.go @@ -99,14 +99,14 @@ func ResourceEBSVolume() *schema.Resource { Type: schema.TypeInt, Optional: true, Computed: true, - AtLeastOneOf: []string{names.AttrSize, "snapshot_id"}, + AtLeastOneOf: []string{names.AttrSize, names.AttrSnapshotID}, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, Computed: true, ForceNew: true, - AtLeastOneOf: []string{names.AttrSize, "snapshot_id"}, + AtLeastOneOf: []string{names.AttrSize, names.AttrSnapshotID}, }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -159,7 +159,7 @@ func resourceEBSVolumeCreate(ctx context.Context, d *schema.ResourceData, meta i input.Size = aws.Int32(int32(value.(int))) } - if value, ok := d.GetOk("snapshot_id"); ok { + if value, ok := d.GetOk(names.AttrSnapshotID); ok { input.SnapshotId = aws.String(value.(string)) } @@ -217,7 +217,7 @@ func resourceEBSVolumeRead(ctx context.Context, d *schema.ResourceData, meta int d.Set("multi_attach_enabled", volume.MultiAttachEnabled) d.Set("outpost_arn", volume.OutpostArn) d.Set(names.AttrSize, volume.Size) - d.Set("snapshot_id", volume.SnapshotId) + d.Set(names.AttrSnapshotID, volume.SnapshotId) d.Set("throughput", volume.Throughput) d.Set(names.AttrType, volume.VolumeType) diff --git a/internal/service/ec2/ebs_volume_data_source.go b/internal/service/ec2/ebs_volume_data_source.go index 8b62b93ce48..95ab70992d7 100644 --- a/internal/service/ec2/ebs_volume_data_source.go +++ b/internal/service/ec2/ebs_volume_data_source.go @@ -69,7 +69,7 @@ func DataSourceEBSVolume() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -148,7 +148,7 @@ func dataSourceEBSVolumeRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("multi_attach_enabled", volume.MultiAttachEnabled) d.Set("outpost_arn", volume.OutpostArn) d.Set(names.AttrSize, volume.Size) - d.Set("snapshot_id", volume.SnapshotId) + d.Set(names.AttrSnapshotID, volume.SnapshotId) d.Set("throughput", volume.Throughput) d.Set("volume_id", volume.VolumeId) d.Set(names.AttrVolumeType, volume.VolumeType) diff --git a/internal/service/ec2/ebs_volume_test.go b/internal/service/ec2/ebs_volume_test.go index 4a45770ddf3..ea4884a3454 100644 --- a/internal/service/ec2/ebs_volume_test.go +++ b/internal/service/ec2/ebs_volume_test.go @@ -543,7 +543,7 @@ func TestAccEC2EBSVolume_GP3_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "125"), @@ -583,7 +583,7 @@ func TestAccEC2EBSVolume_GP3_iops(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "200"), @@ -607,7 +607,7 @@ func TestAccEC2EBSVolume_GP3_iops(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "200"), @@ -641,7 +641,7 @@ func TestAccEC2EBSVolume_GP3_throughput(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "400"), @@ -665,7 +665,7 @@ func TestAccEC2EBSVolume_GP3_throughput(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "600"), @@ -699,7 +699,7 @@ func TestAccEC2EBSVolume_gp3ToGP2(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "400"), @@ -723,7 +723,7 @@ func TestAccEC2EBSVolume_gp3ToGP2(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "10"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", acctest.CtZero), @@ -757,7 +757,7 @@ func TestAccEC2EBSVolume_io1ToGP3(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "100"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", acctest.CtZero), @@ -781,7 +781,7 @@ func TestAccEC2EBSVolume_io1ToGP3(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "100"), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", "125"), @@ -816,7 +816,7 @@ func TestAccEC2EBSVolume_snapshotID(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, acctest.CtOne), - resource.TestCheckResourceAttrPair(resourceName, "snapshot_id", snapshotResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrSnapshotID, snapshotResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", acctest.CtZero), @@ -857,7 +857,7 @@ func TestAccEC2EBSVolume_snapshotIDAndSize(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "multi_attach_enabled", "false"), resource.TestCheckResourceAttr(resourceName, "outpost_arn", ""), resource.TestCheckResourceAttr(resourceName, names.AttrSize, "20"), - resource.TestCheckResourceAttrPair(resourceName, "snapshot_id", snapshotResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrSnapshotID, snapshotResourceName, names.AttrID), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "tags.Name", rName), resource.TestCheckResourceAttr(resourceName, "throughput", acctest.CtZero), diff --git a/internal/service/ec2/ec2_ami.go b/internal/service/ec2/ec2_ami.go index 819b821e5f6..52e541e1366 100644 --- a/internal/service/ec2/ec2_ami.go +++ b/internal/service/ec2/ec2_ami.go @@ -124,7 +124,7 @@ func ResourceAMI() *schema.Resource { ForceNew: true, ValidateFunc: verify.ValidARN, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -154,7 +154,7 @@ func ResourceAMI() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, @@ -343,7 +343,7 @@ func resourceAMICreate(ctx context.Context, d *schema.ResourceData, meta interfa var snapshot string - if v, ok := tfMap["snapshot_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrSnapshotID].(string); ok && v != "" { snapshot = v } @@ -511,7 +511,7 @@ func resourceAMIDelete(ctx context.Context, d *schema.ResourceData, meta interfa req := &ec2.DeleteSnapshotInput{} for _, ebsBlockDevI := range ebsBlockDevsSet.List() { ebsBlockDev := ebsBlockDevI.(map[string]interface{}) - snapshotId := ebsBlockDev["snapshot_id"].(string) + snapshotId := ebsBlockDev[names.AttrSnapshotID].(string) if snapshotId != "" { req.SnapshotId = aws.String(snapshotId) _, err := conn.DeleteSnapshotWithContext(ctx, req) @@ -623,7 +623,7 @@ func expandBlockDeviceMappingForAMIEBSBlockDevice(tfMap map[string]interface{}) } // "Parameter encrypted is invalid. You cannot specify the encrypted flag if specifying a snapshot id in a block device mapping." - if v, ok := tfMap["snapshot_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrSnapshotID].(string); ok && v != "" { apiObject.Ebs.SnapshotId = aws.String(v) } else if v, ok := tfMap[names.AttrEncrypted].(bool); ok { apiObject.Ebs.Encrypted = aws.Bool(v) @@ -702,7 +702,7 @@ func flattenBlockDeviceMappingForAMIEBSBlockDevice(apiObject *ec2.BlockDeviceMap } if v := apiObject.Ebs.SnapshotId; v != nil { - tfMap["snapshot_id"] = aws.StringValue(v) + tfMap[names.AttrSnapshotID] = aws.StringValue(v) } if v := apiObject.Ebs.Throughput; v != nil { diff --git a/internal/service/ec2/ec2_ami_copy.go b/internal/service/ec2/ec2_ami_copy.go index 51dacb6c3d4..0135f703496 100644 --- a/internal/service/ec2/ec2_ami_copy.go +++ b/internal/service/ec2/ec2_ami_copy.go @@ -102,7 +102,7 @@ func ResourceAMICopy() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -124,7 +124,7 @@ func ResourceAMICopy() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, diff --git a/internal/service/ec2/ec2_ami_data_source.go b/internal/service/ec2/ec2_ami_data_source.go index b439985467f..d94e408c44c 100644 --- a/internal/service/ec2/ec2_ami_data_source.go +++ b/internal/service/ec2/ec2_ami_data_source.go @@ -366,7 +366,7 @@ func flattenAMIBlockDeviceMappings(m []*ec2.BlockDeviceMapping) *schema.Set { names.AttrIOPS: fmt.Sprintf("%d", aws.Int64Value(v.Ebs.Iops)), "throughput": fmt.Sprintf("%d", aws.Int64Value(v.Ebs.Throughput)), names.AttrVolumeSize: fmt.Sprintf("%d", aws.Int64Value(v.Ebs.VolumeSize)), - "snapshot_id": aws.StringValue(v.Ebs.SnapshotId), + names.AttrSnapshotID: aws.StringValue(v.Ebs.SnapshotId), names.AttrVolumeType: aws.StringValue(v.Ebs.VolumeType), } @@ -442,7 +442,7 @@ func amiBlockDeviceMappingHash(v interface{}) int { if d, ok := m["virtual_name"]; ok { buf.WriteString(fmt.Sprintf("%s-", d.(string))) } - if d, ok := m["snapshot_id"]; ok { + if d, ok := m[names.AttrSnapshotID]; ok { buf.WriteString(fmt.Sprintf("%s-", d.(string))) } return create.StringHashcode(buf.String()) diff --git a/internal/service/ec2/ec2_ami_from_instance.go b/internal/service/ec2/ec2_ami_from_instance.go index 911cc3f7ecc..8bf504344ac 100644 --- a/internal/service/ec2/ec2_ami_from_instance.go +++ b/internal/service/ec2/ec2_ami_from_instance.go @@ -96,7 +96,7 @@ func ResourceAMIFromInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -118,7 +118,7 @@ func ResourceAMIFromInstance() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, diff --git a/internal/service/ec2/ec2_instance.go b/internal/service/ec2/ec2_instance.go index 9cb0e2fc31d..9ef3d8f4bef 100644 --- a/internal/service/ec2/ec2_instance.go +++ b/internal/service/ec2/ec2_instance.go @@ -260,7 +260,7 @@ func ResourceInstance() *schema.Resource { Computed: true, ForceNew: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, Computed: true, @@ -298,7 +298,7 @@ func ResourceInstance() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, @@ -2257,8 +2257,8 @@ func readBlockDevices(ctx context.Context, d *schema.ResourceData, meta interfac m[k] = v } - if snapshotID, ok := ibds["snapshot_id"].(string); ok { - m["snapshot_id"] = snapshotID + if snapshotID, ok := ibds[names.AttrSnapshotID].(string); ok { + m[names.AttrSnapshotID] = snapshotID } ibds["ebs"] = []interface{}{m} @@ -2367,7 +2367,7 @@ func readBlockDevicesFromInstance(ctx context.Context, d *schema.ResourceData, m blockDevices["root"] = bd } else { if vol.SnapshotId != nil { - bd["snapshot_id"] = aws.StringValue(vol.SnapshotId) + bd[names.AttrSnapshotID] = aws.StringValue(vol.SnapshotId) } blockDevices["ebs"] = append(blockDevices["ebs"].([]map[string]interface{}), bd) @@ -2378,7 +2378,7 @@ func readBlockDevicesFromInstance(ctx context.Context, d *schema.ResourceData, m // we'll need to set the ebs_block_device as a clone of the root device // with the snapshot_id populated; thus, we store the ID for safe-keeping if blockDevices["root"] != nil && len(blockDevices["ebs"].([]map[string]interface{})) == 0 { - blockDevices["snapshot_id"] = volResp.Volumes[0].SnapshotId + blockDevices[names.AttrSnapshotID] = volResp.Volumes[0].SnapshotId } return blockDevices, nil @@ -2555,7 +2555,7 @@ func readBlockDeviceMappingsFromConfig(ctx context.Context, d *schema.ResourceDa DeleteOnTermination: aws.Bool(bd[names.AttrDeleteOnTermination].(bool)), } - if v, ok := bd["snapshot_id"].(string); ok && v != "" { + if v, ok := bd[names.AttrSnapshotID].(string); ok && v != "" { ebs.SnapshotId = aws.String(v) } diff --git a/internal/service/ec2/ec2_instance_data_source.go b/internal/service/ec2/ec2_instance_data_source.go index 3bcce3fb543..e37ed363aa1 100644 --- a/internal/service/ec2/ec2_instance_data_source.go +++ b/internal/service/ec2/ec2_instance_data_source.go @@ -95,7 +95,7 @@ func DataSourceInstance() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -123,7 +123,7 @@ func DataSourceInstance() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, diff --git a/internal/service/ec2/ec2_instance_migrate.go b/internal/service/ec2/ec2_instance_migrate.go index f0e05eabd2c..453eac6ae4b 100644 --- a/internal/service/ec2/ec2_instance_migrate.go +++ b/internal/service/ec2/ec2_instance_migrate.go @@ -93,7 +93,7 @@ func WriteV1BlockDevice( case "root_block_device": delete(oldBd, "virtual_name") delete(oldBd, names.AttrEncrypted) - delete(oldBd, "snapshot_id") + delete(oldBd, names.AttrSnapshotID) case "ephemeral_block_device": delete(oldBd, names.AttrDeleteOnTermination) delete(oldBd, names.AttrEncrypted) diff --git a/internal/service/ec2/ec2_launch_template.go b/internal/service/ec2/ec2_launch_template.go index d8e18c58b49..fcfad5f9f51 100644 --- a/internal/service/ec2/ec2_launch_template.go +++ b/internal/service/ec2/ec2_launch_template.go @@ -85,7 +85,7 @@ func ResourceLaunchTemplate() *schema.Resource { Optional: true, ValidateFunc: verify.ValidARN, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, }, @@ -1389,7 +1389,7 @@ func expandLaunchTemplateEBSBlockDeviceRequest(tfMap map[string]interface{}) *ec apiObject.KmsKeyId = aws.String(v) } - if v, ok := tfMap["snapshot_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrSnapshotID].(string); ok && v != "" { apiObject.SnapshotId = aws.String(v) } @@ -2411,7 +2411,7 @@ func flattenLaunchTemplateEBSBlockDevice(apiObject *ec2.LaunchTemplateEbsBlockDe } if v := apiObject.SnapshotId; v != nil { - tfMap["snapshot_id"] = aws.StringValue(v) + tfMap[names.AttrSnapshotID] = aws.StringValue(v) } if v := apiObject.Throughput; v != nil { diff --git a/internal/service/ec2/ec2_launch_template_data_source.go b/internal/service/ec2/ec2_launch_template_data_source.go index f357ae07dae..92e7ad69bdc 100644 --- a/internal/service/ec2/ec2_launch_template_data_source.go +++ b/internal/service/ec2/ec2_launch_template_data_source.go @@ -65,7 +65,7 @@ func DataSourceLaunchTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/ec2/ec2_spot_fleet_request.go b/internal/service/ec2/ec2_spot_fleet_request.go index bea65af83fd..2d493ebc3b1 100644 --- a/internal/service/ec2/ec2_spot_fleet_request.go +++ b/internal/service/ec2/ec2_spot_fleet_request.go @@ -166,7 +166,7 @@ func ResourceSpotFleetRequest() *schema.Resource { Computed: true, ForceNew: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, Computed: true, @@ -1344,7 +1344,7 @@ func readSpotFleetBlockDeviceMappingsFromConfig(ctx context.Context, d map[strin DeleteOnTermination: aws.Bool(bd[names.AttrDeleteOnTermination].(bool)), } - if v, ok := bd["snapshot_id"].(string); ok && v != "" { + if v, ok := bd[names.AttrSnapshotID].(string); ok && v != "" { ebs.SnapshotId = aws.String(v) } @@ -1980,7 +1980,7 @@ func ebsBlockDevicesToSet(bdm []*ec2.BlockDeviceMapping, rootDevName *string) *s } if ebs.SnapshotId != nil { - m["snapshot_id"] = aws.StringValue(ebs.SnapshotId) + m[names.AttrSnapshotID] = aws.StringValue(ebs.SnapshotId) } if ebs.Encrypted != nil { @@ -2110,7 +2110,7 @@ func hashEBSBlockDevice(v interface{}) int { if name, ok := m[names.AttrDeviceName]; ok { buf.WriteString(fmt.Sprintf("%s-", name.(string))) } - if id, ok := m["snapshot_id"]; ok { + if id, ok := m[names.AttrSnapshotID]; ok { buf.WriteString(fmt.Sprintf("%s-", id.(string))) } return create.StringHashcode(buf.String()) From 5f8cd852d2cb9b6400b99e34c22013b867091537 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:01 -0400 Subject: [PATCH 23/62] ecr: Use constants for strings --- internal/service/ecr/repository.go | 4 ++-- internal/service/ecr/sweep.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/ecr/repository.go b/internal/service/ecr/repository.go index e086dc17025..6a32373808e 100644 --- a/internal/service/ecr/repository.go +++ b/internal/service/ecr/repository.go @@ -71,7 +71,7 @@ func resourceRepository() *schema.Resource { DiffSuppressFunc: verify.SuppressMissingOptionalConfigurationBlock, ForceNew: true, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, }, @@ -246,7 +246,7 @@ func resourceRepositoryDelete(ctx context.Context, d *schema.ResourceData, meta log.Printf("[DEBUG] Deleting ECR Repository: %s", d.Id()) _, err := conn.DeleteRepository(ctx, &ecr.DeleteRepositoryInput{ - Force: d.Get("force_delete").(bool), + Force: d.Get(names.AttrForceDelete).(bool), RegistryId: aws.String(d.Get("registry_id").(string)), RepositoryName: aws.String(d.Id()), }) diff --git a/internal/service/ecr/sweep.go b/internal/service/ecr/sweep.go index 049a3fd37eb..bdfd7aec118 100644 --- a/internal/service/ecr/sweep.go +++ b/internal/service/ecr/sweep.go @@ -48,7 +48,7 @@ func sweepRepositories(region string) error { r := resourceRepository() d := r.Data(nil) d.SetId(aws.ToString(v.RepositoryName)) - d.Set("force_delete", true) + d.Set(names.AttrForceDelete, true) d.Set("registry_id", v.RegistryId) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) From e27e24445577569e0a7ff8c8b43c810693d63561 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:01 -0400 Subject: [PATCH 24/62] ecs: Use constants for strings --- internal/service/ecs/service.go | 10 +++++----- internal/service/ecs/service_test.go | 6 +++--- internal/service/ecs/task_execution_data_source.go | 4 ++-- internal/service/ecs/task_set.go | 10 +++++----- internal/service/ecs/task_set_test.go | 2 +- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/internal/service/ecs/service.go b/internal/service/ecs/service.go index cae9d6342d7..37d562f3a06 100644 --- a/internal/service/ecs/service.go +++ b/internal/service/ecs/service.go @@ -310,7 +310,7 @@ func ResourceService() *schema.Resource { Optional: true, Computed: true, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeString, Optional: true, DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { @@ -617,7 +617,7 @@ func resourceServiceCreate(ctx context.Context, d *schema.ResourceData, meta int input.PlatformVersion = aws.String(v.(string)) } - if v, ok := d.GetOk("propagate_tags"); ok { + if v, ok := d.GetOk(names.AttrPropagateTags); ok { input.PropagateTags = aws.String(v.(string)) } @@ -744,7 +744,7 @@ func resourceServiceRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("health_check_grace_period_seconds", service.HealthCheckGracePeriodSeconds) d.Set("launch_type", service.LaunchType) d.Set("enable_ecs_managed_tags", service.EnableECSManagedTags) - d.Set("propagate_tags", service.PropagateTags) + d.Set(names.AttrPropagateTags, service.PropagateTags) d.Set("platform_version", service.PlatformVersion) d.Set("enable_execute_command", service.EnableExecuteCommand) @@ -948,8 +948,8 @@ func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, meta int input.PlatformVersion = aws.String(d.Get("platform_version").(string)) } - if d.HasChange("propagate_tags") { - input.PropagateTags = aws.String(d.Get("propagate_tags").(string)) + if d.HasChange(names.AttrPropagateTags) { + input.PropagateTags = aws.String(d.Get(names.AttrPropagateTags).(string)) } if d.HasChange("service_connect_configuration") { diff --git a/internal/service/ecs/service_test.go b/internal/service/ecs/service_test.go index 000707eb596..305acf27c5b 100644 --- a/internal/service/ecs/service_test.go +++ b/internal/service/ecs/service_test.go @@ -1548,21 +1548,21 @@ func TestAccECSService_Tags_propagate(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckServiceExists(ctx, resourceName, &first), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtOne), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", ecs.PropagateTagsService), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, ecs.PropagateTagsService), ), }, { Config: testAccServiceConfig_propagateTags(rName, "TASK_DEFINITION"), Check: resource.ComposeTestCheckFunc( testAccCheckServiceExists(ctx, resourceName, &second), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", ecs.PropagateTagsTaskDefinition), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, ecs.PropagateTagsTaskDefinition), ), }, { Config: testAccServiceConfig_propagateTags(rName, "NONE"), Check: resource.ComposeTestCheckFunc( testAccCheckServiceExists(ctx, resourceName, &third), - resource.TestCheckResourceAttr(resourceName, "propagate_tags", ecs.PropagateTagsNone), + resource.TestCheckResourceAttr(resourceName, names.AttrPropagateTags, ecs.PropagateTagsNone), ), }, }, diff --git a/internal/service/ecs/task_execution_data_source.go b/internal/service/ecs/task_execution_data_source.go index 91b4585b8e7..315e108dccf 100644 --- a/internal/service/ecs/task_execution_data_source.go +++ b/internal/service/ecs/task_execution_data_source.go @@ -246,7 +246,7 @@ func DataSourceTaskExecution() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringInSlice(ecs.PropagateTags_Values(), false), @@ -340,7 +340,7 @@ func dataSourceTaskExecutionRead(ctx context.Context, d *schema.ResourceData, me if v, ok := d.GetOk("platform_version"); ok { input.PlatformVersion = aws.String(v.(string)) } - if v, ok := d.GetOk("propagate_tags"); ok { + if v, ok := d.GetOk(names.AttrPropagateTags); ok { input.PropagateTags = aws.String(v.(string)) } if v, ok := d.GetOk("reference_id"); ok { diff --git a/internal/service/ecs/task_set.go b/internal/service/ecs/task_set.go index 82fad0abcb0..9507a1f5339 100644 --- a/internal/service/ecs/task_set.go +++ b/internal/service/ecs/task_set.go @@ -76,13 +76,13 @@ func ResourceTaskSet() *schema.Resource { Required: true, ForceNew: true, }, - "external_id": { + names.AttrExternalID: { Type: schema.TypeString, Optional: true, ForceNew: true, Computed: true, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, }, @@ -289,7 +289,7 @@ func resourceTaskSetCreate(ctx context.Context, d *schema.ResourceData, meta int input.CapacityProviderStrategy = expandCapacityProviderStrategy(v.(*schema.Set)) } - if v, ok := d.GetOk("external_id"); ok { + if v, ok := d.GetOk(names.AttrExternalID); ok { input.ExternalId = aws.String(v.(string)) } @@ -410,7 +410,7 @@ func resourceTaskSetRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set("cluster", cluster) d.Set("launch_type", taskSet.LaunchType) d.Set("platform_version", taskSet.PlatformVersion) - d.Set("external_id", taskSet.ExternalId) + d.Set(names.AttrExternalID, taskSet.ExternalId) d.Set("service", service) d.Set(names.AttrStatus, taskSet.Status) d.Set("stability_status", taskSet.StabilityStatus) @@ -491,7 +491,7 @@ func resourceTaskSetDelete(ctx context.Context, d *schema.ResourceData, meta int Cluster: aws.String(cluster), Service: aws.String(service), TaskSet: aws.String(taskSetId), - Force: aws.Bool(d.Get("force_delete").(bool)), + Force: aws.Bool(d.Get(names.AttrForceDelete).(bool)), } _, err = conn.DeleteTaskSetWithContext(ctx, input) diff --git a/internal/service/ecs/task_set_test.go b/internal/service/ecs/task_set_test.go index 5f3f0ce145d..8d827b98b47 100644 --- a/internal/service/ecs/task_set_test.go +++ b/internal/service/ecs/task_set_test.go @@ -72,7 +72,7 @@ func TestAccECSTaskSet_withExternalId(t *testing.T) { testAccCheckTaskSetExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "service_registries.#", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "load_balancer.#", acctest.CtZero), - resource.TestCheckResourceAttr(resourceName, "external_id", "TEST_ID"), + resource.TestCheckResourceAttr(resourceName, names.AttrExternalID, "TEST_ID"), ), }, { From f6804e804f3fe2a0a459c8212fa9cc02867aee59 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:01 -0400 Subject: [PATCH 25/62] elasticbeanstalk: Use constants for strings --- internal/service/elasticbeanstalk/application.go | 6 +++--- .../service/elasticbeanstalk/application_data_source.go | 2 +- internal/service/elasticbeanstalk/application_version.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/elasticbeanstalk/application.go b/internal/service/elasticbeanstalk/application.go index 10b936d84b1..90147fcadf1 100644 --- a/internal/service/elasticbeanstalk/application.go +++ b/internal/service/elasticbeanstalk/application.go @@ -56,7 +56,7 @@ func ResourceApplication() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidARN, @@ -256,7 +256,7 @@ func expandApplicationResourceLifecycleConfig(tfMap map[string]interface{}) *aws }, } - if v, ok := tfMap["service_role"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrServiceRole].(string); ok && v != "" { apiObject.ServiceRole = aws.String(v) } @@ -313,7 +313,7 @@ func flattenApplicationResourceLifecycleConfig(apiObject *awstypes.ApplicationRe } if v := apiObject.ServiceRole; v != nil { - tfMap["service_role"] = aws.ToString(v) + tfMap[names.AttrServiceRole] = aws.ToString(v) } return []interface{}{tfMap} diff --git a/internal/service/elasticbeanstalk/application_data_source.go b/internal/service/elasticbeanstalk/application_data_source.go index a5d9086fdb0..ad9adb49a3d 100644 --- a/internal/service/elasticbeanstalk/application_data_source.go +++ b/internal/service/elasticbeanstalk/application_data_source.go @@ -36,7 +36,7 @@ func DataSourceApplication() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/elasticbeanstalk/application_version.go b/internal/service/elasticbeanstalk/application_version.go index db673be445c..2f6a393dc65 100644 --- a/internal/service/elasticbeanstalk/application_version.go +++ b/internal/service/elasticbeanstalk/application_version.go @@ -61,7 +61,7 @@ func ResourceApplicationVersion() *schema.Resource { Required: true, ForceNew: true, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, Default: false, @@ -155,7 +155,7 @@ func resourceApplicationVersionDelete(ctx context.Context, d *schema.ResourceDat application := d.Get("application").(string) name := d.Id() - if !d.Get("force_delete").(bool) { + if !d.Get(names.AttrForceDelete).(bool) { environments, err := versionUsedBy(ctx, application, name, conn) if err != nil { return sdkdiag.AppendErrorf(diags, "deleting Elastic Beanstalk Application Version (%s): %s", d.Id(), err) From c9f2c8341cd190ce7479671827767c1267d03a0d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:01 -0400 Subject: [PATCH 26/62] elbv2: Use constants for strings --- internal/service/elbv2/listener.go | 26 +++++++++---------- .../service/elbv2/listener_data_source.go | 8 +++--- internal/service/elbv2/listener_rule.go | 4 +-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index 5019b7ff218..069e8413d44 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -69,7 +69,7 @@ func ResourceListener() *schema.Resource { Optional: true, ValidateFunc: verify.ValidARN, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Required: true, Elem: &schema.Resource{ @@ -207,7 +207,7 @@ func ResourceListener() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(0, 1024), }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Optional: true, Computed: true, @@ -313,7 +313,7 @@ func ResourceListener() *schema.Resource { Default: "#{query}", ValidateFunc: validation.StringLenBetween(0, 128), }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[awstypes.RedirectActionStatusCodeEnum](), @@ -392,7 +392,7 @@ func ResourceListener() *schema.Resource { CustomizeDiff: customdiff.All( verify.SetTagsDiff, - validateListenerActionsCustomDiff("default_action"), + validateListenerActionsCustomDiff(names.AttrDefaultAction), ), } } @@ -432,8 +432,8 @@ func resourceListenerCreate(ctx context.Context, d *schema.ResourceData, meta in }} } - if v, ok := d.GetOk("default_action"); ok && len(v.([]interface{})) > 0 { - input.DefaultActions = expandLbListenerActions(cty.GetAttrPath("default_action"), v.([]any), &diags) + if v, ok := d.GetOk(names.AttrDefaultAction); ok && len(v.([]interface{})) > 0 { + input.DefaultActions = expandLbListenerActions(cty.GetAttrPath(names.AttrDefaultAction), v.([]any), &diags) if diags.HasError() { return diags } @@ -532,7 +532,7 @@ func resourceListenerRead(ctx context.Context, d *schema.ResourceData, meta inte sort.Slice(listener.DefaultActions, func(i, j int) bool { return aws.ToInt32(listener.DefaultActions[i].Order) < aws.ToInt32(listener.DefaultActions[j].Order) }) - if err := d.Set("default_action", flattenLbListenerActions(d, "default_action", listener.DefaultActions)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenLbListenerActions(d, names.AttrDefaultAction, listener.DefaultActions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set("load_balancer_arn", listener.LoadBalancerArn) @@ -565,8 +565,8 @@ func resourceListenerUpdate(ctx context.Context, d *schema.ResourceData, meta in }} } - if d.HasChange("default_action") { - input.DefaultActions = expandLbListenerActions(cty.GetAttrPath("default_action"), d.Get("default_action").([]any), &diags) + if d.HasChange(names.AttrDefaultAction) { + input.DefaultActions = expandLbListenerActions(cty.GetAttrPath(names.AttrDefaultAction), d.Get(names.AttrDefaultAction).([]any), &diags) if diags.HasError() { return diags } @@ -838,7 +838,7 @@ func expandLbListenerFixedResponseConfig(l []interface{}) *awstypes.FixedRespons return &awstypes.FixedResponseActionConfig{ ContentType: aws.String(tfMap[names.AttrContentType].(string)), MessageBody: aws.String(tfMap["message_body"].(string)), - StatusCode: aws.String(tfMap["status_code"].(string)), + StatusCode: aws.String(tfMap[names.AttrStatusCode].(string)), } } @@ -859,7 +859,7 @@ func expandLbListenerRedirectActionConfig(l []interface{}) *awstypes.RedirectAct Port: aws.String(tfMap[names.AttrPort].(string)), Protocol: aws.String(tfMap[names.AttrProtocol].(string)), Query: aws.String(tfMap["query"].(string)), - StatusCode: awstypes.RedirectActionStatusCodeEnum(tfMap["status_code"].(string)), + StatusCode: awstypes.RedirectActionStatusCodeEnum(tfMap[names.AttrStatusCode].(string)), } } @@ -1120,7 +1120,7 @@ func flattenLbListenerActionFixedResponseConfig(config *awstypes.FixedResponseAc m := map[string]interface{}{ names.AttrContentType: aws.ToString(config.ContentType), "message_body": aws.ToString(config.MessageBody), - "status_code": aws.ToString(config.StatusCode), + names.AttrStatusCode: aws.ToString(config.StatusCode), } return []interface{}{m} @@ -1182,7 +1182,7 @@ func flattenLbListenerActionRedirectConfig(config *awstypes.RedirectActionConfig names.AttrPort: aws.ToString(config.Port), names.AttrProtocol: aws.ToString(config.Protocol), "query": aws.ToString(config.Query), - "status_code": string(config.StatusCode), + names.AttrStatusCode: string(config.StatusCode), } return []interface{}{m} diff --git a/internal/service/elbv2/listener_data_source.go b/internal/service/elbv2/listener_data_source.go index dc40a39a448..20d1c424e13 100644 --- a/internal/service/elbv2/listener_data_source.go +++ b/internal/service/elbv2/listener_data_source.go @@ -48,7 +48,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -161,7 +161,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Computed: true, }, @@ -237,7 +237,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Computed: true, }, @@ -339,7 +339,7 @@ func dataSourceListenerRead(ctx context.Context, d *schema.ResourceData, meta in sort.Slice(listener.DefaultActions, func(i, j int) bool { return aws.ToInt32(listener.DefaultActions[i].Order) < aws.ToInt32(listener.DefaultActions[j].Order) }) - if err := d.Set("default_action", flattenLbListenerActions(d, "default_action", listener.DefaultActions)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenLbListenerActions(d, names.AttrDefaultAction, listener.DefaultActions)); err != nil { return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set("load_balancer_arn", listener.LoadBalancerArn) diff --git a/internal/service/elbv2/listener_rule.go b/internal/service/elbv2/listener_rule.go index 3fd0dcf1675..5e4b6c881eb 100644 --- a/internal/service/elbv2/listener_rule.go +++ b/internal/service/elbv2/listener_rule.go @@ -198,7 +198,7 @@ func ResourceListenerRule() *schema.Resource { ValidateFunc: validation.StringLenBetween(0, 128), }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Required: true, ValidateDiagFunc: enum.Validate[awstypes.RedirectActionStatusCodeEnum](), @@ -232,7 +232,7 @@ func ResourceListenerRule() *schema.Resource { ValidateFunc: validation.StringLenBetween(0, 1024), }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Optional: true, Computed: true, From 3a692630f212d422d472bf7c2b7d602734034491 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 27/62] emr: Use constants for strings --- internal/service/emr/cluster.go | 6 +++--- internal/service/emr/cluster_test.go | 2 +- internal/service/emr/studio.go | 6 +++--- internal/service/emr/studio_test.go | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/service/emr/cluster.go b/internal/service/emr/cluster.go index 4c831205b6e..4d817c3ca85 100644 --- a/internal/service/emr/cluster.go +++ b/internal/service/emr/cluster.go @@ -682,7 +682,7 @@ func resourceCluster() *schema.Resource { ForceNew: true, Optional: true, }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, ForceNew: true, Required: true, @@ -918,7 +918,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int Applications: emrApps, ReleaseLabel: aws.String(d.Get("release_label").(string)), - ServiceRole: aws.String(d.Get("service_role").(string)), + ServiceRole: aws.String(d.Get(names.AttrServiceRole).(string)), VisibleToAllUsers: aws.Bool(d.Get("visible_to_all_users").(bool)), Tags: getTagsIn(ctx), } @@ -1117,7 +1117,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrName, cluster.Name) - d.Set("service_role", cluster.ServiceRole) + d.Set(names.AttrServiceRole, cluster.ServiceRole) d.Set("security_configuration", cluster.SecurityConfiguration) d.Set("autoscaling_role", cluster.AutoScalingRole) d.Set("release_label", cluster.ReleaseLabel) diff --git a/internal/service/emr/cluster_test.go b/internal/service/emr/cluster_test.go index 790ffd01c56..81179cef9ba 100644 --- a/internal/service/emr/cluster_test.go +++ b/internal/service/emr/cluster_test.go @@ -57,7 +57,7 @@ func TestAccEMRCluster_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "ec2_attributes.0.instance_profile", "aws_iam_instance_profile.emr_instance_profile", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "scale_down_behavior", "TERMINATE_AT_TASK_COMPLETION"), resource.TestCheckResourceAttr(resourceName, "ebs_root_volume_size", "21"), - resource.TestCheckResourceAttrPair(resourceName, "service_role", "aws_iam_role.emr_service", names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, "aws_iam_role.emr_service", names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "autoscaling_role", "aws_iam_role.emr_autoscaling_role", names.AttrARN), resource.TestCheckNoResourceAttr(resourceName, "additional_info"), resource.TestCheckResourceAttr(resourceName, "bootstrap_action.#", acctest.CtZero), diff --git a/internal/service/emr/studio.go b/internal/service/emr/studio.go index 0cf93b0680a..13639db44e2 100644 --- a/internal/service/emr/studio.go +++ b/internal/service/emr/studio.go @@ -78,7 +78,7 @@ func resourceStudio() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 256), }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -126,7 +126,7 @@ func resourceStudioCreate(ctx context.Context, d *schema.ResourceData, meta inte DefaultS3Location: aws.String(d.Get("default_s3_location").(string)), EngineSecurityGroupId: aws.String(d.Get("engine_security_group_id").(string)), Name: aws.String(d.Get(names.AttrName).(string)), - ServiceRole: aws.String(d.Get("service_role").(string)), + ServiceRole: aws.String(d.Get(names.AttrServiceRole).(string)), SubnetIds: flex.ExpandStringSet(d.Get(names.AttrSubnetIDs).(*schema.Set)), Tags: getTagsIn(ctx), VpcId: aws.String(d.Get(names.AttrVPCID).(string)), @@ -235,7 +235,7 @@ func resourceStudioRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("idp_auth_url", studio.IdpAuthUrl) d.Set("idp_relay_state_parameter_name", studio.IdpRelayStateParameterName) d.Set(names.AttrName, studio.Name) - d.Set("service_role", studio.ServiceRole) + d.Set(names.AttrServiceRole, studio.ServiceRole) d.Set(names.AttrURL, studio.Url) d.Set("user_role", studio.UserRole) d.Set(names.AttrVPCID, studio.VpcId) diff --git a/internal/service/emr/studio_test.go b/internal/service/emr/studio_test.go index 33090217ca9..c504fc12420 100644 --- a/internal/service/emr/studio_test.go +++ b/internal/service/emr/studio_test.go @@ -45,7 +45,7 @@ func TestAccEMRStudio_sso(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "workspace_security_group_id", "aws_security_group.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "engine_security_group_id", "aws_security_group.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "user_role", "aws_iam_role.test", names.AttrARN), - resource.TestCheckResourceAttrPair(resourceName, "service_role", "aws_iam_role.test", names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, "aws_iam_role.test", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), @@ -67,7 +67,7 @@ func TestAccEMRStudio_sso(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "workspace_security_group_id", "aws_security_group.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "engine_security_group_id", "aws_security_group.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "user_role", "aws_iam_role.test", names.AttrARN), - resource.TestCheckResourceAttrPair(resourceName, "service_role", "aws_iam_role.test", names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, "aws_iam_role.test", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), @@ -98,7 +98,7 @@ func TestAccEMRStudio_iam(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, names.AttrVPCID, "aws_vpc.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "workspace_security_group_id", "aws_security_group.test", names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "engine_security_group_id", "aws_security_group.test", names.AttrID), - resource.TestCheckResourceAttrPair(resourceName, "service_role", "aws_iam_role.test", names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrServiceRole, "aws_iam_role.test", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "subnet_ids.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), From a58fa75d226b866fc0ef9a70254ebb604af5ef62 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 28/62] events: Use constants for strings --- internal/service/events/target.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/events/target.go b/internal/service/events/target.go index 1650525b2a9..674019b22d9 100644 --- a/internal/service/events/target.go +++ b/internal/service/events/target.go @@ -228,7 +228,7 @@ func resourceTarget() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(0, 1600), }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeString, Optional: true, ValidateDiagFunc: enum.Validate[types.PropagateTags](), @@ -963,7 +963,7 @@ func expandTargetECSParameters(ctx context.Context, tfList []interface{}) *types ecsParameters.PlacementStrategy = expandTargetPlacementStrategies(v.([]interface{})) } - if v, ok := tfMap["propagate_tags"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrPropagateTags].(string); ok && v != "" { ecsParameters.PropagateTags = types.PropagateTags(v) } @@ -1188,7 +1188,7 @@ func flattenTargetECSParameters(ctx context.Context, ecsParameters *types.EcsPar config["platform_version"] = aws.ToString(ecsParameters.PlatformVersion) } - config["propagate_tags"] = ecsParameters.PropagateTags + config[names.AttrPropagateTags] = ecsParameters.PropagateTags if ecsParameters.PlacementConstraints != nil { config["placement_constraint"] = flattenTargetPlacementConstraints(ecsParameters.PlacementConstraints) From b295a2974caadbaef3babe0409440bfe3b17290f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 29/62] evidently: Use constants for strings --- internal/service/evidently/launch.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/evidently/launch.go b/internal/service/evidently/launch.go index 559ae83b848..f9dd456ece7 100644 --- a/internal/service/evidently/launch.go +++ b/internal/service/evidently/launch.go @@ -283,7 +283,7 @@ func ResourceLaunch() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -392,7 +392,7 @@ func resourceLaunchRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set("project", launch.Project) d.Set("randomization_salt", launch.RandomizationSalt) d.Set(names.AttrStatus, launch.Status) - d.Set("status_reason", launch.StatusReason) + d.Set(names.AttrStatusReason, launch.StatusReason) d.Set(names.AttrType, launch.Type) setTagsOut(ctx, launch.Tags) From 163886a3d0acefa787f2ba2ed74d3e3cd02273e0 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 30/62] finspace: Use constants for strings --- internal/service/finspace/kx_cluster.go | 4 ++-- internal/service/finspace/kx_scaling_group.go | 4 ++-- internal/service/finspace/kx_volume.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/finspace/kx_cluster.go b/internal/service/finspace/kx_cluster.go index 294e68500aa..633be8dc95b 100644 --- a/internal/service/finspace/kx_cluster.go +++ b/internal/service/finspace/kx_cluster.go @@ -306,7 +306,7 @@ func ResourceKxCluster() *schema.Resource { }, }, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -542,7 +542,7 @@ func resourceKxClusterRead(ctx context.Context, d *schema.ResourceData, meta int } d.Set(names.AttrStatus, out.Status) - d.Set("status_reason", out.StatusReason) + d.Set(names.AttrStatusReason, out.StatusReason) d.Set("created_timestamp", out.CreatedTimestamp.String()) d.Set("last_modified_timestamp", out.LastModifiedTimestamp.String()) d.Set(names.AttrName, out.ClusterName) diff --git a/internal/service/finspace/kx_scaling_group.go b/internal/service/finspace/kx_scaling_group.go index 0c761132e4f..4641d2eb62a 100644 --- a/internal/service/finspace/kx_scaling_group.go +++ b/internal/service/finspace/kx_scaling_group.go @@ -92,7 +92,7 @@ func ResourceKxScalingGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -164,7 +164,7 @@ func resourceKxScalingGroupRead(ctx context.Context, d *schema.ResourceData, met } d.Set(names.AttrARN, out.ScalingGroupArn) d.Set(names.AttrStatus, out.Status) - d.Set("status_reason", out.StatusReason) + d.Set(names.AttrStatusReason, out.StatusReason) d.Set("created_timestamp", out.CreatedTimestamp.String()) d.Set("last_modified_timestamp", out.LastModifiedTimestamp.String()) d.Set(names.AttrName, out.ScalingGroupName) diff --git a/internal/service/finspace/kx_volume.go b/internal/service/finspace/kx_volume.go index 3d44a8ca6b8..8408cd7da6d 100644 --- a/internal/service/finspace/kx_volume.go +++ b/internal/service/finspace/kx_volume.go @@ -141,7 +141,7 @@ func ResourceKxVolume() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -240,7 +240,7 @@ func resourceKxVolumeRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set(names.AttrDescription, out.Description) d.Set(names.AttrType, out.VolumeType) d.Set(names.AttrStatus, out.Status) - d.Set("status_reason", out.StatusReason) + d.Set(names.AttrStatusReason, out.StatusReason) d.Set("az_mode", out.AzMode) d.Set(names.AttrDescription, out.Description) d.Set("created_timestamp", out.CreatedTimestamp.String()) From c5ea0483a87d6abe3a01fac395f79a7d1018e529 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 31/62] fsx: Use constants for strings --- internal/service/fsx/openzfs_snapshot_data_source.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/fsx/openzfs_snapshot_data_source.go b/internal/service/fsx/openzfs_snapshot_data_source.go index 2b6af22364c..84dc0da1f7b 100644 --- a/internal/service/fsx/openzfs_snapshot_data_source.go +++ b/internal/service/fsx/openzfs_snapshot_data_source.go @@ -45,7 +45,7 @@ func dataSourceOpenzfsSnapshot() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, @@ -107,7 +107,7 @@ func dataSourceOpenZFSSnapshotRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrARN, snapshot.ResourceARN) d.Set(names.AttrCreationTime, snapshot.CreationTime.Format(time.RFC3339)) d.Set(names.AttrName, snapshot.Name) - d.Set("snapshot_id", snapshot.SnapshotId) + d.Set(names.AttrSnapshotID, snapshot.SnapshotId) d.Set("volume_id", snapshot.VolumeId) setTagsOut(ctx, snapshot.Tags) From ed7e9cda08b305bb4036fb9d8b3de6950741b108 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:02 -0400 Subject: [PATCH 32/62] glue: Use constants for strings --- internal/service/glue/job.go | 12 ++++++------ internal/service/glue/job_test.go | 6 +++--- internal/service/glue/ml_transform.go | 14 +++++++------- internal/service/glue/ml_transform_test.go | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/service/glue/job.go b/internal/service/glue/job.go index 84959214878..b197c026e37 100644 --- a/internal/service/glue/job.go +++ b/internal/service/glue/job.go @@ -113,7 +113,7 @@ func ResourceJob() *schema.Resource { Optional: true, Computed: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeFloat, Optional: true, Computed: true, @@ -154,7 +154,7 @@ func ResourceJob() *schema.Resource { Type: schema.TypeInt, Optional: true, Computed: true, - ConflictsWith: []string{"max_capacity"}, + ConflictsWith: []string{names.AttrMaxCapacity}, ValidateFunc: validation.IntAtLeast(1), }, names.AttrRoleARN: { @@ -178,7 +178,7 @@ func ResourceJob() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - ConflictsWith: []string{"max_capacity"}, + ConflictsWith: []string{names.AttrMaxCapacity}, ValidateFunc: validation.StringInSlice(glue.WorkerType_Values(), false), }, }, @@ -223,7 +223,7 @@ func resourceJobCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.GlueVersion = aws.String(v.(string)) } - if v, ok := d.GetOk("max_capacity"); ok { + if v, ok := d.GetOk(names.AttrMaxCapacity); ok { input.MaxCapacity = aws.Float64(v.(float64)) } @@ -303,7 +303,7 @@ func resourceJobRead(ctx context.Context, d *schema.ResourceData, meta interface return sdkdiag.AppendErrorf(diags, "setting execution_property: %s", err) } d.Set("glue_version", job.GlueVersion) - d.Set("max_capacity", job.MaxCapacity) + d.Set(names.AttrMaxCapacity, job.MaxCapacity) d.Set("max_retries", job.MaxRetries) d.Set(names.AttrName, job.Name) d.Set("non_overridable_arguments", aws.StringValueMap(job.NonOverridableArguments)) @@ -370,7 +370,7 @@ func resourceJobUpdate(ctx context.Context, d *schema.ResourceData, meta interfa if v, ok := d.GetOk("number_of_workers"); ok { jobUpdate.NumberOfWorkers = aws.Int64(int64(v.(int))) } else { - if v, ok := d.GetOk("max_capacity"); ok { + if v, ok := d.GetOk(names.AttrMaxCapacity); ok { jobUpdate.MaxCapacity = aws.Float64(v.(float64)) } } diff --git a/internal/service/glue/job_test.go b/internal/service/glue/job_test.go index dd9983faa80..e64ca84dd58 100644 --- a/internal/service/glue/job_test.go +++ b/internal/service/glue/job_test.go @@ -691,7 +691,7 @@ func TestAccGlueJob_pythonShell(t *testing.T) { Config: testAccJobConfig_pythonShell(rName), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "0.0625"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "0.0625"), resource.TestCheckResourceAttr(resourceName, "command.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "command.0.script_location", "testscriptlocation"), resource.TestCheckResourceAttr(resourceName, "command.0.name", "pythonshell"), @@ -785,7 +785,7 @@ func TestAccGlueJob_maxCapacity(t *testing.T) { Config: testAccJobConfig_maxCapacity(rName, 10), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "10"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "10"), resource.TestCheckResourceAttr(resourceName, "command.#", acctest.CtOne), resource.TestCheckResourceAttr(resourceName, "command.0.script_location", "testscriptlocation"), resource.TestCheckResourceAttr(resourceName, "command.0.name", "glueetl"), @@ -795,7 +795,7 @@ func TestAccGlueJob_maxCapacity(t *testing.T) { Config: testAccJobConfig_maxCapacity(rName, 15), Check: resource.ComposeTestCheckFunc( testAccCheckJobExists(ctx, resourceName, &job), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "15"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "15"), ), }, { diff --git a/internal/service/glue/ml_transform.go b/internal/service/glue/ml_transform.go index 88d2b6bf32d..5ca13450554 100644 --- a/internal/service/glue/ml_transform.go +++ b/internal/service/glue/ml_transform.go @@ -116,7 +116,7 @@ func ResourceMLTransform() *schema.Resource { Optional: true, Computed: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeFloat, Optional: true, Computed: true, @@ -149,14 +149,14 @@ func ResourceMLTransform() *schema.Resource { "worker_type": { Type: schema.TypeString, Optional: true, - ConflictsWith: []string{"max_capacity"}, + ConflictsWith: []string{names.AttrMaxCapacity}, ValidateFunc: validation.StringInSlice(glue.WorkerType_Values(), false), RequiredWith: []string{"number_of_workers"}, }, "number_of_workers": { Type: schema.TypeInt, Optional: true, - ConflictsWith: []string{"max_capacity"}, + ConflictsWith: []string{names.AttrMaxCapacity}, ValidateFunc: validation.IntAtLeast(1), RequiredWith: []string{"worker_type"}, }, @@ -197,7 +197,7 @@ func resourceMLTransformCreate(ctx context.Context, d *schema.ResourceData, meta Parameters: expandMLTransformParameters(d.Get(names.AttrParameters).([]interface{})), } - if v, ok := d.GetOk("max_capacity"); ok { + if v, ok := d.GetOk(names.AttrMaxCapacity); ok { input.MaxCapacity = aws.Float64(v.(float64)) } @@ -270,7 +270,7 @@ func resourceMLTransformRead(ctx context.Context, d *schema.ResourceData, meta i d.Set(names.AttrDescription, output.Description) d.Set("glue_version", output.GlueVersion) - d.Set("max_capacity", output.MaxCapacity) + d.Set(names.AttrMaxCapacity, output.MaxCapacity) d.Set("max_retries", output.MaxRetries) d.Set(names.AttrName, output.Name) d.Set(names.AttrRoleARN, output.Role) @@ -298,7 +298,7 @@ func resourceMLTransformUpdate(ctx context.Context, d *schema.ResourceData, meta var diags diag.Diagnostics conn := meta.(*conns.AWSClient).GlueConn(ctx) - if d.HasChanges(names.AttrDescription, "glue_version", "max_capacity", "max_retries", "number_of_workers", + if d.HasChanges(names.AttrDescription, "glue_version", names.AttrMaxCapacity, "max_retries", "number_of_workers", names.AttrRoleARN, names.AttrTimeout, "worker_type", names.AttrParameters) { input := &glue.UpdateMLTransformInput{ TransformId: aws.String(d.Id()), @@ -321,7 +321,7 @@ func resourceMLTransformUpdate(ctx context.Context, d *schema.ResourceData, meta if v, ok := d.GetOk("number_of_workers"); ok { input.NumberOfWorkers = aws.Int64(int64(v.(int))) } else { - if v, ok := d.GetOk("max_capacity"); ok { + if v, ok := d.GetOk(names.AttrMaxCapacity); ok { input.MaxCapacity = aws.Float64(v.(float64)) } } diff --git a/internal/service/glue/ml_transform_test.go b/internal/service/glue/ml_transform_test.go index 935fcd66104..f6c83e6c9db 100644 --- a/internal/service/glue/ml_transform_test.go +++ b/internal/service/glue/ml_transform_test.go @@ -383,14 +383,14 @@ func TestAccGlueMlTransform_maxCapacity(t *testing.T) { Config: testAccMLTransformConfig_maxCapacity(rName, 10), Check: resource.ComposeTestCheckFunc( testAccCheckMLTransformExists(ctx, resourceName, &transform), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "10"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "10"), ), }, { Config: testAccMLTransformConfig_maxCapacity(rName, 15), Check: resource.ComposeTestCheckFunc( testAccCheckMLTransformExists(ctx, resourceName, &transform), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "15"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "15"), ), }, { From 7a7f669a3887943e19a2f29d8727c2559847de23 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:03 -0400 Subject: [PATCH 33/62] identitystore: Use constants for strings --- internal/service/identitystore/flex.go | 2 +- internal/service/identitystore/group_data_source.go | 2 +- internal/service/identitystore/user_data_source.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/identitystore/flex.go b/internal/service/identitystore/flex.go index bdc3c534eec..974cf225e6b 100644 --- a/internal/service/identitystore/flex.go +++ b/internal/service/identitystore/flex.go @@ -132,7 +132,7 @@ func expandAlternateIdentifier(tfMap map[string]interface{}) types.AlternateIden return nil } - if v, ok := tfMap["external_id"]; ok && len(v.([]interface{})) > 0 { + if v, ok := tfMap[names.AttrExternalID]; ok && len(v.([]interface{})) > 0 { return &types.AlternateIdentifierMemberExternalId{ Value: *expandExternalId(v.([]interface{})[0].(map[string]interface{})), } diff --git a/internal/service/identitystore/group_data_source.go b/internal/service/identitystore/group_data_source.go index 559f88ea204..4ef3e5c1369 100644 --- a/internal/service/identitystore/group_data_source.go +++ b/internal/service/identitystore/group_data_source.go @@ -32,7 +32,7 @@ func DataSourceGroup() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "external_id": { + names.AttrExternalID: { Type: schema.TypeList, Optional: true, MaxItems: 1, diff --git a/internal/service/identitystore/user_data_source.go b/internal/service/identitystore/user_data_source.go index 1f1e89b0c61..c5790eeed9c 100644 --- a/internal/service/identitystore/user_data_source.go +++ b/internal/service/identitystore/user_data_source.go @@ -73,7 +73,7 @@ func DataSourceUser() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "external_id": { + names.AttrExternalID: { Type: schema.TypeList, Optional: true, MaxItems: 1, From 56d24cdae70c08b4c5889c9701aefdee1e428fb4 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:03 -0400 Subject: [PATCH 34/62] imagebuilder: Use constants for strings --- internal/service/imagebuilder/container_recipe.go | 2 +- .../service/imagebuilder/container_recipe_data_source.go | 2 +- internal/service/imagebuilder/image_recipe.go | 6 +++--- internal/service/imagebuilder/image_recipe_data_source.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/service/imagebuilder/container_recipe.go b/internal/service/imagebuilder/container_recipe.go index f9f84f4dba1..3d7fc461ab6 100644 --- a/internal/service/imagebuilder/container_recipe.go +++ b/internal/service/imagebuilder/container_recipe.go @@ -160,7 +160,7 @@ func ResourceContainerRecipe() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 1024), }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, ForceNew: true, diff --git a/internal/service/imagebuilder/container_recipe_data_source.go b/internal/service/imagebuilder/container_recipe_data_source.go index 4f669ae25b2..c6f4b8043b8 100644 --- a/internal/service/imagebuilder/container_recipe_data_source.go +++ b/internal/service/imagebuilder/container_recipe_data_source.go @@ -110,7 +110,7 @@ func DataSourceContainerRecipe() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/imagebuilder/image_recipe.go b/internal/service/imagebuilder/image_recipe.go index e1f442cec4f..afa83c15a14 100644 --- a/internal/service/imagebuilder/image_recipe.go +++ b/internal/service/imagebuilder/image_recipe.go @@ -85,7 +85,7 @@ func ResourceImageRecipe() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 1024), }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -495,7 +495,7 @@ func expandEBSInstanceBlockDeviceSpecification(tfMap map[string]interface{}) *im apiObject.KmsKeyId = aws.String(v) } - if v, ok := tfMap["snapshot_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrSnapshotID].(string); ok && v != "" { apiObject.SnapshotId = aws.String(v) } @@ -678,7 +678,7 @@ func flattenEBSInstanceBlockDeviceSpecification(apiObject *imagebuilder.EbsInsta } if v := apiObject.SnapshotId; v != nil { - tfMap["snapshot_id"] = aws.StringValue(v) + tfMap[names.AttrSnapshotID] = aws.StringValue(v) } if v := apiObject.Throughput; v != nil { diff --git a/internal/service/imagebuilder/image_recipe_data_source.go b/internal/service/imagebuilder/image_recipe_data_source.go index 40e9c1110ba..bfa025193ea 100644 --- a/internal/service/imagebuilder/image_recipe_data_source.go +++ b/internal/service/imagebuilder/image_recipe_data_source.go @@ -58,7 +58,7 @@ func DataSourceImageRecipe() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Computed: true, }, From 10ea4a4df63431521787e2bff60436ab1981f293 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:03 -0400 Subject: [PATCH 35/62] kendra: Use constants for strings --- internal/service/kendra/data_source.go | 12 ++++++------ internal/service/kendra/data_source_test.go | 10 +++++----- internal/service/kendra/faq.go | 6 +++--- internal/service/kendra/faq_data_source.go | 4 ++-- internal/service/kendra/faq_data_source_test.go | 2 +- internal/service/kendra/faq_test.go | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/internal/service/kendra/data_source.go b/internal/service/kendra/data_source.go index 260f208b10c..ad5bcf49237 100644 --- a/internal/service/kendra/data_source.go +++ b/internal/service/kendra/data_source.go @@ -428,7 +428,7 @@ func ResourceDataSource() *schema.Resource { "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Optional: true, Computed: true, @@ -617,7 +617,7 @@ func resourceDataSourceCreate(ctx context.Context, d *schema.ResourceData, meta input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("language_code"); ok { + if v, ok := d.GetOk(names.AttrLanguageCode); ok { input.LanguageCode = aws.String(v.(string)) } @@ -702,7 +702,7 @@ func resourceDataSourceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrDescription, resp.Description) d.Set("error_message", resp.ErrorMessage) d.Set("index_id", resp.IndexId) - d.Set("language_code", resp.LanguageCode) + d.Set(names.AttrLanguageCode, resp.LanguageCode) d.Set(names.AttrName, resp.Name) d.Set(names.AttrRoleARN, resp.RoleArn) d.Set(names.AttrSchedule, resp.Schedule) @@ -726,7 +726,7 @@ func resourceDataSourceUpdate(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).KendraClient(ctx) - if d.HasChanges(names.AttrConfiguration, "custom_document_enrichment_configuration", names.AttrDescription, "language_code", names.AttrName, names.AttrRoleARN, names.AttrSchedule) { + if d.HasChanges(names.AttrConfiguration, "custom_document_enrichment_configuration", names.AttrDescription, names.AttrLanguageCode, names.AttrName, names.AttrRoleARN, names.AttrSchedule) { id, indexId, err := DataSourceParseResourceID(d.Id()) if err != nil { return sdkdiag.AppendFromErr(diags, err) @@ -749,8 +749,8 @@ func resourceDataSourceUpdate(ctx context.Context, d *schema.ResourceData, meta input.Description = aws.String(d.Get(names.AttrDescription).(string)) } - if d.HasChange("language_code") { - input.LanguageCode = aws.String(d.Get("language_code").(string)) + if d.HasChange(names.AttrLanguageCode) { + input.LanguageCode = aws.String(d.Get(names.AttrLanguageCode).(string)) } if d.HasChange(names.AttrName) { diff --git a/internal/service/kendra/data_source_test.go b/internal/service/kendra/data_source_test.go index 65ee90e7faf..32a9a85f328 100644 --- a/internal/service/kendra/data_source_test.go +++ b/internal/service/kendra/data_source_test.go @@ -46,7 +46,7 @@ func TestAccKendraDataSource_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "kendra", regexache.MustCompile(`index/.+/data-source/.+$`)), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt), resource.TestCheckResourceAttrPair(resourceName, "index_id", "aws_kendra_index.test", names.AttrID), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName4), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(types.DataSourceStatusActive)), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(types.DataSourceTypeCustom)), @@ -162,7 +162,7 @@ func TestAccKendraDataSource_description(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, originalDescription), resource.TestCheckResourceAttrPair(resourceName, "index_id", "aws_kendra_index.test", names.AttrID), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName4), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(types.DataSourceStatusActive)), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(types.DataSourceTypeCustom)), @@ -182,7 +182,7 @@ func TestAccKendraDataSource_description(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, updatedDescription), resource.TestCheckResourceAttrPair(resourceName, "index_id", "aws_kendra_index.test", names.AttrID), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName4), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, string(types.DataSourceStatusActive)), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(types.DataSourceTypeCustom)), @@ -217,7 +217,7 @@ func TestAccKendraDataSource_languageCode(t *testing.T) { Config: testAccDataSourceConfig_languageCode(rName, rName2, rName3, rName4, originalLanguageCode), Check: resource.ComposeTestCheckFunc( testAccCheckDataSourceExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "language_code", originalLanguageCode), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, originalLanguageCode), ), }, { @@ -229,7 +229,7 @@ func TestAccKendraDataSource_languageCode(t *testing.T) { Config: testAccDataSourceConfig_languageCode(rName, rName2, rName3, rName4, updatedLanguageCode), Check: resource.ComposeTestCheckFunc( testAccCheckDataSourceExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "language_code", updatedLanguageCode), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, updatedLanguageCode), ), }, }, diff --git a/internal/service/kendra/faq.go b/internal/service/kendra/faq.go index a8eb2fb7f4b..7a17dc4ae5b 100644 --- a/internal/service/kendra/faq.go +++ b/internal/service/kendra/faq.go @@ -84,7 +84,7 @@ func ResourceFaq() *schema.Resource { "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Optional: true, Computed: true, @@ -172,7 +172,7 @@ func resourceFaqCreate(ctx context.Context, d *schema.ResourceData, meta interfa input.FileFormat = types.FaqFileFormat(v.(string)) } - if v, ok := d.GetOk("language_code"); ok { + if v, ok := d.GetOk(names.AttrLanguageCode); ok { input.LanguageCode = aws.String(v.(string)) } @@ -250,7 +250,7 @@ func resourceFaqRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("faq_id", resp.Id) d.Set("file_format", resp.FileFormat) d.Set("index_id", resp.IndexId) - d.Set("language_code", resp.LanguageCode) + d.Set(names.AttrLanguageCode, resp.LanguageCode) d.Set(names.AttrName, resp.Name) d.Set(names.AttrRoleARN, resp.RoleArn) d.Set(names.AttrStatus, resp.Status) diff --git a/internal/service/kendra/faq_data_source.go b/internal/service/kendra/faq_data_source.go index bf7fb4e6ff3..7c8174f9f2c 100644 --- a/internal/service/kendra/faq_data_source.go +++ b/internal/service/kendra/faq_data_source.go @@ -64,7 +64,7 @@ func DataSourceFaq() *schema.Resource { "Starts with an alphanumeric character. Subsequently, can contain alphanumeric characters and hyphens. Fixed length of 36.", ), }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Computed: true, }, @@ -139,7 +139,7 @@ func dataSourceFaqRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("faq_id", resp.Id) d.Set("file_format", resp.FileFormat) d.Set("index_id", resp.IndexId) - d.Set("language_code", resp.LanguageCode) + d.Set(names.AttrLanguageCode, resp.LanguageCode) d.Set(names.AttrName, resp.Name) d.Set(names.AttrRoleARN, resp.RoleArn) d.Set(names.AttrStatus, resp.Status) diff --git a/internal/service/kendra/faq_data_source_test.go b/internal/service/kendra/faq_data_source_test.go index 3bdb7fbe7fc..dcdb6a89a7a 100644 --- a/internal/service/kendra/faq_data_source_test.go +++ b/internal/service/kendra/faq_data_source_test.go @@ -43,7 +43,7 @@ func TestAccKendraFaqDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(datasourceName, "file_format", resourceName, "file_format"), resource.TestCheckResourceAttrPair(datasourceName, "index_id", resourceName, "index_id"), resource.TestCheckResourceAttrPair(datasourceName, names.AttrID, resourceName, names.AttrID), - resource.TestCheckResourceAttrPair(datasourceName, "language_code", resourceName, "language_code"), + resource.TestCheckResourceAttrPair(datasourceName, names.AttrLanguageCode, resourceName, names.AttrLanguageCode), resource.TestCheckResourceAttrPair(datasourceName, names.AttrName, resourceName, names.AttrName), resource.TestCheckResourceAttrPair(datasourceName, names.AttrRoleARN, resourceName, names.AttrRoleARN), resource.TestCheckResourceAttrPair(datasourceName, "s3_path.#", resourceName, "s3_path.#"), diff --git a/internal/service/kendra/faq_test.go b/internal/service/kendra/faq_test.go index 3f046e99147..f56fa304430 100644 --- a/internal/service/kendra/faq_test.go +++ b/internal/service/kendra/faq_test.go @@ -47,7 +47,7 @@ func TestAccKendraFaq_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedAt), resource.TestCheckResourceAttrSet(resourceName, "faq_id"), resource.TestCheckResourceAttrPair(resourceName, "index_id", "aws_kendra_index.test", names.AttrID), - resource.TestCheckResourceAttr(resourceName, "language_code", "en"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName5), resource.TestCheckResourceAttrPair(resourceName, names.AttrRoleARN, "aws_iam_role.test_faq", names.AttrARN), resource.TestCheckResourceAttr(resourceName, "s3_path.#", acctest.CtOne), @@ -162,7 +162,7 @@ func TestAccKendraFaq_languageCode(t *testing.T) { Config: testAccFaqConfig_languageCode(rName, rName2, rName3, rName4, rName5, languageCode), Check: resource.ComposeTestCheckFunc( testAccCheckFaqExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "language_code", languageCode), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, languageCode), ), }, { From 73ea6f31b49ccac8dd5798bf99f2bb0d0e978c62 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:03 -0400 Subject: [PATCH 36/62] lightsail: Use constants for strings --- internal/service/lightsail/bucket.go | 4 ++-- internal/service/lightsail/bucket_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/lightsail/bucket.go b/internal/service/lightsail/bucket.go index 9b1f71ebfaf..1ab9b4bf4e2 100644 --- a/internal/service/lightsail/bucket.go +++ b/internal/service/lightsail/bucket.go @@ -53,7 +53,7 @@ func ResourceBucket() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, Default: false, @@ -177,7 +177,7 @@ func resourceBucketDelete(ctx context.Context, d *schema.ResourceData, meta inte log.Printf("[DEBUG] Deleting Lightsail Bucket: %s", d.Id()) out, err := conn.DeleteBucket(ctx, &lightsail.DeleteBucketInput{ BucketName: aws.String(d.Id()), - ForceDelete: aws.Bool(d.Get("force_delete").(bool)), + ForceDelete: aws.Bool(d.Get(names.AttrForceDelete).(bool)), }) if err != nil && errs.IsA[*types.NotFoundException](err) { diff --git a/internal/service/lightsail/bucket_test.go b/internal/service/lightsail/bucket_test.go index 1927137ee7b..4eac7e95468 100644 --- a/internal/service/lightsail/bucket_test.go +++ b/internal/service/lightsail/bucket_test.go @@ -51,8 +51,8 @@ func TestAccLightsailBucket_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "support_code"), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttrSet(resourceName, names.AttrURL), - resource.TestCheckResourceAttrSet(resourceName, "force_delete"), - resource.TestCheckResourceAttr(resourceName, "force_delete", "false"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrForceDelete), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "false"), ), }, { @@ -60,7 +60,7 @@ func TestAccLightsailBucket_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "force_delete", + names.AttrForceDelete, }, }, }, @@ -96,7 +96,7 @@ func TestAccLightsailBucket_BundleId(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "force_delete", + names.AttrForceDelete, }, }, { @@ -165,7 +165,7 @@ func TestAccLightsailBucket_tags(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "force_delete", + names.AttrForceDelete, }, }, { @@ -261,7 +261,7 @@ func TestAccLightsailBucket_forceDelete(t *testing.T) { Config: testAccBucketConfig_forceDelete(rName), Check: resource.ComposeTestCheckFunc( testAccCheckBucketExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "force_delete", "true"), + resource.TestCheckResourceAttr(resourceName, names.AttrForceDelete, "true"), ), }, { @@ -269,7 +269,7 @@ func TestAccLightsailBucket_forceDelete(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateVerifyIgnore: []string{ - "force_delete", + names.AttrForceDelete, }, }, }, From 019ae7926eb43722f42b1b1b859c1bec525354f3 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:03 -0400 Subject: [PATCH 37/62] macie2: Use constants for strings --- internal/service/macie2/account.go | 4 ++-- internal/service/macie2/account_test.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/macie2/account.go b/internal/service/macie2/account.go index 5013e0c1fc1..30cd3cbca81 100644 --- a/internal/service/macie2/account.go +++ b/internal/service/macie2/account.go @@ -46,7 +46,7 @@ func ResourceAccount() *schema.Resource { Computed: true, ValidateFunc: validation.StringInSlice(macie2.MacieStatus_Values(), false), }, - "service_role": { + names.AttrServiceRole: { Type: schema.TypeString, Computed: true, }, @@ -126,7 +126,7 @@ func resourceAccountRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrStatus, resp.Status) d.Set("finding_publishing_frequency", resp.FindingPublishingFrequency) - d.Set("service_role", resp.ServiceRole) + d.Set(names.AttrServiceRole, resp.ServiceRole) d.Set(names.AttrCreatedAt, aws.TimeValue(resp.CreatedAt).Format(time.RFC3339)) d.Set("updated_at", aws.TimeValue(resp.UpdatedAt).Format(time.RFC3339)) diff --git a/internal/service/macie2/account_test.go b/internal/service/macie2/account_test.go index c9d8cdffdb0..b3f85ef113c 100644 --- a/internal/service/macie2/account_test.go +++ b/internal/service/macie2/account_test.go @@ -35,7 +35,7 @@ func testAccAccount_basic(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyFifteenMinutes), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusEnabled), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -66,7 +66,7 @@ func testAccAccount_FindingPublishingFrequency(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyFifteenMinutes), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusEnabled), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -77,7 +77,7 @@ func testAccAccount_FindingPublishingFrequency(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyOneHour), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusEnabled), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -108,7 +108,7 @@ func testAccAccount_WithStatus(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyFifteenMinutes), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusEnabled), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -119,7 +119,7 @@ func testAccAccount_WithStatus(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyFifteenMinutes), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusPaused), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -150,7 +150,7 @@ func testAccAccount_WithFindingAndStatus(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyFifteenMinutes), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusEnabled), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), @@ -161,7 +161,7 @@ func testAccAccount_WithFindingAndStatus(t *testing.T) { testAccCheckAccountExists(ctx, resourceName, &macie2Output), resource.TestCheckResourceAttr(resourceName, "finding_publishing_frequency", macie2.FindingPublishingFrequencyOneHour), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, macie2.MacieStatusPaused), - acctest.CheckResourceAttrGlobalARN(resourceName, "service_role", "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), + acctest.CheckResourceAttrGlobalARN(resourceName, names.AttrServiceRole, "iam", "role/aws-service-role/macie.amazonaws.com/AWSServiceRoleForAmazonMacie"), acctest.CheckResourceAttrRFC3339(resourceName, names.AttrCreatedAt), acctest.CheckResourceAttrRFC3339(resourceName, "updated_at"), ), From c0a4ea3c5a821574ffe4952e6eadd9f70f4f3746 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:04 -0400 Subject: [PATCH 38/62] medialive: Use constants for strings --- internal/service/medialive/channel.go | 12 ++++++------ .../channel_encoder_settings_schema.go | 18 +++++++++--------- .../service/medialive/multiplex_program.go | 6 +++--- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/internal/service/medialive/channel.go b/internal/service/medialive/channel.go index e2bc56a8d91..3e66e3c449c 100644 --- a/internal/service/medialive/channel.go +++ b/internal/service/medialive/channel.go @@ -291,7 +291,7 @@ func ResourceChannel() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, }, @@ -366,7 +366,7 @@ func ResourceChannel() *schema.Resource { Type: schema.TypeString, Required: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Optional: true, }, @@ -1302,7 +1302,7 @@ func expandInputAttachmentInputSettingsAudioSelectorsSelectorSettingsAudioLangua m := tfList[0].(map[string]interface{}) var out types.AudioLanguageSelection - if v, ok := m["language_code"].(string); ok && len(v) > 0 { + if v, ok := m[names.AttrLanguageCode].(string); ok && len(v) > 0 { out.LanguageCode = aws.String(v) } if v, ok := m["language_selection_policy"].(string); ok && len(v) > 0 { @@ -1399,7 +1399,7 @@ func expandInputAttachmentInputSettingsCaptionSelectors(tfList []interface{}) [] if v, ok := m[names.AttrName].(string); ok && v != "" { o.Name = aws.String(v) } - if v, ok := m["language_code"].(string); ok && v != "" { + if v, ok := m[names.AttrLanguageCode].(string); ok && v != "" { o.LanguageCode = aws.String(v) } if v, ok := m["selector_settings"].([]interface{}); ok && len(v) > 0 { @@ -1836,7 +1836,7 @@ func flattenInputAttachmentsInputSettingsAudioSelectorsSelectorSettingsAudioLang } m := map[string]interface{}{ - "language_code": aws.ToString(in.LanguageCode), + names.AttrLanguageCode: aws.ToString(in.LanguageCode), "language_selection_policy": string(in.LanguageSelectionPolicy), } @@ -1908,7 +1908,7 @@ func flattenInputAttachmentsInputSettingsCaptionSelectors(tfList []types.Caption for _, v := range tfList { m := map[string]interface{}{ names.AttrName: aws.ToString(v.Name), - "language_code": aws.ToString(v.LanguageCode), + names.AttrLanguageCode: aws.ToString(v.LanguageCode), "selector_settings": flattenInputAttachmentsInputSettingsCaptionSelectorsSelectorSettings(v.SelectorSettings), } diff --git a/internal/service/medialive/channel_encoder_settings_schema.go b/internal/service/medialive/channel_encoder_settings_schema.go index 76db6c65e5d..2f7df56bdfa 100644 --- a/internal/service/medialive/channel_encoder_settings_schema.go +++ b/internal/service/medialive/channel_encoder_settings_schema.go @@ -484,7 +484,7 @@ func channelEncoderSettingsSchema() *schema.Schema { }, }, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Optional: true, Computed: true, @@ -685,7 +685,7 @@ func channelEncoderSettingsSchema() *schema.Schema { Type: schema.TypeInt, Required: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, }, @@ -2252,7 +2252,7 @@ func channelEncoderSettingsSchema() *schema.Schema { }, }, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Optional: true, }, @@ -3138,7 +3138,7 @@ func expandChannelEncoderSettingsAudioDescriptions(tfList []interface{}) []types if v, ok := m["codec_settings"].([]interface{}); ok && len(v) > 0 { a.CodecSettings = expandChannelEncoderSettingsAudioDescriptionsCodecSettings(v) } - if v, ok := m["language_code"].(string); ok && v != "" { + if v, ok := m[names.AttrLanguageCode].(string); ok && v != "" { a.LanguageCode = aws.String(v) } if v, ok := m["language_code_control"].(string); ok && v != "" { @@ -4040,7 +4040,7 @@ func expandHSLGroupSettingsCaptionLanguageMappings(tfList []interface{}) []types if v, ok := m["caption_channel"].(int); ok && v != 0 { o.CaptionChannel = aws.Int32(int32(v)) } - if v, ok := m["language_code"].(string); ok && v != "" { + if v, ok := m[names.AttrLanguageCode].(string); ok && v != "" { o.LanguageCode = aws.String(v) } if v, ok := m["language_description"].(string); ok && v != "" { @@ -4970,7 +4970,7 @@ func expandChannelEncoderSettingsCaptionDescriptions(tfList []interface{}) []typ if v, ok := m["destination_settings"].([]interface{}); ok && len(v) > 0 { d.DestinationSettings = expandChannelEncoderSettingsCaptionDescriptionsDestinationSettings(v) } - if v, ok := m["language_code"].(string); ok && v != "" { + if v, ok := m[names.AttrLanguageCode].(string); ok && v != "" { d.LanguageCode = aws.String(v) } if v, ok := m["language_description"].(string); ok && v != "" { @@ -5821,7 +5821,7 @@ func flattenAudioDescriptions(od []types.AudioDescription) []interface{} { "audio_type_control": v.AudioTypeControl, "audio_watermark_settings": flattenAudioWatermarkSettings(v.AudioWatermarkingSettings), "codec_settings": flattenAudioDescriptionsCodecSettings(v.CodecSettings), - "language_code": aws.ToString(v.LanguageCode), + names.AttrLanguageCode: aws.ToString(v.LanguageCode), "language_code_control": string(v.LanguageCodeControl), "remix_settings": flattenAudioDescriptionsRemixSettings(v.RemixSettings), "stream_name": aws.ToString(v.StreamName), @@ -6376,7 +6376,7 @@ func flattenHLSCaptionLanguageMappings(in []types.CaptionLanguageMapping) []inte for _, item := range in { m := map[string]interface{}{ "caption_channel": int(aws.ToInt32(item.CaptionChannel)), - "language_code": aws.ToString(item.LanguageCode), + names.AttrLanguageCode: aws.ToString(item.LanguageCode), "language_description": aws.ToString(item.LanguageDescription), } @@ -6695,7 +6695,7 @@ func flattenCaptionDescriptions(tfList []types.CaptionDescription) []interface{} names.AttrName: aws.ToString(item.Name), "accessibility": string(item.Accessibility), "destination_settings": flattenCaptionDescriptionsCaptionDestinationSettings(item.DestinationSettings), - "language_code": aws.ToString(item.LanguageCode), + names.AttrLanguageCode: aws.ToString(item.LanguageCode), "language_description": aws.ToString(item.LanguageDescription), } diff --git a/internal/service/medialive/multiplex_program.go b/internal/service/medialive/multiplex_program.go index d6c588a6f0b..a712c3d615d 100644 --- a/internal/service/medialive/multiplex_program.go +++ b/internal/service/medialive/multiplex_program.go @@ -92,7 +92,7 @@ func (m *multiplexProgram) Schema(ctx context.Context, req resource.SchemaReques }, NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "provider_name": schema.StringAttribute{ + names.AttrProviderName: schema.StringAttribute{ Required: true, }, names.AttrServiceName: schema.StringAttribute{ @@ -495,7 +495,7 @@ var ( } serviceDescriptorAttrs = map[string]attr.Type{ - "provider_name": types.StringType, + names.AttrProviderName: types.StringType, names.AttrServiceName: types.StringType, } @@ -533,7 +533,7 @@ func flattenServiceDescriptor(ctx context.Context, sd *mltypes.MultiplexProgramS } attrs := map[string]attr.Value{} - attrs["provider_name"] = flex.StringToFrameworkLegacy(ctx, sd.ProviderName) + attrs[names.AttrProviderName] = flex.StringToFrameworkLegacy(ctx, sd.ProviderName) attrs[names.AttrServiceName] = flex.StringToFrameworkLegacy(ctx, sd.ServiceName) vals := types.ObjectValueMust(serviceDescriptorAttrs, attrs) From 302dc1214251eff493b6ccea193fb5bcf304d702 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:04 -0400 Subject: [PATCH 39/62] neptune: Use constants for strings --- internal/service/neptune/cluster.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/neptune/cluster.go b/internal/service/neptune/cluster.go index 9db2a17576c..19ab26ef214 100644 --- a/internal/service/neptune/cluster.go +++ b/internal/service/neptune/cluster.go @@ -249,7 +249,7 @@ func ResourceCluster() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeFloat, Optional: true, Default: ServerlessMaxNCUs, @@ -979,7 +979,7 @@ func expandServerlessConfiguration(l []interface{}) *neptune.ServerlessV2Scaling tfMap := l[0].(map[string]interface{}) return &neptune.ServerlessV2ScalingConfiguration{ MinCapacity: aws.Float64(tfMap["min_capacity"].(float64)), - MaxCapacity: aws.Float64(tfMap["max_capacity"].(float64)), + MaxCapacity: aws.Float64(tfMap[names.AttrMaxCapacity].(float64)), } } @@ -990,7 +990,7 @@ func flattenServerlessV2ScalingConfigurationInfo(serverlessConfig *neptune.Serve m := map[string]interface{}{ "min_capacity": aws.Float64Value(serverlessConfig.MinCapacity), - "max_capacity": aws.Float64Value(serverlessConfig.MaxCapacity), + names.AttrMaxCapacity: aws.Float64Value(serverlessConfig.MaxCapacity), } return []map[string]interface{}{m} From bfdab8ebfb223bce1ca0119570ddec5473f2a955 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:04 -0400 Subject: [PATCH 40/62] networkmanager: Use constants for strings --- internal/service/networkmanager/link.go | 8 ++++---- internal/service/networkmanager/link_data_source.go | 4 ++-- internal/service/networkmanager/link_data_source_test.go | 2 +- internal/service/networkmanager/link_test.go | 6 +++--- internal/service/networkmanager/links_data_source.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/service/networkmanager/link.go b/internal/service/networkmanager/link.go index 369c193d968..c3a8626eecd 100644 --- a/internal/service/networkmanager/link.go +++ b/internal/service/networkmanager/link.go @@ -97,7 +97,7 @@ func ResourceLink() *schema.Resource { Required: true, ForceNew: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(0, 128), @@ -138,7 +138,7 @@ func resourceLinkCreate(ctx context.Context, d *schema.ResourceData, meta interf input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("provider_name"); ok { + if v, ok := d.GetOk(names.AttrProviderName); ok { input.Provider = aws.String(v.(string)) } @@ -190,7 +190,7 @@ func resourceLinkRead(ctx context.Context, d *schema.ResourceData, meta interfac } d.Set(names.AttrDescription, link.Description) d.Set("global_network_id", link.GlobalNetworkId) - d.Set("provider_name", link.Provider) + d.Set(names.AttrProviderName, link.Provider) d.Set("site_id", link.SiteId) d.Set(names.AttrType, link.Type) @@ -210,7 +210,7 @@ func resourceLinkUpdate(ctx context.Context, d *schema.ResourceData, meta interf Description: aws.String(d.Get(names.AttrDescription).(string)), GlobalNetworkId: aws.String(globalNetworkID), LinkId: aws.String(d.Id()), - Provider: aws.String(d.Get("provider_name").(string)), + Provider: aws.String(d.Get(names.AttrProviderName).(string)), Type: aws.String(d.Get(names.AttrType).(string)), } diff --git a/internal/service/networkmanager/link_data_source.go b/internal/service/networkmanager/link_data_source.go index ecf4db8a1f9..91a4ec8be5e 100644 --- a/internal/service/networkmanager/link_data_source.go +++ b/internal/service/networkmanager/link_data_source.go @@ -52,7 +52,7 @@ func DataSourceLink() *schema.Resource { Type: schema.TypeString, Required: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, @@ -95,7 +95,7 @@ func dataSourceLinkRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set(names.AttrDescription, link.Description) d.Set("global_network_id", link.GlobalNetworkId) d.Set("link_id", link.LinkId) - d.Set("provider_name", link.Provider) + d.Set(names.AttrProviderName, link.Provider) d.Set("site_id", link.SiteId) d.Set(names.AttrType, link.Type) diff --git a/internal/service/networkmanager/link_data_source_test.go b/internal/service/networkmanager/link_data_source_test.go index 86f46a7371e..2d716ad4b16 100644 --- a/internal/service/networkmanager/link_data_source_test.go +++ b/internal/service/networkmanager/link_data_source_test.go @@ -32,7 +32,7 @@ func TestAccNetworkManagerLinkDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(dataSourceName, names.AttrDescription, resourceName, names.AttrDescription), resource.TestCheckResourceAttrPair(dataSourceName, "global_network_id", resourceName, "global_network_id"), resource.TestCheckResourceAttrPair(dataSourceName, "link_id", resourceName, names.AttrID), - resource.TestCheckResourceAttrPair(dataSourceName, "provider_name", resourceName, "provider_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrProviderName, resourceName, names.AttrProviderName), resource.TestCheckResourceAttrPair(dataSourceName, "site_id", resourceName, "site_id"), resource.TestCheckResourceAttrPair(dataSourceName, acctest.CtTagsPercent, resourceName, acctest.CtTagsPercent), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrType, resourceName, names.AttrType), diff --git a/internal/service/networkmanager/link_test.go b/internal/service/networkmanager/link_test.go index 579573c6b46..448493fa17a 100644 --- a/internal/service/networkmanager/link_test.go +++ b/internal/service/networkmanager/link_test.go @@ -38,7 +38,7 @@ func TestAccNetworkManagerLink_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "bandwidth.0.download_speed", "50"), resource.TestCheckResourceAttr(resourceName, "bandwidth.0.upload_speed", "10"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, ""), - resource.TestCheckResourceAttr(resourceName, "provider_name", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, ""), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), resource.TestCheckResourceAttr(resourceName, names.AttrType, ""), ), @@ -141,7 +141,7 @@ func TestAccNetworkManagerLink_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "bandwidth.0.download_speed", "50"), resource.TestCheckResourceAttr(resourceName, "bandwidth.0.upload_speed", "10"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "description1"), - resource.TestCheckResourceAttr(resourceName, "provider_name", "provider1"), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, "provider1"), resource.TestCheckResourceAttr(resourceName, names.AttrType, "type1"), ), }, @@ -159,7 +159,7 @@ func TestAccNetworkManagerLink_allAttributes(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "bandwidth.0.download_speed", "75"), resource.TestCheckResourceAttr(resourceName, "bandwidth.0.upload_speed", "20"), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "description2"), - resource.TestCheckResourceAttr(resourceName, "provider_name", "provider2"), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, "provider2"), resource.TestCheckResourceAttr(resourceName, names.AttrType, "type2"), ), }, diff --git a/internal/service/networkmanager/links_data_source.go b/internal/service/networkmanager/links_data_source.go index f4718d4ba6e..5fb5eff5f2e 100644 --- a/internal/service/networkmanager/links_data_source.go +++ b/internal/service/networkmanager/links_data_source.go @@ -31,7 +31,7 @@ func DataSourceLinks() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Optional: true, }, @@ -59,7 +59,7 @@ func dataSourceLinksRead(ctx context.Context, d *schema.ResourceData, meta inter GlobalNetworkId: aws.String(d.Get("global_network_id").(string)), } - if v, ok := d.GetOk("provider_name"); ok { + if v, ok := d.GetOk(names.AttrProviderName); ok { input.Provider = aws.String(v.(string)) } From cdb0b40dc00ed67956e82dd8fd3df0015ea5a578 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:04 -0400 Subject: [PATCH 41/62] opsworks: Use constants for strings --- internal/service/opsworks/instance.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/opsworks/instance.go b/internal/service/opsworks/instance.go index bab8188ae6c..17dd37eac08 100644 --- a/internal/service/opsworks/instance.go +++ b/internal/service/opsworks/instance.go @@ -326,7 +326,7 @@ func ResourceInstance() *schema.Resource { ForceNew: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, Computed: true, @@ -352,7 +352,7 @@ func ResourceInstance() *schema.Resource { var buf bytes.Buffer m := v.(map[string]interface{}) buf.WriteString(fmt.Sprintf("%s-", m[names.AttrDeviceName].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["snapshot_id"].(string))) + buf.WriteString(fmt.Sprintf("%s-", m[names.AttrSnapshotID].(string))) return create.StringHashcode(buf.String()) }, }, @@ -639,7 +639,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, meta in DeleteOnTermination: aws.Bool(bd[names.AttrDeleteOnTermination].(bool)), } - if v, ok := bd["snapshot_id"].(string); ok && v != "" { + if v, ok := bd[names.AttrSnapshotID].(string); ok && v != "" { ebs.SnapshotId = aws.String(v) } @@ -1010,7 +1010,7 @@ func readBlockDevices(instance *opsworks.Instance) map[string]interface{} { blockDevices["ephemeral"] = append(blockDevices["ephemeral"].([]map[string]interface{}), bd) } else { if bdm.Ebs != nil && bdm.Ebs.SnapshotId != nil { - bd["snapshot_id"] = aws.StringValue(bdm.Ebs.SnapshotId) + bd[names.AttrSnapshotID] = aws.StringValue(bdm.Ebs.SnapshotId) } blockDevices["ebs"] = append(blockDevices["ebs"].([]map[string]interface{}), bd) } From 5d0d6fe937ea86e02969e9508adcf5dbb59fde6e Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:05 -0400 Subject: [PATCH 42/62] pipes: Use constants for strings --- internal/service/pipes/target_parameters.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/pipes/target_parameters.go b/internal/service/pipes/target_parameters.go index 523ca205641..3757aff8af9 100644 --- a/internal/service/pipes/target_parameters.go +++ b/internal/service/pipes/target_parameters.go @@ -479,7 +479,7 @@ func targetParametersSchema() *schema.Schema { Type: schema.TypeString, Optional: true, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeString, Optional: true, ValidateDiagFunc: enum.Validate[types.PropagateTags](), @@ -1161,7 +1161,7 @@ func expandPipeTargetECSTaskParameters(tfMap map[string]interface{}) *types.Pipe apiObject.PlatformVersion = aws.String(v) } - if v, ok := tfMap["propagate_tags"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrPropagateTags].(string); ok && v != "" { apiObject.PropagateTags = types.PropagateTags(v) } @@ -2153,7 +2153,7 @@ func flattenPipeTargetECSTaskParameters(apiObject *types.PipeTargetEcsTaskParame } if v := apiObject.PropagateTags; v != "" { - tfMap["propagate_tags"] = v + tfMap[names.AttrPropagateTags] = v } if v := apiObject.ReferenceId; v != nil { From 73c956284f72b66b77bb13dac497884c180b5df9 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:05 -0400 Subject: [PATCH 43/62] polly: Use constants for strings --- internal/service/polly/voices_data_source.go | 4 ++-- internal/service/polly/voices_data_source_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/polly/voices_data_source.go b/internal/service/polly/voices_data_source.go index af4facafbd5..ce8aba98128 100644 --- a/internal/service/polly/voices_data_source.go +++ b/internal/service/polly/voices_data_source.go @@ -46,7 +46,7 @@ func (d *dataSourceVoices) Schema(ctx context.Context, req datasource.SchemaRequ "include_additional_language_codes": schema.BoolAttribute{ Optional: true, }, - "language_code": schema.StringAttribute{ + names.AttrLanguageCode: schema.StringAttribute{ CustomType: fwtypes.StringEnumType[awstypes.LanguageCode](), Optional: true, }, @@ -67,7 +67,7 @@ func (d *dataSourceVoices) Schema(ctx context.Context, req datasource.SchemaRequ names.AttrID: schema.StringAttribute{ Computed: true, }, - "language_code": schema.StringAttribute{ + names.AttrLanguageCode: schema.StringAttribute{ Computed: true, }, "language_name": schema.StringAttribute{ diff --git a/internal/service/polly/voices_data_source_test.go b/internal/service/polly/voices_data_source_test.go index c8ec47c8ea7..d329c2b42cb 100644 --- a/internal/service/polly/voices_data_source_test.go +++ b/internal/service/polly/voices_data_source_test.go @@ -32,7 +32,7 @@ func TestAccPollyVoicesDataSource_basic(t *testing.T) { // verify a known voice is returned in the results resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "voices.*", map[string]string{ "gender": "Female", - "language_code": "en-US", + names.AttrLanguageCode: "en-US", names.AttrName: "Kendra", }), ), @@ -60,7 +60,7 @@ func TestAccPollyVoicesDataSource_languageCode(t *testing.T) { // verify a known voice is returned in the results resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "voices.*", map[string]string{ "gender": "Female", - "language_code": "en-US", + names.AttrLanguageCode: "en-US", names.AttrName: "Kendra", }), ), From d89a63eccf7d10d56bfdf53e0b5ef7f886846581 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:05 -0400 Subject: [PATCH 44/62] rds: Use constants for strings --- internal/service/rds/cluster.go | 4 ++-- internal/service/rds/cluster_migrate.go | 4 ++-- internal/service/rds/flex.go | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/rds/cluster.go b/internal/service/rds/cluster.go index 364269e2436..ba1901a0c27 100644 --- a/internal/service/rds/cluster.go +++ b/internal/service/rds/cluster.go @@ -454,7 +454,7 @@ func ResourceCluster() *schema.Resource { Optional: true, Default: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeInt, Optional: true, Default: clusterScalingConfiguration_DefaultMaxCapacity, @@ -486,7 +486,7 @@ func ResourceCluster() *schema.Resource { DiffSuppressFunc: verify.SuppressMissingOptionalConfigurationBlock, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeFloat, Required: true, ValidateFunc: validation.FloatBetween(0.5, 128), diff --git a/internal/service/rds/cluster_migrate.go b/internal/service/rds/cluster_migrate.go index dfad4383c6d..5b16329fc2c 100644 --- a/internal/service/rds/cluster_migrate.go +++ b/internal/service/rds/cluster_migrate.go @@ -329,7 +329,7 @@ func resourceClusterResourceV0() *schema.Resource { Optional: true, Default: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeInt, Optional: true, Default: clusterScalingConfiguration_DefaultMaxCapacity, @@ -358,7 +358,7 @@ func resourceClusterResourceV0() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeFloat, Required: true, }, diff --git a/internal/service/rds/flex.go b/internal/service/rds/flex.go index 00fe4191557..d0a6039a0fb 100644 --- a/internal/service/rds/flex.go +++ b/internal/service/rds/flex.go @@ -24,7 +24,7 @@ func expandScalingConfiguration(tfMap map[string]interface{}) *rds.ScalingConfig apiObject.AutoPause = aws.Bool(v) } - if v, ok := tfMap["max_capacity"].(int); ok { + if v, ok := tfMap[names.AttrMaxCapacity].(int); ok { apiObject.MaxCapacity = aws.Int64(int64(v)) } @@ -74,11 +74,11 @@ func flattenScalingConfigurationInfo(apiObject *rds.ScalingConfigurationInfo) ma } if v := apiObject.MaxCapacity; v != nil { - tfMap["max_capacity"] = aws.Int64Value(v) + tfMap[names.AttrMaxCapacity] = aws.Int64Value(v) } if v := apiObject.MaxCapacity; v != nil { - tfMap["max_capacity"] = aws.Int64Value(v) + tfMap[names.AttrMaxCapacity] = aws.Int64Value(v) } if v := apiObject.MinCapacity; v != nil { @@ -103,7 +103,7 @@ func expandServerlessV2ScalingConfiguration(tfMap map[string]interface{}) *rds.S apiObject := &rds.ServerlessV2ScalingConfiguration{} - if v, ok := tfMap["max_capacity"].(float64); ok && v != 0.0 { + if v, ok := tfMap[names.AttrMaxCapacity].(float64); ok && v != 0.0 { apiObject.MaxCapacity = aws.Float64(v) } @@ -122,7 +122,7 @@ func flattenServerlessV2ScalingConfigurationInfo(apiObject *rds.ServerlessV2Scal tfMap := map[string]interface{}{} if v := apiObject.MaxCapacity; v != nil { - tfMap["max_capacity"] = aws.Float64Value(v) + tfMap[names.AttrMaxCapacity] = aws.Float64Value(v) } if v := apiObject.MinCapacity; v != nil { From 04a9949677b58122d9230e4c0bb409a3cd9d246d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:06 -0400 Subject: [PATCH 45/62] redshift: Use constants for strings --- internal/service/redshift/endpoint_authorization.go | 4 ++-- internal/service/redshift/endpoint_authorization_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/redshift/endpoint_authorization.go b/internal/service/redshift/endpoint_authorization.go index 63e13d900ca..64c56754f0f 100644 --- a/internal/service/redshift/endpoint_authorization.go +++ b/internal/service/redshift/endpoint_authorization.go @@ -54,7 +54,7 @@ func resourceEndpointAuthorization() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "force_delete": { + names.AttrForceDelete: { Type: schema.TypeBool, Optional: true, Default: false, @@ -184,7 +184,7 @@ func resourceEndpointAuthorizationDelete(ctx context.Context, d *schema.Resource input := &redshift.RevokeEndpointAccessInput{ Account: aws.String(account), ClusterIdentifier: aws.String(clusterId), - Force: aws.Bool(d.Get("force_delete").(bool)), + Force: aws.Bool(d.Get(names.AttrForceDelete).(bool)), } _, err = conn.RevokeEndpointAccessWithContext(ctx, input) diff --git a/internal/service/redshift/endpoint_authorization_test.go b/internal/service/redshift/endpoint_authorization_test.go index 2f2a1705ed0..8277bc5605f 100644 --- a/internal/service/redshift/endpoint_authorization_test.go +++ b/internal/service/redshift/endpoint_authorization_test.go @@ -49,7 +49,7 @@ func TestAccRedshiftEndpointAuthorization_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"force_delete"}, + ImportStateVerifyIgnore: []string{names.AttrForceDelete}, }, }, }) @@ -82,7 +82,7 @@ func TestAccRedshiftEndpointAuthorization_vpcs(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"force_delete"}, + ImportStateVerifyIgnore: []string{names.AttrForceDelete}, }, { Config: testAccEndpointAuthorizationConfig_vpcsUpdated(rName), From 3dd7f231c0b1b429dbd88b4f2396f68b3e80b8bc Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:06 -0400 Subject: [PATCH 46/62] redshiftserverless: Use constants for strings --- internal/service/redshiftserverless/workgroup.go | 8 ++++---- .../service/redshiftserverless/workgroup_test.go | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/service/redshiftserverless/workgroup.go b/internal/service/redshiftserverless/workgroup.go index fc24b2eb27b..72608454afc 100644 --- a/internal/service/redshiftserverless/workgroup.go +++ b/internal/service/redshiftserverless/workgroup.go @@ -154,7 +154,7 @@ func resourceWorkgroup() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "max_capacity": { + names.AttrMaxCapacity: { Type: schema.TypeInt, Optional: true, }, @@ -228,7 +228,7 @@ func resourceWorkgroupCreate(ctx context.Context, d *schema.ResourceData, meta i input.EnhancedVpcRouting = aws.Bool(v.(bool)) } - if v, ok := d.GetOk("max_capacity"); ok { + if v, ok := d.GetOk(names.AttrMaxCapacity); ok { input.MaxCapacity = aws.Int64(int64(v.(int))) } @@ -289,7 +289,7 @@ func resourceWorkgroupRead(ctx context.Context, d *schema.ResourceData, meta int return sdkdiag.AppendErrorf(diags, "setting endpoint: %s", err) } d.Set("enhanced_vpc_routing", out.EnhancedVpcRouting) - d.Set("max_capacity", out.MaxCapacity) + d.Set(names.AttrMaxCapacity, out.MaxCapacity) d.Set("namespace_name", out.NamespaceName) d.Set(names.AttrPort, flattenEndpoint(out.Endpoint)[names.AttrPort]) d.Set(names.AttrPubliclyAccessible, out.PubliclyAccessible) @@ -323,7 +323,7 @@ func resourceWorkgroupUpdate(ctx context.Context, d *schema.ResourceData, meta i // Some validations, such as increasing base_capacity beyond an unchanged max_capacity, are deferred to the AWS API. hasBaseCapacityChange, _, newBaseCapacity := checkCapacityChange("base_capacity") - hasMaxCapacityChange, oldMaxCapacity, newMaxCapacity := checkCapacityChange("max_capacity") + hasMaxCapacityChange, oldMaxCapacity, newMaxCapacity := checkCapacityChange(names.AttrMaxCapacity) switch { case hasMaxCapacityChange && newMaxCapacity == 0: diff --git a/internal/service/redshiftserverless/workgroup_test.go b/internal/service/redshiftserverless/workgroup_test.go index dee6089a5ef..de3a9c2452e 100644 --- a/internal/service/redshiftserverless/workgroup_test.go +++ b/internal/service/redshiftserverless/workgroup_test.go @@ -68,35 +68,35 @@ func TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible( Check: resource.ComposeTestCheckFunc( testAccCheckWorkgroupExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "base_capacity", "128"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", acctest.CtZero), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, acctest.CtZero), ), }, { Config: testAccWorkgroupConfig_baseCapacity(rName, 256), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "256"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", acctest.CtZero), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, acctest.CtZero), ), }, { Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 64, 128, false), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "64"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "128"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "128"), ), }, { Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 128, 256, false), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "128"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "256"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "256"), ), }, { Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 512, 5632, false), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "512"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "5632"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "5632"), resource.TestCheckResourceAttr(resourceName, names.AttrPubliclyAccessible, "false"), ), }, @@ -104,7 +104,7 @@ func TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible( Config: testAccWorkgroupConfig_baseAndMaxCapacityAndPubliclyAccessible(rName, 128, 256, true), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "128"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", "256"), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, "256"), resource.TestCheckResourceAttr(resourceName, names.AttrPubliclyAccessible, "true"), ), }, @@ -112,7 +112,7 @@ func TestAccRedshiftServerlessWorkgroup_baseAndMaxCapacityAndPubliclyAccessible( Config: testAccWorkgroupConfig_baseCapacity(rName, 128), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "base_capacity", "128"), - resource.TestCheckResourceAttr(resourceName, "max_capacity", acctest.CtZero), + resource.TestCheckResourceAttr(resourceName, names.AttrMaxCapacity, acctest.CtZero), ), }, }, From 9a5ef2dd8cd36026a5f43462f7f16086b05cc590 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:06 -0400 Subject: [PATCH 47/62] scheduler: Use constants for strings --- internal/service/scheduler/flex.go | 4 ++-- internal/service/scheduler/schedule.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/service/scheduler/flex.go b/internal/service/scheduler/flex.go index 086b150c899..bc58d362a77 100644 --- a/internal/service/scheduler/flex.go +++ b/internal/service/scheduler/flex.go @@ -127,7 +127,7 @@ func expandECSParameters(ctx context.Context, tfMap map[string]interface{}) *typ a.PlatformVersion = aws.String(v) } - if v, ok := tfMap["propagate_tags"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrPropagateTags].(string); ok && v != "" { a.PropagateTags = types.PropagateTags(v) } @@ -219,7 +219,7 @@ func flattenECSParameters(ctx context.Context, apiObject *types.EcsParameters) m } if v := string(apiObject.PropagateTags); v != "" { - m["propagate_tags"] = v + m[names.AttrPropagateTags] = v } if v := apiObject.ReferenceId; v != nil { diff --git a/internal/service/scheduler/schedule.go b/internal/service/scheduler/schedule.go index a7d42a2f16c..3eb79b89832 100644 --- a/internal/service/scheduler/schedule.go +++ b/internal/service/scheduler/schedule.go @@ -280,7 +280,7 @@ func resourceSchedule() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "propagate_tags": { + names.AttrPropagateTags: { Type: schema.TypeString, Optional: true, ValidateDiagFunc: enum.Validate[types.PropagateTags](), From 2ad862a63fd0f77dda04fc2096d3b5cc9b4caa1b Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:06 -0400 Subject: [PATCH 48/62] securitylake: Use constants for strings --- internal/service/securitylake/custom_log_source.go | 2 +- internal/service/securitylake/subscriber.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/securitylake/custom_log_source.go b/internal/service/securitylake/custom_log_source.go index 8a02c9b1f75..6a03249b736 100644 --- a/internal/service/securitylake/custom_log_source.go +++ b/internal/service/securitylake/custom_log_source.go @@ -151,7 +151,7 @@ func (r *customLogSourceResource) Schema(ctx context.Context, request resource.S }, NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "external_id": schema.StringAttribute{ + names.AttrExternalID: schema.StringAttribute{ Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/service/securitylake/subscriber.go b/internal/service/securitylake/subscriber.go index 497ab997d9d..d6c92e9c7d0 100644 --- a/internal/service/securitylake/subscriber.go +++ b/internal/service/securitylake/subscriber.go @@ -180,7 +180,7 @@ func (r *subscriberResource) Schema(ctx context.Context, request resource.Schema }, NestedObject: schema.NestedBlockObject{ Attributes: map[string]schema.Attribute{ - "external_id": schema.StringAttribute{ + names.AttrExternalID: schema.StringAttribute{ Required: true, }, names.AttrPrincipal: schema.StringAttribute{ From c47976faf7334b3c869a9b9ff5886707803f5a5f Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:06 -0400 Subject: [PATCH 49/62] servicecatalog: Use constants for strings --- internal/service/servicecatalog/portfolio.go | 10 +++++----- .../service/servicecatalog/portfolio_data_source.go | 4 ++-- .../servicecatalog/portfolio_data_source_test.go | 2 +- internal/service/servicecatalog/portfolio_test.go | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/internal/service/servicecatalog/portfolio.go b/internal/service/servicecatalog/portfolio.go index d8d48890d6e..54f35265957 100644 --- a/internal/service/servicecatalog/portfolio.go +++ b/internal/service/servicecatalog/portfolio.go @@ -65,7 +65,7 @@ func ResourcePortfolio() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 100), }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 50), @@ -93,7 +93,7 @@ func resourcePortfolioCreate(ctx context.Context, d *schema.ResourceData, meta i input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("provider_name"); ok { + if v, ok := d.GetOk(names.AttrProviderName); ok { input.ProviderName = aws.String(v.(string)) } @@ -129,7 +129,7 @@ func resourcePortfolioRead(ctx context.Context, d *schema.ResourceData, meta int d.Set(names.AttrCreatedTime, portfolioDetail.CreatedTime.Format(time.RFC3339)) d.Set(names.AttrDescription, portfolioDetail.Description) d.Set(names.AttrName, portfolioDetail.DisplayName) - d.Set("provider_name", portfolioDetail.ProviderName) + d.Set(names.AttrProviderName, portfolioDetail.ProviderName) setTagsOut(ctx, output.Tags) @@ -157,8 +157,8 @@ func resourcePortfolioUpdate(ctx context.Context, d *schema.ResourceData, meta i input.DisplayName = aws.String(d.Get(names.AttrName).(string)) } - if d.HasChange("provider_name") { - input.ProviderName = aws.String(d.Get("provider_name").(string)) + if d.HasChange(names.AttrProviderName) { + input.ProviderName = aws.String(d.Get(names.AttrProviderName).(string)) } if d.HasChange(names.AttrTagsAll) { diff --git a/internal/service/servicecatalog/portfolio_data_source.go b/internal/service/servicecatalog/portfolio_data_source.go index af401596f2d..a136ddad122 100644 --- a/internal/service/servicecatalog/portfolio_data_source.go +++ b/internal/service/servicecatalog/portfolio_data_source.go @@ -55,7 +55,7 @@ func DataSourcePortfolio() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "provider_name": { + names.AttrProviderName: { Type: schema.TypeString, Computed: true, }, @@ -97,7 +97,7 @@ func dataSourcePortfolioRead(ctx context.Context, d *schema.ResourceData, meta i d.Set(names.AttrARN, detail.ARN) d.Set(names.AttrDescription, detail.Description) d.Set(names.AttrName, detail.DisplayName) - d.Set("provider_name", detail.ProviderName) + d.Set(names.AttrProviderName, detail.ProviderName) ignoreTagsConfig := meta.(*conns.AWSClient).IgnoreTagsConfig tags := KeyValueTags(ctx, output.Tags) diff --git a/internal/service/servicecatalog/portfolio_data_source_test.go b/internal/service/servicecatalog/portfolio_data_source_test.go index b40c3761559..b654fc3f56a 100644 --- a/internal/service/servicecatalog/portfolio_data_source_test.go +++ b/internal/service/servicecatalog/portfolio_data_source_test.go @@ -31,7 +31,7 @@ func TestAccServiceCatalogPortfolioDataSource_basic(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, names.AttrCreatedTime, dataSourceName, names.AttrCreatedTime), resource.TestCheckResourceAttrPair(resourceName, names.AttrDescription, dataSourceName, names.AttrDescription), resource.TestCheckResourceAttrPair(resourceName, names.AttrName, dataSourceName, names.AttrName), - resource.TestCheckResourceAttrPair(resourceName, "provider_name", dataSourceName, "provider_name"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrProviderName, dataSourceName, names.AttrProviderName), resource.TestCheckResourceAttrPair(resourceName, acctest.CtTagsPercent, dataSourceName, acctest.CtTagsPercent), resource.TestCheckResourceAttrPair(resourceName, "tags.Chicane", dataSourceName, "tags.Chicane"), ), diff --git a/internal/service/servicecatalog/portfolio_test.go b/internal/service/servicecatalog/portfolio_test.go index f4363c8ae25..10a9b4b7e50 100644 --- a/internal/service/servicecatalog/portfolio_test.go +++ b/internal/service/servicecatalog/portfolio_test.go @@ -40,7 +40,7 @@ func TestAccServiceCatalogPortfolio_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrCreatedTime), resource.TestCheckResourceAttr(resourceName, names.AttrName, name), resource.TestCheckResourceAttr(resourceName, names.AttrDescription, "test-2"), - resource.TestCheckResourceAttr(resourceName, "provider_name", "test-3"), + resource.TestCheckResourceAttr(resourceName, names.AttrProviderName, "test-3"), resource.TestCheckResourceAttr(resourceName, acctest.CtTagsPercent, acctest.CtZero), ), }, From 55bed3addc5fdbd00e36a433e237ea2ed3653ea1 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:07 -0400 Subject: [PATCH 50/62] ses: Use constants for strings --- internal/service/ses/receipt_rule.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/ses/receipt_rule.go b/internal/service/ses/receipt_rule.go index 75791aeaed6..783f2a22152 100644 --- a/internal/service/ses/receipt_rule.go +++ b/internal/service/ses/receipt_rule.go @@ -94,7 +94,7 @@ func ResourceReceiptRule() *schema.Resource { Type: schema.TypeString, Required: true, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeString, Optional: true, }, @@ -347,7 +347,7 @@ func resourceReceiptRuleRead(ctx context.Context, d *schema.ResourceData, meta i } if element.BounceAction.StatusCode != nil { - bounceAction["status_code"] = aws.StringValue(element.BounceAction.StatusCode) + bounceAction[names.AttrStatusCode] = aws.StringValue(element.BounceAction.StatusCode) } if element.BounceAction.TopicArn != nil { @@ -616,8 +616,8 @@ func buildReceiptRule(d *schema.ResourceData) *ses.ReceiptRule { SmtpReplyCode: aws.String(elem["smtp_reply_code"].(string)), } - if elem["status_code"] != "" { - bounceAction.StatusCode = aws.String(elem["status_code"].(string)) + if elem[names.AttrStatusCode] != "" { + bounceAction.StatusCode = aws.String(elem[names.AttrStatusCode].(string)) } if elem[names.AttrTopicARN] != "" { From 9ce3ea960bec93395dab112687309a3126755194 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:07 -0400 Subject: [PATCH 51/62] signer: Use constants for strings --- internal/service/signer/signing_job.go | 4 ++-- internal/service/signer/signing_job_data_source.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/service/signer/signing_job.go b/internal/service/signer/signing_job.go index 0f7239d890d..6ece28a96d7 100644 --- a/internal/service/signer/signing_job.go +++ b/internal/service/signer/signing_job.go @@ -196,7 +196,7 @@ func ResourceSigningJob() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -328,7 +328,7 @@ func resourceSigningJobRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "setting signer signing job status: %s", err) } - if err := d.Set("status_reason", describeSigningJobOutput.StatusReason); err != nil { + if err := d.Set(names.AttrStatusReason, describeSigningJobOutput.StatusReason); err != nil { return sdkdiag.AppendErrorf(diags, "setting signer signing job status reason: %s", err) } diff --git a/internal/service/signer/signing_job_data_source.go b/internal/service/signer/signing_job_data_source.go index d841d5ad9ac..aef1572b7d8 100644 --- a/internal/service/signer/signing_job_data_source.go +++ b/internal/service/signer/signing_job_data_source.go @@ -142,7 +142,7 @@ func DataSourceSigningJob() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -223,7 +223,7 @@ func dataSourceSigningJobRead(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "setting signer signing job status: %s", err) } - if err := d.Set("status_reason", describeSigningJobOutput.StatusReason); err != nil { + if err := d.Set(names.AttrStatusReason, describeSigningJobOutput.StatusReason); err != nil { return sdkdiag.AppendErrorf(diags, "setting signer signing job status reason: %s", err) } From 4d8c884e5ff70bda4f70b38d29f34f059bb6bf14 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:07 -0400 Subject: [PATCH 52/62] ssoadmin: Use constants for strings --- .../service/ssoadmin/instance_access_control_attributes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/ssoadmin/instance_access_control_attributes.go b/internal/service/ssoadmin/instance_access_control_attributes.go index 3ef49c2e48e..7b15dce312f 100644 --- a/internal/service/ssoadmin/instance_access_control_attributes.go +++ b/internal/service/ssoadmin/instance_access_control_attributes.go @@ -72,7 +72,7 @@ func ResourceAccessControlAttributes() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "status_reason": { + names.AttrStatusReason: { Type: schema.TypeString, Computed: true, }, @@ -124,7 +124,7 @@ func resourceAccessControlAttributesRead(ctx context.Context, d *schema.Resource return sdkdiag.AppendErrorf(diags, "setting attribute: %s", err) } d.Set(names.AttrStatus, output.Status) - d.Set("status_reason", output.StatusReason) + d.Set(names.AttrStatusReason, output.StatusReason) return diags } From 184a41a04a983b3f4bf7d6d9521d1cd590c391ac Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:07 -0400 Subject: [PATCH 53/62] storagegateway: Use constants for strings --- internal/service/storagegateway/cached_iscsi_volume.go | 6 +++--- internal/service/storagegateway/cached_iscsi_volume_test.go | 6 +++--- internal/service/storagegateway/stored_iscsi_volume.go | 6 +++--- internal/service/storagegateway/stored_iscsi_volume_test.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/internal/service/storagegateway/cached_iscsi_volume.go b/internal/service/storagegateway/cached_iscsi_volume.go index e3099146a32..8b18bcd4684 100644 --- a/internal/service/storagegateway/cached_iscsi_volume.go +++ b/internal/service/storagegateway/cached_iscsi_volume.go @@ -67,7 +67,7 @@ func ResourceCachediSCSIVolume() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -133,7 +133,7 @@ func resourceCachediSCSIVolumeCreate(ctx context.Context, d *schema.ResourceData Tags: getTagsIn(ctx), } - if v, ok := d.GetOk("snapshot_id"); ok { + if v, ok := d.GetOk(names.AttrSnapshotID); ok { input.SnapshotId = aws.String(v.(string)) } @@ -190,7 +190,7 @@ func resourceCachediSCSIVolumeRead(ctx context.Context, d *schema.ResourceData, arn := aws.StringValue(volume.VolumeARN) d.Set(names.AttrARN, arn) - d.Set("snapshot_id", volume.SourceSnapshotId) + d.Set(names.AttrSnapshotID, volume.SourceSnapshotId) d.Set("volume_arn", arn) d.Set("volume_id", volume.VolumeId) d.Set("volume_size_in_bytes", volume.VolumeSizeInBytes) diff --git a/internal/service/storagegateway/cached_iscsi_volume_test.go b/internal/service/storagegateway/cached_iscsi_volume_test.go index a44dd27aa98..9d07e6a7bb4 100644 --- a/internal/service/storagegateway/cached_iscsi_volume_test.go +++ b/internal/service/storagegateway/cached_iscsi_volume_test.go @@ -101,7 +101,7 @@ func TestAccStorageGatewayCachediSCSIVolume_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "lun_number", acctest.CtZero), resource.TestMatchResourceAttr(resourceName, names.AttrNetworkInterfaceID, regexache.MustCompile(`^\d+\.\d+\.\d+\.\d+$`)), resource.TestMatchResourceAttr(resourceName, "network_interface_port", regexache.MustCompile(`^\d+$`)), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrTargetARN, "storagegateway", regexache.MustCompile(fmt.Sprintf(`gateway/sgw-.+/target/iqn.1997-05.com.amazon:%s`, rName))), resource.TestCheckResourceAttr(resourceName, "target_name", rName), resource.TestMatchResourceAttr(resourceName, "volume_id", regexache.MustCompile(`^vol-.+$`)), @@ -220,7 +220,7 @@ func TestAccStorageGatewayCachediSCSIVolume_snapshotID(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "lun_number", acctest.CtZero), resource.TestMatchResourceAttr(resourceName, names.AttrNetworkInterfaceID, regexache.MustCompile(`^\d+\.\d+\.\d+\.\d+$`)), resource.TestMatchResourceAttr(resourceName, "network_interface_port", regexache.MustCompile(`^\d+$`)), - resource.TestMatchResourceAttr(resourceName, "snapshot_id", regexache.MustCompile(`^snap-.+$`)), + resource.TestMatchResourceAttr(resourceName, names.AttrSnapshotID, regexache.MustCompile(`^snap-.+$`)), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrTargetARN, "storagegateway", regexache.MustCompile(fmt.Sprintf(`gateway/sgw-.+/target/iqn.1997-05.com.amazon:%s`, rName))), resource.TestCheckResourceAttr(resourceName, "target_name", rName), resource.TestMatchResourceAttr(resourceName, "volume_id", regexache.MustCompile(`^vol-.+$`)), @@ -258,7 +258,7 @@ func TestAccStorageGatewayCachediSCSIVolume_sourceVolumeARN(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, "gateway_arn", "storagegateway", regexache.MustCompile(`gateway/sgw-.+`)), resource.TestMatchResourceAttr(resourceName, names.AttrNetworkInterfaceID, regexache.MustCompile(`^\d+\.\d+\.\d+\.\d+$`)), resource.TestMatchResourceAttr(resourceName, "network_interface_port", regexache.MustCompile(`^\d+$`)), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), acctest.MatchResourceAttrRegionalARN(resourceName, "source_volume_arn", "storagegateway", regexache.MustCompile(`gateway/sgw-.+/volume/vol-.+`)), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrTargetARN, "storagegateway", regexache.MustCompile(fmt.Sprintf(`gateway/sgw-.+/target/iqn.1997-05.com.amazon:%s`, rName))), resource.TestCheckResourceAttr(resourceName, "target_name", rName), diff --git a/internal/service/storagegateway/stored_iscsi_volume.go b/internal/service/storagegateway/stored_iscsi_volume.go index 66bb6ba0bc2..b6aea3f5606 100644 --- a/internal/service/storagegateway/stored_iscsi_volume.go +++ b/internal/service/storagegateway/stored_iscsi_volume.go @@ -82,7 +82,7 @@ func ResourceStorediSCSIVolume() *schema.Resource { Type: schema.TypeInt, Computed: true, }, - "snapshot_id": { + names.AttrSnapshotID: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -140,7 +140,7 @@ func resourceStorediSCSIVolumeCreate(ctx context.Context, d *schema.ResourceData Tags: getTagsIn(ctx), } - if v, ok := d.GetOk("snapshot_id"); ok { + if v, ok := d.GetOk(names.AttrSnapshotID); ok { input.SnapshotId = aws.String(v.(string)) } @@ -200,7 +200,7 @@ func resourceStorediSCSIVolumeRead(ctx context.Context, d *schema.ResourceData, arn := aws.StringValue(volume.VolumeARN) d.Set(names.AttrARN, arn) d.Set("disk_id", volume.VolumeDiskId) - d.Set("snapshot_id", volume.SourceSnapshotId) + d.Set(names.AttrSnapshotID, volume.SourceSnapshotId) d.Set("volume_id", volume.VolumeId) d.Set(names.AttrVolumeType, volume.VolumeType) d.Set("volume_size_in_bytes", volume.VolumeSizeInBytes) diff --git a/internal/service/storagegateway/stored_iscsi_volume_test.go b/internal/service/storagegateway/stored_iscsi_volume_test.go index 3dd5b5fc285..05abfdbeae2 100644 --- a/internal/service/storagegateway/stored_iscsi_volume_test.go +++ b/internal/service/storagegateway/stored_iscsi_volume_test.go @@ -45,7 +45,7 @@ func TestAccStorageGatewayStorediSCSIVolume_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "lun_number", acctest.CtZero), resource.TestCheckResourceAttrPair(resourceName, names.AttrNetworkInterfaceID, "aws_instance.test", "private_ip"), resource.TestMatchResourceAttr(resourceName, "network_interface_port", regexache.MustCompile(`^\d+$`)), - resource.TestCheckResourceAttr(resourceName, "snapshot_id", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSnapshotID, ""), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrTargetARN, "storagegateway", regexache.MustCompile(fmt.Sprintf(`gateway/sgw-.+/target/iqn.1997-05.com.amazon:%s`, rName))), resource.TestCheckResourceAttr(resourceName, "target_name", rName), resource.TestMatchResourceAttr(resourceName, "volume_id", regexache.MustCompile(`^vol-+`)), @@ -164,7 +164,7 @@ func TestAccStorageGatewayStorediSCSIVolume_snapshotID(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "lun_number", acctest.CtZero), resource.TestCheckResourceAttrPair(resourceName, names.AttrNetworkInterfaceID, "aws_instance.test", "private_ip"), resource.TestMatchResourceAttr(resourceName, "network_interface_port", regexache.MustCompile(`^\d+$`)), - resource.TestCheckResourceAttrPair(resourceName, "snapshot_id", "aws_ebs_snapshot.test", names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrSnapshotID, "aws_ebs_snapshot.test", names.AttrID), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrTargetARN, "storagegateway", regexache.MustCompile(fmt.Sprintf(`gateway/sgw-.+/target/iqn.1997-05.com.amazon:%s`, rName))), resource.TestCheckResourceAttr(resourceName, "target_name", rName), resource.TestMatchResourceAttr(resourceName, "volume_id", regexache.MustCompile(`^vol-+`)), From dc0fca8713411f9a5b3b125be2c377d5f9b7d7e3 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:07 -0400 Subject: [PATCH 54/62] transcribe: Use constants for strings --- internal/service/transcribe/language_model.go | 6 +++--- internal/service/transcribe/language_model_test.go | 2 +- internal/service/transcribe/medical_vocabulary.go | 8 ++++---- internal/service/transcribe/medical_vocabulary_test.go | 2 +- internal/service/transcribe/vocabulary.go | 8 ++++---- internal/service/transcribe/vocabulary_filter.go | 6 +++--- internal/service/transcribe/vocabulary_filter_test.go | 4 ++-- internal/service/transcribe/vocabulary_test.go | 4 ++-- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/service/transcribe/language_model.go b/internal/service/transcribe/language_model.go index cc2b850a2f6..1467d2d6725 100644 --- a/internal/service/transcribe/language_model.go +++ b/internal/service/transcribe/language_model.go @@ -83,7 +83,7 @@ func ResourceLanguageModel() *schema.Resource { }, }, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -113,7 +113,7 @@ func resourceLanguageModelCreate(ctx context.Context, d *schema.ResourceData, me in := &transcribe.CreateLanguageModelInput{ BaseModelName: types.BaseModelName(d.Get("base_model_name").(string)), - LanguageCode: types.CLMLanguageCode(d.Get("language_code").(string)), + LanguageCode: types.CLMLanguageCode(d.Get(names.AttrLanguageCode).(string)), ModelName: aws.String(d.Get("model_name").(string)), Tags: getTagsIn(ctx), } @@ -173,7 +173,7 @@ func resourceLanguageModelRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, arn) d.Set("base_model_name", out.BaseModelName) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) d.Set("model_name", out.ModelName) if err := d.Set("input_data_config", flattenInputDataConfig(out.InputDataConfig)); err != nil { diff --git a/internal/service/transcribe/language_model_test.go b/internal/service/transcribe/language_model_test.go index f0f308ea8be..baf81f0c091 100644 --- a/internal/service/transcribe/language_model_test.go +++ b/internal/service/transcribe/language_model_test.go @@ -46,7 +46,7 @@ func TestAccTranscribeLanguageModel_basic(t *testing.T) { testAccCheckLanguageModelExists(ctx, resourceName, &languageModel), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "base_model_name", "NarrowBand"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, { diff --git a/internal/service/transcribe/medical_vocabulary.go b/internal/service/transcribe/medical_vocabulary.go index b8de5d28c7b..92ea911f852 100644 --- a/internal/service/transcribe/medical_vocabulary.go +++ b/internal/service/transcribe/medical_vocabulary.go @@ -53,7 +53,7 @@ func ResourceMedicalVocabulary() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -85,7 +85,7 @@ func resourceMedicalVocabularyCreate(ctx context.Context, d *schema.ResourceData in := &transcribe.CreateMedicalVocabularyInput{ VocabularyName: aws.String(vocabularyName), VocabularyFileUri: aws.String(d.Get("vocabulary_file_uri").(string)), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), Tags: getTagsIn(ctx), } @@ -133,7 +133,7 @@ func resourceMedicalVocabularyRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrARN, arn) d.Set("download_uri", out.DownloadUri) d.Set("vocabulary_name", out.VocabularyName) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) return nil } @@ -144,7 +144,7 @@ func resourceMedicalVocabularyUpdate(ctx context.Context, d *schema.ResourceData if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { in := &transcribe.UpdateMedicalVocabularyInput{ VocabularyName: aws.String(d.Id()), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), } if d.HasChanges("vocabulary_file_uri") { diff --git a/internal/service/transcribe/medical_vocabulary_test.go b/internal/service/transcribe/medical_vocabulary_test.go index c6038ce92d0..3b78783a1b5 100644 --- a/internal/service/transcribe/medical_vocabulary_test.go +++ b/internal/service/transcribe/medical_vocabulary_test.go @@ -45,7 +45,7 @@ func TestAccTranscribeMedicalVocabulary_basic(t *testing.T) { testAccCheckMedicalVocabularyExists(ctx, resourceName, &medicalVocabulary), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "download_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, { diff --git a/internal/service/transcribe/vocabulary.go b/internal/service/transcribe/vocabulary.go index 221074d89ab..e1c8f2b7763 100644 --- a/internal/service/transcribe/vocabulary.go +++ b/internal/service/transcribe/vocabulary.go @@ -54,7 +54,7 @@ func ResourceVocabulary() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -97,7 +97,7 @@ func resourceVocabularyCreate(ctx context.Context, d *schema.ResourceData, meta in := &transcribe.CreateVocabularyInput{ VocabularyName: aws.String(d.Get("vocabulary_name").(string)), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), Tags: getTagsIn(ctx), } @@ -153,7 +153,7 @@ func resourceVocabularyRead(ctx context.Context, d *schema.ResourceData, meta in d.Set(names.AttrARN, arn) d.Set("download_uri", out.DownloadUri) d.Set("vocabulary_name", out.VocabularyName) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) return nil } @@ -164,7 +164,7 @@ func resourceVocabularyUpdate(ctx context.Context, d *schema.ResourceData, meta if d.HasChangesExcept(names.AttrTags, names.AttrTagsAll) { in := &transcribe.UpdateVocabularyInput{ VocabularyName: aws.String(d.Id()), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), } if d.HasChanges("vocabulary_file_uri", "phrases") { diff --git a/internal/service/transcribe/vocabulary_filter.go b/internal/service/transcribe/vocabulary_filter.go index 9aa142c70cc..74b4964982b 100644 --- a/internal/service/transcribe/vocabulary_filter.go +++ b/internal/service/transcribe/vocabulary_filter.go @@ -49,7 +49,7 @@ func ResourceVocabularyFilter() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "language_code": { + names.AttrLanguageCode: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -99,7 +99,7 @@ func resourceVocabularyFilterCreate(ctx context.Context, d *schema.ResourceData, in := &transcribe.CreateVocabularyFilterInput{ VocabularyFilterName: aws.String(d.Get("vocabulary_filter_name").(string)), - LanguageCode: types.LanguageCode(d.Get("language_code").(string)), + LanguageCode: types.LanguageCode(d.Get(names.AttrLanguageCode).(string)), Tags: getTagsIn(ctx), } @@ -150,7 +150,7 @@ func resourceVocabularyFilterRead(ctx context.Context, d *schema.ResourceData, m d.Set(names.AttrARN, arn) d.Set("vocabulary_filter_name", out.VocabularyFilterName) - d.Set("language_code", out.LanguageCode) + d.Set(names.AttrLanguageCode, out.LanguageCode) // GovCloud does not set a download URI downloadUri := aws.ToString(out.DownloadUri) diff --git a/internal/service/transcribe/vocabulary_filter_test.go b/internal/service/transcribe/vocabulary_filter_test.go index 6d44f4836fe..ef15693f22e 100644 --- a/internal/service/transcribe/vocabulary_filter_test.go +++ b/internal/service/transcribe/vocabulary_filter_test.go @@ -47,7 +47,7 @@ func TestAccTranscribeVocabularyFilter_basic(t *testing.T) { testAccCheckVocabularyFilterExists(ctx, resourceName, &vocabularyFilter), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "download_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, { @@ -86,7 +86,7 @@ func TestAccTranscribeVocabularyFilter_basicWords(t *testing.T) { testAccCheckVocabularyFilterExists(ctx, resourceName, &vocabularyFilter), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "download_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, }, diff --git a/internal/service/transcribe/vocabulary_test.go b/internal/service/transcribe/vocabulary_test.go index f20921a69a5..d9a1a56690b 100644 --- a/internal/service/transcribe/vocabulary_test.go +++ b/internal/service/transcribe/vocabulary_test.go @@ -47,7 +47,7 @@ func TestAccTranscribeVocabulary_basic(t *testing.T) { testAccCheckVocabularyExists(ctx, resourceName, &vocabulary), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "download_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, { @@ -86,7 +86,7 @@ func TestAccTranscribeVocabulary_basicPhrases(t *testing.T) { testAccCheckVocabularyExists(ctx, resourceName, &vocabulary), resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "download_uri"), - resource.TestCheckResourceAttr(resourceName, "language_code", "en-US"), + resource.TestCheckResourceAttr(resourceName, names.AttrLanguageCode, "en-US"), ), }, }, From 59bc88af3f5cb3c2054089b79951d2f68598400c Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:08 -0400 Subject: [PATCH 55/62] transfer: Use constants for strings --- internal/service/transfer/access.go | 6 +++--- internal/service/transfer/access_test.go | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/transfer/access.go b/internal/service/transfer/access.go index 23974d6d91e..16059aabd25 100644 --- a/internal/service/transfer/access.go +++ b/internal/service/transfer/access.go @@ -34,7 +34,7 @@ func ResourceAccess() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "external_id": { + names.AttrExternalID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), @@ -130,7 +130,7 @@ func resourceAccessCreate(ctx context.Context, d *schema.ResourceData, meta inte var diags diag.Diagnostics conn := meta.(*conns.AWSClient).TransferConn(ctx) - externalID := d.Get("external_id").(string) + externalID := d.Get(names.AttrExternalID).(string) serverID := d.Get("server_id").(string) id := AccessCreateResourceID(serverID, externalID) input := &transfer.CreateAccessInput{ @@ -201,7 +201,7 @@ func resourceAccessRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "reading Transfer Access (%s): %s", d.Id(), err) } - d.Set("external_id", access.ExternalId) + d.Set(names.AttrExternalID, access.ExternalId) d.Set("home_directory", access.HomeDirectory) if err := d.Set("home_directory_mappings", flattenHomeDirectoryMappings(access.HomeDirectoryMappings)); err != nil { return sdkdiag.AppendErrorf(diags, "setting home_directory_mappings: %s", err) diff --git a/internal/service/transfer/access_test.go b/internal/service/transfer/access_test.go index 0b75d490e31..0b1a99ad916 100644 --- a/internal/service/transfer/access_test.go +++ b/internal/service/transfer/access_test.go @@ -40,7 +40,7 @@ func testAccAccess_s3_basic(t *testing.T) { Config: testAccAccessConfig_s3Basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAccessExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "external_id", "S-1-1-12-1234567890-123456789-1234567890-1234"), + resource.TestCheckResourceAttr(resourceName, names.AttrExternalID, "S-1-1-12-1234567890-123456789-1234567890-1234"), resource.TestCheckResourceAttr(resourceName, "home_directory", "/"+rName+"/"), resource.TestCheckResourceAttr(resourceName, "home_directory_type", "PATH"), resource.TestCheckResourceAttrSet(resourceName, names.AttrRole), @@ -56,7 +56,7 @@ func testAccAccess_s3_basic(t *testing.T) { Config: testAccAccessConfig_s3Updated(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAccessExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "external_id", "S-1-1-12-1234567890-123456789-1234567890-1234"), + resource.TestCheckResourceAttr(resourceName, names.AttrExternalID, "S-1-1-12-1234567890-123456789-1234567890-1234"), resource.TestCheckResourceAttr(resourceName, "home_directory", "/"+rName+"/test"), resource.TestCheckResourceAttr(resourceName, "home_directory_type", "PATH"), ), @@ -86,7 +86,7 @@ func testAccAccess_efs_basic(t *testing.T) { Config: testAccAccessConfig_efsBasic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAccessExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "external_id", "S-1-1-12-1234567890-123456789-1234567890-1234"), + resource.TestCheckResourceAttr(resourceName, names.AttrExternalID, "S-1-1-12-1234567890-123456789-1234567890-1234"), resource.TestCheckResourceAttrSet(resourceName, "home_directory"), resource.TestCheckResourceAttr(resourceName, "home_directory_type", "PATH"), resource.TestCheckResourceAttrSet(resourceName, names.AttrRole), @@ -102,7 +102,7 @@ func testAccAccess_efs_basic(t *testing.T) { Config: testAccAccessConfig_efsUpdated(rName), Check: resource.ComposeTestCheckFunc( testAccCheckAccessExists(ctx, resourceName, &conf), - resource.TestCheckResourceAttr(resourceName, "external_id", "S-1-1-12-1234567890-123456789-1234567890-1234"), + resource.TestCheckResourceAttr(resourceName, names.AttrExternalID, "S-1-1-12-1234567890-123456789-1234567890-1234"), resource.TestCheckResourceAttrSet(resourceName, "home_directory"), resource.TestCheckResourceAttr(resourceName, "home_directory_type", "PATH"), resource.TestCheckResourceAttrSet(resourceName, names.AttrRole), From eea9237f6241535e9879fc4d9557a185e6220993 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:08 -0400 Subject: [PATCH 56/62] vpclattice: Use constants for strings --- internal/service/vpclattice/listener.go | 16 ++++++++-------- .../service/vpclattice/listener_data_source.go | 8 ++++---- internal/service/vpclattice/listener_rule.go | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/internal/service/vpclattice/listener.go b/internal/service/vpclattice/listener.go index a10a7500be1..8deba47aa07 100644 --- a/internal/service/vpclattice/listener.go +++ b/internal/service/vpclattice/listener.go @@ -65,7 +65,7 @@ func ResourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, MaxItems: 1, MinItems: 1, @@ -78,7 +78,7 @@ func ResourceListener() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status_code": { + names.AttrStatusCode: { Type: schema.TypeInt, Required: true, }, @@ -170,7 +170,7 @@ func resourceListenerCreate(ctx context.Context, d *schema.ResourceData, meta in in := &vpclattice.CreateListenerInput{ Name: aws.String(d.Get(names.AttrName).(string)), - DefaultAction: expandDefaultAction(d.Get("default_action").([]interface{})), + DefaultAction: expandDefaultAction(d.Get(names.AttrDefaultAction).([]interface{})), Protocol: types.ListenerProtocol(d.Get(names.AttrProtocol).(string)), Tags: getTagsIn(ctx), } @@ -244,7 +244,7 @@ func resourceListenerRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("service_arn", out.ServiceArn) d.Set("service_identifier", out.ServiceId) - if err := d.Set("default_action", flattenListenerRuleActions(out.DefaultAction)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenListenerRuleActions(out.DefaultAction)); err != nil { return create.DiagError(names.VPCLattice, create.ErrActionSetting, ResNameListener, d.Id(), err) } @@ -264,8 +264,8 @@ func resourceListenerUpdate(ctx context.Context, d *schema.ResourceData, meta in } // Cannot edit listener name, protocol, or port after creation - if d.HasChanges("default_action") { - in.DefaultAction = expandDefaultAction(d.Get("default_action").([]interface{})) + if d.HasChanges(names.AttrDefaultAction) { + in.DefaultAction = expandDefaultAction(d.Get(names.AttrDefaultAction).([]interface{})) } log.Printf("[DEBUG] Updating VPC Lattice Listener (%s): %#v", d.Id(), in) @@ -351,7 +351,7 @@ func flattenFixedResponseAction(response *types.FixedResponseAction) []interface tfMap := map[string]interface{}{} if v := response.StatusCode; v != nil { - tfMap["status_code"] = aws.ToInt32(v) + tfMap[names.AttrStatusCode] = aws.ToInt32(v) } return []interface{}{tfMap} @@ -449,7 +449,7 @@ func expandDefaultActionFixedResponseStatus(l []interface{}) *types.FixedRespons fixedResponseAction := &types.FixedResponseAction{} - if v, ok := lRaw["status_code"].(int); ok { + if v, ok := lRaw[names.AttrStatusCode].(int); ok { fixedResponseAction.StatusCode = aws.Int32(int32(v)) } diff --git a/internal/service/vpclattice/listener_data_source.go b/internal/service/vpclattice/listener_data_source.go index 0c47a69d081..c13bd27754f 100644 --- a/internal/service/vpclattice/listener_data_source.go +++ b/internal/service/vpclattice/listener_data_source.go @@ -35,7 +35,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -45,7 +45,7 @@ func DataSourceListener() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status_code": { + names.AttrStatusCode: { Type: schema.TypeInt, Computed: true, }, @@ -148,7 +148,7 @@ func dataSourceListenerRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("service_id", out.ServiceId) // Flatten complex default_action attribute - uses flatteners from listener.go - if err := d.Set("default_action", flattenListenerRuleActionsDataSource(out.DefaultAction)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenListenerRuleActionsDataSource(out.DefaultAction)); err != nil { return create.DiagError(names.VPCLattice, create.ErrActionSetting, DSNameListener, d.Id(), err) } @@ -216,7 +216,7 @@ func flattenRuleActionMemberFixedResponseDataSource(response *types.FixedRespons tfMap := map[string]interface{}{} if v := response.StatusCode; v != nil { - tfMap["status_code"] = aws.ToInt32(v) + tfMap[names.AttrStatusCode] = aws.ToInt32(v) } return []interface{}{tfMap} diff --git a/internal/service/vpclattice/listener_rule.go b/internal/service/vpclattice/listener_rule.go index c6b3fdb7dee..5b85b1bf528 100644 --- a/internal/service/vpclattice/listener_rule.go +++ b/internal/service/vpclattice/listener_rule.go @@ -73,7 +73,7 @@ func ResourceListenerRule() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "status_code": { + names.AttrStatusCode: { Type: schema.TypeInt, Required: true, }, @@ -438,7 +438,7 @@ func flattenRuleActionMemberFixedResponse(apiObject *types.RuleActionMemberFixed tfMap := map[string]interface{}{} if v := apiObject.Value.StatusCode; v != nil { - tfMap["status_code"] = aws.ToInt32(v) + tfMap[names.AttrStatusCode] = aws.ToInt32(v) } return tfMap @@ -688,7 +688,7 @@ func expandRuleAction(tfMap map[string]interface{}) types.RuleAction { func expandFixedResponseAction(tfMap map[string]interface{}) *types.RuleActionMemberFixedResponse { apiObject := &types.RuleActionMemberFixedResponse{} - if v, ok := tfMap["status_code"].(int); ok && v != 0 { + if v, ok := tfMap[names.AttrStatusCode].(int); ok && v != 0 { apiObject.Value.StatusCode = aws.Int32(int32(v)) } From f235205a6d880af85bd398460c87425d5ad2d9e8 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:08 -0400 Subject: [PATCH 57/62] waf: Use constants for strings --- internal/service/waf/web_acl.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/waf/web_acl.go b/internal/service/waf/web_acl.go index b5d8be6451e..5a1ca0df2e3 100644 --- a/internal/service/waf/web_acl.go +++ b/internal/service/waf/web_acl.go @@ -49,7 +49,7 @@ func resourceWebACL() *schema.Resource { Required: true, ForceNew: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -170,7 +170,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte output, err := newRetryer(conn).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), Tags: getTagsIn(ctx), @@ -207,7 +207,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte _, err := newRetryer(conn).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules([]interface{}{}, rules), WebACLId: aws.String(d.Id()), } @@ -241,7 +241,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf arn := aws.ToString(webACL.WebACLArn) d.Set(names.AttrARN, arn) - if err := d.Set("default_action", flattenAction(webACL.DefaultAction)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenAction(webACL.DefaultAction)); err != nil { return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set(names.AttrMetricName, webACL.MetricName) @@ -276,14 +276,14 @@ func resourceWebACLUpdate(ctx context.Context, d *schema.ResourceData, meta inte var diags diag.Diagnostics conn := meta.(*conns.AWSClient).WAFClient(ctx) - if d.HasChanges("default_action", "rules") { + if d.HasChanges(names.AttrDefaultAction, "rules") { o, n := d.GetChange("rules") oldR, newR := o.(*schema.Set).List(), n.(*schema.Set).List() _, err := newRetryer(conn).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules(oldR, newR), WebACLId: aws.String(d.Id()), } @@ -332,7 +332,7 @@ func resourceWebACLDelete(ctx context.Context, d *schema.ResourceData, meta inte _, err := newRetryer(conn).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules(rules, []interface{}{}), WebACLId: aws.String(d.Id()), } From e1d6b4f4774cd0dc71b265030dfb9fab4ff9b322 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:08 -0400 Subject: [PATCH 58/62] wafregional: Use constants for strings --- internal/service/wafregional/web_acl.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/wafregional/web_acl.go b/internal/service/wafregional/web_acl.go index c3348cc4717..6e7f0a22f89 100644 --- a/internal/service/wafregional/web_acl.go +++ b/internal/service/wafregional/web_acl.go @@ -42,7 +42,7 @@ func resourceWebACL() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -173,7 +173,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte output, err := newRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &wafregional.CreateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), Tags: getTagsIn(ctx), @@ -212,7 +212,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte _, err := newRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &wafregional.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules([]interface{}{}, rules), WebACLId: aws.String(d.Id()), } @@ -252,7 +252,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf Resource: "webacl/" + d.Id(), }.String() d.Set(names.AttrARN, arn) - if err := d.Set("default_action", flattenAction(webACL.DefaultAction)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenAction(webACL.DefaultAction)); err != nil { return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set(names.AttrMetricName, webACL.MetricName) @@ -288,14 +288,14 @@ func resourceWebACLUpdate(ctx context.Context, d *schema.ResourceData, meta inte conn := meta.(*conns.AWSClient).WAFRegionalClient(ctx) region := meta.(*conns.AWSClient).Region - if d.HasChanges("default_action", names.AttrRule) { + if d.HasChanges(names.AttrDefaultAction, names.AttrRule) { o, n := d.GetChange(names.AttrRule) oldR, newR := o.(*schema.Set).List(), n.(*schema.Set).List() _, err := newRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &wafregional.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules(oldR, newR), WebACLId: aws.String(d.Id()), } @@ -344,7 +344,7 @@ func resourceWebACLDelete(ctx context.Context, d *schema.ResourceData, meta inte _, err := newRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &wafregional.UpdateWebACLInput{ ChangeToken: token, - DefaultAction: expandAction(d.Get("default_action").([]interface{})), + DefaultAction: expandAction(d.Get(names.AttrDefaultAction).([]interface{})), Updates: diffWebACLRules(rules, []interface{}{}), WebACLId: aws.String(d.Id()), } From ce4912c70b9f2a7a50d78970c328d85b92610a90 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:08 -0400 Subject: [PATCH 59/62] wafv2: Use constants for strings --- internal/service/wafv2/flex.go | 4 ++-- internal/service/wafv2/schemas.go | 2 +- internal/service/wafv2/web_acl.go | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/internal/service/wafv2/flex.go b/internal/service/wafv2/flex.go index 157743b4a56..3c51a665c0d 100644 --- a/internal/service/wafv2/flex.go +++ b/internal/service/wafv2/flex.go @@ -1378,7 +1378,7 @@ func expandResponseInspection(tfList []interface{}) *awstypes.ResponseInspection if v, ok := m[names.AttrJSON].([]interface{}); ok && len(v) > 0 { out.Json = expandResponseInspectionJSON(v) } - if v, ok := m["status_code"].([]interface{}); ok && len(v) > 0 { + if v, ok := m[names.AttrStatusCode].([]interface{}); ok && len(v) > 0 { out.StatusCode = expandStatusCode(v) } @@ -2774,7 +2774,7 @@ func flattenResponseInspection(apiObject *awstypes.ResponseInspection) []interfa m[names.AttrJSON] = flattenResponseInspectionJSON(apiObject.Json) } if apiObject.StatusCode != nil { - m["status_code"] = flattenStatusCode(apiObject.StatusCode) + m[names.AttrStatusCode] = flattenStatusCode(apiObject.StatusCode) } return []interface{}{m} diff --git a/internal/service/wafv2/schemas.go b/internal/service/wafv2/schemas.go index 1819d9bc1f5..d7bc4a6e514 100644 --- a/internal/service/wafv2/schemas.go +++ b/internal/service/wafv2/schemas.go @@ -1542,7 +1542,7 @@ func managedRuleGroupConfigATPResponseInspectionSchema() *schema.Schema { }, }, }, - "status_code": { + names.AttrStatusCode: { Type: schema.TypeList, Optional: true, MaxItems: 1, diff --git a/internal/service/wafv2/web_acl.go b/internal/service/wafv2/web_acl.go index d0fa3785264..1196d11dc85 100644 --- a/internal/service/wafv2/web_acl.go +++ b/internal/service/wafv2/web_acl.go @@ -77,7 +77,7 @@ func resourceWebACL() *schema.Resource { "captcha_config": outerCaptchaConfigSchema(), "challenge_config": outerChallengeConfigSchema(), "custom_response_body": customResponseBodySchema(), - "default_action": { + names.AttrDefaultAction: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -187,7 +187,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte AssociationConfig: expandAssociationConfig(d.Get("association_config").([]interface{})), CaptchaConfig: expandCaptchaConfig(d.Get("captcha_config").([]interface{})), ChallengeConfig: expandChallengeConfig(d.Get("challenge_config").([]interface{})), - DefaultAction: expandDefaultAction(d.Get("default_action").([]interface{})), + DefaultAction: expandDefaultAction(d.Get(names.AttrDefaultAction).([]interface{})), Name: aws.String(name), Rules: expandWebACLRules(d.Get(names.AttrRule).(*schema.Set).List()), Scope: awstypes.Scope(d.Get(names.AttrScope).(string)), @@ -253,7 +253,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf if err := d.Set("custom_response_body", flattenCustomResponseBodies(webACL.CustomResponseBodies)); err != nil { return diag.Errorf("setting custom_response_body: %s", err) } - if err := d.Set("default_action", flattenDefaultAction(webACL.DefaultAction)); err != nil { + if err := d.Set(names.AttrDefaultAction, flattenDefaultAction(webACL.DefaultAction)); err != nil { return diag.Errorf("setting default_action: %s", err) } d.Set(names.AttrDescription, webACL.Description) @@ -294,7 +294,7 @@ func resourceWebACLUpdate(ctx context.Context, d *schema.ResourceData, meta inte AssociationConfig: expandAssociationConfig(d.Get("association_config").([]interface{})), CaptchaConfig: expandCaptchaConfig(d.Get("captcha_config").([]interface{})), ChallengeConfig: expandChallengeConfig(d.Get("challenge_config").([]interface{})), - DefaultAction: expandDefaultAction(d.Get("default_action").([]interface{})), + DefaultAction: expandDefaultAction(d.Get(names.AttrDefaultAction).([]interface{})), Id: aws.String(aclID), LockToken: aws.String(aclLockToken), Name: aws.String(aclName), From 841a43160c72f0c60992c5c2161cf9c03e232c85 Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:53:09 -0400 Subject: [PATCH 60/62] names: Use constants for strings --- names/attr_constants.csv | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/names/attr_constants.csv b/names/attr_constants.csv index 8ce0920be20..53574cef4bd 100644 --- a/names/attr_constants.csv +++ b/names/attr_constants.csv @@ -34,6 +34,7 @@ creation_date,CreationDate creation_time,CreationTime database,Database database_name,DatabaseName +default_action,DefaultAction default_value,DefaultValue delete_on_termination,DeleteOnTermination description,Description @@ -56,10 +57,12 @@ engine_version,EngineVersion environment,Environment execution_role_arn,ExecutionRoleARN expression,Expression +external_id,ExternalID family,Family field,Field file_system_id,FileSystemID filter,Filter +force_delete,ForceDelete force_destroy,ForceDestroy format,Format function_arn,FunctionARN @@ -85,11 +88,13 @@ key_id,KeyID kms_key,KMSKey kms_key_arn,KMSKeyARN kms_key_id,KMSKeyID +language_code,LanguageCode last_updated_date,LastUpdatedDate launch_template,LaunchTemplate log_group_name,LogGroupName logging_configuration,LoggingConfiguration max,Max +max_capacity,MaxCapacity message,Message metric_name,MetricName min,Min @@ -116,8 +121,10 @@ principal,Principal priority,Priority private_key,PrivateKey profile,Profile +propagate_tags,PropagateTags properties,Properties protocol,Protocol +provider_name,ProviderName public_key,PublicKey publicly_accessible,PubliclyAccessible region,Region @@ -142,6 +149,7 @@ secret_key,SecretKey security_group_ids,SecurityGroupIDs security_groups,SecurityGroups service_name,ServiceName +service_role,ServiceRole service_role_arn,ServiceRoleARN session,Session shared_config_files,SharedConfigFiles @@ -149,6 +157,7 @@ size,Size skip_credentials_validation,SkipCredentialsValidation skip_destroy,SkipDestroy skip_requesting_account_id,SkipRequestingAccountID +snapshot_id,SnapshotID sns_topic_arn,SNSTopicARN source,Source source_type,SourceType @@ -156,7 +165,9 @@ stage,Stage start_time,StartTime state,State status,Status +status_code,StatusCode status_message,StatusMessage +status_reason,StatusReason storage_type,StorageType stream_arn,StreamARN subnet_id,SubnetID From d862d1fbc52bc3665110264b10e3dd82fd03279d Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 19:59:52 -0400 Subject: [PATCH 61/62] Fix format --- .../service/apigatewayv2/integration_test.go | 6 +-- internal/service/appsync/graphql_api.go | 4 +- .../service/autoscalingplans/scaling_plan.go | 2 +- .../autoscalingplans/scaling_plan_test.go | 12 +++--- .../bedrock/foundation_models_data_source.go | 2 +- internal/service/cognitoidentity/pool_test.go | 6 +-- internal/service/dynamodb/table_test.go | 40 +++++++++---------- internal/service/ec2/ec2_ami_data_source.go | 2 +- internal/service/elbv2/listener.go | 14 +++---- internal/service/medialive/channel.go | 8 ++-- .../channel_encoder_settings_schema.go | 6 +-- .../service/medialive/multiplex_program.go | 4 +- internal/service/neptune/cluster.go | 2 +- .../service/polly/voices_data_source_test.go | 8 ++-- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/internal/service/apigatewayv2/integration_test.go b/internal/service/apigatewayv2/integration_test.go index 4cab7382dcb..20c02b15774 100644 --- a/internal/service/apigatewayv2/integration_test.go +++ b/internal/service/apigatewayv2/integration_test.go @@ -173,13 +173,13 @@ func TestAccAPIGatewayV2Integration_dataMappingHTTP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "request_templates.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "response_parameters.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - names.AttrStatusCode: "500", + names.AttrStatusCode: "500", "mappings.%": acctest.CtTwo, "mappings.append:header.header1": "$context.requestId", "mappings.overwrite:statuscode": "403", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - names.AttrStatusCode: "404", + names.AttrStatusCode: "404", "mappings.%": acctest.CtOne, "mappings.append:header.error": "$stageVariables.environmentId", }), @@ -210,7 +210,7 @@ func TestAccAPIGatewayV2Integration_dataMappingHTTP(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "request_templates.%", acctest.CtZero), resource.TestCheckResourceAttr(resourceName, "response_parameters.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "response_parameters.*", map[string]string{ - names.AttrStatusCode: "500", + names.AttrStatusCode: "500", "mappings.%": acctest.CtTwo, "mappings.append:header.header1": "$context.requestId", "mappings.overwrite:statuscode": "403", diff --git a/internal/service/appsync/graphql_api.go b/internal/service/appsync/graphql_api.go index 8e3b628accf..cefd2bb9e64 100644 --- a/internal/service/appsync/graphql_api.go +++ b/internal/service/appsync/graphql_api.go @@ -772,9 +772,9 @@ func flattenGraphQLAPIUserPoolConfig(userPoolConfig *appsync.UserPoolConfig) []i } m := map[string]interface{}{ - "aws_region": aws.StringValue(userPoolConfig.AwsRegion), + "aws_region": aws.StringValue(userPoolConfig.AwsRegion), names.AttrDefaultAction: aws.StringValue(userPoolConfig.DefaultAction), - "user_pool_id": aws.StringValue(userPoolConfig.UserPoolId), + "user_pool_id": aws.StringValue(userPoolConfig.UserPoolId), } if userPoolConfig.AppIdClientRegex != nil { diff --git a/internal/service/autoscalingplans/scaling_plan.go b/internal/service/autoscalingplans/scaling_plan.go index 2eadb0198e3..ad856f57f9b 100644 --- a/internal/service/autoscalingplans/scaling_plan.go +++ b/internal/service/autoscalingplans/scaling_plan.go @@ -731,7 +731,7 @@ func flattenScalingInstructions(scalingInstructions []awstypes.ScalingInstructio for _, scalingInstruction := range scalingInstructions { mScalingInstruction := map[string]interface{}{ "disable_dynamic_scaling": aws.ToBool(scalingInstruction.DisableDynamicScaling), - names.AttrMaxCapacity: int(aws.ToInt32(scalingInstruction.MaxCapacity)), + names.AttrMaxCapacity: int(aws.ToInt32(scalingInstruction.MaxCapacity)), "min_capacity": int(aws.ToInt32(scalingInstruction.MinCapacity)), "predictive_scaling_max_capacity_behavior": scalingInstruction.PredictiveScalingMaxCapacityBehavior, "predictive_scaling_max_capacity_buffer": int(aws.ToInt32(scalingInstruction.PredictiveScalingMaxCapacityBuffer)), diff --git a/internal/service/autoscalingplans/scaling_plan_test.go b/internal/service/autoscalingplans/scaling_plan_test.go index f8660ac3449..ab217ec7111 100644 --- a/internal/service/autoscalingplans/scaling_plan_test.go +++ b/internal/service/autoscalingplans/scaling_plan_test.go @@ -50,7 +50,7 @@ func TestAccAutoScalingPlansScalingPlan_basicDynamicScaling(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -110,7 +110,7 @@ func TestAccAutoScalingPlansScalingPlan_basicPredictiveScaling(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "true", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtOne, "predefined_load_metric_specification.0.predefined_load_metric_type": "ASGTotalCPUUtilization", @@ -174,7 +174,7 @@ func TestAccAutoScalingPlansScalingPlan_basicUpdate(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -207,7 +207,7 @@ func TestAccAutoScalingPlansScalingPlan_basicUpdate(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "true", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtOne, "predefined_load_metric_specification.0.predefined_load_metric_type": "ASGTotalCPUUtilization", @@ -291,7 +291,7 @@ func TestAccAutoScalingPlansScalingPlan_DynamicScaling_customizedScalingMetricSp resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), @@ -330,7 +330,7 @@ func TestAccAutoScalingPlansScalingPlan_DynamicScaling_customizedScalingMetricSp resource.TestCheckTypeSetElemNestedAttrs(resourceName, "scaling_instruction.*", map[string]string{ "customized_load_metric_specification.#": acctest.CtZero, "disable_dynamic_scaling": "false", - names.AttrMaxCapacity: acctest.CtThree, + names.AttrMaxCapacity: acctest.CtThree, "min_capacity": acctest.CtZero, "predefined_load_metric_specification.#": acctest.CtZero, names.AttrResourceID: fmt.Sprintf("autoScalingGroup/%s", rName), diff --git a/internal/service/bedrock/foundation_models_data_source.go b/internal/service/bedrock/foundation_models_data_source.go index ce071eae625..24730098de8 100644 --- a/internal/service/bedrock/foundation_models_data_source.go +++ b/internal/service/bedrock/foundation_models_data_source.go @@ -68,7 +68,7 @@ func (d *foundationModelsDataSource) Schema(ctx context.Context, request datasou "model_id": types.StringType, "model_name": types.StringType, "output_modalities": types.SetType{ElemType: types.StringType}, - names.AttrProviderName: types.StringType, + names.AttrProviderName: types.StringType, "response_streaming_supported": types.BoolType, }, }, diff --git a/internal/service/cognitoidentity/pool_test.go b/internal/service/cognitoidentity/pool_test.go index b758352c862..cc350dc3010 100644 --- a/internal/service/cognitoidentity/pool_test.go +++ b/internal/service/cognitoidentity/pool_test.go @@ -271,12 +271,12 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", - names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", - names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Ab129faBb", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Ab129faBb", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), ), @@ -295,7 +295,7 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ names.AttrClientID: "6lhlkkfbfb4q5kpp90urffae", - names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), + names.AttrProviderName: fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Zr231apJu", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), ), diff --git a/internal/service/dynamodb/table_test.go b/internal/service/dynamodb/table_test.go index dd99b7380fc..16379be1378 100644 --- a/internal/service/dynamodb/table_test.go +++ b/internal/service/dynamodb/table_test.go @@ -2077,11 +2077,11 @@ func TestAccDynamoDBTable_Replica_tagsOneOfTwo(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 0), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "false", }), ), @@ -2117,11 +2117,11 @@ func TestAccDynamoDBTable_Replica_tagsTwoOfTwo(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 3), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "true", }), ), @@ -2156,7 +2156,7 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.AlternateRegion(), 2), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), ), @@ -2169,11 +2169,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 2), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "true", }), ), @@ -2185,7 +2185,7 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.AlternateRegion(), 2), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), ), @@ -2198,11 +2198,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 0), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "false", }), ), @@ -2215,11 +2215,11 @@ func TestAccDynamoDBTable_Replica_tagsNext(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 0), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "false", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "false", }), ), @@ -2254,7 +2254,7 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.AlternateRegion(), 2), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), ), @@ -2266,7 +2266,7 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.AlternateRegion(), 4), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtOne), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), ), @@ -2279,11 +2279,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 4), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "true", }), ), @@ -2296,11 +2296,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 6), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "true", }), ), @@ -2313,11 +2313,11 @@ func TestAccDynamoDBTable_Replica_tagsUpdate(t *testing.T) { testAccCheckReplicaHasTags(ctx, resourceName, acctest.ThirdRegion(), 1), resource.TestCheckResourceAttr(resourceName, "replica.#", acctest.CtTwo), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.AlternateRegion(), + "region_name": acctest.AlternateRegion(), names.AttrPropagateTags: "true", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "replica.*", map[string]string{ - "region_name": acctest.ThirdRegion(), + "region_name": acctest.ThirdRegion(), names.AttrPropagateTags: "true", }), ), diff --git a/internal/service/ec2/ec2_ami_data_source.go b/internal/service/ec2/ec2_ami_data_source.go index d94e408c44c..01b56c4fd41 100644 --- a/internal/service/ec2/ec2_ami_data_source.go +++ b/internal/service/ec2/ec2_ami_data_source.go @@ -366,7 +366,7 @@ func flattenAMIBlockDeviceMappings(m []*ec2.BlockDeviceMapping) *schema.Set { names.AttrIOPS: fmt.Sprintf("%d", aws.Int64Value(v.Ebs.Iops)), "throughput": fmt.Sprintf("%d", aws.Int64Value(v.Ebs.Throughput)), names.AttrVolumeSize: fmt.Sprintf("%d", aws.Int64Value(v.Ebs.VolumeSize)), - names.AttrSnapshotID: aws.StringValue(v.Ebs.SnapshotId), + names.AttrSnapshotID: aws.StringValue(v.Ebs.SnapshotId), names.AttrVolumeType: aws.StringValue(v.Ebs.VolumeType), } diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index 069e8413d44..181c549470e 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -1120,7 +1120,7 @@ func flattenLbListenerActionFixedResponseConfig(config *awstypes.FixedResponseAc m := map[string]interface{}{ names.AttrContentType: aws.ToString(config.ContentType), "message_body": aws.ToString(config.MessageBody), - names.AttrStatusCode: aws.ToString(config.StatusCode), + names.AttrStatusCode: aws.ToString(config.StatusCode), } return []interface{}{m} @@ -1177,12 +1177,12 @@ func flattenLbListenerActionRedirectConfig(config *awstypes.RedirectActionConfig } m := map[string]interface{}{ - "host": aws.ToString(config.Host), - names.AttrPath: aws.ToString(config.Path), - names.AttrPort: aws.ToString(config.Port), - names.AttrProtocol: aws.ToString(config.Protocol), - "query": aws.ToString(config.Query), - names.AttrStatusCode: string(config.StatusCode), + "host": aws.ToString(config.Host), + names.AttrPath: aws.ToString(config.Path), + names.AttrPort: aws.ToString(config.Port), + names.AttrProtocol: aws.ToString(config.Protocol), + "query": aws.ToString(config.Query), + names.AttrStatusCode: string(config.StatusCode), } return []interface{}{m} diff --git a/internal/service/medialive/channel.go b/internal/service/medialive/channel.go index 3e66e3c449c..c0e399562c3 100644 --- a/internal/service/medialive/channel.go +++ b/internal/service/medialive/channel.go @@ -1836,7 +1836,7 @@ func flattenInputAttachmentsInputSettingsAudioSelectorsSelectorSettingsAudioLang } m := map[string]interface{}{ - names.AttrLanguageCode: aws.ToString(in.LanguageCode), + names.AttrLanguageCode: aws.ToString(in.LanguageCode), "language_selection_policy": string(in.LanguageSelectionPolicy), } @@ -1907,9 +1907,9 @@ func flattenInputAttachmentsInputSettingsCaptionSelectors(tfList []types.Caption for _, v := range tfList { m := map[string]interface{}{ - names.AttrName: aws.ToString(v.Name), - names.AttrLanguageCode: aws.ToString(v.LanguageCode), - "selector_settings": flattenInputAttachmentsInputSettingsCaptionSelectorsSelectorSettings(v.SelectorSettings), + names.AttrName: aws.ToString(v.Name), + names.AttrLanguageCode: aws.ToString(v.LanguageCode), + "selector_settings": flattenInputAttachmentsInputSettingsCaptionSelectorsSelectorSettings(v.SelectorSettings), } out = append(out, m) diff --git a/internal/service/medialive/channel_encoder_settings_schema.go b/internal/service/medialive/channel_encoder_settings_schema.go index 2f7df56bdfa..ac438b0ef86 100644 --- a/internal/service/medialive/channel_encoder_settings_schema.go +++ b/internal/service/medialive/channel_encoder_settings_schema.go @@ -5821,7 +5821,7 @@ func flattenAudioDescriptions(od []types.AudioDescription) []interface{} { "audio_type_control": v.AudioTypeControl, "audio_watermark_settings": flattenAudioWatermarkSettings(v.AudioWatermarkingSettings), "codec_settings": flattenAudioDescriptionsCodecSettings(v.CodecSettings), - names.AttrLanguageCode: aws.ToString(v.LanguageCode), + names.AttrLanguageCode: aws.ToString(v.LanguageCode), "language_code_control": string(v.LanguageCodeControl), "remix_settings": flattenAudioDescriptionsRemixSettings(v.RemixSettings), "stream_name": aws.ToString(v.StreamName), @@ -6376,7 +6376,7 @@ func flattenHLSCaptionLanguageMappings(in []types.CaptionLanguageMapping) []inte for _, item := range in { m := map[string]interface{}{ "caption_channel": int(aws.ToInt32(item.CaptionChannel)), - names.AttrLanguageCode: aws.ToString(item.LanguageCode), + names.AttrLanguageCode: aws.ToString(item.LanguageCode), "language_description": aws.ToString(item.LanguageDescription), } @@ -6695,7 +6695,7 @@ func flattenCaptionDescriptions(tfList []types.CaptionDescription) []interface{} names.AttrName: aws.ToString(item.Name), "accessibility": string(item.Accessibility), "destination_settings": flattenCaptionDescriptionsCaptionDestinationSettings(item.DestinationSettings), - names.AttrLanguageCode: aws.ToString(item.LanguageCode), + names.AttrLanguageCode: aws.ToString(item.LanguageCode), "language_description": aws.ToString(item.LanguageDescription), } diff --git a/internal/service/medialive/multiplex_program.go b/internal/service/medialive/multiplex_program.go index a712c3d615d..2f3c40693f1 100644 --- a/internal/service/medialive/multiplex_program.go +++ b/internal/service/medialive/multiplex_program.go @@ -495,8 +495,8 @@ var ( } serviceDescriptorAttrs = map[string]attr.Type{ - names.AttrProviderName: types.StringType, - names.AttrServiceName: types.StringType, + names.AttrProviderName: types.StringType, + names.AttrServiceName: types.StringType, } multiplexProgramSettingsAttrs = map[string]attr.Type{ diff --git a/internal/service/neptune/cluster.go b/internal/service/neptune/cluster.go index 19ab26ef214..42762e77daf 100644 --- a/internal/service/neptune/cluster.go +++ b/internal/service/neptune/cluster.go @@ -989,7 +989,7 @@ func flattenServerlessV2ScalingConfigurationInfo(serverlessConfig *neptune.Serve } m := map[string]interface{}{ - "min_capacity": aws.Float64Value(serverlessConfig.MinCapacity), + "min_capacity": aws.Float64Value(serverlessConfig.MinCapacity), names.AttrMaxCapacity: aws.Float64Value(serverlessConfig.MaxCapacity), } diff --git a/internal/service/polly/voices_data_source_test.go b/internal/service/polly/voices_data_source_test.go index d329c2b42cb..ed4041b2b01 100644 --- a/internal/service/polly/voices_data_source_test.go +++ b/internal/service/polly/voices_data_source_test.go @@ -31,9 +31,9 @@ func TestAccPollyVoicesDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( // verify a known voice is returned in the results resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "voices.*", map[string]string{ - "gender": "Female", + "gender": "Female", names.AttrLanguageCode: "en-US", - names.AttrName: "Kendra", + names.AttrName: "Kendra", }), ), }, @@ -59,9 +59,9 @@ func TestAccPollyVoicesDataSource_languageCode(t *testing.T) { Check: resource.ComposeTestCheckFunc( // verify a known voice is returned in the results resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "voices.*", map[string]string{ - "gender": "Female", + "gender": "Female", names.AttrLanguageCode: "en-US", - names.AttrName: "Kendra", + names.AttrName: "Kendra", }), ), }, From 01d910b3e3e580b7b9fdb6216ff6d46138bfd0ec Mon Sep 17 00:00:00 2001 From: Dirk Avery Date: Tue, 14 May 2024 20:02:58 -0400 Subject: [PATCH 62/62] Fix imports --- internal/service/apigateway/gateway_response.go | 1 + internal/service/autoscaling/sweep.go | 1 + internal/service/cognitoidp/identity_provider.go | 1 + internal/service/ecr/sweep.go | 1 + 4 files changed, 4 insertions(+) diff --git a/internal/service/apigateway/gateway_response.go b/internal/service/apigateway/gateway_response.go index a6d4427ab99..2dd6a3a302b 100644 --- a/internal/service/apigateway/gateway_response.go +++ b/internal/service/apigateway/gateway_response.go @@ -20,6 +20,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_api_gateway_gateway_response", name="Gateway Response") diff --git a/internal/service/autoscaling/sweep.go b/internal/service/autoscaling/sweep.go index f7f0d09fd14..4c8100c99b1 100644 --- a/internal/service/autoscaling/sweep.go +++ b/internal/service/autoscaling/sweep.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" + "github.com/hashicorp/terraform-provider-aws/names" ) func RegisterSweepers() { diff --git a/internal/service/cognitoidp/identity_provider.go b/internal/service/cognitoidp/identity_provider.go index 499e02214d4..d27f5ccc00e 100644 --- a/internal/service/cognitoidp/identity_provider.go +++ b/internal/service/cognitoidp/identity_provider.go @@ -21,6 +21,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_cognito_identity_provider", name="Identity Provider") diff --git a/internal/service/ecr/sweep.go b/internal/service/ecr/sweep.go index bdfd7aec118..623ceb1d576 100644 --- a/internal/service/ecr/sweep.go +++ b/internal/service/ecr/sweep.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" + "github.com/hashicorp/terraform-provider-aws/names" ) func RegisterSweepers() {