diff --git a/.ci/.semgrep-constants.yml b/.ci/.semgrep-constants.yml index 0b69a712e66..423e7cbeb10 100644 --- a/.ci/.semgrep-constants.yml +++ b/.ci/.semgrep-constants.yml @@ -160,6 +160,16 @@ rules: - pattern: '"certificate_arn"' severity: ERROR fix: "names.AttrCertificateARN" + - id: literal-client_id-string-constant + languages: [go] + message: Use the constant `names.AttrClientID` for the string literal "client_id" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"client_id"' + severity: ERROR + fix: "names.AttrClientID" - id: literal-cluster_identifier-string-constant languages: [go] message: Use the constant `names.AttrClusterIdentifier` for the string literal "cluster_identifier" @@ -390,6 +400,16 @@ rules: - pattern: '"execution_role_arn"' severity: ERROR fix: "names.AttrExecutionRoleARN" + - id: literal-expression-string-constant + languages: [go] + message: Use the constant `names.AttrExpression` for the string literal "expression" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"expression"' + severity: ERROR + fix: "names.AttrExpression" - id: literal-file_system_id-string-constant languages: [go] message: Use the constant `names.AttrFileSystemID` for the string literal "file_system_id" @@ -430,6 +450,16 @@ rules: - pattern: '"format"' severity: ERROR fix: "names.AttrFormat" + - id: literal-group_name-string-constant + languages: [go] + message: Use the constant `names.AttrGroupName` for the string literal "group_name" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"group_name"' + severity: ERROR + fix: "names.AttrGroupName" - id: literal-hosted_zone_id-string-constant languages: [go] message: Use the constant `names.AttrHostedZoneID` for the string literal "hosted_zone_id" @@ -450,6 +480,16 @@ rules: - pattern: '"id"' severity: ERROR fix: "names.AttrID" + - id: literal-ip_address-string-constant + languages: [go] + message: Use the constant `names.AttrIPAddress` for the string literal "ip_address" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"ip_address"' + severity: ERROR + fix: "names.AttrIPAddress" - id: literal-identifier-string-constant languages: [go] message: Use the constant `names.AttrIdentifier` for the string literal "identifier" @@ -540,6 +580,16 @@ rules: - pattern: '"max"' severity: ERROR fix: "names.AttrMax" + - id: literal-metric_name-string-constant + languages: [go] + message: Use the constant `names.AttrMetricName` for the string literal "metric_name" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"metric_name"' + severity: ERROR + fix: "names.AttrMetricName" - id: literal-min-string-constant languages: [go] message: Use the constant `names.AttrMin` for the string literal "min" @@ -700,6 +750,16 @@ rules: - pattern: '"prefix"' severity: ERROR fix: "names.AttrPrefix" + - id: literal-principal-string-constant + languages: [go] + message: Use the constant `names.AttrPrincipal` for the string literal "principal" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"principal"' + severity: ERROR + fix: "names.AttrPrincipal" - id: literal-priority-string-constant languages: [go] message: Use the constant `names.AttrPriority` for the string literal "priority" @@ -710,6 +770,16 @@ rules: - pattern: '"priority"' severity: ERROR fix: "names.AttrPriority" + - id: literal-private_key-string-constant + languages: [go] + message: Use the constant `names.AttrPrivateKey` for the string literal "private_key" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"private_key"' + severity: ERROR + fix: "names.AttrPrivateKey" - id: literal-profile-string-constant languages: [go] message: Use the constant `names.AttrProfile` for the string literal "profile" @@ -720,6 +790,16 @@ rules: - pattern: '"profile"' severity: ERROR fix: "names.AttrProfile" + - id: literal-properties-string-constant + languages: [go] + message: Use the constant `names.AttrProperties` for the string literal "properties" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"properties"' + severity: ERROR + fix: "names.AttrProperties" - id: literal-protocol-string-constant languages: [go] message: Use the constant `names.AttrProtocol` for the string literal "protocol" @@ -800,6 +880,16 @@ rules: - pattern: '"sns_topic_arn"' severity: ERROR fix: "names.AttrSNSTopicARN" + - id: literal-schedule-string-constant + languages: [go] + message: Use the constant `names.AttrSchedule` for the string literal "schedule" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"schedule"' + severity: ERROR + fix: "names.AttrSchedule" - id: literal-schedule_expression-string-constant languages: [go] message: Use the constant `names.AttrScheduleExpression` for the string literal "schedule_expression" @@ -1060,6 +1150,16 @@ rules: - pattern: '"username"' severity: ERROR fix: "names.AttrUsername" + - id: literal-vpc_config-string-constant + languages: [go] + message: Use the constant `names.AttrVPCConfig` for the string literal "vpc_config" + paths: + include: + - "internal/service/**/*.go" + patterns: + - pattern: '"vpc_config"' + severity: ERROR + fix: "names.AttrVPCConfig" - id: literal-vpc_id-string-constant languages: [go] message: Use the constant `names.AttrVPCID` for the string literal "vpc_id" diff --git a/internal/service/acm/certificate.go b/internal/service/acm/certificate.go index a1c76180533..1d6df83d364 100644 --- a/internal/service/acm/certificate.go +++ b/internal/service/acm/certificate.go @@ -76,12 +76,12 @@ func resourceCertificate() *schema.Resource { Optional: true, ForceNew: true, ValidateFunc: verify.ValidARN, - ConflictsWith: []string{"certificate_body", "private_key", "validation_method"}, + ConflictsWith: []string{"certificate_body", names.AttrPrivateKey, "validation_method"}, }, "certificate_body": { Type: schema.TypeString, Optional: true, - RequiredWith: []string{"private_key"}, + RequiredWith: []string{names.AttrPrivateKey}, ConflictsWith: []string{"certificate_authority_arn", names.AttrDomainName, "validation_method"}, }, "certificate_chain": { @@ -95,8 +95,8 @@ func resourceCertificate() *schema.Resource { Computed: true, ForceNew: true, ValidateFunc: validation.StringDoesNotMatch(regexache.MustCompile(`\.$`), "cannot end with a period"), - ExactlyOneOf: []string{names.AttrDomainName, "private_key"}, - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key"}, + ExactlyOneOf: []string{names.AttrDomainName, names.AttrPrivateKey}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey}, }, "domain_validation_options": { Type: schema.TypeSet, @@ -127,7 +127,7 @@ func resourceCertificate() *schema.Resource { Type: schema.TypeString, Optional: true, ValidateDiagFunc: validateHybridDuration, - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key", "validation_method"}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey, "validation_method"}, }, "key_algorithm": { Type: schema.TypeString, @@ -135,7 +135,7 @@ func resourceCertificate() *schema.Resource { Computed: true, ForceNew: true, ValidateDiagFunc: enum.Validate[types.KeyAlgorithm](), - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key"}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey}, }, "not_after": { Type: schema.TypeString, @@ -157,7 +157,7 @@ func resourceCertificate() *schema.Resource { Optional: true, Default: types.CertificateTransparencyLoggingPreferenceEnabled, ValidateDiagFunc: enum.Validate[types.CertificateTransparencyLoggingPreference](), - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key"}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey}, }, }, }, @@ -166,11 +166,11 @@ func resourceCertificate() *schema.Resource { Type: schema.TypeBool, Computed: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, Sensitive: true, - ExactlyOneOf: []string{names.AttrDomainName, "private_key"}, + ExactlyOneOf: []string{names.AttrDomainName, names.AttrPrivateKey}, }, "renewal_eligibility": { Type: schema.TypeString, @@ -212,7 +212,7 @@ func resourceCertificate() *schema.Resource { validation.StringDoesNotMatch(regexache.MustCompile(`\.$`), "cannot end with a period"), ), }, - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key"}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey}, }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -231,7 +231,7 @@ func resourceCertificate() *schema.Resource { Computed: true, ForceNew: true, ValidateDiagFunc: enum.Validate[types.ValidationMethod](), - ConflictsWith: []string{"certificate_authority_arn", "certificate_body", "certificate_chain", "private_key"}, + ConflictsWith: []string{"certificate_authority_arn", "certificate_body", "certificate_chain", names.AttrPrivateKey}, }, "validation_option": { Type: schema.TypeSet, @@ -251,7 +251,7 @@ func resourceCertificate() *schema.Resource { }, }, }, - ConflictsWith: []string{"certificate_body", "certificate_chain", "private_key"}, + ConflictsWith: []string{"certificate_body", "certificate_chain", names.AttrPrivateKey}, }, }, @@ -382,7 +382,7 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, meta } else { input := &acm.ImportCertificateInput{ Certificate: []byte(d.Get("certificate_body").(string)), - PrivateKey: []byte(d.Get("private_key").(string)), + PrivateKey: []byte(d.Get(names.AttrPrivateKey).(string)), Tags: getTagsIn(ctx), } @@ -482,16 +482,16 @@ func resourceCertificateUpdate(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).ACMClient(ctx) - if d.HasChanges("private_key", "certificate_body", "certificate_chain") { + if d.HasChanges(names.AttrPrivateKey, "certificate_body", "certificate_chain") { oCBRaw, nCBRaw := d.GetChange("certificate_body") oCCRaw, nCCRaw := d.GetChange("certificate_chain") - oPKRaw, nPKRaw := d.GetChange("private_key") + oPKRaw, nPKRaw := d.GetChange(names.AttrPrivateKey) if !isChangeNormalizeCertRemoval(oCBRaw, nCBRaw) || !isChangeNormalizeCertRemoval(oCCRaw, nCCRaw) || !isChangeNormalizeCertRemoval(oPKRaw, nPKRaw) { input := &acm.ImportCertificateInput{ Certificate: []byte(d.Get("certificate_body").(string)), CertificateArn: aws.String(d.Get(names.AttrARN).(string)), - PrivateKey: []byte(d.Get("private_key").(string)), + PrivateKey: []byte(d.Get(names.AttrPrivateKey).(string)), } if chain, ok := d.GetOk("certificate_chain"); ok { diff --git a/internal/service/acm/certificate_test.go b/internal/service/acm/certificate_test.go index 636ccba2a02..149bfb07b7b 100644 --- a/internal/service/acm/certificate_test.go +++ b/internal/service/acm/certificate_test.go @@ -1547,7 +1547,7 @@ func TestAccACMCertificate_Imported_domainName(t *testing.T) { ImportState: true, ImportStateVerify: true, // These are not returned by the API - ImportStateVerifyIgnore: []string{"private_key", "certificate_body", "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, "certificate_body", "certificate_chain"}, }, }, }) @@ -1588,7 +1588,7 @@ func TestAccACMCertificate_Imported_validityDates(t *testing.T) { ImportState: true, ImportStateVerify: true, // These are not returned by the API - ImportStateVerifyIgnore: []string{"private_key", "certificate_body", "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, "certificate_body", "certificate_chain"}, }, }, }) @@ -1621,7 +1621,7 @@ func TestAccACMCertificate_Imported_ipAddress(t *testing.T) { ImportState: true, ImportStateVerify: true, // These are not returned by the API - ImportStateVerifyIgnore: []string{"private_key", "certificate_body"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, "certificate_body"}, }, }, }) @@ -1655,7 +1655,7 @@ func TestAccACMCertificate_PrivateKey_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", "certificate_body"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, "certificate_body"}, }, { Config: testAccCertificateConfig_tags2(certificate1, key1, "key1", "value1updated", "key2", "value2"), diff --git a/internal/service/acmpca/permission.go b/internal/service/acmpca/permission.go index cbe92fb3943..f00ab73f3d6 100644 --- a/internal/service/acmpca/permission.go +++ b/internal/service/acmpca/permission.go @@ -56,7 +56,7 @@ func resourcePermission() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, ForceNew: true, Required: true, @@ -79,7 +79,7 @@ func resourcePermissionCreate(ctx context.Context, d *schema.ResourceData, meta conn := meta.(*conns.AWSClient).ACMPCAClient(ctx) caARN := d.Get("certificate_authority_arn").(string) - principal := d.Get("principal").(string) + principal := d.Get(names.AttrPrincipal).(string) sourceAccount := d.Get("source_account").(string) id := errs.Must(flex.FlattenResourceId([]string{caARN, principal, sourceAccount}, permissionResourceIDPartCount, true)) input := &acmpca.CreatePermissionInput{ @@ -128,7 +128,7 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("actions", flattenPermissionActions(permission.Actions)) d.Set("certificate_authority_arn", permission.CertificateAuthorityArn) d.Set(names.AttrPolicy, permission.Policy) - d.Set("principal", permission.Principal) + d.Set(names.AttrPrincipal, permission.Principal) d.Set("source_account", permission.SourceAccount) return diags diff --git a/internal/service/acmpca/permission_test.go b/internal/service/acmpca/permission_test.go index 3bde03512cd..93daef315bb 100644 --- a/internal/service/acmpca/permission_test.go +++ b/internal/service/acmpca/permission_test.go @@ -39,7 +39,7 @@ func TestAccACMPCAPermission_basic(t *testing.T) { resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "IssueCertificate"), resource.TestCheckTypeSetElemAttr(resourceName, "actions.*", "ListPermissions"), resource.TestCheckResourceAttrSet(resourceName, names.AttrPolicy), - resource.TestCheckResourceAttr(resourceName, "principal", "acm.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "acm.amazonaws.com"), acctest.CheckResourceAttrAccountID(resourceName, "source_account"), ), }, @@ -103,7 +103,7 @@ func testAccCheckPermissionDestroy(ctx context.Context) resource.TestCheckFunc { continue } - _, err := tfacmpca.FindPermissionByThreePartKey(ctx, conn, rs.Primary.Attributes["certificate_authority_arn"], rs.Primary.Attributes["principal"], rs.Primary.Attributes["source_account"]) + _, err := tfacmpca.FindPermissionByThreePartKey(ctx, conn, rs.Primary.Attributes["certificate_authority_arn"], rs.Primary.Attributes[names.AttrPrincipal], rs.Primary.Attributes["source_account"]) if tfresource.NotFound(err) { continue @@ -129,7 +129,7 @@ func testAccCheckPermissionExists(ctx context.Context, n string, v *types.Permis conn := acctest.Provider.Meta().(*conns.AWSClient).ACMPCAClient(ctx) - output, err := tfacmpca.FindPermissionByThreePartKey(ctx, conn, rs.Primary.Attributes["certificate_authority_arn"], rs.Primary.Attributes["principal"], rs.Primary.Attributes["source_account"]) + output, err := tfacmpca.FindPermissionByThreePartKey(ctx, conn, rs.Primary.Attributes["certificate_authority_arn"], rs.Primary.Attributes[names.AttrPrincipal], rs.Primary.Attributes["source_account"]) if err != nil { return err diff --git a/internal/service/apigateway/documentation_part.go b/internal/service/apigateway/documentation_part.go index 151e2277d5d..bdabcea7a7f 100644 --- a/internal/service/apigateway/documentation_part.go +++ b/internal/service/apigateway/documentation_part.go @@ -74,7 +74,7 @@ func resourceDocumentationPart() *schema.Resource { }, }, }, - "properties": { + names.AttrProperties: { Type: schema.TypeString, Required: true, }, @@ -94,7 +94,7 @@ func resourceDocumentationPartCreate(ctx context.Context, d *schema.ResourceData apiID := d.Get("rest_api_id").(string) input := &apigateway.CreateDocumentationPartInput{ Location: expandDocumentationPartLocation(d.Get("location").([]interface{})), - Properties: aws.String(d.Get("properties").(string)), + Properties: aws.String(d.Get(names.AttrProperties).(string)), RestApiId: aws.String(apiID), } @@ -132,7 +132,7 @@ func resourceDocumentationPartRead(ctx context.Context, d *schema.ResourceData, d.Set("documentation_part_id", docPart.Id) d.Set("location", flattenDocumentationPartLocation(docPart.Location)) - d.Set("properties", docPart.Properties) + d.Set(names.AttrProperties, docPart.Properties) d.Set("rest_api_id", apiID) return diags @@ -153,8 +153,8 @@ func resourceDocumentationPartUpdate(ctx context.Context, d *schema.ResourceData } operations := make([]types.PatchOperation, 0) - if d.HasChange("properties") { - properties := d.Get("properties").(string) + if d.HasChange(names.AttrProperties) { + properties := d.Get(names.AttrProperties).(string) operations = append(operations, types.PatchOperation{ Op: types.OpReplace, Path: aws.String("/properties"), diff --git a/internal/service/apigateway/documentation_part_test.go b/internal/service/apigateway/documentation_part_test.go index 52790306749..94470348c26 100644 --- a/internal/service/apigateway/documentation_part_test.go +++ b/internal/service/apigateway/documentation_part_test.go @@ -42,7 +42,7 @@ func TestAccAPIGatewayDocumentationPart_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "documentation_part_id"), resource.TestCheckResourceAttr(resourceName, "location.#", "1"), resource.TestCheckResourceAttr(resourceName, "location.0.type", "API"), - resource.TestCheckResourceAttr(resourceName, "properties", properties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, properties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, @@ -57,7 +57,7 @@ func TestAccAPIGatewayDocumentationPart_basic(t *testing.T) { testAccCheckDocumentationPartExists(ctx, resourceName, &conf), resource.TestCheckResourceAttr(resourceName, "location.#", "1"), resource.TestCheckResourceAttr(resourceName, "location.0.type", "API"), - resource.TestCheckResourceAttr(resourceName, "properties", uProperties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, uProperties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, @@ -88,7 +88,7 @@ func TestAccAPIGatewayDocumentationPart_method(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "location.0.type", "METHOD"), resource.TestCheckResourceAttr(resourceName, "location.0.method", "GET"), resource.TestCheckResourceAttr(resourceName, "location.0.path", "/terraform-acc-test"), - resource.TestCheckResourceAttr(resourceName, "properties", properties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, properties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, @@ -105,7 +105,7 @@ func TestAccAPIGatewayDocumentationPart_method(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "location.0.type", "METHOD"), resource.TestCheckResourceAttr(resourceName, "location.0.method", "GET"), resource.TestCheckResourceAttr(resourceName, "location.0.path", "/terraform-acc-test"), - resource.TestCheckResourceAttr(resourceName, "properties", uProperties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, uProperties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, @@ -138,7 +138,7 @@ func TestAccAPIGatewayDocumentationPart_responseHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "location.0.name", "tfacc"), resource.TestCheckResourceAttr(resourceName, "location.0.path", "/terraform-acc-test"), resource.TestCheckResourceAttr(resourceName, "location.0.status_code", "200"), - resource.TestCheckResourceAttr(resourceName, "properties", properties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, properties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, @@ -157,7 +157,7 @@ func TestAccAPIGatewayDocumentationPart_responseHeader(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "location.0.name", "tfacc"), resource.TestCheckResourceAttr(resourceName, "location.0.path", "/terraform-acc-test"), resource.TestCheckResourceAttr(resourceName, "location.0.status_code", "200"), - resource.TestCheckResourceAttr(resourceName, "properties", uProperties), + resource.TestCheckResourceAttr(resourceName, names.AttrProperties, uProperties), resource.TestCheckResourceAttrSet(resourceName, "rest_api_id"), ), }, diff --git a/internal/service/appautoscaling/policy.go b/internal/service/appautoscaling/policy.go index dfbe4fff78c..8cbe25e727c 100644 --- a/internal/service/appautoscaling/policy.go +++ b/internal/service/appautoscaling/policy.go @@ -151,7 +151,7 @@ func resourcePolicy() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.metrics"}, @@ -162,7 +162,7 @@ func resourcePolicy() *schema.Resource { ConflictsWith: []string{"target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.dimensions", "target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.metric_name", "target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.namespace", "target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.statistic", "target_tracking_scaling_policy_configuration.0.customized_metric_specification.0.unit"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 2047), @@ -205,7 +205,7 @@ func resourcePolicy() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -548,7 +548,7 @@ func expandCustomizedMetricSpecification(configured []interface{}) *applicationa if val, ok := data["metrics"].(*schema.Set); ok && val.Len() > 0 { spec.Metrics = expandTargetTrackingMetricDataQueries(val.List()) } else { - if v, ok := data["metric_name"]; ok { + if v, ok := data[names.AttrMetricName]; ok { spec.MetricName = aws.String(v.(string)) } @@ -595,7 +595,7 @@ func expandTargetTrackingMetricDataQueries(metricDataQuerySlices []interface{}) metricStatSpec := val.([]interface{})[0].(map[string]interface{}) metricSpec := metricStatSpec["metric"].([]interface{})[0].(map[string]interface{}) metric := &applicationautoscaling.TargetTrackingMetric{ - MetricName: aws.String(metricSpec["metric_name"].(string)), + MetricName: aws.String(metricSpec[names.AttrMetricName].(string)), Namespace: aws.String(metricSpec[names.AttrNamespace].(string)), } if v, ok := metricSpec["dimensions"]; ok { @@ -620,7 +620,7 @@ func expandTargetTrackingMetricDataQueries(metricDataQuerySlices []interface{}) } metricDataQuery.MetricStat = metricStat } - if val, ok := metricDataQueryFlat["expression"]; ok && val.(string) != "" { + if val, ok := metricDataQueryFlat[names.AttrExpression]; ok && val.(string) != "" { metricDataQuery.Expression = aws.String(val.(string)) } if val, ok := metricDataQueryFlat["label"]; ok && val.(string) != "" { @@ -847,7 +847,7 @@ func flattenCustomizedMetricSpecification(cfg *applicationautoscaling.Customized } if v := cfg.MetricName; v != nil { - m["metric_name"] = aws.StringValue(v) + m[names.AttrMetricName] = aws.StringValue(v) } if v := cfg.Namespace; v != nil { @@ -873,7 +873,7 @@ func flattenTargetTrackingMetricDataQueries(metricDataQueries []*applicationauto rawMetricDataQuery := metricDataQueries[i] metricDataQuery[names.AttrID] = aws.StringValue(rawMetricDataQuery.Id) if rawMetricDataQuery.Expression != nil { - metricDataQuery["expression"] = aws.StringValue(rawMetricDataQuery.Expression) + metricDataQuery[names.AttrExpression] = aws.StringValue(rawMetricDataQuery.Expression) } if rawMetricDataQuery.Label != nil { metricDataQuery["label"] = aws.StringValue(rawMetricDataQuery.Label) @@ -894,7 +894,7 @@ func flattenTargetTrackingMetricDataQueries(metricDataQueries []*applicationauto } metricSpec["dimensions"] = dimSpec } - metricSpec["metric_name"] = aws.StringValue(rawMetric.MetricName) + metricSpec[names.AttrMetricName] = aws.StringValue(rawMetric.MetricName) metricSpec[names.AttrNamespace] = aws.StringValue(rawMetric.Namespace) metricStatSpec["metric"] = []map[string]interface{}{metricSpec} metricStatSpec["stat"] = aws.StringValue(rawMetricStat.Stat) diff --git a/internal/service/appautoscaling/scheduled_action.go b/internal/service/appautoscaling/scheduled_action.go index ecc51d6efe0..f03bd1df86d 100644 --- a/internal/service/appautoscaling/scheduled_action.go +++ b/internal/service/appautoscaling/scheduled_action.go @@ -85,7 +85,7 @@ func resourceScheduledAction() *schema.Resource { }, }, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Required: true, }, @@ -130,7 +130,7 @@ func resourceScheduledActionPut(ctx context.Context, d *schema.ResourceData, met input.EndTime = aws.Time(t) } input.ScalableTargetAction = expandScalableTargetAction(d.Get("scalable_target_action").([]interface{})) - input.Schedule = aws.String(d.Get("schedule").(string)) + input.Schedule = aws.String(d.Get(names.AttrSchedule).(string)) if v, ok := d.GetOk("start_time"); ok { t, _ := time.Parse(time.RFC3339, v.(string)) input.StartTime = aws.Time(t) @@ -144,8 +144,8 @@ func resourceScheduledActionPut(ctx context.Context, d *schema.ResourceData, met if d.HasChange("scalable_target_action") { input.ScalableTargetAction = expandScalableTargetAction(d.Get("scalable_target_action").([]interface{})) } - if d.HasChange("schedule") { - input.Schedule = aws.String(d.Get("schedule").(string)) + if d.HasChange(names.AttrSchedule) { + input.Schedule = aws.String(d.Get(names.AttrSchedule).(string)) } if v, ok := d.GetOk("start_time"); ok { t, _ := time.Parse(time.RFC3339, v.(string)) @@ -197,7 +197,7 @@ func resourceScheduledActionRead(ctx context.Context, d *schema.ResourceData, me if err := d.Set("scalable_target_action", flattenScalableTargetAction(scheduledAction.ScalableTargetAction)); err != nil { return sdkdiag.AppendErrorf(diags, "setting scalable_target_action: %s", err) } - d.Set("schedule", scheduledAction.Schedule) + d.Set(names.AttrSchedule, scheduledAction.Schedule) if scheduledAction.StartTime != nil { d.Set("start_time", scheduledAction.StartTime.Format(time.RFC3339)) } diff --git a/internal/service/appautoscaling/scheduled_action_test.go b/internal/service/appautoscaling/scheduled_action_test.go index e739daab86e..8a20b333c6b 100644 --- a/internal/service/appautoscaling/scheduled_action_test.go +++ b/internal/service/appautoscaling/scheduled_action_test.go @@ -46,7 +46,7 @@ func TestAccAppAutoScalingScheduledAction_dynamoDB(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", schedule1)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", schedule1)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -65,7 +65,7 @@ func TestAccAppAutoScalingScheduledAction_dynamoDB(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", schedule2)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", schedule2)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "2"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "9"), @@ -127,7 +127,7 @@ func TestAccAppAutoScalingScheduledAction_ecs(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -164,7 +164,7 @@ func TestAccAppAutoScalingScheduledAction_ecsUpdateScheduleRetainStartAndEndTime resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -182,7 +182,7 @@ func TestAccAppAutoScalingScheduledAction_ecsUpdateScheduleRetainStartAndEndTime resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", tsUpdate)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", tsUpdate)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -221,7 +221,7 @@ func TestAccAppAutoScalingScheduledAction_ecsUpdateStartAndEndTime(t *testing.T) resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -239,7 +239,7 @@ func TestAccAppAutoScalingScheduledAction_ecsUpdateStartAndEndTime(t *testing.T) resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", tsUpdate)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", tsUpdate)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -278,7 +278,7 @@ func TestAccAppAutoScalingScheduledAction_ecsAddStartTimeAndEndTimeAfterResource resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -296,7 +296,7 @@ func TestAccAppAutoScalingScheduledAction_ecsAddStartTimeAndEndTimeAfterResource resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", tsUpdate)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", tsUpdate)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -332,7 +332,7 @@ func TestAccAppAutoScalingScheduledAction_emr(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "5"), @@ -391,7 +391,7 @@ func TestAccAppAutoScalingScheduledAction_spotFleet(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", ts)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", ts)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "3"), @@ -429,7 +429,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleAtExpression_timezone(t *testi resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", at), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, at), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -465,7 +465,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleCronExpression_basic(t *testin resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", cron), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, cron), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -504,7 +504,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleCronExpression_timezone(t *tes resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", cron), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, cron), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -547,7 +547,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleCronExpression_startEndTimeTim resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", cron), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, cron), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -565,7 +565,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleCronExpression_startEndTimeTim resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", cron), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, cron), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -601,7 +601,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleRateExpression_basic(t *testin resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", rate), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, rate), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -640,7 +640,7 @@ func TestAccAppAutoScalingScheduledAction_ScheduleRateExpression_timezone(t *tes resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", rate), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, rate), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), @@ -676,7 +676,7 @@ func TestAccAppAutoScalingScheduledAction_minCapacity(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", schedule)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", schedule)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", ""), @@ -732,7 +732,7 @@ func TestAccAppAutoScalingScheduledAction_maxCapacity(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "service_namespace", autoscalingTargetResourceName, "service_namespace"), resource.TestCheckResourceAttrPair(resourceName, "resource_id", autoscalingTargetResourceName, "resource_id"), resource.TestCheckResourceAttrPair(resourceName, "scalable_dimension", autoscalingTargetResourceName, "scalable_dimension"), - resource.TestCheckResourceAttr(resourceName, "schedule", fmt.Sprintf("at(%s)", schedule)), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, fmt.Sprintf("at(%s)", schedule)), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.min_capacity", ""), resource.TestCheckResourceAttr(resourceName, "scalable_target_action.0.max_capacity", "10"), diff --git a/internal/service/appflow/connector_profile.go b/internal/service/appflow/connector_profile.go index 8c85304f145..1a91ef3f17c 100644 --- a/internal/service/appflow/connector_profile.go +++ b/internal/service/appflow/connector_profile.go @@ -195,7 +195,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.All( @@ -308,7 +308,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -469,7 +469,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -647,7 +647,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -757,7 +757,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -881,7 +881,7 @@ func resourceConnectorProfile() *schema.Resource { validation.StringMatch(regexache.MustCompile(`\S+`), "must not contain any whitespace characters"), ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -1695,7 +1695,7 @@ func expandDynatraceConnectorProfileCredentials(m map[string]interface{}) *types func expandGoogleAnalyticsConnectorProfileCredentials(m map[string]interface{}) *types.GoogleAnalyticsConnectorProfileCredentials { credentials := &types.GoogleAnalyticsConnectorProfileCredentials{ - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), } @@ -1741,7 +1741,7 @@ func expandInforNexusConnectorProfileCredentials(m map[string]interface{}) *type func expandMarketoConnectorProfileCredentials(m map[string]interface{}) *types.MarketoConnectorProfileCredentials { credentials := &types.MarketoConnectorProfileCredentials{ - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), } @@ -1822,7 +1822,7 @@ func expandSingularConnectorProfileCredentials(m map[string]interface{}) *types. func expandSlackConnectorProfileCredentials(m map[string]interface{}) *types.SlackConnectorProfileCredentials { credentials := &types.SlackConnectorProfileCredentials{ AccessToken: aws.String(m["access_token"].(string)), - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), } @@ -1862,7 +1862,7 @@ func expandVeevaConnectorProfileCredentials(m map[string]interface{}) *types.Vee func expandZendeskConnectorProfileCredentials(m map[string]interface{}) *types.ZendeskConnectorProfileCredentials { credentials := &types.ZendeskConnectorProfileCredentials{ AccessToken: aws.String(m["access_token"].(string)), - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), } @@ -1931,7 +1931,7 @@ func expandCustomAuthCredentials(m map[string]interface{}) *types.CustomAuthCred func expandOAuthCredentials(m map[string]interface{}) *types.OAuthCredentials { credentials := &types.OAuthCredentials{ - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), } @@ -1954,7 +1954,7 @@ func expandOAuth2Credentials(m map[string]interface{}) *types.OAuth2Credentials if v, ok := m["access_token"].(string); ok && v != "" { credentials.AccessToken = aws.String(v) } - if v, ok := m["client_id"].(string); ok && v != "" { + if v, ok := m[names.AttrClientID].(string); ok && v != "" { credentials.ClientId = aws.String(v) } if v, ok := m["client_secret"].(string); ok && v != "" { diff --git a/internal/service/appmesh/flex.go b/internal/service/appmesh/flex.go index f85a7c36868..7d0798331b0 100644 --- a/internal/service/appmesh/flex.go +++ b/internal/service/appmesh/flex.go @@ -38,7 +38,7 @@ func expandClientPolicy(vClientPolicy []interface{}) *appmesh.ClientPolicy { if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { file.CertificateChain = aws.String(vCertificateChain) } - if vPrivateKey, ok := mFile["private_key"].(string); ok && vPrivateKey != "" { + if vPrivateKey, ok := mFile[names.AttrPrivateKey].(string); ok && vPrivateKey != "" { file.PrivateKey = aws.String(vPrivateKey) } @@ -927,7 +927,7 @@ func expandVirtualNodeSpec(vSpec []interface{}) *appmesh.VirtualNodeSpec { if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { file.CertificateChain = aws.String(vCertificateChain) } - if vPrivateKey, ok := mFile["private_key"].(string); ok && vPrivateKey != "" { + if vPrivateKey, ok := mFile[names.AttrPrivateKey].(string); ok && vPrivateKey != "" { file.PrivateKey = aws.String(vPrivateKey) } @@ -1221,8 +1221,8 @@ func flattenClientPolicy(clientPolicy *appmesh.ClientPolicy) []interface{} { if file := certificate.File; file != nil { mFile := map[string]interface{}{ - "certificate_chain": aws.StringValue(file.CertificateChain), - "private_key": aws.StringValue(file.PrivateKey), + "certificate_chain": aws.StringValue(file.CertificateChain), + names.AttrPrivateKey: aws.StringValue(file.PrivateKey), } mCertificate["file"] = []interface{}{mFile} @@ -1773,8 +1773,8 @@ func flattenVirtualNodeSpec(spec *appmesh.VirtualNodeSpec) []interface{} { if file := certificate.File; file != nil { mFile := map[string]interface{}{ - "certificate_chain": aws.StringValue(file.CertificateChain), - "private_key": aws.StringValue(file.PrivateKey), + "certificate_chain": aws.StringValue(file.CertificateChain), + names.AttrPrivateKey: aws.StringValue(file.PrivateKey), } mCertificate["file"] = []interface{}{mFile} diff --git a/internal/service/appmesh/virtual_gateway.go b/internal/service/appmesh/virtual_gateway.go index 4e6ac67608d..5b75eb0e9de 100644 --- a/internal/service/appmesh/virtual_gateway.go +++ b/internal/service/appmesh/virtual_gateway.go @@ -134,7 +134,7 @@ func resourceVirtualGatewaySpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -469,7 +469,7 @@ func resourceVirtualGatewaySpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -992,7 +992,7 @@ func expandVirtualGatewaySpec(vSpec []interface{}) *appmesh.VirtualGatewaySpec { if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { file.CertificateChain = aws.String(vCertificateChain) } - if vPrivateKey, ok := mFile["private_key"].(string); ok && vPrivateKey != "" { + if vPrivateKey, ok := mFile[names.AttrPrivateKey].(string); ok && vPrivateKey != "" { file.PrivateKey = aws.String(vPrivateKey) } @@ -1165,7 +1165,7 @@ func expandVirtualGatewayClientPolicy(vClientPolicy []interface{}) *appmesh.Virt if vCertificateChain, ok := mFile["certificate_chain"].(string); ok && vCertificateChain != "" { file.CertificateChain = aws.String(vCertificateChain) } - if vPrivateKey, ok := mFile["private_key"].(string); ok && vPrivateKey != "" { + if vPrivateKey, ok := mFile[names.AttrPrivateKey].(string); ok && vPrivateKey != "" { file.PrivateKey = aws.String(vPrivateKey) } @@ -1360,8 +1360,8 @@ func flattenVirtualGatewaySpec(spec *appmesh.VirtualGatewaySpec) []interface{} { if file := certificate.File; file != nil { mFile := map[string]interface{}{ - "certificate_chain": aws.StringValue(file.CertificateChain), - "private_key": aws.StringValue(file.PrivateKey), + "certificate_chain": aws.StringValue(file.CertificateChain), + names.AttrPrivateKey: aws.StringValue(file.PrivateKey), } mCertificate["file"] = []interface{}{mFile} @@ -1493,8 +1493,8 @@ func flattenVirtualGatewayClientPolicy(clientPolicy *appmesh.VirtualGatewayClien if file := certificate.File; file != nil { mFile := map[string]interface{}{ - "certificate_chain": aws.StringValue(file.CertificateChain), - "private_key": aws.StringValue(file.PrivateKey), + "certificate_chain": aws.StringValue(file.CertificateChain), + names.AttrPrivateKey: aws.StringValue(file.PrivateKey), } mCertificate["file"] = []interface{}{mFile} diff --git a/internal/service/appmesh/virtual_node.go b/internal/service/appmesh/virtual_node.go index 22a3c8d57a7..1128e4cca48 100644 --- a/internal/service/appmesh/virtual_node.go +++ b/internal/service/appmesh/virtual_node.go @@ -124,7 +124,7 @@ func resourceVirtualNodeSpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -724,7 +724,7 @@ func resourceVirtualNodeSpecSchema() *schema.Schema { Required: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), diff --git a/internal/service/appstream/fleet.go b/internal/service/appstream/fleet.go index 1dccfabdee1..ccd54bef258 100644 --- a/internal/service/appstream/fleet.go +++ b/internal/service/appstream/fleet.go @@ -190,7 +190,7 @@ func ResourceFleet() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -281,7 +281,7 @@ func resourceFleetCreate(ctx context.Context, d *schema.ResourceData, meta inter input.StreamView = aws.String(v.(string)) } - if v, ok := d.GetOk("vpc_config"); ok { + if v, ok := d.GetOk(names.AttrVPCConfig); ok { input.VpcConfig = expandVPCConfig(v.([]interface{})) } @@ -397,11 +397,11 @@ func resourceFleetRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("stream_view", fleet.StreamView) if fleet.VpcConfig != nil { - if err = d.Set("vpc_config", []interface{}{flattenVPCConfig(fleet.VpcConfig)}); err != nil { - return create.AppendDiagSettingError(diags, names.AppStream, "Fleet", d.Id(), "vpc_config", err) + if err = d.Set(names.AttrVPCConfig, []interface{}{flattenVPCConfig(fleet.VpcConfig)}); err != nil { + return create.AppendDiagSettingError(diags, names.AppStream, "Fleet", d.Id(), names.AttrVPCConfig, err) } } else { - d.Set("vpc_config", nil) + d.Set(names.AttrVPCConfig, nil) } return diags @@ -416,7 +416,7 @@ func resourceFleetUpdate(ctx context.Context, d *schema.ResourceData, meta inter } shouldStop := false - if d.HasChanges(names.AttrDescription, "domain_join_info", "enable_default_internet_access", "iam_role_arn", names.AttrInstanceType, "max_user_duration_in_seconds", "stream_view", "vpc_config") { + if d.HasChanges(names.AttrDescription, "domain_join_info", "enable_default_internet_access", "iam_role_arn", names.AttrInstanceType, "max_user_duration_in_seconds", "stream_view", names.AttrVPCConfig) { shouldStop = true } @@ -489,8 +489,8 @@ func resourceFleetUpdate(ctx context.Context, d *schema.ResourceData, meta inter input.MaxUserDurationInSeconds = aws.Int64(int64(d.Get("max_user_duration_in_seconds").(int))) } - if d.HasChange("vpc_config") { - input.VpcConfig = expandVPCConfig(d.Get("vpc_config").([]interface{})) + if d.HasChange(names.AttrVPCConfig) { + input.VpcConfig = expandVPCConfig(d.Get(names.AttrVPCConfig).([]interface{})) } _, err := conn.UpdateFleetWithContext(ctx, input) diff --git a/internal/service/appstream/image_builder.go b/internal/service/appstream/image_builder.go index ed52557dfd4..20afac1550e 100644 --- a/internal/service/appstream/image_builder.go +++ b/internal/service/appstream/image_builder.go @@ -150,7 +150,7 @@ func ResourceImageBuilder() *schema.Resource { }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -227,7 +227,7 @@ func resourceImageBuilderCreate(ctx context.Context, d *schema.ResourceData, met input.ImageName = aws.String(v.(string)) } - if v, ok := d.GetOk("vpc_config"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrVPCConfig); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.VpcConfig = expandImageBuilderVPCConfig(v.([]interface{})) } @@ -288,11 +288,11 @@ func resourceImageBuilderRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrName, imageBuilder.Name) d.Set(names.AttrState, imageBuilder.State) if imageBuilder.VpcConfig != nil { - if err = d.Set("vpc_config", []interface{}{flattenVPCConfig(imageBuilder.VpcConfig)}); err != nil { + if err = d.Set(names.AttrVPCConfig, []interface{}{flattenVPCConfig(imageBuilder.VpcConfig)}); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } } else { - d.Set("vpc_config", nil) + d.Set(names.AttrVPCConfig, nil) } return diags diff --git a/internal/service/appsync/graphql_api.go b/internal/service/appsync/graphql_api.go index 48a49287d6f..5af2e0a7f75 100644 --- a/internal/service/appsync/graphql_api.go +++ b/internal/service/appsync/graphql_api.go @@ -87,7 +87,7 @@ func ResourceGraphQLAPI() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, }, @@ -210,7 +210,7 @@ func ResourceGraphQLAPI() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, }, @@ -626,7 +626,7 @@ func expandGraphQLAPIOpenIDConnectConfig(l []interface{}) *appsync.OpenIDConnect openIDConnectConfig.AuthTTL = aws.Int64(int64(v)) } - if v, ok := m["client_id"].(string); ok && v != "" { + if v, ok := m[names.AttrClientID].(string); ok && v != "" { openIDConnectConfig.ClientId = aws.String(v) } @@ -757,10 +757,10 @@ func flattenGraphQLAPIOpenIDConnectConfig(openIDConnectConfig *appsync.OpenIDCon } m := map[string]interface{}{ - "auth_ttl": aws.Int64Value(openIDConnectConfig.AuthTTL), - "client_id": aws.StringValue(openIDConnectConfig.ClientId), - "iat_ttl": aws.Int64Value(openIDConnectConfig.IatTTL), - "issuer": aws.StringValue(openIDConnectConfig.Issuer), + "auth_ttl": aws.Int64Value(openIDConnectConfig.AuthTTL), + names.AttrClientID: aws.StringValue(openIDConnectConfig.ClientId), + "iat_ttl": aws.Int64Value(openIDConnectConfig.IatTTL), + "issuer": aws.StringValue(openIDConnectConfig.Issuer), } return []interface{}{m} diff --git a/internal/service/athena/database.go b/internal/service/athena/database.go index 33d55768ad8..33fec64079d 100644 --- a/internal/service/athena/database.go +++ b/internal/service/athena/database.go @@ -102,7 +102,7 @@ func resourceDatabase() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringMatch(regexache.MustCompile("^[0-9a-z_]+$"), "must be lowercase letters, numbers, or underscore ('_')"), }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, ForceNew: true, @@ -126,7 +126,7 @@ func resourceDatabaseCreate(ctx context.Context, d *schema.ResourceData, meta in queryString.WriteString(commentStmt) } - if v, ok := d.GetOk("properties"); ok && len(v.(map[string]interface{})) > 0 { + if v, ok := d.GetOk(names.AttrProperties); ok && len(v.(map[string]interface{})) > 0 { var props []string for k, v := range v.(map[string]interface{}) { prop := fmt.Sprintf(" '%[1]s' = '%[2]s' ", k, v.(string)) @@ -177,7 +177,7 @@ func resourceDatabaseRead(ctx context.Context, d *schema.ResourceData, meta inte d.Set("comment", db.Description) d.Set(names.AttrName, db.Name) - d.Set("properties", db.Parameters) + d.Set(names.AttrProperties, db.Parameters) return diags } diff --git a/internal/service/autoscaling/policy.go b/internal/service/autoscaling/policy.go index b6d4c5904fa..b503ed65a63 100644 --- a/internal/service/autoscaling/policy.go +++ b/internal/service/autoscaling/policy.go @@ -50,7 +50,7 @@ func resourcePolicy() *schema.Resource { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 1023), @@ -93,7 +93,7 @@ func resourcePolicy() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -366,7 +366,7 @@ func resourcePolicy() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"target_tracking_configuration.0.customized_metric_specification.0.metrics"}, @@ -377,7 +377,7 @@ func resourcePolicy() *schema.Resource { ConflictsWith: []string{"target_tracking_configuration.0.customized_metric_specification.0.metric_dimension", "target_tracking_configuration.0.customized_metric_specification.0.metric_name", "target_tracking_configuration.0.customized_metric_specification.0.namespace", "target_tracking_configuration.0.customized_metric_specification.0.statistic", "target_tracking_configuration.0.customized_metric_specification.0.unit"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 2047), @@ -420,7 +420,7 @@ func resourcePolicy() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -802,7 +802,7 @@ func expandTargetTrackingConfiguration(configs []interface{}) *awstypes.TargetTr customSpec.Metrics = expandTargetTrackingMetricDataQueries(val.List()) } else { customSpec.Namespace = aws.String(spec[names.AttrNamespace].(string)) - customSpec.MetricName = aws.String(spec["metric_name"].(string)) + customSpec.MetricName = aws.String(spec[names.AttrMetricName].(string)) customSpec.Statistic = awstypes.MetricStatistic(spec["statistic"].(string)) if val, ok := spec[names.AttrUnit]; ok && len(val.(string)) > 0 { customSpec.Unit = aws.String(val.(string)) @@ -841,7 +841,7 @@ func expandTargetTrackingMetricDataQueries(metricDataQuerySlices []interface{}) metricStatSpec := val.([]interface{})[0].(map[string]interface{}) metricSpec := metricStatSpec["metric"].([]interface{})[0].(map[string]interface{}) metric := &awstypes.Metric{ - MetricName: aws.String(metricSpec["metric_name"].(string)), + MetricName: aws.String(metricSpec[names.AttrMetricName].(string)), Namespace: aws.String(metricSpec[names.AttrNamespace].(string)), } if v, ok := metricSpec["dimensions"]; ok { @@ -866,7 +866,7 @@ func expandTargetTrackingMetricDataQueries(metricDataQuerySlices []interface{}) } metricDataQuery.MetricStat = metricStat } - if val, ok := metricDataQueryFlat["expression"]; ok && val.(string) != "" { + if val, ok := metricDataQueryFlat[names.AttrExpression]; ok && val.(string) != "" { metricDataQuery.Expression = aws.String(val.(string)) } if val, ok := metricDataQueryFlat["label"]; ok && val.(string) != "" { @@ -1006,7 +1006,7 @@ func expandMetricDataQueries(metricDataQuerySlices []interface{}) []awstypes.Met metricStatSpec := val.([]interface{})[0].(map[string]interface{}) metricSpec := metricStatSpec["metric"].([]interface{})[0].(map[string]interface{}) metric := &awstypes.Metric{ - MetricName: aws.String(metricSpec["metric_name"].(string)), + MetricName: aws.String(metricSpec[names.AttrMetricName].(string)), Namespace: aws.String(metricSpec[names.AttrNamespace].(string)), } if v, ok := metricSpec["dimensions"]; ok { @@ -1031,7 +1031,7 @@ func expandMetricDataQueries(metricDataQuerySlices []interface{}) []awstypes.Met } metricDataQuery.MetricStat = metricStat } - if val, ok := metricDataQueryFlat["expression"]; ok && val.(string) != "" { + if val, ok := metricDataQueryFlat[names.AttrExpression]; ok && val.(string) != "" { metricDataQuery.Expression = aws.String(val.(string)) } if val, ok := metricDataQueryFlat["label"]; ok && val.(string) != "" { @@ -1066,7 +1066,7 @@ func flattenTargetTrackingConfiguration(config *awstypes.TargetTrackingConfigura if config.CustomizedMetricSpecification.Metrics != nil { spec["metrics"] = flattenTargetTrackingMetricDataQueries(config.CustomizedMetricSpecification.Metrics) } else { - spec["metric_name"] = aws.ToString(config.CustomizedMetricSpecification.MetricName) + spec[names.AttrMetricName] = aws.ToString(config.CustomizedMetricSpecification.MetricName) spec[names.AttrNamespace] = aws.ToString(config.CustomizedMetricSpecification.Namespace) spec["statistic"] = string(config.CustomizedMetricSpecification.Statistic) if config.CustomizedMetricSpecification.Unit != nil { @@ -1096,7 +1096,7 @@ func flattenTargetTrackingMetricDataQueries(metricDataQueries []awstypes.TargetT rawMetricDataQuery := metricDataQueries[i] metricDataQuery[names.AttrID] = aws.ToString(rawMetricDataQuery.Id) if rawMetricDataQuery.Expression != nil { - metricDataQuery["expression"] = aws.ToString(rawMetricDataQuery.Expression) + metricDataQuery[names.AttrExpression] = aws.ToString(rawMetricDataQuery.Expression) } if rawMetricDataQuery.Label != nil { metricDataQuery["label"] = aws.ToString(rawMetricDataQuery.Label) @@ -1117,7 +1117,7 @@ func flattenTargetTrackingMetricDataQueries(metricDataQueries []awstypes.TargetT } metricSpec["dimensions"] = dimSpec } - metricSpec["metric_name"] = aws.ToString(rawMetric.MetricName) + metricSpec[names.AttrMetricName] = aws.ToString(rawMetric.MetricName) metricSpec[names.AttrNamespace] = aws.ToString(rawMetric.Namespace) metricStatSpec["metric"] = []map[string]interface{}{metricSpec} metricStatSpec["stat"] = aws.ToString(rawMetricStat.Stat) @@ -1247,7 +1247,7 @@ func flattenMetricDataQueries(metricDataQueries []awstypes.MetricDataQuery) []in rawMetricDataQuery := metricDataQueries[i] metricDataQuery[names.AttrID] = aws.ToString(rawMetricDataQuery.Id) if rawMetricDataQuery.Expression != nil { - metricDataQuery["expression"] = aws.ToString(rawMetricDataQuery.Expression) + metricDataQuery[names.AttrExpression] = aws.ToString(rawMetricDataQuery.Expression) } if rawMetricDataQuery.Label != nil { metricDataQuery["label"] = aws.ToString(rawMetricDataQuery.Label) @@ -1268,7 +1268,7 @@ func flattenMetricDataQueries(metricDataQueries []awstypes.MetricDataQuery) []in } metricSpec["dimensions"] = dimSpec } - metricSpec["metric_name"] = aws.ToString(rawMetric.MetricName) + metricSpec[names.AttrMetricName] = aws.ToString(rawMetric.MetricName) metricSpec[names.AttrNamespace] = aws.ToString(rawMetric.Namespace) metricStatSpec["metric"] = []map[string]interface{}{metricSpec} metricStatSpec["stat"] = aws.ToString(rawMetricStat.Stat) diff --git a/internal/service/autoscalingplans/scaling_plan.go b/internal/service/autoscalingplans/scaling_plan.go index 3c8336a2da0..5d2d086c554 100644 --- a/internal/service/autoscalingplans/scaling_plan.go +++ b/internal/service/autoscalingplans/scaling_plan.go @@ -107,7 +107,7 @@ func ResourceScalingPlan() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -239,7 +239,7 @@ func ResourceScalingPlan() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -608,7 +608,7 @@ func expandScalingInstructions(vScalingInstructions *schema.Set) []awstypes.Scal customizedLoadMetricSpecification.Dimensions = dimensions } - if v, ok := mCustomizedLoadMetricSpecification["metric_name"].(string); ok && v != "" { + if v, ok := mCustomizedLoadMetricSpecification[names.AttrMetricName].(string); ok && v != "" { customizedLoadMetricSpecification.MetricName = aws.String(v) } if v, ok := mCustomizedLoadMetricSpecification[names.AttrNamespace].(string); ok && v != "" { @@ -682,7 +682,7 @@ func expandScalingInstructions(vScalingInstructions *schema.Set) []awstypes.Scal customizedScalingMetricSpecification.Dimensions = dimensions } - if v, ok := mCustomizedScalingMetricSpecification["metric_name"].(string); ok && v != "" { + if v, ok := mCustomizedScalingMetricSpecification[names.AttrMetricName].(string); ok && v != "" { customizedScalingMetricSpecification.MetricName = aws.String(v) } if v, ok := mCustomizedScalingMetricSpecification[names.AttrNamespace].(string); ok && v != "" { @@ -751,11 +751,11 @@ func flattenScalingInstructions(scalingInstructions []awstypes.ScalingInstructio mScalingInstruction["customized_load_metric_specification"] = []interface{}{ map[string]interface{}{ - "dimensions": mDimensions, - "metric_name": aws.ToString(customizedLoadMetricSpecification.MetricName), - names.AttrNamespace: aws.ToString(customizedLoadMetricSpecification.Namespace), - "statistic": string(customizedLoadMetricSpecification.Statistic), - names.AttrUnit: aws.ToString(customizedLoadMetricSpecification.Unit), + "dimensions": mDimensions, + names.AttrMetricName: aws.ToString(customizedLoadMetricSpecification.MetricName), + names.AttrNamespace: aws.ToString(customizedLoadMetricSpecification.Namespace), + "statistic": string(customizedLoadMetricSpecification.Statistic), + names.AttrUnit: aws.ToString(customizedLoadMetricSpecification.Unit), }, } } @@ -789,11 +789,11 @@ func flattenScalingInstructions(scalingInstructions []awstypes.ScalingInstructio mTargetTrackingConfiguration["customized_scaling_metric_specification"] = []interface{}{ map[string]interface{}{ - "dimensions": mDimensions, - "metric_name": aws.ToString(customizedScalingMetricSpecification.MetricName), - names.AttrNamespace: aws.ToString(customizedScalingMetricSpecification.Namespace), - "statistic": string(customizedScalingMetricSpecification.Statistic), - names.AttrUnit: aws.ToString(customizedScalingMetricSpecification.Unit), + "dimensions": mDimensions, + names.AttrMetricName: aws.ToString(customizedScalingMetricSpecification.MetricName), + names.AttrNamespace: aws.ToString(customizedScalingMetricSpecification.Namespace), + "statistic": string(customizedScalingMetricSpecification.Statistic), + names.AttrUnit: aws.ToString(customizedScalingMetricSpecification.Unit), }, } } diff --git a/internal/service/backup/plan.go b/internal/service/backup/plan.go index b3c196a86ce..f951c80bdad 100644 --- a/internal/service/backup/plan.go +++ b/internal/service/backup/plan.go @@ -152,7 +152,7 @@ func ResourcePlan() *schema.Resource { validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z_.-]+$`), "must contain only alphanumeric characters, hyphens, underscores, and periods"), ), }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Optional: true, }, @@ -331,7 +331,7 @@ func expandPlanRules(ctx context.Context, vRules *schema.Set) []*backup.RuleInpu if vTargetVaultName, ok := mRule["target_vault_name"].(string); ok && vTargetVaultName != "" { rule.TargetBackupVaultName = aws.String(vTargetVaultName) } - if vSchedule, ok := mRule["schedule"].(string); ok && vSchedule != "" { + if vSchedule, ok := mRule[names.AttrSchedule].(string); ok && vSchedule != "" { rule.ScheduleExpression = aws.String(vSchedule) } if vEnableContinuousBackup, ok := mRule["enable_continuous_backup"].(bool); ok { @@ -437,7 +437,7 @@ func flattenPlanRules(ctx context.Context, rules []*backup.Rule) *schema.Set { mRule := map[string]interface{}{ "rule_name": aws.StringValue(rule.RuleName), "target_vault_name": aws.StringValue(rule.TargetBackupVaultName), - "schedule": aws.StringValue(rule.ScheduleExpression), + names.AttrSchedule: aws.StringValue(rule.ScheduleExpression), "enable_continuous_backup": aws.BoolValue(rule.EnableContinuousBackup), "start_window": int(aws.Int64Value(rule.StartWindowMinutes)), "completion_window": int(aws.Int64Value(rule.CompletionWindowMinutes)), @@ -522,7 +522,7 @@ func planHash(vRule interface{}) int { if v, ok := mRule["target_vault_name"].(string); ok { buf.WriteString(fmt.Sprintf("%s-", v)) } - if v, ok := mRule["schedule"].(string); ok { + if v, ok := mRule[names.AttrSchedule].(string); ok { buf.WriteString(fmt.Sprintf("%s-", v)) } if v, ok := mRule["enable_continuous_backup"].(bool); ok { diff --git a/internal/service/backup/plan_test.go b/internal/service/backup/plan_test.go index d510ae3c9ae..154c0b38575 100644 --- a/internal/service/backup/plan_test.go +++ b/internal/service/backup/plan_test.go @@ -42,7 +42,7 @@ func TestAccBackupPlan_basic(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -136,13 +136,13 @@ func TestAccBackupPlan_withRules(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rule1Name, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rule2Name, "target_vault_name": rName, - "schedule": "cron(0 6 * * ? *)", + names.AttrSchedule: "cron(0 6 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -162,19 +162,19 @@ func TestAccBackupPlan_withRules(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rule1Name, "target_vault_name": rName, - "schedule": "cron(0 6 * * ? *)", + names.AttrSchedule: "cron(0 6 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rule2Name, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rule3Name, "target_vault_name": rName, - "schedule": "cron(0 18 * * ? *)", + names.AttrSchedule: "cron(0 18 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -189,7 +189,7 @@ func TestAccBackupPlan_withRules(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -308,7 +308,7 @@ func TestAccBackupPlan_withRecoveryPointTags(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", "recovery_point_tags.%": "3", "recovery_point_tags.Name": rName, @@ -332,7 +332,7 @@ func TestAccBackupPlan_withRecoveryPointTags(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", "recovery_point_tags.%": "3", "recovery_point_tags.Name": rName, @@ -351,7 +351,7 @@ func TestAccBackupPlan_withRecoveryPointTags(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "lifecycle.#": "0", }), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -633,7 +633,7 @@ func TestAccBackupPlan_enableContinuousBackup(t *testing.T) { resource.TestCheckTypeSetElemNestedAttrs(resourceName, "rule.*", map[string]string{ "rule_name": rName, "target_vault_name": rName, - "schedule": "cron(0 12 * * ? *)", + names.AttrSchedule: "cron(0 12 * * ? *)", "enable_continuous_backup": "true", "lifecycle.#": "1", "lifecycle.0.delete_after": "35", diff --git a/internal/service/bedrock/custom_model.go b/internal/service/bedrock/custom_model.go index 847c0b502c4..b7de5503dc4 100644 --- a/internal/service/bedrock/custom_model.go +++ b/internal/service/bedrock/custom_model.go @@ -246,7 +246,7 @@ func (r *customModelResource) Schema(ctx context.Context, request resource.Schem }, }, }, - "vpc_config": schema.ListNestedBlock{ + names.AttrVPCConfig: schema.ListNestedBlock{ CustomType: fwtypes.NewListNestedObjectTypeOf[customModelVPCConfigModel](ctx), PlanModifiers: []planmodifier.List{ listplanmodifier.RequiresReplace(), diff --git a/internal/service/cloudcontrol/resource.go b/internal/service/cloudcontrol/resource.go index ae09be4c3cc..eddc29ca059 100644 --- a/internal/service/cloudcontrol/resource.go +++ b/internal/service/cloudcontrol/resource.go @@ -50,7 +50,7 @@ func resourceResource() *schema.Resource { Type: schema.TypeString, Required: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeString, Computed: true, }, @@ -79,7 +79,7 @@ func resourceResource() *schema.Resource { CustomizeDiff: customdiff.Sequence( resourceResourceCustomizeDiffGetSchema, resourceResourceCustomizeDiffSchemaDiff, - customdiff.ComputedIf("properties", func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) bool { + customdiff.ComputedIf(names.AttrProperties, func(ctx context.Context, diff *schema.ResourceDiff, meta interface{}) bool { return diff.HasChange("desired_state") }), ), @@ -152,7 +152,7 @@ func resourceResourceRead(ctx context.Context, d *schema.ResourceData, meta inte return sdkdiag.AppendErrorf(diags, "reading Cloud Control API (%s) Resource (%s): %s", typeName, d.Id(), err) } - d.Set("properties", resourceDescription.Properties) + d.Set(names.AttrProperties, resourceDescription.Properties) return diags } diff --git a/internal/service/cloudcontrol/resource_data_source.go b/internal/service/cloudcontrol/resource_data_source.go index dedac6350db..0cfe70ddac4 100644 --- a/internal/service/cloudcontrol/resource_data_source.go +++ b/internal/service/cloudcontrol/resource_data_source.go @@ -26,7 +26,7 @@ func dataSourceResource() *schema.Resource { Type: schema.TypeString, Required: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeString, Computed: true, }, @@ -67,7 +67,7 @@ func dataSourceResourceRead(ctx context.Context, d *schema.ResourceData, meta in d.SetId(aws.ToString(resourceDescription.Identifier)) - d.Set("properties", resourceDescription.Properties) + d.Set(names.AttrProperties, resourceDescription.Properties) return diags } diff --git a/internal/service/cloudcontrol/resource_data_source_test.go b/internal/service/cloudcontrol/resource_data_source_test.go index 771f8180e69..f39de71bb6c 100644 --- a/internal/service/cloudcontrol/resource_data_source_test.go +++ b/internal/service/cloudcontrol/resource_data_source_test.go @@ -29,7 +29,7 @@ func TestAccCloudControlResourceDataSource_basic(t *testing.T) { Config: testAccResourceDataSourceConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, names.AttrID, resourceName, names.AttrID), - resource.TestCheckResourceAttrPair(dataSourceName, "properties", resourceName, "properties"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrProperties, resourceName, names.AttrProperties), resource.TestCheckResourceAttrPair(dataSourceName, "type_name", resourceName, "type_name"), ), }, diff --git a/internal/service/cloudcontrol/resource_test.go b/internal/service/cloudcontrol/resource_test.go index a31c6fc28f2..851a9adcddd 100644 --- a/internal/service/cloudcontrol/resource_test.go +++ b/internal/service/cloudcontrol/resource_test.go @@ -46,7 +46,7 @@ func TestAccCloudControlResource_basic(t *testing.T) { { Config: testAccResourceConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`^\{.*\}$`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`^\{.*\}$`)), resource.TestMatchResourceAttr(resourceName, "schema", regexache.MustCompile(`^\{.*`)), ), }, @@ -90,13 +90,13 @@ func TestAccCloudControlResource_DesiredState_booleanValueAdded(t *testing.T) { { Config: testAccResourceConfig_desiredStateBooleanValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":false`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":false`)), ), }, { Config: testAccResourceConfig_desiredStateBooleanValue(rName, true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":true`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":true`)), ), }, }, @@ -117,13 +117,13 @@ func TestAccCloudControlResource_DesiredState_booleanValueRemoved(t *testing.T) { Config: testAccResourceConfig_desiredStateBooleanValue(rName, true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":true`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":true`)), ), }, { Config: testAccResourceConfig_desiredStateBooleanValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":false`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":false`)), ), }, }, @@ -144,13 +144,13 @@ func TestAccCloudControlResource_DesiredState_booleanValueUpdate(t *testing.T) { { Config: testAccResourceConfig_desiredStateBooleanValue(rName, true), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":true`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":true`)), ), }, { Config: testAccResourceConfig_desiredStateBooleanValue(rName, false), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Enabled":false`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Enabled":false`)), ), }, }, @@ -172,13 +172,13 @@ func TestAccCloudControlResource_DesiredState_createOnly(t *testing.T) { { Config: testAccResourceConfig_desiredStateCreateOnly(rName1), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"LogGroupName":"`+rName1+`"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"LogGroupName":"`+rName1+`"`)), ), }, { Config: testAccResourceConfig_desiredStateCreateOnly(rName2), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"LogGroupName":"`+rName2+`"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"LogGroupName":"`+rName2+`"`)), ), }, }, @@ -199,13 +199,13 @@ func TestAccCloudControlResource_DesiredState_integerValueAdded(t *testing.T) { { Config: testAccResourceConfig_desiredStateIntegerValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"LogGroupName":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"LogGroupName":`)), ), }, { Config: testAccResourceConfig_desiredStateIntegerValue(rName, 14), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"RetentionInDays":14`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"RetentionInDays":14`)), ), }, }, @@ -226,13 +226,13 @@ func TestAccCloudControlResource_DesiredState_integerValueRemoved(t *testing.T) { Config: testAccResourceConfig_desiredStateIntegerValue(rName, 14), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"RetentionInDays":14`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"RetentionInDays":14`)), ), }, { Config: testAccResourceConfig_desiredStateIntegerValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"LogGroupName":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"LogGroupName":`)), ), }, }, @@ -253,13 +253,13 @@ func TestAccCloudControlResource_DesiredState_integerValueUpdate(t *testing.T) { { Config: testAccResourceConfig_desiredStateIntegerValue(rName, 7), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"RetentionInDays":7`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"RetentionInDays":7`)), ), }, { Config: testAccResourceConfig_desiredStateIntegerValue(rName, 14), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"RetentionInDays":14`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"RetentionInDays":14`)), ), }, }, @@ -316,13 +316,13 @@ func TestAccCloudControlResource_DesiredState_objectValueAdded(t *testing.T) { { Config: testAccResourceConfig_desiredStateObjectValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"ClusterName":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"ClusterName":`)), ), }, { Config: testAccResourceConfig_desiredStateObjectValue1(rName, "key1", "value1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Value":"value1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Value":"value1"`)), ), }, }, @@ -343,13 +343,13 @@ func TestAccCloudControlResource_DesiredState_objectValueRemoved(t *testing.T) { { Config: testAccResourceConfig_desiredStateObjectValue1(rName, "key1", "value1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Value":"value1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Value":"value1"`)), ), }, { Config: testAccResourceConfig_desiredStateObjectValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"ClusterName":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"ClusterName":`)), ), }, }, @@ -370,19 +370,19 @@ func TestAccCloudControlResource_DesiredState_objectValueUpdate(t *testing.T) { { Config: testAccResourceConfig_desiredStateObjectValue1(rName, "key1", "value1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Value":"value1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Value":"value1"`)), ), }, { Config: testAccResourceConfig_desiredStateObjectValue1(rName, "key1", "value1updated"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Value":"value1updated"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Value":"value1updated"`)), ), }, { Config: testAccResourceConfig_desiredStateObjectValue1(rName, "key2", "value2"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Value":"value2"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Value":"value2"`)), ), }, }, @@ -403,13 +403,13 @@ func TestAccCloudControlResource_DesiredState_stringValueAdded(t *testing.T) { { Config: testAccResourceConfig_desiredStateStringValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Name":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Name":`)), ), }, { Config: testAccResourceConfig_desiredStateStringValue(rName, "description1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Description":"description1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Description":"description1"`)), ), }, }, @@ -430,13 +430,13 @@ func TestAccCloudControlResource_DesiredState_stringValueRemoved(t *testing.T) { { Config: testAccResourceConfig_desiredStateStringValue(rName, "description1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Description":"description1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Description":"description1"`)), ), }, { Config: testAccResourceConfig_desiredStateStringValueRemoved(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Name":`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Name":`)), ), }, }, @@ -457,13 +457,13 @@ func TestAccCloudControlResource_DesiredState_stringValueUpdate(t *testing.T) { { Config: testAccResourceConfig_desiredStateStringValue(rName, "description1"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Description":"description1"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Description":"description1"`)), ), }, { Config: testAccResourceConfig_desiredStateStringValue(rName, "description2"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`"Description":"description2"`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`"Description":"description2"`)), ), }, }, @@ -513,7 +513,7 @@ func TestAccCloudControlResource_lambdaFunction(t *testing.T) { { Config: testAccResourceConfig_lambdaFunction(rName), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestMatchResourceAttr(resourceName, "properties", regexache.MustCompile(`^\{.*\}$`)), + resource.TestMatchResourceAttr(resourceName, names.AttrProperties, regexache.MustCompile(`^\{.*\}$`)), resource.TestMatchResourceAttr(resourceName, "schema", regexache.MustCompile(`^\{.*`)), ), }, diff --git a/internal/service/cloudhsmv2/hsm.go b/internal/service/cloudhsmv2/hsm.go index 879ce99aca5..b334ed49972 100644 --- a/internal/service/cloudhsmv2/hsm.go +++ b/internal/service/cloudhsmv2/hsm.go @@ -64,7 +64,7 @@ func resourceHSM() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Optional: true, Computed: true, @@ -107,7 +107,7 @@ func resourceHSMCreate(ctx context.Context, d *schema.ResourceData, meta interfa } } - if v, ok := d.GetOk("ip_address"); ok { + if v, ok := d.GetOk(names.AttrIPAddress); ok { input.IpAddress = aws.String(v.(string)) } @@ -152,7 +152,7 @@ func resourceHSMRead(ctx context.Context, d *schema.ResourceData, meta interface d.Set("hsm_eni_id", hsm.EniId) d.Set("hsm_id", hsm.HsmId) d.Set("hsm_state", hsm.State) - d.Set("ip_address", hsm.EniIp) + d.Set(names.AttrIPAddress, hsm.EniIp) d.Set(names.AttrSubnetID, hsm.SubnetId) return diags diff --git a/internal/service/cloudhsmv2/hsm_test.go b/internal/service/cloudhsmv2/hsm_test.go index d4bc6d9455a..19035bffe43 100644 --- a/internal/service/cloudhsmv2/hsm_test.go +++ b/internal/service/cloudhsmv2/hsm_test.go @@ -40,7 +40,7 @@ func testAccHSM_basic(t *testing.T) { resource.TestMatchResourceAttr(resourceName, "hsm_eni_id", regexache.MustCompile(`^eni-.+`)), resource.TestMatchResourceAttr(resourceName, "hsm_id", regexache.MustCompile(`^hsm-.+`)), resource.TestCheckResourceAttr(resourceName, "hsm_state", string(types.HsmStateActive)), - resource.TestCheckResourceAttrSet(resourceName, "ip_address"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(resourceName, names.AttrSubnetID, "aws_subnet.test.0", names.AttrID), ), }, @@ -118,7 +118,7 @@ func testAccHSM_IPAddress(t *testing.T) { Config: testAccHSMConfig_ipAddress(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckHSMExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "ip_address", "10.0.0.5"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "10.0.0.5"), ), }, { diff --git a/internal/service/cloudwatch/metric_alarm.go b/internal/service/cloudwatch/metric_alarm.go index 1808541abc5..81d52588b93 100644 --- a/internal/service/cloudwatch/metric_alarm.go +++ b/internal/service/cloudwatch/metric_alarm.go @@ -125,7 +125,7 @@ func resourceMetricAlarm() *schema.Resource { ), }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Optional: true, ConflictsWith: []string{"metric_query"}, @@ -134,7 +134,7 @@ func resourceMetricAlarm() *schema.Resource { "metric_query": { Type: schema.TypeSet, Optional: true, - ConflictsWith: []string{"metric_name"}, + ConflictsWith: []string{names.AttrMetricName}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ names.AttrAccountID: { @@ -142,7 +142,7 @@ func resourceMetricAlarm() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 1024), @@ -163,7 +163,7 @@ func resourceMetricAlarm() *schema.Resource { Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -291,7 +291,7 @@ func resourceMetricAlarm() *schema.Resource { CustomizeDiff: customdiff.All( verify.SetTagsDiff, func(_ context.Context, diff *schema.ResourceDiff, v interface{}) error { - _, metricNameOk := diff.GetOk("metric_name") + _, metricNameOk := diff.GetOk(names.AttrMetricName) _, statisticOk := diff.GetOk("statistic") _, extendedStatisticOk := diff.GetOk("extended_statistic") @@ -302,7 +302,7 @@ func resourceMetricAlarm() *schema.Resource { if v := diff.Get("metric_query"); v != nil { for _, v := range v.(*schema.Set).List() { tfMap := v.(map[string]interface{}) - if v, ok := tfMap["expression"]; ok && v.(string) != "" { + if v, ok := tfMap[names.AttrExpression]; ok && v.(string) != "" { if v := tfMap["metric"]; v != nil { if len(v.([]interface{})) > 0 { return errors.New("No metric_query may have both `expression` and a `metric` specified") @@ -393,7 +393,7 @@ func resourceMetricAlarmRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("evaluation_periods", alarm.EvaluationPeriods) d.Set("extended_statistic", alarm.ExtendedStatistic) d.Set("insufficient_data_actions", alarm.InsufficientDataActions) - d.Set("metric_name", alarm.MetricName) + d.Set(names.AttrMetricName, alarm.MetricName) if len(alarm.Metrics) > 0 { if err := d.Set("metric_query", flattenMetricAlarmMetrics(alarm.Metrics)); err != nil { return sdkdiag.AppendErrorf(diags, "setting metric_query: %s", err) @@ -512,7 +512,7 @@ func expandPutMetricAlarmInput(ctx context.Context, d *schema.ResourceData) *clo apiObject.InsufficientDataActions = flex.ExpandStringValueSet(v.(*schema.Set)) } - if v, ok := d.GetOk("metric_name"); ok { + if v, ok := d.GetOk(names.AttrMetricName); ok { apiObject.MetricName = aws.String(v.(string)) } @@ -568,11 +568,11 @@ func flattenMetricAlarmMetrics(apiObjects []types.MetricDataQuery) []interface{} for _, apiObject := range apiObjects { tfMap := map[string]interface{}{ - names.AttrAccountID: aws.ToString(apiObject.AccountId), - "expression": aws.ToString(apiObject.Expression), - names.AttrID: aws.ToString(apiObject.Id), - "label": aws.ToString(apiObject.Label), - "return_data": aws.ToBool(apiObject.ReturnData), + names.AttrAccountID: aws.ToString(apiObject.AccountId), + names.AttrExpression: aws.ToString(apiObject.Expression), + names.AttrID: aws.ToString(apiObject.Id), + "label": aws.ToString(apiObject.Label), + "return_data": aws.ToBool(apiObject.ReturnData), } if v := apiObject.MetricStat; v != nil { @@ -602,7 +602,7 @@ func flattenMetricAlarmMetricsMetricStat(apiObject *types.MetricStat) map[string if v := apiObject.Metric; v != nil { tfMap["dimensions"] = flattenMetricAlarmDimensions(v.Dimensions) - tfMap["metric_name"] = aws.ToString(v.MetricName) + tfMap[names.AttrMetricName] = aws.ToString(v.MetricName) tfMap[names.AttrNamespace] = aws.ToString(v.Namespace) } @@ -631,7 +631,7 @@ func expandMetricAlarmMetrics(tfList []interface{}) []types.MetricDataQuery { apiObject.AccountId = aws.String(v.(string)) } - if v, ok := tfMap["expression"]; ok && v.(string) != "" { + if v, ok := tfMap[names.AttrExpression]; ok && v.(string) != "" { apiObject.Expression = aws.String(v.(string)) } @@ -668,7 +668,7 @@ func expandMetricAlarmMetricsMetric(tfMap map[string]interface{}) *types.MetricS apiObject := &types.MetricStat{ Metric: &types.Metric{ - MetricName: aws.String(tfMap["metric_name"].(string)), + MetricName: aws.String(tfMap[names.AttrMetricName].(string)), }, Stat: aws.String(tfMap["stat"].(string)), } diff --git a/internal/service/cloudwatch/metric_alarm_test.go b/internal/service/cloudwatch/metric_alarm_test.go index 17c2f25e1ed..51ee5d946c6 100755 --- a/internal/service/cloudwatch/metric_alarm_test.go +++ b/internal/service/cloudwatch/metric_alarm_test.go @@ -36,7 +36,7 @@ func TestAccCloudWatchMetricAlarm_basic(t *testing.T) { Config: testAccMetricAlarmConfig_basic(rName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckMetricAlarmExists(ctx, resourceName, &alarm), - resource.TestCheckResourceAttr(resourceName, "metric_name", "CPUUtilization"), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, "CPUUtilization"), resource.TestCheckResourceAttr(resourceName, "statistic", "Average"), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "cloudwatch", regexache.MustCompile(`alarm:.+`)), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), @@ -437,11 +437,11 @@ func TestAccCloudWatchMetricAlarm_metricQuery(t *testing.T) { testAccCheckMetricAlarmExists(ctx, resourceName, &alarm), resource.TestCheckResourceAttr(resourceName, "metric_query.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ - names.AttrID: "m1", - "expression": "SELECT MAX(MillisBehindLatest) FROM SCHEMA(\"foo\", Operation, ShardId) WHERE Operation = 'ProcessTask'", - "period": "60", - "label": "cat", - "return_data": "true", + names.AttrID: "m1", + names.AttrExpression: "SELECT MAX(MillisBehindLatest) FROM SCHEMA(\"foo\", Operation, ShardId) WHERE Operation = 'ProcessTask'", + "period": "60", + "label": "cat", + "return_data": "true", }), ), }, @@ -457,11 +457,11 @@ func TestAccCloudWatchMetricAlarm_metricQuery(t *testing.T) { testAccCheckMetricAlarmExists(ctx, resourceName, &alarm), resource.TestCheckResourceAttr(resourceName, "metric_query.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ - names.AttrID: "e1", - "expression": "m1", - "label": "cat", - "return_data": "true", - "period": "", + names.AttrID: "e1", + names.AttrExpression: "m1", + "label": "cat", + "return_data": "true", + "period": "", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ names.AttrID: "m1", @@ -505,18 +505,18 @@ func TestAccCloudWatchMetricAlarm_metricQuery(t *testing.T) { testAccCheckMetricAlarmExists(ctx, resourceName, &alarm), resource.TestCheckResourceAttr(resourceName, "metric_query.#", "3"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ - names.AttrID: "e1", - "expression": "m1", - "label": "cat", - "return_data": "", - "period": "", + names.AttrID: "e1", + names.AttrExpression: "m1", + "label": "cat", + "return_data": "", + "period": "", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ - names.AttrID: "e2", - "expression": "e1", - "label": "bug", - "return_data": "true", - "period": "", + names.AttrID: "e2", + names.AttrExpression: "e1", + "label": "bug", + "return_data": "true", + "period": "", }), ), }, @@ -545,11 +545,11 @@ func TestAccCloudWatchMetricAlarm_metricQuery(t *testing.T) { testAccCheckMetricAlarmExists(ctx, resourceName, &alarm), resource.TestCheckResourceAttr(resourceName, "metric_query.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "metric_query.*", map[string]string{ - names.AttrID: "e1", - "expression": "ANOMALY_DETECTION_BAND(m1)", - "label": "CPUUtilization (Expected)", - "return_data": "true", - "period": "", + names.AttrID: "e1", + names.AttrExpression: "ANOMALY_DETECTION_BAND(m1)", + "label": "CPUUtilization (Expected)", + "return_data": "true", + "period": "", }), ), }, diff --git a/internal/service/cloudwatch/metric_stream.go b/internal/service/cloudwatch/metric_stream.go index 494b12c7f1b..4a68f1056d5 100644 --- a/internal/service/cloudwatch/metric_stream.go +++ b/internal/service/cloudwatch/metric_stream.go @@ -178,7 +178,7 @@ func resourceMetricStream() *schema.Resource { Required: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 255), @@ -546,7 +546,7 @@ func expandMetricStreamStatisticsConfigurationsIncludeMetrics(tfList []interface apiObject := types.MetricStreamStatisticsMetric{} - if v, ok := tfMap["metric_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrMetricName].(string); ok && v != "" { apiObject.MetricName = aws.String(v) } @@ -599,7 +599,7 @@ func flattenMetricStreamStatisticsConfigurationsIncludeMetrics(apiObjects []type tfMap := map[string]interface{}{} if v := apiObject.MetricName; v != nil { - tfMap["metric_name"] = aws.ToString(v) + tfMap[names.AttrMetricName] = aws.ToString(v) } if v := apiObject.Namespace; v != nil { diff --git a/internal/service/codebuild/project.go b/internal/service/codebuild/project.go index fb8192ef0bf..b77ce14239c 100644 --- a/internal/service/codebuild/project.go +++ b/internal/service/codebuild/project.go @@ -356,7 +356,7 @@ func resourceProject() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Optional: true, }, @@ -664,7 +664,7 @@ func resourceProject() *schema.Resource { }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -803,7 +803,7 @@ func resourceProjectCreate(ctx context.Context, d *schema.ResourceData, meta int input.TimeoutInMinutes = aws.Int32(int32(v.(int))) } - if v, ok := d.GetOk("vpc_config"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrVPCConfig); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.VpcConfig = expandVPCConfig(v.([]interface{})[0].(map[string]interface{})) } @@ -914,7 +914,7 @@ func resourceProjectRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrSource, nil) } d.Set("source_version", project.SourceVersion) - if err := d.Set("vpc_config", flattenVPCConfig(project.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfig(project.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } @@ -1051,8 +1051,8 @@ func resourceProjectUpdate(ctx context.Context, d *schema.ResourceData, meta int input.TimeoutInMinutes = aws.Int32(int32(d.Get("build_timeout").(int))) } - if d.HasChange("vpc_config") { - if v, ok := d.GetOk("vpc_config"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if d.HasChange(names.AttrVPCConfig) { + if v, ok := d.GetOk(names.AttrVPCConfig); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.VpcConfig = expandVPCConfig(v.([]interface{})[0].(map[string]interface{})) } else { input.VpcConfig = &types.VpcConfig{} @@ -1429,7 +1429,7 @@ func expandCloudWatchLogsConfig(tfMap map[string]interface{}) *types.CloudWatchL Status: types.LogsConfigStatusType(tfMap[names.AttrStatus].(string)), } - if v, ok := tfMap["group_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrGroupName].(string); ok && v != "" { apiObject.GroupName = aws.String(v) } @@ -1662,7 +1662,7 @@ func flattenCloudWatchLogs(apiObject *types.CloudWatchLogsConfig) []interface{} if apiObject == nil { tfMap[names.AttrStatus] = types.LogsConfigStatusTypeDisabled } else { - tfMap["group_name"] = aws.ToString(apiObject.GroupName) + tfMap[names.AttrGroupName] = aws.ToString(apiObject.GroupName) tfMap[names.AttrStatus] = apiObject.Status tfMap["stream_name"] = aws.ToString(apiObject.StreamName) } diff --git a/internal/service/cognitoidentity/flex.go b/internal/service/cognitoidentity/flex.go index 4e28b17e47c..90be9bfc07b 100644 --- a/internal/service/cognitoidentity/flex.go +++ b/internal/service/cognitoidentity/flex.go @@ -72,7 +72,7 @@ func expandIdentityProviders(s *schema.Set) []awstypes.CognitoIdentityProvider { ip := awstypes.CognitoIdentityProvider{} - if sv, ok := s["client_id"].(string); ok { + if sv, ok := s[names.AttrClientID].(string); ok { ip.ClientId = aws.String(sv) } @@ -151,7 +151,7 @@ func flattenIdentityProviders(ips []awstypes.CognitoIdentityProvider) []map[stri ip := make(map[string]interface{}) if v.ClientId != nil { - ip["client_id"] = aws.ToString(v.ClientId) + ip[names.AttrClientID] = aws.ToString(v.ClientId) } if v.ProviderName != nil { diff --git a/internal/service/cognitoidentity/pool.go b/internal/service/cognitoidentity/pool.go index dc6e5fbfd2e..b510daf4d55 100644 --- a/internal/service/cognitoidentity/pool.go +++ b/internal/service/cognitoidentity/pool.go @@ -54,7 +54,7 @@ func resourcePool() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, ValidateFunc: validIdentityProvidersClientID, diff --git a/internal/service/cognitoidentity/pool_data_source.go b/internal/service/cognitoidentity/pool_data_source.go index b118d39d5f1..2b9c46dbd8e 100644 --- a/internal/service/cognitoidentity/pool_data_source.go +++ b/internal/service/cognitoidentity/pool_data_source.go @@ -43,7 +43,7 @@ func dataSourcePool() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/cognitoidentity/pool_test.go b/internal/service/cognitoidentity/pool_test.go index 8ba45b039e2..aa8e23ef5bc 100644 --- a/internal/service/cognitoidentity/pool_test.go +++ b/internal/service/cognitoidentity/pool_test.go @@ -270,12 +270,12 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "identity_pool_name", fmt.Sprintf("identity pool %s", name)), resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ - "client_id": "7lhlkkfbfb4q5kpp90urffao", + names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", "provider_name": 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{ - "client_id": "7lhlkkfbfb4q5kpp90urffao", + names.AttrClientID: "7lhlkkfbfb4q5kpp90urffao", "provider_name": fmt.Sprintf("cognito-idp.%[1]s.%[2]s/%[1]s_Ab129faBb", acctest.Region(), acctest.PartitionDNSSuffix()), "server_side_token_check": "false", }), @@ -294,7 +294,7 @@ func TestAccCognitoIdentityPool_cognitoIdentityProviders(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "identity_pool_name", fmt.Sprintf("identity pool %s", name)), resource.TestCheckResourceAttr(resourceName, "cognito_identity_providers.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cognito_identity_providers.*", map[string]string{ - "client_id": "6lhlkkfbfb4q5kpp90urffae", + names.AttrClientID: "6lhlkkfbfb4q5kpp90urffae", "provider_name": 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 98d0e95b4d6..2675d2b036e 100644 --- a/internal/service/cognitoidentity/validate_test.go +++ b/internal/service/cognitoidentity/validate_test.go @@ -58,7 +58,7 @@ func TestValidIdentityProvidersClientID(t *testing.T) { } for _, s := range validValues { - _, errors := validIdentityProvidersClientID(s, "client_id") + _, errors := validIdentityProvidersClientID(s, names.AttrClientID) if len(errors) > 0 { t.Fatalf("%q should be a valid Cognito Identity Provider Client ID: %v", s, errors) } @@ -73,7 +73,7 @@ func TestValidIdentityProvidersClientID(t *testing.T) { } for _, s := range invalidValues { - _, errors := validIdentityProvidersClientID(s, "client_id") + _, errors := validIdentityProvidersClientID(s, names.AttrClientID) if len(errors) == 0 { t.Fatalf("%q should not be a valid Cognito Identity Provider Client ID: %v", s, errors) } diff --git a/internal/service/cognitoidp/risk_configuration.go b/internal/service/cognitoidp/risk_configuration.go index 1610664c7d3..2d2d4baa5df 100644 --- a/internal/service/cognitoidp/risk_configuration.go +++ b/internal/service/cognitoidp/risk_configuration.go @@ -42,7 +42,7 @@ func resourceRiskConfiguration() *schema.Resource { ForceNew: true, ValidateFunc: validUserPoolID, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -300,7 +300,7 @@ func resourceRiskConfigurationPut(ctx context.Context, d *schema.ResourceData, m UserPoolId: aws.String(userPoolId), } - if v, ok := d.GetOk("client_id"); ok { + if v, ok := d.GetOk(names.AttrClientID); ok { input.ClientId = aws.String(v.(string)) id = fmt.Sprintf("%s:%s", userPoolId, v.(string)) } @@ -351,7 +351,7 @@ func resourceRiskConfigurationRead(ctx context.Context, d *schema.ResourceData, d.Set("user_pool_id", userPoolId) if clientId != "" { - d.Set("client_id", clientId) + d.Set(names.AttrClientID, clientId) } if riskConfig.RiskExceptionConfiguration != nil { diff --git a/internal/service/cognitoidp/risk_configuration_test.go b/internal/service/cognitoidp/risk_configuration_test.go index 6aa9535989e..885769075c7 100644 --- a/internal/service/cognitoidp/risk_configuration_test.go +++ b/internal/service/cognitoidp/risk_configuration_test.go @@ -35,7 +35,7 @@ func TestAccCognitoIDPRiskConfiguration_exception(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckRiskConfigurationExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", "aws_cognito_user_pool.test", names.AttrID), - resource.TestCheckNoResourceAttr(resourceName, "client_id"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrClientID), resource.TestCheckResourceAttr(resourceName, "account_takeover_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "compromised_credentials_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "risk_exception_configuration.#", "1"), @@ -54,7 +54,7 @@ func TestAccCognitoIDPRiskConfiguration_exception(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckRiskConfigurationExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", "aws_cognito_user_pool.test", names.AttrID), - resource.TestCheckNoResourceAttr(resourceName, "client_id"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrClientID), resource.TestCheckResourceAttr(resourceName, "account_takeover_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "compromised_credentials_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "risk_exception_configuration.#", "1"), @@ -85,7 +85,7 @@ func TestAccCognitoIDPRiskConfiguration_client(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckRiskConfigurationExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", "aws_cognito_user_pool.test", names.AttrID), - resource.TestCheckResourceAttrPair(resourceName, "client_id", "aws_cognito_user_pool_client.test", names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, "aws_cognito_user_pool_client.test", names.AttrID), resource.TestCheckResourceAttr(resourceName, "account_takeover_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "compromised_credentials_risk_configuration.#", "0"), resource.TestCheckResourceAttr(resourceName, "risk_exception_configuration.#", "1"), diff --git a/internal/service/cognitoidp/user_groups_data_source.go b/internal/service/cognitoidp/user_groups_data_source.go index d9bc902de68..b7f1777d305 100644 --- a/internal/service/cognitoidp/user_groups_data_source.go +++ b/internal/service/cognitoidp/user_groups_data_source.go @@ -51,7 +51,7 @@ func (d *userGroupsDataSource) Schema(ctx context.Context, request datasource.Sc names.AttrDescription: schema.StringAttribute{ Computed: true, }, - "group_name": schema.StringAttribute{ + names.AttrGroupName: schema.StringAttribute{ Computed: true, }, "precedence": schema.Int64Attribute{ diff --git a/internal/service/cognitoidp/user_in_group.go b/internal/service/cognitoidp/user_in_group.go index 8c0f4369da2..fc9a732c648 100644 --- a/internal/service/cognitoidp/user_in_group.go +++ b/internal/service/cognitoidp/user_in_group.go @@ -24,7 +24,7 @@ func resourceUserInGroup() *schema.Resource { ReadWithoutTimeout: resourceUserInGroupRead, DeleteWithoutTimeout: resourceUserInGroupDelete, Schema: map[string]*schema.Schema{ - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -52,7 +52,7 @@ func resourceUserInGroupCreate(ctx context.Context, d *schema.ResourceData, meta input := &cognitoidentityprovider.AdminAddUserToGroupInput{} - if v, ok := d.GetOk("group_name"); ok { + if v, ok := d.GetOk(names.AttrGroupName); ok { input.GroupName = aws.String(v.(string)) } @@ -80,7 +80,7 @@ func resourceUserInGroupRead(ctx context.Context, d *schema.ResourceData, meta i var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) userPoolId := d.Get("user_pool_id").(string) username := d.Get(names.AttrUsername).(string) @@ -101,7 +101,7 @@ func resourceUserInGroupDelete(ctx context.Context, d *schema.ResourceData, meta var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) userPoolID := d.Get("user_pool_id").(string) username := d.Get(names.AttrUsername).(string) diff --git a/internal/service/cognitoidp/user_in_group_test.go b/internal/service/cognitoidp/user_in_group_test.go index 90881542614..90fab5437e0 100644 --- a/internal/service/cognitoidp/user_in_group_test.go +++ b/internal/service/cognitoidp/user_in_group_test.go @@ -39,7 +39,7 @@ func TestAccCognitoIDPUserInGroup_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckUserInGroupExists(ctx, resourceName), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), - resource.TestCheckResourceAttrPair(resourceName, "group_name", userGroupResourceName, names.AttrName), + resource.TestCheckResourceAttrPair(resourceName, names.AttrGroupName, userGroupResourceName, names.AttrName), resource.TestCheckResourceAttrPair(resourceName, names.AttrUsername, userResourceName, names.AttrUsername), ), }, @@ -110,7 +110,7 @@ func testAccCheckUserInGroupExists(ctx context.Context, resourceName string) res conn := acctest.Provider.Meta().(*conns.AWSClient).CognitoIDPConn(ctx) - groupName := rs.Primary.Attributes["group_name"] + groupName := rs.Primary.Attributes[names.AttrGroupName] userPoolId := rs.Primary.Attributes["user_pool_id"] username := rs.Primary.Attributes[names.AttrUsername] @@ -137,7 +137,7 @@ func testAccCheckUserInGroupDestroy(ctx context.Context) resource.TestCheckFunc continue } - groupName := rs.Primary.Attributes["group_name"] + groupName := rs.Primary.Attributes[names.AttrGroupName] userPoolId := rs.Primary.Attributes["user_pool_id"] username := rs.Primary.Attributes[names.AttrUsername] diff --git a/internal/service/cognitoidp/user_pool_client_data_source.go b/internal/service/cognitoidp/user_pool_client_data_source.go index 2335ab620c3..ad59a7c7c2e 100644 --- a/internal/service/cognitoidp/user_pool_client_data_source.go +++ b/internal/service/cognitoidp/user_pool_client_data_source.go @@ -79,7 +79,7 @@ func dataSourceUserPoolClient() *schema.Resource { Type: schema.TypeString, }, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, }, @@ -187,7 +187,7 @@ func dataSourceUserPoolClientRead(ctx context.Context, d *schema.ResourceData, m var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - clientId := d.Get("client_id").(string) + clientId := d.Get(names.AttrClientID).(string) d.SetId(clientId) userPoolClient, err := FindCognitoUserPoolClientByID(ctx, conn, d.Get("user_pool_id").(string), d.Id()) diff --git a/internal/service/cognitoidp/user_pool_ui_customization.go b/internal/service/cognitoidp/user_pool_ui_customization.go index 76a698a7781..15db428eb67 100644 --- a/internal/service/cognitoidp/user_pool_ui_customization.go +++ b/internal/service/cognitoidp/user_pool_ui_customization.go @@ -36,7 +36,7 @@ func resourceUserPoolUICustomization() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Optional: true, Default: "ALL", @@ -83,7 +83,7 @@ func resourceUserPoolUICustomizationPut(ctx context.Context, d *schema.ResourceD var diags diag.Diagnostics conn := meta.(*conns.AWSClient).CognitoIDPConn(ctx) - userPoolID, clientID := d.Get("user_pool_id").(string), d.Get("client_id").(string) + userPoolID, clientID := d.Get("user_pool_id").(string), d.Get(names.AttrClientID).(string) id := errs.Must(flex.FlattenResourceId([]string{userPoolID, clientID}, userPoolUICustomizationResourceIDPartCount, false)) input := &cognitoidentityprovider.SetUICustomizationInput{ ClientId: aws.String(clientID), @@ -135,7 +135,7 @@ func resourceUserPoolUICustomizationRead(ctx context.Context, d *schema.Resource return sdkdiag.AppendErrorf(diags, "reading Cognito User Pool UI Customization (%s): %s", d.Id(), err) } - d.Set("client_id", uiCustomization.ClientId) + d.Set(names.AttrClientID, uiCustomization.ClientId) d.Set(names.AttrCreationDate, aws.TimeValue(uiCustomization.CreationDate).Format(time.RFC3339)) d.Set("css", uiCustomization.CSS) d.Set("css_version", uiCustomization.CSSVersion) diff --git a/internal/service/cognitoidp/user_pool_ui_customization_test.go b/internal/service/cognitoidp/user_pool_ui_customization_test.go index 9e4d31a4e04..fcda5313649 100644 --- a/internal/service/cognitoidp/user_pool_ui_customization_test.go +++ b/internal/service/cognitoidp/user_pool_ui_customization_test.go @@ -40,7 +40,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_CSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", css), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrSet(resourceName, "css_version"), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), ), @@ -57,7 +57,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_CSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", cssUpdated), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrSet(resourceName, "css_version"), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), ), @@ -116,7 +116,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_imageFile(t *testing.T) Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "image_url"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), @@ -133,7 +133,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_imageFile(t *testing.T) Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "image_url"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), @@ -170,7 +170,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_CSSAndImageFile(t *test Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttr(resourceName, "css", css), resource.TestCheckResourceAttrSet(resourceName, "css_version"), resource.TestCheckResourceAttrSet(resourceName, "image_url"), @@ -191,7 +191,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_CSSAndImageFile(t *test resource.TestCheckResourceAttr(resourceName, "css", css), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrSet(resourceName, "css_version"), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), ), @@ -201,7 +201,7 @@ func TestAccCognitoIDPUserPoolUICustomization_AllClients_CSSAndImageFile(t *test Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), resource.TestCheckResourceAttrSet(resourceName, "image_url"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), @@ -240,7 +240,7 @@ func TestAccCognitoIDPUserPoolUICustomization_Client_CSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", css), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrSet(resourceName, "css_version"), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), ), @@ -257,7 +257,7 @@ func TestAccCognitoIDPUserPoolUICustomization_Client_CSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", cssUpdated), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), resource.TestCheckResourceAttrSet(resourceName, "css_version"), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), ), @@ -317,7 +317,7 @@ func TestAccCognitoIDPUserPoolUICustomization_Client_image(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(resourceName, "image_url"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), @@ -334,7 +334,7 @@ func TestAccCognitoIDPUserPoolUICustomization_Client_image(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttrSet(resourceName, names.AttrCreationDate), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(resourceName, "image_url"), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), @@ -378,7 +378,7 @@ func TestAccCognitoIDPUserPoolUICustomization_ClientAndAll_cSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", allCSS), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), - resource.TestCheckResourceAttrPair(clientUIResourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(clientUIResourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(clientUIResourceName, names.AttrCreationDate), resource.TestCheckResourceAttr(clientUIResourceName, "css", allCSS), resource.TestCheckResourceAttrSet(clientUIResourceName, "last_modified_date"), @@ -405,7 +405,7 @@ func TestAccCognitoIDPUserPoolUICustomization_ClientAndAll_cSS(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "css", allCSS), resource.TestCheckResourceAttrSet(resourceName, "last_modified_date"), resource.TestCheckResourceAttrPair(resourceName, "user_pool_id", userPoolResourceName, names.AttrID), - resource.TestCheckResourceAttrPair(clientUIResourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(clientUIResourceName, names.AttrClientID, clientResourceName, names.AttrID), resource.TestCheckResourceAttrSet(clientUIResourceName, names.AttrCreationDate), resource.TestCheckResourceAttr(clientUIResourceName, "css", clientCSS), resource.TestCheckResourceAttrSet(clientUIResourceName, "last_modified_date"), @@ -446,7 +446,7 @@ func TestAccCognitoIDPUserPoolUICustomization_UpdateClientToAll_cSS(t *testing.T Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "css", css), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), ), }, { @@ -454,7 +454,7 @@ func TestAccCognitoIDPUserPoolUICustomization_UpdateClientToAll_cSS(t *testing.T Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "css", cssUpdated), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), ), }, { @@ -486,7 +486,7 @@ func TestAccCognitoIDPUserPoolUICustomization_UpdateAllToClient_cSS(t *testing.T Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "css", css), - resource.TestCheckResourceAttr(resourceName, "client_id", "ALL"), + resource.TestCheckResourceAttr(resourceName, names.AttrClientID, "ALL"), ), }, { @@ -494,7 +494,7 @@ func TestAccCognitoIDPUserPoolUICustomization_UpdateAllToClient_cSS(t *testing.T Check: resource.ComposeAggregateTestCheckFunc( testAccCheckUserPoolUICustomizationExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "css", cssUpdated), - resource.TestCheckResourceAttrPair(resourceName, "client_id", clientResourceName, names.AttrID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrClientID, clientResourceName, names.AttrID), ), }, { @@ -515,7 +515,7 @@ func testAccCheckUserPoolUICustomizationDestroy(ctx context.Context) resource.Te continue } - _, err := tfcognitoidp.FindUserPoolUICustomizationByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes["client_id"]) + _, err := tfcognitoidp.FindUserPoolUICustomizationByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes[names.AttrClientID]) if tfresource.NotFound(err) { continue @@ -541,7 +541,7 @@ func testAccCheckUserPoolUICustomizationExists(ctx context.Context, n string) re conn := acctest.Provider.Meta().(*conns.AWSClient).CognitoIDPConn(ctx) - _, err := tfcognitoidp.FindUserPoolUICustomizationByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes["client_id"]) + _, err := tfcognitoidp.FindUserPoolUICustomizationByTwoPartKey(ctx, conn, rs.Primary.Attributes["user_pool_id"], rs.Primary.Attributes[names.AttrClientID]) return err } diff --git a/internal/service/comprehend/document_classifier.go b/internal/service/comprehend/document_classifier.go index 921231a4daa..a28e9e6dca6 100644 --- a/internal/service/comprehend/document_classifier.go +++ b/internal/service/comprehend/document_classifier.go @@ -213,7 +213,7 @@ func ResourceDocumentClassifier() *schema.Resource { DiffSuppressFunc: tfkms.DiffSuppressKey, ValidateFunc: tfkms.ValidateKey, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -333,7 +333,7 @@ func resourceDocumentClassifierRead(ctx context.Context, d *schema.ResourceData, return sdkdiag.AppendErrorf(diags, "setting output_data_config: %s", err) } - if err := d.Set("vpc_config", flattenVPCConfig(out.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfig(out.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } @@ -475,7 +475,7 @@ func documentClassifierPublishVersion(ctx context.Context, conn *comprehend.Clie Mode: types.DocumentClassifierMode(d.Get(names.AttrMode).(string)), OutputDataConfig: expandDocumentClassifierOutputDataConfig(d.Get("output_data_config").([]interface{})), VersionName: versionName, - VpcConfig: expandVPCConfig(d.Get("vpc_config").([]interface{})), + VpcConfig: expandVPCConfig(d.Get(names.AttrVPCConfig).([]interface{})), ClientRequestToken: aws.String(id.UniqueId()), Tags: getTagsIn(ctx), } diff --git a/internal/service/comprehend/entity_recognizer.go b/internal/service/comprehend/entity_recognizer.go index aeef2053db5..87061dcbb5e 100644 --- a/internal/service/comprehend/entity_recognizer.go +++ b/internal/service/comprehend/entity_recognizer.go @@ -234,7 +234,7 @@ func ResourceEntityRecognizer() *schema.Resource { DiffSuppressFunc: tfkms.DiffSuppressKey, ValidateFunc: tfkms.ValidateKey, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -363,7 +363,7 @@ func resourceEntityRecognizerRead(ctx context.Context, d *schema.ResourceData, m return sdkdiag.AppendErrorf(diags, "setting input_data_config: %s", err) } - if err := d.Set("vpc_config", flattenVPCConfig(out.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfig(out.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } @@ -503,7 +503,7 @@ func entityRecognizerPublishVersion(ctx context.Context, conn *comprehend.Client LanguageCode: types.LanguageCode(d.Get("language_code").(string)), RecognizerName: aws.String(d.Get(names.AttrName).(string)), VersionName: versionName, - VpcConfig: expandVPCConfig(d.Get("vpc_config").([]interface{})), + VpcConfig: expandVPCConfig(d.Get(names.AttrVPCConfig).([]interface{})), ClientRequestToken: aws.String(id.UniqueId()), Tags: getTagsIn(ctx), } diff --git a/internal/service/datasync/agent.go b/internal/service/datasync/agent.go index 2d7af7e05c5..eac1ab7ccf7 100644 --- a/internal/service/datasync/agent.go +++ b/internal/service/datasync/agent.go @@ -52,9 +52,9 @@ func ResourceAgent() *schema.Resource { Optional: true, Computed: true, ForceNew: true, - ConflictsWith: []string{"private_link_endpoint", "ip_address"}, + ConflictsWith: []string{"private_link_endpoint", names.AttrIPAddress}, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Optional: true, Computed: true, @@ -102,7 +102,7 @@ func resourceAgentCreate(ctx context.Context, d *schema.ResourceData, meta inter conn := meta.(*conns.AWSClient).DataSyncClient(ctx) activationKey := d.Get("activation_key").(string) - agentIpAddress := d.Get("ip_address").(string) + agentIpAddress := d.Get(names.AttrIPAddress).(string) // Perform one time fetch of activation key from gateway IP address. if activationKey == "" { diff --git a/internal/service/datasync/agent_test.go b/internal/service/datasync/agent_test.go index b56c6133d57..62835f55722 100644 --- a/internal/service/datasync/agent_test.go +++ b/internal/service/datasync/agent_test.go @@ -51,7 +51,7 @@ func TestAccDataSyncAgent_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"activation_key", "ip_address"}, + ImportStateVerifyIgnore: []string{"activation_key", names.AttrIPAddress}, }, }, }) @@ -112,7 +112,7 @@ func TestAccDataSyncAgent_agentName(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"activation_key", "ip_address"}, + ImportStateVerifyIgnore: []string{"activation_key", names.AttrIPAddress}, }, }, }) @@ -142,7 +142,7 @@ func TestAccDataSyncAgent_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"activation_key", "ip_address"}, + ImportStateVerifyIgnore: []string{"activation_key", names.AttrIPAddress}, }, { Config: testAccAgentConfig_tags2(rName, "key1", "value1updated", "key2", "value2"), @@ -197,7 +197,7 @@ func TestAccDataSyncAgent_vpcEndpointID(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"activation_key", "ip_address", "private_link_ip"}, + ImportStateVerifyIgnore: []string{"activation_key", names.AttrIPAddress, "private_link_ip"}, }, }, }) diff --git a/internal/service/datasync/task.go b/internal/service/datasync/task.go index 9ad9cd01637..462a1dd65e3 100644 --- a/internal/service/datasync/task.go +++ b/internal/service/datasync/task.go @@ -198,7 +198,7 @@ func resourceTask() *schema.Resource { }, }, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -337,7 +337,7 @@ func resourceTaskCreate(ctx context.Context, d *schema.ResourceData, meta interf input.TaskReportConfig = expandTaskReportConfig(v.([]interface{})) } - if v, ok := d.GetOk("schedule"); ok { + if v, ok := d.GetOk(names.AttrSchedule); ok { input.Schedule = expandTaskSchedule(v.([]interface{})) } @@ -385,7 +385,7 @@ func resourceTaskRead(ctx context.Context, d *schema.ResourceData, meta interfac if err := d.Set("options", flattenOptions(output.Options)); err != nil { return sdkdiag.AppendErrorf(diags, "setting options: %s", err) } - if err := d.Set("schedule", flattenTaskSchedule(output.Schedule)); err != nil { + if err := d.Set(names.AttrSchedule, flattenTaskSchedule(output.Schedule)); err != nil { return sdkdiag.AppendErrorf(diags, "setting schedule: %s", err) } if err := d.Set("task_report_config", flattenTaskReportConfig(output.TaskReportConfig)); err != nil { @@ -425,8 +425,8 @@ func resourceTaskUpdate(ctx context.Context, d *schema.ResourceData, meta interf input.Options = expandOptions(d.Get("options").([]interface{})) } - if d.HasChanges("schedule") { - input.Schedule = expandTaskSchedule(d.Get("schedule").([]interface{})) + if d.HasChanges(names.AttrSchedule) { + input.Schedule = expandTaskSchedule(d.Get(names.AttrSchedule).([]interface{})) } if d.HasChanges("task_report_config") { diff --git a/internal/service/devicefarm/test_grid_project.go b/internal/service/devicefarm/test_grid_project.go index ec6fdfa9cbf..8b7bea88a44 100644 --- a/internal/service/devicefarm/test_grid_project.go +++ b/internal/service/devicefarm/test_grid_project.go @@ -51,7 +51,7 @@ func ResourceTestGridProject() *schema.Resource { }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -94,7 +94,7 @@ func resourceTestGridProjectCreate(ctx context.Context, d *schema.ResourceData, input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("vpc_config"); ok { + if v, ok := d.GetOk(names.AttrVPCConfig); ok { input.VpcConfig = expandTestGridProjectVPCConfig(v.([]interface{})) } @@ -133,7 +133,7 @@ func resourceTestGridProjectRead(ctx context.Context, d *schema.ResourceData, me d.Set(names.AttrName, project.Name) d.Set(names.AttrARN, arn) d.Set(names.AttrDescription, project.Description) - if err := d.Set("vpc_config", flattenTestGridProjectVPCConfig(project.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenTestGridProjectVPCConfig(project.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } diff --git a/internal/service/dlm/lifecycle_policy.go b/internal/service/dlm/lifecycle_policy.go index 9ea28b7bcf8..58c1991dfc9 100644 --- a/internal/service/dlm/lifecycle_policy.go +++ b/internal/service/dlm/lifecycle_policy.go @@ -216,7 +216,7 @@ func ResourceLifecyclePolicy() *schema.Resource { Default: dlm.PolicyTypeValuesEbsSnapshotManagement, ValidateFunc: validation.StringInSlice(dlm.PolicyTypeValues_Values(), false), }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, Optional: true, MinItems: 1, @@ -624,7 +624,7 @@ func expandPolicyDetails(cfg []interface{}) *dlm.PolicyDetails { if v, ok := m["resource_locations"].([]interface{}); ok && len(v) > 0 { policyDetails.ResourceLocations = flex.ExpandStringList(v) } - if v, ok := m["schedule"].([]interface{}); ok && len(v) > 0 { + if v, ok := m[names.AttrSchedule].([]interface{}); ok && len(v) > 0 { policyDetails.Schedules = expandSchedules(v) } if v, ok := m[names.AttrAction].([]interface{}); ok && len(v) > 0 { @@ -649,7 +649,7 @@ func flattenPolicyDetails(policyDetails *dlm.PolicyDetails) []map[string]interfa result["resource_locations"] = flex.FlattenStringList(policyDetails.ResourceLocations) result[names.AttrAction] = flattenActions(policyDetails.Actions) result["event_source"] = flattenEventSource(policyDetails.EventSource) - result["schedule"] = flattenSchedules(policyDetails.Schedules) + result[names.AttrSchedule] = flattenSchedules(policyDetails.Schedules) result["target_tags"] = flattenTags(policyDetails.TargetTags) result["policy_type"] = aws.StringValue(policyDetails.PolicyType) diff --git a/internal/service/ec2/ec2_availability_zone_data_source.go b/internal/service/ec2/ec2_availability_zone_data_source.go index 88d8ba74dc2..20507dba754 100644 --- a/internal/service/ec2/ec2_availability_zone_data_source.go +++ b/internal/service/ec2/ec2_availability_zone_data_source.go @@ -33,7 +33,7 @@ func DataSourceAvailabilityZone() *schema.Resource { Optional: true, }, names.AttrFilter: customFiltersSchema(), - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Computed: true, }, @@ -132,7 +132,7 @@ func dataSourceAvailabilityZoneRead(ctx context.Context, d *schema.ResourceData, nameSuffix = strings.TrimLeft(nameSuffix, "-") d.SetId(aws.StringValue(az.ZoneName)) - d.Set("group_name", az.GroupName) + d.Set(names.AttrGroupName, az.GroupName) d.Set(names.AttrName, az.ZoneName) d.Set("name_suffix", nameSuffix) d.Set("network_border_group", az.NetworkBorderGroup) diff --git a/internal/service/ec2/ec2_availability_zone_data_source_test.go b/internal/service/ec2/ec2_availability_zone_data_source_test.go index 75f1fa8d273..3ab925d5062 100644 --- a/internal/service/ec2/ec2_availability_zone_data_source_test.go +++ b/internal/service/ec2/ec2_availability_zone_data_source_test.go @@ -31,7 +31,7 @@ func TestAccEC2AvailabilityZoneDataSource_allAvailabilityZones(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_allAZs(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "group_name", acctest.Region()), + resource.TestCheckResourceAttr(dataSourceName, names.AttrGroupName, acctest.Region()), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z]$`)), resource.TestCheckResourceAttr(dataSourceName, "network_border_group", acctest.Region()), @@ -60,7 +60,7 @@ func TestAccEC2AvailabilityZoneDataSource_filter(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_filter(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "group_name", acctest.Region()), + resource.TestCheckResourceAttr(dataSourceName, names.AttrGroupName, acctest.Region()), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z]$`)), resource.TestCheckResourceAttr(dataSourceName, "network_border_group", acctest.Region()), @@ -89,7 +89,7 @@ func TestAccEC2AvailabilityZoneDataSource_localZone(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_type("local-zone"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet(dataSourceName, "group_name"), + resource.TestCheckResourceAttrSet(dataSourceName, names.AttrGroupName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[0-9a-z][0-9a-z-]+$`)), resource.TestCheckResourceAttrSet(dataSourceName, "network_border_group"), @@ -118,7 +118,7 @@ func TestAccEC2AvailabilityZoneDataSource_name(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_name(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "group_name", acctest.Region()), + resource.TestCheckResourceAttr(dataSourceName, names.AttrGroupName, acctest.Region()), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z]$`)), resource.TestCheckResourceAttr(dataSourceName, "network_border_group", acctest.Region()), @@ -147,7 +147,7 @@ func TestAccEC2AvailabilityZoneDataSource_wavelengthZone(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_type("wavelength-zone"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet(dataSourceName, "group_name"), + resource.TestCheckResourceAttrSet(dataSourceName, names.AttrGroupName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[0-9a-z][0-9a-z-]+$`)), resource.TestCheckResourceAttrSet(dataSourceName, "network_border_group"), @@ -176,7 +176,7 @@ func TestAccEC2AvailabilityZoneDataSource_zoneID(t *testing.T) { { Config: testAccAvailabilityZoneDataSourceConfig_id(), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttr(dataSourceName, "group_name", acctest.Region()), + resource.TestCheckResourceAttr(dataSourceName, names.AttrGroupName, acctest.Region()), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrName, availabilityZonesDataSourceName, "names.0"), resource.TestMatchResourceAttr(dataSourceName, "name_suffix", regexache.MustCompile(`^[a-z]$`)), resource.TestCheckResourceAttr(dataSourceName, "network_border_group", acctest.Region()), diff --git a/internal/service/ec2/ec2_availability_zone_group.go b/internal/service/ec2/ec2_availability_zone_group.go index 2e824e76673..f13eac56aaf 100644 --- a/internal/service/ec2/ec2_availability_zone_group.go +++ b/internal/service/ec2/ec2_availability_zone_group.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_ec2_availability_zone_group") @@ -29,7 +30,7 @@ func ResourceAvailabilityZoneGroup() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -50,7 +51,7 @@ func resourceAvailabilityZoneGroupCreate(ctx context.Context, d *schema.Resource var diags diag.Diagnostics conn := meta.(*conns.AWSClient).EC2Conn(ctx) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) availabilityZone, err := FindAvailabilityZoneGroupByName(ctx, conn, groupName) if err != nil { @@ -82,7 +83,7 @@ func resourceAvailabilityZoneGroupRead(ctx context.Context, d *schema.ResourceDa return sdkdiag.AppendErrorf(diags, "unnecessary handling of EC2 Availability Zone Group (%s), status: %s", d.Id(), ec2.AvailabilityZoneOptInStatusOptInNotRequired) } - d.Set("group_name", availabilityZone.GroupName) + d.Set(names.AttrGroupName, availabilityZone.GroupName) d.Set("opt_in_status", availabilityZone.OptInStatus) return diags diff --git a/internal/service/ec2/ec2_fleet.go b/internal/service/ec2/ec2_fleet.go index 6db388018a4..387bc2922a3 100644 --- a/internal/service/ec2/ec2_fleet.go +++ b/internal/service/ec2/ec2_fleet.go @@ -1183,7 +1183,7 @@ func expandPlacement(tfMap map[string]interface{}) *ec2.Placement { apiObject.GroupId = aws.String(v) } - if v, ok := tfMap["group_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrGroupName].(string); ok && v != "" { apiObject.GroupName = aws.String(v) } @@ -1513,7 +1513,7 @@ func flattenPlacement(apiObject *ec2.PlacementResponse) map[string]interface{} { tfMap := map[string]interface{}{} if v := apiObject.GroupName; v != nil { - tfMap["group_name"] = aws.StringValue(v) + tfMap[names.AttrGroupName] = aws.StringValue(v) } return tfMap diff --git a/internal/service/ec2/ec2_launch_template.go b/internal/service/ec2/ec2_launch_template.go index d4b8eb16887..f9fda75e831 100644 --- a/internal/service/ec2/ec2_launch_template.go +++ b/internal/service/ec2/ec2_launch_template.go @@ -851,7 +851,7 @@ func ResourceLaunchTemplate() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Optional: true, }, @@ -2103,7 +2103,7 @@ func expandLaunchTemplatePlacementRequest(tfMap map[string]interface{}) *ec2.Lau apiObject.AvailabilityZone = aws.String(v) } - if v, ok := tfMap["group_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrGroupName].(string); ok && v != "" { apiObject.GroupName = aws.String(v) } @@ -3097,7 +3097,7 @@ func flattenLaunchTemplatePlacement(apiObject *ec2.LaunchTemplatePlacement) map[ } if v := apiObject.GroupName; v != nil { - tfMap["group_name"] = aws.StringValue(v) + tfMap[names.AttrGroupName] = aws.StringValue(v) } if v := apiObject.HostId; 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 4d0412979a0..07aa6e555ce 100644 --- a/internal/service/ec2/ec2_launch_template_data_source.go +++ b/internal/service/ec2/ec2_launch_template_data_source.go @@ -696,7 +696,7 @@ func DataSourceLaunchTemplate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/ec2/verifiedaccess_trust_provider.go b/internal/service/ec2/verifiedaccess_trust_provider.go index ff6dc0f1c15..10b936d9698 100644 --- a/internal/service/ec2/verifiedaccess_trust_provider.go +++ b/internal/service/ec2/verifiedaccess_trust_provider.go @@ -81,7 +81,7 @@ func ResourceVerifiedAccessTrustProvider() *schema.Resource { Optional: true, ValidateFunc: validation.IsURLWithHTTPS, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, ForceNew: true, Optional: true, @@ -302,7 +302,7 @@ func flattenOIDCOptions(apiObject *types.OidcOptions, clientSecret string) []int tfMap["authorization_endpoint"] = aws.ToString(v) } if v := apiObject.ClientId; v != nil { - tfMap["client_id"] = aws.ToString(v) + tfMap[names.AttrClientID] = aws.ToString(v) } if v := apiObject.Issuer; v != nil { tfMap["issuer"] = aws.ToString(v) @@ -344,7 +344,7 @@ func expandCreateVerifiedAccessTrustProviderOIDCOptions(tfMap map[string]interfa if v, ok := tfMap["authorization_endpoint"].(string); ok && v != "" { apiObject.AuthorizationEndpoint = aws.String(v) } - if v, ok := tfMap["client_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrClientID].(string); ok && v != "" { apiObject.ClientId = aws.String(v) } if v, ok := tfMap["client_secret"].(string); ok && v != "" { diff --git a/internal/service/ec2/vpnsite_customer_gateway.go b/internal/service/ec2/vpnsite_customer_gateway.go index eafcea47309..7b7dcce0606 100644 --- a/internal/service/ec2/vpnsite_customer_gateway.go +++ b/internal/service/ec2/vpnsite_customer_gateway.go @@ -60,7 +60,7 @@ func resourceCustomerGateway() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -108,7 +108,7 @@ func resourceCustomerGatewayCreate(ctx context.Context, d *schema.ResourceData, input.DeviceName = aws.String(v.(string)) } - if v, ok := d.GetOk("ip_address"); ok { + if v, ok := d.GetOk(names.AttrIPAddress); ok { input.IpAddress = aws.String(v.(string)) } @@ -155,7 +155,7 @@ func resourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData, me d.Set("bgp_asn", customerGateway.BgpAsn) d.Set(names.AttrCertificateARN, customerGateway.CertificateArn) d.Set(names.AttrDeviceName, customerGateway.DeviceName) - d.Set("ip_address", customerGateway.IpAddress) + d.Set(names.AttrIPAddress, customerGateway.IpAddress) d.Set(names.AttrType, customerGateway.Type) setTagsOut(ctx, customerGateway.Tags) diff --git a/internal/service/ec2/vpnsite_customer_gateway_data_source.go b/internal/service/ec2/vpnsite_customer_gateway_data_source.go index 5a2684ea766..7b797d7f45e 100644 --- a/internal/service/ec2/vpnsite_customer_gateway_data_source.go +++ b/internal/service/ec2/vpnsite_customer_gateway_data_source.go @@ -53,7 +53,7 @@ func dataSourceCustomerGateway() *schema.Resource { Optional: true, Computed: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -111,7 +111,7 @@ func dataSourceCustomerGatewayRead(ctx context.Context, d *schema.ResourceData, } d.Set(names.AttrCertificateARN, cgw.CertificateArn) d.Set(names.AttrDeviceName, cgw.DeviceName) - d.Set("ip_address", cgw.IpAddress) + d.Set(names.AttrIPAddress, cgw.IpAddress) d.Set(names.AttrType, cgw.Type) if err := d.Set(names.AttrTags, KeyValueTags(ctx, cgw.Tags).IgnoreAWS().IgnoreConfig(ignoreTagsConfig).Map()); err != nil { diff --git a/internal/service/ec2/vpnsite_customer_gateway_data_source_test.go b/internal/service/ec2/vpnsite_customer_gateway_data_source_test.go index 20723c16ee0..84ecfd573b8 100644 --- a/internal/service/ec2/vpnsite_customer_gateway_data_source_test.go +++ b/internal/service/ec2/vpnsite_customer_gateway_data_source_test.go @@ -34,7 +34,7 @@ func TestAccSiteVPNCustomerGatewayDataSource_filter(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "bgp_asn", dataSourceName, "bgp_asn"), resource.TestCheckResourceAttrPair(resourceName, names.AttrCertificateARN, dataSourceName, names.AttrCertificateARN), resource.TestCheckResourceAttrPair(resourceName, names.AttrDeviceName, dataSourceName, names.AttrDeviceName), - resource.TestCheckResourceAttrPair(resourceName, "ip_address", dataSourceName, "ip_address"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrIPAddress, dataSourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(resourceName, "tags.%", dataSourceName, "tags.%"), resource.TestCheckResourceAttrPair(resourceName, names.AttrType, dataSourceName, names.AttrType), ), @@ -64,7 +64,7 @@ func TestAccSiteVPNCustomerGatewayDataSource_id(t *testing.T) { resource.TestCheckResourceAttrPair(resourceName, "bgp_asn", dataSourceName, "bgp_asn"), resource.TestCheckResourceAttrPair(resourceName, names.AttrCertificateARN, dataSourceName, names.AttrCertificateARN), resource.TestCheckResourceAttrPair(resourceName, names.AttrDeviceName, dataSourceName, names.AttrDeviceName), - resource.TestCheckResourceAttrPair(resourceName, "ip_address", dataSourceName, "ip_address"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrIPAddress, dataSourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(resourceName, "tags.%", dataSourceName, "tags.%"), resource.TestCheckResourceAttrPair(resourceName, names.AttrType, dataSourceName, names.AttrType), ), diff --git a/internal/service/ec2/vpnsite_customer_gateway_test.go b/internal/service/ec2/vpnsite_customer_gateway_test.go index e8ef5737fbd..f039dd5efa1 100644 --- a/internal/service/ec2/vpnsite_customer_gateway_test.go +++ b/internal/service/ec2/vpnsite_customer_gateway_test.go @@ -42,7 +42,7 @@ func TestAccSiteVPNCustomerGateway_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "bgp_asn", strconv.Itoa(rBgpAsn)), resource.TestCheckResourceAttr(resourceName, names.AttrCertificateARN, ""), resource.TestCheckResourceAttr(resourceName, names.AttrDeviceName, ""), - resource.TestCheckResourceAttr(resourceName, "ip_address", "172.0.0.1"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "172.0.0.1"), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrType, "ipsec.1"), ), @@ -217,7 +217,7 @@ func TestAccSiteVPNCustomerGateway_certificate(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckCustomerGatewayExists(ctx, resourceName, &gateway), resource.TestCheckResourceAttrPair(resourceName, names.AttrCertificateARN, acmCertificateResourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "ip_address", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, ""), ), }, { diff --git a/internal/service/ecs/service.go b/internal/service/ecs/service.go index e8479dc2218..ad323fabed8 100644 --- a/internal/service/ecs/service.go +++ b/internal/service/ecs/service.go @@ -293,7 +293,7 @@ func ResourceService() *schema.Resource { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, }, @@ -1295,7 +1295,7 @@ func expandPlacementConstraints(tfList []interface{}) ([]*ecs.PlacementConstrain apiObject := &ecs.PlacementConstraint{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { apiObject.Expression = aws.String(v) } @@ -1322,7 +1322,7 @@ func flattenServicePlacementConstraints(pcs []*ecs.PlacementConstraint) []map[st c := make(map[string]interface{}) c[names.AttrType] = aws.StringValue(pc.Type) if pc.Expression != nil { - c["expression"] = aws.StringValue(pc.Expression) + c[names.AttrExpression] = aws.StringValue(pc.Expression) } results = append(results, c) diff --git a/internal/service/ecs/task_definition.go b/internal/service/ecs/task_definition.go index 479a3b4f021..2ff407c855b 100644 --- a/internal/service/ecs/task_definition.go +++ b/internal/service/ecs/task_definition.go @@ -184,7 +184,7 @@ func ResourceTaskDefinition() *schema.Resource { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, ForceNew: true, Optional: true, @@ -210,7 +210,7 @@ func ResourceTaskDefinition() *schema.Resource { Required: true, ForceNew: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Elem: &schema.Schema{Type: schema.TypeString}, Optional: true, @@ -762,7 +762,7 @@ func flattenPlacementConstraints(pcs []*ecs.TaskDefinitionPlacementConstraint) [ for _, pc := range pcs { c := make(map[string]interface{}) c[names.AttrType] = aws.StringValue(pc.Type) - c["expression"] = aws.StringValue(pc.Expression) + c[names.AttrExpression] = aws.StringValue(pc.Expression) results = append(results, c) } return results @@ -809,7 +809,7 @@ func flattenProxyConfiguration(pc *ecs.ProxyConfiguration) []map[string]interfac config := make(map[string]interface{}) config["container_name"] = aws.StringValue(pc.ContainerName) config[names.AttrType] = aws.StringValue(pc.Type) - config["properties"] = meshProperties + config[names.AttrProperties] = meshProperties return []map[string]interface{}{ config, @@ -848,7 +848,7 @@ func expandTaskDefinitionPlacementConstraints(constraints []interface{}) ([]*ecs for _, raw := range constraints { p := raw.(map[string]interface{}) t := p[names.AttrType].(string) - e := p["expression"].(string) + e := p[names.AttrExpression].(string) if err := validPlacementConstraint(t, e); err != nil { return nil, err } @@ -884,7 +884,7 @@ func expandTaskDefinitionProxyConfiguration(proxyConfigs []interface{}) *ecs.Pro proxyConfig := proxyConfigs[0] configMap := proxyConfig.(map[string]interface{}) - rawProperties := configMap["properties"].(map[string]interface{}) + rawProperties := configMap[names.AttrProperties].(map[string]interface{}) properties := make([]*ecs.KeyValuePair, len(rawProperties)) i := 0 diff --git a/internal/service/ecs/task_execution_data_source.go b/internal/service/ecs/task_execution_data_source.go index 2b1d0acdce4..70a10ef9105 100644 --- a/internal/service/ecs/task_execution_data_source.go +++ b/internal/service/ecs/task_execution_data_source.go @@ -213,7 +213,7 @@ func DataSourceTaskExecution() *schema.Resource { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, }, diff --git a/internal/service/ecs/validate_test.go b/internal/service/ecs/validate_test.go index 71c0be520ff..45835d7a5ed 100644 --- a/internal/service/ecs/validate_test.go +++ b/internal/service/ecs/validate_test.go @@ -5,6 +5,8 @@ package ecs import ( "testing" + + "github.com/hashicorp/terraform-provider-aws/names" ) func TestValidPlacementConstraint(t *testing.T) { @@ -27,12 +29,12 @@ func TestValidPlacementConstraint(t *testing.T) { }, { constType: "distinctInstance", - constExpr: "expression", + constExpr: names.AttrExpression, Err: false, }, { constType: "memberOf", - constExpr: "expression", + constExpr: names.AttrExpression, Err: false, }, } diff --git a/internal/service/efs/mount_target.go b/internal/service/efs/mount_target.go index 5d0a7eb1fd1..2dfdc3ac32b 100644 --- a/internal/service/efs/mount_target.go +++ b/internal/service/efs/mount_target.go @@ -65,7 +65,7 @@ func ResourceMountTarget() *schema.Resource { Required: true, ForceNew: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Optional: true, Computed: true, @@ -124,7 +124,7 @@ func resourceMountTargetCreate(ctx context.Context, d *schema.ResourceData, meta SubnetId: aws.String(subnetID), } - if v, ok := d.GetOk("ip_address"); ok { + if v, ok := d.GetOk(names.AttrIPAddress); ok { input.IpAddress = aws.String(v.(string)) } @@ -176,7 +176,7 @@ func resourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) d.Set("file_system_arn", fsARN) d.Set(names.AttrFileSystemID, fsID) - d.Set("ip_address", mt.IpAddress) + d.Set(names.AttrIPAddress, mt.IpAddress) d.Set("mount_target_dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fmt.Sprintf("%s.%s.efs", aws.StringValue(mt.AvailabilityZoneName), aws.StringValue(mt.FileSystemId)))) d.Set(names.AttrNetworkInterfaceID, mt.NetworkInterfaceId) d.Set(names.AttrOwnerID, mt.OwnerId) diff --git a/internal/service/efs/mount_target_data_source.go b/internal/service/efs/mount_target_data_source.go index 12d4c215255..e2c0b0224e4 100644 --- a/internal/service/efs/mount_target_data_source.go +++ b/internal/service/efs/mount_target_data_source.go @@ -48,7 +48,7 @@ func DataSourceMountTarget() *schema.Resource { Optional: true, Computed: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -120,7 +120,7 @@ func dataSourceMountTargetRead(ctx context.Context, d *schema.ResourceData, meta d.Set("dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fsID+".efs")) d.Set("file_system_arn", fsARN) d.Set(names.AttrFileSystemID, fsID) - d.Set("ip_address", mt.IpAddress) + d.Set(names.AttrIPAddress, mt.IpAddress) d.Set("mount_target_dns_name", meta.(*conns.AWSClient).RegionalHostname(ctx, fmt.Sprintf("%s.%s.efs", aws.StringValue(mt.AvailabilityZoneName), aws.StringValue(mt.FileSystemId)))) d.Set("mount_target_id", mt.MountTargetId) d.Set(names.AttrNetworkInterfaceID, mt.NetworkInterfaceId) diff --git a/internal/service/efs/mount_target_data_source_test.go b/internal/service/efs/mount_target_data_source_test.go index 0fecf6be98e..1f508ff360c 100644 --- a/internal/service/efs/mount_target_data_source_test.go +++ b/internal/service/efs/mount_target_data_source_test.go @@ -29,7 +29,7 @@ func TestAccEFSMountTargetDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, "file_system_arn", resourceName, "file_system_arn"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrFileSystemID, resourceName, names.AttrFileSystemID), - resource.TestCheckResourceAttrPair(dataSourceName, "ip_address", resourceName, "ip_address"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), @@ -60,7 +60,7 @@ func TestAccEFSMountTargetDataSource_byAccessPointID(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, "file_system_arn", resourceName, "file_system_arn"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrFileSystemID, resourceName, names.AttrFileSystemID), - resource.TestCheckResourceAttrPair(dataSourceName, "ip_address", resourceName, "ip_address"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), @@ -91,7 +91,7 @@ func TestAccEFSMountTargetDataSource_byFileSystemID(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, "file_system_arn", resourceName, "file_system_arn"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrFileSystemID, resourceName, names.AttrFileSystemID), - resource.TestCheckResourceAttrPair(dataSourceName, "ip_address", resourceName, "ip_address"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrSubnetID, resourceName, names.AttrSubnetID), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrNetworkInterfaceID, resourceName, names.AttrNetworkInterfaceID), resource.TestCheckResourceAttrPair(dataSourceName, "dns_name", resourceName, "dns_name"), diff --git a/internal/service/efs/mount_target_test.go b/internal/service/efs/mount_target_test.go index d0df620ebff..560fa635134 100644 --- a/internal/service/efs/mount_target_test.go +++ b/internal/service/efs/mount_target_test.go @@ -41,7 +41,7 @@ func TestAccEFSMountTarget_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "availability_zone_name"), acctest.MatchResourceAttrRegionalHostname(resourceName, "dns_name", "efs", regexache.MustCompile(`fs-[^.]+`)), acctest.MatchResourceAttrRegionalARN(resourceName, "file_system_arn", "elasticfilesystem", regexache.MustCompile(`file-system/fs-.+`)), - resource.TestMatchResourceAttr(resourceName, "ip_address", regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), + resource.TestMatchResourceAttr(resourceName, names.AttrIPAddress, regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), resource.TestCheckResourceAttrSet(resourceName, "mount_target_dns_name"), resource.TestCheckResourceAttrSet(resourceName, names.AttrNetworkInterfaceID), acctest.CheckResourceAttrAccountID(resourceName, names.AttrOwnerID), @@ -105,7 +105,7 @@ func TestAccEFSMountTarget_ipAddress(t *testing.T) { Config: testAccMountTargetConfig_ipAddress(rName, "10.0.0.100"), Check: resource.ComposeTestCheckFunc( testAccCheckMountTargetExists(ctx, resourceName, &mount), - resource.TestCheckResourceAttr(resourceName, "ip_address", "10.0.0.100"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "10.0.0.100"), ), }, { @@ -134,7 +134,7 @@ func TestAccEFSMountTarget_IPAddress_emptyString(t *testing.T) { Config: testAccMountTargetConfig_ipAddressNullIP(rName), Check: resource.ComposeTestCheckFunc( testAccCheckMountTargetExists(ctx, resourceName, &mount), - resource.TestMatchResourceAttr(resourceName, "ip_address", regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), + resource.TestMatchResourceAttr(resourceName, names.AttrIPAddress, regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), ), }, { diff --git a/internal/service/eks/cluster.go b/internal/service/eks/cluster.go index 2826bc48f23..8e887ca5147 100644 --- a/internal/service/eks/cluster.go +++ b/internal/service/eks/cluster.go @@ -222,7 +222,7 @@ func resourceCluster() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -262,7 +262,7 @@ func resourceCluster() *schema.Resource { Optional: true, Computed: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, MinItems: 1, MaxItems: 1, @@ -324,7 +324,7 @@ func resourceClusterCreate(ctx context.Context, d *schema.ResourceData, meta int EncryptionConfig: expandEncryptionConfig(d.Get("encryption_config").([]interface{})), Logging: expandLogging(d.Get("enabled_cluster_log_types").(*schema.Set)), Name: aws.String(name), - ResourcesVpcConfig: expandVpcConfigRequest(d.Get("vpc_config").([]interface{})), + ResourcesVpcConfig: expandVpcConfigRequest(d.Get(names.AttrVPCConfig).([]interface{})), RoleArn: aws.String(d.Get(names.AttrRoleARN).(string)), Tags: getTagsIn(ctx), } @@ -447,7 +447,7 @@ func resourceClusterRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrRoleARN, cluster.RoleArn) d.Set(names.AttrStatus, cluster.Status) d.Set(names.AttrVersion, cluster.Version) - if err := d.Set("vpc_config", flattenVPCConfigResponse(cluster.ResourcesVpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfigResponse(cluster.ResourcesVpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } @@ -929,7 +929,7 @@ func expandControlPlanePlacementRequest(tfList []interface{}) *types.ControlPlan apiObject := &types.ControlPlanePlacementRequest{} - if v, ok := tfMap["group_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrGroupName].(string); ok && v != "" { apiObject.GroupName = aws.String(v) } @@ -1153,7 +1153,7 @@ func flattenControlPlanePlacementResponse(apiObject *types.ControlPlanePlacement } tfMap := map[string]interface{}{ - "group_name": aws.ToString(apiObject.GroupName), + names.AttrGroupName: aws.ToString(apiObject.GroupName), } return []interface{}{tfMap} diff --git a/internal/service/eks/cluster_data_source.go b/internal/service/eks/cluster_data_source.go index d71e738b2e4..0e91e1e3759 100644 --- a/internal/service/eks/cluster_data_source.go +++ b/internal/service/eks/cluster_data_source.go @@ -125,7 +125,7 @@ func dataSourceCluster() *schema.Resource { Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Computed: true, }, @@ -159,7 +159,7 @@ func dataSourceCluster() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -246,7 +246,7 @@ func dataSourceClusterRead(ctx context.Context, d *schema.ResourceData, meta int d.Set(names.AttrRoleARN, cluster.RoleArn) d.Set(names.AttrStatus, cluster.Status) d.Set(names.AttrVersion, cluster.Version) - if err := d.Set("vpc_config", flattenVPCConfigResponse(cluster.ResourcesVpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfigResponse(cluster.ResourcesVpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } diff --git a/internal/service/eks/identity_provider_config.go b/internal/service/eks/identity_provider_config.go index 91a52ce049d..824e7fea50d 100644 --- a/internal/service/eks/identity_provider_config.go +++ b/internal/service/eks/identity_provider_config.go @@ -65,7 +65,7 @@ func resourceIdentityProviderConfig() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -323,7 +323,7 @@ func expandOIDCIdentityProviderConfigRequest(tfMap map[string]interface{}) (stri apiObject := &types.OidcIdentityProviderConfigRequest{} - if v, ok := tfMap["client_id"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrClientID].(string); ok && v != "" { apiObject.ClientId = aws.String(v) } @@ -368,7 +368,7 @@ func flattenOIDCIdentityProviderConfig(apiObject *types.OidcIdentityProviderConf tfMap := map[string]interface{}{} if v := apiObject.ClientId; v != nil { - tfMap["client_id"] = aws.ToString(v) + tfMap[names.AttrClientID] = aws.ToString(v) } if v := apiObject.GroupsClaim; v != nil { diff --git a/internal/service/elbv2/listener.go b/internal/service/elbv2/listener.go index c3733a283a6..14d17be5ad5 100644 --- a/internal/service/elbv2/listener.go +++ b/internal/service/elbv2/listener.go @@ -139,7 +139,7 @@ func ResourceListener() *schema.Resource { Type: schema.TypeString, Required: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, }, @@ -798,7 +798,7 @@ func expandAuthenticateOIDCConfig(l []interface{}) *awstypes.AuthenticateOidcAct config := &awstypes.AuthenticateOidcActionConfig{ AuthenticationRequestExtraParams: flex.ExpandStringValueMap(tfMap["authentication_request_extra_params"].(map[string]interface{})), AuthorizationEndpoint: aws.String(tfMap["authorization_endpoint"].(string)), - ClientId: aws.String(tfMap["client_id"].(string)), + ClientId: aws.String(tfMap[names.AttrClientID].(string)), ClientSecret: aws.String(tfMap["client_secret"].(string)), Issuer: aws.String(tfMap["issuer"].(string)), TokenEndpoint: aws.String(tfMap["token_endpoint"].(string)), @@ -1079,7 +1079,7 @@ func flattenAuthenticateOIDCActionConfig(config *awstypes.AuthenticateOidcAction m := map[string]interface{}{ "authentication_request_extra_params": config.AuthenticationRequestExtraParams, "authorization_endpoint": aws.ToString(config.AuthorizationEndpoint), - "client_id": aws.ToString(config.ClientId), + names.AttrClientID: aws.ToString(config.ClientId), "client_secret": clientSecret, "issuer": aws.ToString(config.Issuer), "on_unauthenticated_request": string(config.OnUnauthenticatedRequest), diff --git a/internal/service/elbv2/listener_data_source.go b/internal/service/elbv2/listener_data_source.go index 52dc29b4d9f..d23e993c358 100644 --- a/internal/service/elbv2/listener_data_source.go +++ b/internal/service/elbv2/listener_data_source.go @@ -108,7 +108,7 @@ func DataSourceListener() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/elbv2/listener_rule.go b/internal/service/elbv2/listener_rule.go index b9b6b3eab08..5f294c46afa 100644 --- a/internal/service/elbv2/listener_rule.go +++ b/internal/service/elbv2/listener_rule.go @@ -308,7 +308,7 @@ func ResourceListenerRule() *schema.Resource { Type: schema.TypeString, Required: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, }, diff --git a/internal/service/emr/cluster.go b/internal/service/emr/cluster.go index 62e403b6a2e..3f98e67b052 100644 --- a/internal/service/emr/cluster.go +++ b/internal/service/emr/cluster.go @@ -86,7 +86,7 @@ func resourceCluster() *schema.Resource { Optional: true, ForceNew: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, ForceNew: true, @@ -725,7 +725,7 @@ func resourceCluster() *schema.Resource { Optional: true, ForceNew: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, ForceNew: true, @@ -1783,10 +1783,10 @@ func flattenHadoopStepConfig(config *emr.HadoopStepConfig) map[string]interface{ } m := map[string]interface{}{ - "args": aws.StringValueSlice(config.Args), - "jar": aws.StringValue(config.Jar), - "main_class": aws.StringValue(config.MainClass), - "properties": aws.StringValueMap(config.Properties), + "args": aws.StringValueSlice(config.Args), + "jar": aws.StringValue(config.Jar), + "main_class": aws.StringValue(config.MainClass), + names.AttrProperties: aws.StringValueMap(config.Properties), } return m @@ -1906,7 +1906,7 @@ func expandHadoopJarStepConfig(m map[string]interface{}) *emr.HadoopJarStepConfi hadoopJarStepConfig.MainClass = aws.String(v.(string)) } - if v, ok := m["properties"]; ok { + if v, ok := m[names.AttrProperties]; ok { hadoopJarStepConfig.Properties = expandKeyValues(v.(map[string]interface{})) } @@ -2362,7 +2362,7 @@ func expandConfigurations(configurations []interface{}) []*emr.Configuration { config.Configurations = expandConfigurations(v) } - if v, ok := configAttributes["properties"].(map[string]interface{}); ok { + if v, ok := configAttributes[names.AttrProperties].(map[string]interface{}); ok { properties := make(map[string]string) for k, pv := range v { properties[k] = pv.(string) diff --git a/internal/service/emr/instance_fleet.go b/internal/service/emr/instance_fleet.go index 840fdca6279..4876a486945 100644 --- a/internal/service/emr/instance_fleet.go +++ b/internal/service/emr/instance_fleet.go @@ -79,7 +79,7 @@ func resourceInstanceFleet() *schema.Resource { Optional: true, ForceNew: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, ForceNew: true, diff --git a/internal/service/emrcontainers/job_template.go b/internal/service/emrcontainers/job_template.go index d4e0ed52d98..8f34a3da7f3 100644 --- a/internal/service/emrcontainers/job_template.go +++ b/internal/service/emrcontainers/job_template.go @@ -86,7 +86,7 @@ func ResourceJobTemplate() *schema.Resource { Optional: true, ForceNew: true, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -94,7 +94,7 @@ func ResourceJobTemplate() *schema.Resource { }, }, }, - "properties": { + names.AttrProperties: { Type: schema.TypeMap, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, @@ -439,7 +439,7 @@ func expandConfiguration(tfMap map[string]interface{}) *emrcontainers.Configurat apiObject.Configurations = expandConfigurations(v) } - if v, ok := tfMap["properties"].(map[string]interface{}); ok && len(v) > 0 { + if v, ok := tfMap[names.AttrProperties].(map[string]interface{}); ok && len(v) > 0 { apiObject.Properties = flex.ExpandStringMap(v) } @@ -636,7 +636,7 @@ func flattenConfiguration(apiObject *emrcontainers.Configuration) map[string]int } if v := apiObject.Properties; v != nil { - tfMap["properties"] = aws.StringValueMap(v) + tfMap[names.AttrProperties] = aws.StringValueMap(v) } return tfMap diff --git a/internal/service/events/connection.go b/internal/service/events/connection.go index 273031cb160..b56faeb2920 100644 --- a/internal/service/events/connection.go +++ b/internal/service/events/connection.go @@ -189,7 +189,7 @@ func resourceConnection() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( @@ -558,7 +558,7 @@ func expandCreateConnectionOAuthClientRequestParameters(config []interface{}) *t oAuthClientRequestParameters := &types.CreateConnectionOAuthClientRequestParameters{} for _, c := range config { param := c.(map[string]interface{}) - if val, ok := param["client_id"].(string); ok && val != "" { + if val, ok := param[names.AttrClientID].(string); ok && val != "" { oAuthClientRequestParameters.ClientID = aws.String(val) } if val, ok := param["client_secret"].(string); ok && val != "" { @@ -740,7 +740,7 @@ func flattenConnectionOAuthClientResponseParameters(oAuthClientRequestParameters config := make(map[string]interface{}) if oAuthClientRequestParameters.ClientID != nil { - config["client_id"] = aws.ToString(oAuthClientRequestParameters.ClientID) + config[names.AttrClientID] = aws.ToString(oAuthClientRequestParameters.ClientID) } if v, ok := d.GetOk("auth_parameters.0.oauth.0.client_parameters.0.client_secret"); ok { @@ -889,7 +889,7 @@ func expandUpdateConnectionOAuthClientRequestParameters(config []interface{}) *t oAuthClientRequestParameters := &types.UpdateConnectionOAuthClientRequestParameters{} for _, c := range config { param := c.(map[string]interface{}) - if val, ok := param["client_id"].(string); ok && val != "" { + if val, ok := param[names.AttrClientID].(string); ok && val != "" { oAuthClientRequestParameters.ClientID = aws.String(val) } if val, ok := param["client_secret"].(string); ok && val != "" { diff --git a/internal/service/events/permission.go b/internal/service/events/permission.go index a1ef536a223..1e49842e120 100644 --- a/internal/service/events/permission.go +++ b/internal/service/events/permission.go @@ -76,7 +76,7 @@ func resourcePermission() *schema.Resource { ValidateFunc: validBusName, Default: DefaultEventBusName, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validatePermissionPrincipal, @@ -102,7 +102,7 @@ func resourcePermissionCreate(ctx context.Context, d *schema.ResourceData, meta Action: aws.String(d.Get(names.AttrAction).(string)), Condition: expandCondition(d.Get("condition").([]interface{})), EventBusName: aws.String(eventBusName), - Principal: aws.String(d.Get("principal").(string)), + Principal: aws.String(d.Get(names.AttrPrincipal).(string)), StatementId: aws.String(statementID), } @@ -150,7 +150,7 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("event_bus_name", eventBusName) switch principal := policyStatement.Principal.(type) { case string: - d.Set("principal", principal) + d.Set(names.AttrPrincipal, principal) case map[string]interface{}: if v, ok := principal["AWS"].(string); ok { if arn.IsARN(v) { @@ -159,9 +159,9 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendFromErr(diags, err) } - d.Set("principal", principalARN.AccountID) + d.Set(names.AttrPrincipal, principalARN.AccountID) } else { - d.Set("principal", v) + d.Set(names.AttrPrincipal, v) } } } @@ -183,7 +183,7 @@ func resourcePermissionUpdate(ctx context.Context, d *schema.ResourceData, meta Action: aws.String(d.Get(names.AttrAction).(string)), Condition: expandCondition(d.Get("condition").([]interface{})), EventBusName: aws.String(eventBusName), - Principal: aws.String(d.Get("principal").(string)), + Principal: aws.String(d.Get(names.AttrPrincipal).(string)), StatementId: aws.String(statementID), } diff --git a/internal/service/events/permission_test.go b/internal/service/events/permission_test.go index 6804b46604f..dbfa594e77b 100644 --- a/internal/service/events/permission_test.go +++ b/internal/service/events/permission_test.go @@ -66,7 +66,7 @@ func TestAccEventsPermission_basic(t *testing.T) { testAccCheckPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "events:PutEvents"), resource.TestCheckResourceAttr(resourceName, "condition.#", "0"), - resource.TestCheckResourceAttr(resourceName, "principal", principal1), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, principal1), resource.TestCheckResourceAttr(resourceName, "statement_id", statementID), resource.TestCheckResourceAttr(resourceName, "event_bus_name", tfevents.DefaultEventBusName), ), @@ -75,7 +75,7 @@ func TestAccEventsPermission_basic(t *testing.T) { Config: testAccPermissionConfig_basic(principal2, statementID), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "principal", principal2), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, principal2), ), }, { @@ -111,7 +111,7 @@ func TestAccEventsPermission_eventBusName(t *testing.T) { testAccCheckPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "events:PutEvents"), resource.TestCheckResourceAttr(resourceName, "condition.#", "0"), - resource.TestCheckResourceAttr(resourceName, "principal", principal1), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, principal1), resource.TestCheckResourceAttr(resourceName, "statement_id", statementID), resource.TestCheckResourceAttr(resourceName, "event_bus_name", busName), ), @@ -228,7 +228,7 @@ func TestAccEventsPermission_multiple(t *testing.T) { Config: testAccPermissionConfig_basic(principal1, statementID1), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName1), - resource.TestCheckResourceAttr(resourceName1, "principal", principal1), + resource.TestCheckResourceAttr(resourceName1, names.AttrPrincipal, principal1), resource.TestCheckResourceAttr(resourceName1, "statement_id", statementID1), ), }, @@ -237,9 +237,9 @@ func TestAccEventsPermission_multiple(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName1), testAccCheckPermissionExists(ctx, resourceName2), - resource.TestCheckResourceAttr(resourceName1, "principal", principal1), + resource.TestCheckResourceAttr(resourceName1, names.AttrPrincipal, principal1), resource.TestCheckResourceAttr(resourceName1, "statement_id", statementID1), - resource.TestCheckResourceAttr(resourceName2, "principal", principal2), + resource.TestCheckResourceAttr(resourceName2, names.AttrPrincipal, principal2), resource.TestCheckResourceAttr(resourceName2, "statement_id", statementID2), ), }, diff --git a/internal/service/events/target.go b/internal/service/events/target.go index 25094dfcca0..4923ef4836f 100644 --- a/internal/service/events/target.go +++ b/internal/service/events/target.go @@ -211,7 +211,7 @@ func resourceTarget() *schema.Resource { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, }, @@ -1358,7 +1358,7 @@ func expandTargetPlacementConstraints(tfList []interface{}) []types.PlacementCon apiObject := types.PlacementConstraint{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { apiObject.Expression = aws.String(v) } @@ -1445,7 +1445,7 @@ func flattenTargetPlacementConstraints(pcs []types.PlacementConstraint) []map[st c := make(map[string]interface{}) c[names.AttrType] = pc.Type if pc.Expression != nil { - c["expression"] = aws.ToString(pc.Expression) + c[names.AttrExpression] = aws.ToString(pc.Expression) } results = append(results, c) diff --git a/internal/service/firehose/delivery_stream.go b/internal/service/firehose/delivery_stream.go index c242b8d71bd..4341e20b147 100644 --- a/internal/service/firehose/delivery_stream.go +++ b/internal/service/firehose/delivery_stream.go @@ -377,7 +377,7 @@ func resourceDeliveryStream() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(0, 100), }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, ForceNew: true, @@ -944,7 +944,7 @@ func resourceDeliveryStream() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(0, 100), }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, ForceNew: true, @@ -1017,7 +1017,7 @@ func resourceDeliveryStream() *schema.Resource { Optional: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, Sensitive: true, @@ -1139,7 +1139,7 @@ func resourceDeliveryStream() *schema.Resource { ValidateDiagFunc: enum.Validate[types.AmazonOpenSearchServerlessS3BackupMode](), }, "s3_configuration": s3ConfigurationSchema(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, ForceNew: true, @@ -2345,7 +2345,7 @@ func expandCloudWatchLoggingOptions(s3 map[string]interface{}) *types.CloudWatch } func expandVPCConfiguration(es map[string]interface{}) *types.VpcConfiguration { - config := es["vpc_config"].([]interface{}) + config := es[names.AttrVPCConfig].([]interface{}) if len(config) == 0 { return nil } @@ -2465,7 +2465,7 @@ func expandElasticsearchDestinationConfiguration(es map[string]interface{}) *typ config.S3BackupMode = types.ElasticsearchS3BackupMode(s3BackupMode.(string)) } - if _, ok := es["vpc_config"]; ok { + if _, ok := es[names.AttrVPCConfig]; ok { config.VpcConfiguration = expandVPCConfiguration(es) } @@ -2540,7 +2540,7 @@ func expandAmazonopensearchserviceDestinationConfiguration(os map[string]interfa config.S3BackupMode = types.AmazonopensearchserviceS3BackupMode(s3BackupMode.(string)) } - if _, ok := os["vpc_config"]; ok { + if _, ok := os[names.AttrVPCConfig]; ok { config.VpcConfiguration = expandVPCConfiguration(os) } @@ -2615,7 +2615,7 @@ func expandAmazonOpenSearchServerlessDestinationConfiguration(oss map[string]int config.S3BackupMode = types.AmazonOpenSearchServerlessS3BackupMode(s3BackupMode.(string)) } - if _, ok := oss["vpc_config"]; ok { + if _, ok := oss[names.AttrVPCConfig]; ok { config.VpcConfiguration = expandVPCConfiguration(oss) } @@ -2651,7 +2651,7 @@ func expandSnowflakeDestinationConfiguration(tfMap map[string]interface{}) *type apiObject := &types.SnowflakeDestinationConfiguration{ AccountUrl: aws.String(tfMap["account_url"].(string)), Database: aws.String(tfMap["database"].(string)), - PrivateKey: aws.String(tfMap["private_key"].(string)), + PrivateKey: aws.String(tfMap[names.AttrPrivateKey].(string)), RetryOptions: expandSnowflakeRetryOptions(tfMap), RoleARN: aws.String(roleARN), S3Configuration: expandS3DestinationConfiguration(tfMap["s3_configuration"].([]interface{})), @@ -2704,7 +2704,7 @@ func expandSnowflakeDestinationUpdate(tfMap map[string]interface{}) *types.Snowf apiObject := &types.SnowflakeDestinationUpdate{ AccountUrl: aws.String(tfMap["account_url"].(string)), Database: aws.String(tfMap["database"].(string)), - PrivateKey: aws.String(tfMap["private_key"].(string)), + PrivateKey: aws.String(tfMap[names.AttrPrivateKey].(string)), RetryOptions: expandSnowflakeRetryOptions(tfMap), RoleARN: aws.String(roleARN), S3Update: expandS3DestinationUpdate(tfMap["s3_configuration"].([]interface{})), @@ -3229,7 +3229,7 @@ func flattenElasticsearchDestinationDescription(description *types.Elasticsearch "s3_backup_mode": description.S3BackupMode, "s3_configuration": flattenS3DestinationDescription(description.S3DestinationDescription), "index_rotation_period": description.IndexRotationPeriod, - "vpc_config": flattenVPCConfigurationDescription(description.VpcConfigurationDescription), + names.AttrVPCConfig: flattenVPCConfigurationDescription(description.VpcConfigurationDescription), "processing_configuration": flattenProcessingConfiguration(description.ProcessingConfiguration, destinationTypeElasticsearch, aws.ToString(description.RoleARN)), } @@ -3266,7 +3266,7 @@ func flattenAmazonopensearchserviceDestinationDescription(description *types.Ama "s3_backup_mode": description.S3BackupMode, "s3_configuration": flattenS3DestinationDescription(description.S3DestinationDescription), "index_rotation_period": description.IndexRotationPeriod, - "vpc_config": flattenVPCConfigurationDescription(description.VpcConfigurationDescription), + names.AttrVPCConfig: flattenVPCConfigurationDescription(description.VpcConfigurationDescription), "processing_configuration": flattenProcessingConfiguration(description.ProcessingConfiguration, destinationTypeOpenSearch, aws.ToString(description.RoleARN)), } @@ -3305,7 +3305,7 @@ func flattenAmazonOpenSearchServerlessDestinationDescription(description *types. "index_name": aws.ToString(description.IndexName), "s3_backup_mode": description.S3BackupMode, "s3_configuration": flattenS3DestinationDescription(description.S3DestinationDescription), - "vpc_config": flattenVPCConfigurationDescription(description.VpcConfigurationDescription), + names.AttrVPCConfig: flattenVPCConfigurationDescription(description.VpcConfigurationDescription), "processing_configuration": flattenProcessingConfiguration(description.ProcessingConfiguration, destinationTypeOpenSearchServerless, aws.ToString(description.RoleARN)), } @@ -3417,7 +3417,7 @@ func flattenSnowflakeDestinationDescription(apiObject *types.SnowflakeDestinatio "database": aws.ToString(apiObject.Database), "key_passphrase": configuredKeyPassphrase, "metadata_column_name": aws.ToString(apiObject.MetaDataColumnName), - "private_key": configuredPrivateKey, + names.AttrPrivateKey: configuredPrivateKey, "processing_configuration": flattenProcessingConfiguration(apiObject.ProcessingConfiguration, destinationTypeSnowflake, roleARN), names.AttrRoleARN: roleARN, "s3_backup_mode": apiObject.S3BackupMode, diff --git a/internal/service/glue/catalog_database.go b/internal/service/glue/catalog_database.go index d3ae76e8ccd..8151b350715 100644 --- a/internal/service/glue/catalog_database.go +++ b/internal/service/glue/catalog_database.go @@ -73,7 +73,7 @@ func ResourceCatalogDatabase() *schema.Resource { ValidateFunc: validation.StringInSlice(glue.Permission_Values(), false), }, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -460,7 +460,7 @@ func expandDatabasePrincipalPermission(tfMap map[string]interface{}) *glue.Princ apiObject.Permissions = flex.ExpandStringSet(v) } - if v, ok := tfMap["principal"].([]interface{}); ok && len(v) > 0 { + if v, ok := tfMap[names.AttrPrincipal].([]interface{}); ok && len(v) > 0 { apiObject.Principal = expandDatabasePrincipal(v[0].(map[string]interface{})) } @@ -511,7 +511,7 @@ func flattenDatabasePrincipalPermission(apiObject *glue.PrincipalPermissions) ma } if v := apiObject.Principal; v != nil { - tfMap["principal"] = []interface{}{flattenDatabasePrincipal(v)} + tfMap[names.AttrPrincipal] = []interface{}{flattenDatabasePrincipal(v)} } return tfMap diff --git a/internal/service/glue/crawler.go b/internal/service/glue/crawler.go index e2494367ed5..ce641fa9957 100644 --- a/internal/service/glue/crawler.go +++ b/internal/service/glue/crawler.go @@ -386,7 +386,7 @@ func ResourceCrawler() *schema.Resource { }, }, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Optional: true, }, @@ -509,9 +509,9 @@ func resourceCrawlerRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrConfiguration, crawler.Configuration) d.Set(names.AttrDescription, crawler.Description) d.Set("security_configuration", crawler.CrawlerSecurityConfiguration) - d.Set("schedule", "") + d.Set(names.AttrSchedule, "") if crawler.Schedule != nil { - d.Set("schedule", crawler.Schedule.ScheduleExpression) + d.Set(names.AttrSchedule, crawler.Schedule.ScheduleExpression) } if err := d.Set("classifiers", flex.FlattenStringList(crawler.Classifiers)); err != nil { return sdkdiag.AppendErrorf(diags, "setting classifiers: %s", err) @@ -660,7 +660,7 @@ func createCrawlerInput(ctx context.Context, d *schema.ResourceData, crawlerName if description, ok := d.GetOk(names.AttrDescription); ok { crawlerInput.Description = aws.String(description.(string)) } - if schedule, ok := d.GetOk("schedule"); ok { + if schedule, ok := d.GetOk(names.AttrSchedule); ok { crawlerInput.Schedule = aws.String(schedule.(string)) } if classifiers, ok := d.GetOk("classifiers"); ok { @@ -714,7 +714,7 @@ func updateCrawlerInput(d *schema.ResourceData, crawlerName string) (*glue.Updat crawlerInput.Description = aws.String(description.(string)) } - if schedule, ok := d.GetOk("schedule"); ok { + if schedule, ok := d.GetOk(names.AttrSchedule); ok { crawlerInput.Schedule = aws.String(schedule.(string)) } else { crawlerInput.Schedule = aws.String("") diff --git a/internal/service/glue/crawler_test.go b/internal/service/glue/crawler_test.go index fa1e35f6f46..81f810d2e08 100644 --- a/internal/service/glue/crawler_test.go +++ b/internal/service/glue/crawler_test.go @@ -53,7 +53,7 @@ func TestAccGlueCrawler_dynamoDBTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "role", rName), resource.TestCheckResourceAttr(resourceName, "s3_target.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -77,7 +77,7 @@ func TestAccGlueCrawler_dynamoDBTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "role", rName), resource.TestCheckResourceAttr(resourceName, "s3_target.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -216,7 +216,7 @@ func TestAccGlueCrawler_jdbcTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "role", rName), resource.TestCheckResourceAttr(resourceName, "s3_target.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -242,7 +242,7 @@ func TestAccGlueCrawler_jdbcTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "role", rName), resource.TestCheckResourceAttr(resourceName, "s3_target.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -273,7 +273,7 @@ func TestAccGlueCrawler_jdbcTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "role", rName), resource.TestCheckResourceAttr(resourceName, "s3_target.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -704,7 +704,7 @@ func TestAccGlueCrawler_s3Target(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "s3_target.#", "1"), resource.TestCheckResourceAttr(resourceName, "s3_target.0.exclusions.#", "0"), resource.TestCheckResourceAttr(resourceName, "s3_target.0.path", "s3://bucket1"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -728,7 +728,7 @@ func TestAccGlueCrawler_s3Target(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "s3_target.#", "1"), resource.TestCheckResourceAttr(resourceName, "s3_target.0.exclusions.#", "0"), resource.TestCheckResourceAttr(resourceName, "s3_target.0.path", "s3://bucket2"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "DEPRECATE_IN_DATABASE"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -1033,7 +1033,7 @@ func TestAccGlueCrawler_catalogTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "catalog_target.0.database_name", rName), resource.TestCheckResourceAttr(resourceName, "catalog_target.0.tables.#", "1"), resource.TestCheckResourceAttr(resourceName, "catalog_target.0.tables.0", fmt.Sprintf("%s_table_0", rName)), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "LOG"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -1060,7 +1060,7 @@ func TestAccGlueCrawler_catalogTarget(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "catalog_target.0.tables.#", "2"), resource.TestCheckResourceAttr(resourceName, "catalog_target.0.tables.0", fmt.Sprintf("%s_table_0", rName)), resource.TestCheckResourceAttr(resourceName, "catalog_target.0.tables.1", fmt.Sprintf("%s_table_1", rName)), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.delete_behavior", "LOG"), resource.TestCheckResourceAttr(resourceName, "schema_change_policy.0.update_behavior", "UPDATE_IN_DATABASE"), @@ -1385,14 +1385,14 @@ func TestAccGlueCrawler_schedule(t *testing.T) { Config: testAccCrawlerConfig_schedule(rName, "cron(0 1 * * ? *)"), Check: resource.ComposeTestCheckFunc( testAccCheckCrawlerExists(ctx, resourceName, &crawler), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 1 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 1 * * ? *)"), ), }, { Config: testAccCrawlerConfig_schedule(rName, "cron(0 2 * * ? *)"), Check: resource.ComposeTestCheckFunc( testAccCheckCrawlerExists(ctx, resourceName, &crawler), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 2 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 2 * * ? *)"), ), }, { @@ -1404,7 +1404,7 @@ func TestAccGlueCrawler_schedule(t *testing.T) { Config: testAccCrawlerConfig_s3Target(rName, "s3://bucket-name"), Check: resource.ComposeTestCheckFunc( testAccCheckCrawlerExists(ctx, resourceName, &crawler), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), ), }, }, diff --git a/internal/service/glue/trigger.go b/internal/service/glue/trigger.go index 629c02f947e..d6247338c9a 100644 --- a/internal/service/glue/trigger.go +++ b/internal/service/glue/trigger.go @@ -179,7 +179,7 @@ func ResourceTrigger() *schema.Resource { }, }, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Optional: true, }, @@ -234,7 +234,7 @@ func resourceTriggerCreate(ctx context.Context, d *schema.ResourceData, meta int input.Predicate = expandPredicate(v.([]interface{})) } - if v, ok := d.GetOk("schedule"); ok { + if v, ok := d.GetOk(names.AttrSchedule); ok { input.Schedule = aws.String(v.(string)) } @@ -365,7 +365,7 @@ func resourceTriggerRead(ctx context.Context, d *schema.ResourceData, meta inter } d.Set(names.AttrName, trigger.Name) - d.Set("schedule", trigger.Schedule) + d.Set(names.AttrSchedule, trigger.Schedule) d.Set(names.AttrType, trigger.Type) d.Set("workflow_name", trigger.WorkflowName) @@ -376,7 +376,7 @@ func resourceTriggerUpdate(ctx context.Context, d *schema.ResourceData, meta int var diags diag.Diagnostics conn := meta.(*conns.AWSClient).GlueConn(ctx) - if d.HasChanges("actions", names.AttrDescription, "predicate", "schedule", "event_batching_condition") { + if d.HasChanges("actions", names.AttrDescription, "predicate", names.AttrSchedule, "event_batching_condition") { triggerUpdate := &glue.TriggerUpdate{ Actions: expandActions(d.Get("actions").([]interface{})), } @@ -389,7 +389,7 @@ func resourceTriggerUpdate(ctx context.Context, d *schema.ResourceData, meta int triggerUpdate.Predicate = expandPredicate(v.([]interface{})) } - if v, ok := d.GetOk("schedule"); ok { + if v, ok := d.GetOk(names.AttrSchedule); ok { triggerUpdate.Schedule = aws.String(v.(string)) } diff --git a/internal/service/glue/trigger_test.go b/internal/service/glue/trigger_test.go index 3ea0adf706e..eef956e28ba 100644 --- a/internal/service/glue/trigger_test.go +++ b/internal/service/glue/trigger_test.go @@ -45,7 +45,7 @@ func TestAccGlueTrigger_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", ""), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, ""), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, names.AttrType, "ON_DEMAND"), resource.TestCheckResourceAttr(resourceName, "workflow_name", ""), @@ -254,14 +254,14 @@ func TestAccGlueTrigger_schedule(t *testing.T) { Config: testAccTriggerConfig_schedule(rName, "cron(1 2 * * ? *)"), Check: resource.ComposeTestCheckFunc( testAccCheckTriggerExists(ctx, resourceName, &trigger), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(1 2 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(1 2 * * ? *)"), ), }, { Config: testAccTriggerConfig_schedule(rName, "cron(2 3 * * ? *)"), Check: resource.ComposeTestCheckFunc( testAccCheckTriggerExists(ctx, resourceName, &trigger), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(2 3 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(2 3 * * ? *)"), ), }, { @@ -291,7 +291,7 @@ func TestAccGlueTrigger_startOnCreate(t *testing.T) { Config: testAccTriggerConfig_scheduleStart(rName, "cron(1 2 * * ? *)"), Check: resource.ComposeTestCheckFunc( testAccCheckTriggerExists(ctx, resourceName, &trigger), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(1 2 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(1 2 * * ? *)"), ), }, { diff --git a/internal/service/iam/group_data_source.go b/internal/service/iam/group_data_source.go index e8c1ac9211f..423ea58855a 100644 --- a/internal/service/iam/group_data_source.go +++ b/internal/service/iam/group_data_source.go @@ -34,7 +34,7 @@ func dataSourceGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, }, @@ -70,7 +70,7 @@ func dataSourceGroupRead(ctx context.Context, d *schema.ResourceData, meta inter var diags diag.Diagnostics conn := meta.(*conns.AWSClient).IAMClient(ctx) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) req := &iam.GetGroupInput{ GroupName: aws.String(groupName), diff --git a/internal/service/iam/group_data_source_test.go b/internal/service/iam/group_data_source_test.go index 87542af7ce7..80c5b3af4fe 100644 --- a/internal/service/iam/group_data_source_test.go +++ b/internal/service/iam/group_data_source_test.go @@ -27,7 +27,7 @@ func TestAccIAMGroupDataSource_basic(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.aws_iam_group.test", "group_id"), resource.TestCheckResourceAttr("data.aws_iam_group.test", names.AttrPath, "/"), - resource.TestCheckResourceAttr("data.aws_iam_group.test", "group_name", groupName), + resource.TestCheckResourceAttr("data.aws_iam_group.test", names.AttrGroupName, groupName), acctest.CheckResourceAttrGlobalARN("data.aws_iam_group.test", names.AttrARN, "iam", fmt.Sprintf("group/%s", groupName)), ), }, @@ -52,7 +52,7 @@ func TestAccIAMGroupDataSource_users(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttrSet("data.aws_iam_group.test", "group_id"), resource.TestCheckResourceAttr("data.aws_iam_group.test", names.AttrPath, "/"), - resource.TestCheckResourceAttr("data.aws_iam_group.test", "group_name", groupName), + resource.TestCheckResourceAttr("data.aws_iam_group.test", names.AttrGroupName, groupName), acctest.CheckResourceAttrGlobalARN("data.aws_iam_group.test", names.AttrARN, "iam", fmt.Sprintf("group/%s", groupName)), resource.TestCheckResourceAttr("data.aws_iam_group.test", "users.#", fmt.Sprint(userCount)), resource.TestCheckResourceAttrSet("data.aws_iam_group.test", "users.0.arn"), diff --git a/internal/service/iam/server_certificate.go b/internal/service/iam/server_certificate.go index 2ebb8aff1b7..ecbef85b5b5 100644 --- a/internal/service/iam/server_certificate.go +++ b/internal/service/iam/server_certificate.go @@ -88,7 +88,7 @@ func resourceServerCertificate() *schema.Resource { Default: "/", ForceNew: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -115,7 +115,7 @@ func resourceServerCertificateCreate(ctx context.Context, d *schema.ResourceData sslCertName := create.Name(d.Get(names.AttrName).(string), d.Get(names.AttrNamePrefix).(string)) input := &iam.UploadServerCertificateInput{ CertificateBody: aws.String(d.Get("certificate_body").(string)), - PrivateKey: aws.String(d.Get("private_key").(string)), + PrivateKey: aws.String(d.Get(names.AttrPrivateKey).(string)), ServerCertificateName: aws.String(sslCertName), Tags: getTagsIn(ctx), } diff --git a/internal/service/iam/server_certificate_test.go b/internal/service/iam/server_certificate_test.go index eb60037495e..35f7a7cc9c2 100644 --- a/internal/service/iam/server_certificate_test.go +++ b/internal/service/iam/server_certificate_test.go @@ -54,7 +54,7 @@ func TestAccIAMServerCertificate_basic(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateId: rName, - ImportStateVerifyIgnore: []string{"private_key"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey}, }, }, }) @@ -163,7 +163,7 @@ func TestAccIAMServerCertificate_tags(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateId: rName, - ImportStateVerifyIgnore: []string{"private_key"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey}, }, { Config: testAccServerCertificateConfig_tags2(rName, key, certificate, "key1", "value1updated", "key2", "value2"), @@ -211,7 +211,7 @@ func TestAccIAMServerCertificate_file(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateId: rName, - ImportStateVerifyIgnore: []string{"private_key"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey}, }, { Config: testAccServerCertificateConfig_file(rName, winFile), @@ -249,7 +249,7 @@ func TestAccIAMServerCertificate_path(t *testing.T) { ImportState: true, ImportStateVerify: true, ImportStateId: rName, - ImportStateVerifyIgnore: []string{"private_key"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey}, }, }, }) diff --git a/internal/service/imagebuilder/image_pipeline.go b/internal/service/imagebuilder/image_pipeline.go index c579dddfd32..b43290c02db 100644 --- a/internal/service/imagebuilder/image_pipeline.go +++ b/internal/service/imagebuilder/image_pipeline.go @@ -157,7 +157,7 @@ func ResourceImagePipeline() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -241,7 +241,7 @@ func resourceImagePipelineCreate(ctx context.Context, d *schema.ResourceData, me input.Name = aws.String(v.(string)) } - if v, ok := d.GetOk("schedule"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrSchedule); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Schedule = expandPipelineSchedule(v.([]interface{})[0].(map[string]interface{})) } @@ -314,9 +314,9 @@ func resourceImagePipelineRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrName, imagePipeline.Name) d.Set("platform", imagePipeline.Platform) if imagePipeline.Schedule != nil { - d.Set("schedule", []interface{}{flattenSchedule(imagePipeline.Schedule)}) + d.Set(names.AttrSchedule, []interface{}{flattenSchedule(imagePipeline.Schedule)}) } else { - d.Set("schedule", nil) + d.Set(names.AttrSchedule, nil) } d.Set(names.AttrStatus, imagePipeline.Status) @@ -336,7 +336,7 @@ func resourceImagePipelineUpdate(ctx context.Context, d *schema.ResourceData, me "image_scanning_configuration", "image_tests_configuration", "infrastructure_configuration_arn", - "schedule", + names.AttrSchedule, names.AttrStatus, ) { input := &imagebuilder.UpdateImagePipelineInput{ @@ -373,7 +373,7 @@ func resourceImagePipelineUpdate(ctx context.Context, d *schema.ResourceData, me input.InfrastructureConfigurationArn = aws.String(v.(string)) } - if v, ok := d.GetOk("schedule"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrSchedule); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.Schedule = expandPipelineSchedule(v.([]interface{})[0].(map[string]interface{})) } diff --git a/internal/service/imagebuilder/image_pipeline_data_source.go b/internal/service/imagebuilder/image_pipeline_data_source.go index 25305d6364d..a7eb9cf47ee 100644 --- a/internal/service/imagebuilder/image_pipeline_data_source.go +++ b/internal/service/imagebuilder/image_pipeline_data_source.go @@ -123,7 +123,7 @@ func DataSourceImagePipeline() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -195,9 +195,9 @@ func dataSourceImagePipelineRead(ctx context.Context, d *schema.ResourceData, me d.Set(names.AttrName, imagePipeline.Name) d.Set("platform", imagePipeline.Platform) if imagePipeline.Schedule != nil { - d.Set("schedule", []interface{}{flattenSchedule(imagePipeline.Schedule)}) + d.Set(names.AttrSchedule, []interface{}{flattenSchedule(imagePipeline.Schedule)}) } else { - d.Set("schedule", nil) + d.Set(names.AttrSchedule, nil) } d.Set(names.AttrStatus, imagePipeline.Status) diff --git a/internal/service/iot/billing_group.go b/internal/service/iot/billing_group.go index 69c7b507311..5c6c6303f41 100644 --- a/internal/service/iot/billing_group.go +++ b/internal/service/iot/billing_group.go @@ -59,7 +59,7 @@ func ResourceBillingGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 128), }, - "properties": { + names.AttrProperties: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -94,7 +94,7 @@ func resourceBillingGroupCreate(ctx context.Context, d *schema.ResourceData, met Tags: getTagsIn(ctx), } - if v, ok := d.GetOk("properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrProperties); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.BillingGroupProperties = expandBillingGroupProperties(v.([]interface{})[0].(map[string]interface{})) } @@ -136,11 +136,11 @@ func resourceBillingGroupRead(ctx context.Context, d *schema.ResourceData, meta d.Set("metadata", nil) } if v := flattenBillingGroupProperties(output.BillingGroupProperties); len(v) > 0 { - if err := d.Set("properties", []interface{}{v}); err != nil { + if err := d.Set(names.AttrProperties, []interface{}{v}); err != nil { return sdkdiag.AppendErrorf(diags, "setting properties: %s", err) } } else { - d.Set("properties", nil) + d.Set(names.AttrProperties, nil) } d.Set(names.AttrVersion, output.Version) @@ -157,7 +157,7 @@ func resourceBillingGroupUpdate(ctx context.Context, d *schema.ResourceData, met ExpectedVersion: aws.Int64(int64(d.Get(names.AttrVersion).(int))), } - if v, ok := d.GetOk("properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrProperties); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.BillingGroupProperties = expandBillingGroupProperties(v.([]interface{})[0].(map[string]interface{})) } else { input.BillingGroupProperties = &iot.BillingGroupProperties{} diff --git a/internal/service/iot/certificate.go b/internal/service/iot/certificate.go index e3011e73b9a..5ec8aee5209 100644 --- a/internal/service/iot/certificate.go +++ b/internal/service/iot/certificate.go @@ -58,7 +58,7 @@ func ResourceCertificate() *schema.Resource { Optional: true, ForceNew: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Computed: true, Sensitive: true, @@ -136,7 +136,7 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, meta } d.SetId(aws.StringValue(output.CertificateId)) - d.Set("private_key", output.KeyPair.PrivateKey) + d.Set(names.AttrPrivateKey, output.KeyPair.PrivateKey) d.Set("public_key", output.KeyPair.PublicKey) } diff --git a/internal/service/iot/certificate_test.go b/internal/service/iot/certificate_test.go index 3961dea988f..9714a5f0eb2 100644 --- a/internal/service/iot/certificate_test.go +++ b/internal/service/iot/certificate_test.go @@ -35,7 +35,7 @@ func TestAccIoTCertificate_csr(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "certificate_pem"), resource.TestCheckResourceAttrSet(resourceName, "csr"), - resource.TestCheckNoResourceAttr(resourceName, "private_key"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), resource.TestCheckNoResourceAttr(resourceName, "public_key"), ), }, @@ -61,7 +61,7 @@ func TestAccIoTCertificate_Keys_certificate(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "certificate_pem"), resource.TestCheckNoResourceAttr(resourceName, "csr"), - resource.TestCheckResourceAttrSet(resourceName, "private_key"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrPrivateKey), resource.TestCheckResourceAttrSet(resourceName, "public_key"), ), }, @@ -89,7 +89,7 @@ func TestAccIoTCertificate_Keys_existingCertificate(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, names.AttrARN), resource.TestCheckResourceAttrSet(resourceName, "certificate_pem"), resource.TestCheckNoResourceAttr(resourceName, "csr"), - resource.TestCheckNoResourceAttr(resourceName, "private_key"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), resource.TestCheckNoResourceAttr(resourceName, "public_key"), ), }, diff --git a/internal/service/iot/sweep.go b/internal/service/iot/sweep.go index 3e8f3c4f7d6..56f02338179 100644 --- a/internal/service/iot/sweep.go +++ b/internal/service/iot/sweep.go @@ -333,7 +333,7 @@ func sweepThingPrincipalAttachments(region string) error { r := ResourceThingPrincipalAttachment() d := r.Data(nil) d.SetId(fmt.Sprintf("%s|%s", thingName, aws.StringValue(v))) - d.Set("principal", v) + d.Set(names.AttrPrincipal, v) d.Set("thing", thingName) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) diff --git a/internal/service/iot/thing_group.go b/internal/service/iot/thing_group.go index 65262e20a56..c7793c048fa 100644 --- a/internal/service/iot/thing_group.go +++ b/internal/service/iot/thing_group.go @@ -63,7 +63,7 @@ func ResourceThingGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Computed: true, }, @@ -85,7 +85,7 @@ func ResourceThingGroup() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringLenBetween(1, 128), }, - "properties": { + names.AttrProperties: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -142,7 +142,7 @@ func resourceThingGroupCreate(ctx context.Context, d *schema.ResourceData, meta input.ParentGroupName = aws.String(v.(string)) } - if v, ok := d.GetOk("properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrProperties); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.ThingGroupProperties = expandThingGroupProperties(v.([]interface{})[0].(map[string]interface{})) } @@ -184,11 +184,11 @@ func resourceThingGroupRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("metadata", nil) } if v := flattenThingGroupProperties(output.ThingGroupProperties); len(v) > 0 { - if err := d.Set("properties", []interface{}{v}); err != nil { + if err := d.Set(names.AttrProperties, []interface{}{v}); err != nil { return sdkdiag.AppendErrorf(diags, "setting properties: %s", err) } } else { - d.Set("properties", nil) + d.Set(names.AttrProperties, nil) } if output.ThingGroupMetadata != nil { @@ -211,7 +211,7 @@ func resourceThingGroupUpdate(ctx context.Context, d *schema.ResourceData, meta ThingGroupName: aws.String(d.Get(names.AttrName).(string)), } - if v, ok := d.GetOk("properties"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrProperties); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { input.ThingGroupProperties = expandThingGroupProperties(v.([]interface{})[0].(map[string]interface{})) } else { input.ThingGroupProperties = &iot.ThingGroupProperties{} @@ -332,7 +332,7 @@ func flattenGroupNameAndARN(apiObject *iot.GroupNameAndArn) map[string]interface } if v := apiObject.GroupName; v != nil { - tfMap["group_name"] = aws.StringValue(v) + tfMap[names.AttrGroupName] = aws.StringValue(v) } return tfMap diff --git a/internal/service/iot/thing_principal_attachment.go b/internal/service/iot/thing_principal_attachment.go index b8265a3c991..856fcf2e0a3 100644 --- a/internal/service/iot/thing_principal_attachment.go +++ b/internal/service/iot/thing_principal_attachment.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_iot_thing_principal_attachment") @@ -25,7 +26,7 @@ func ResourceThingPrincipalAttachment() *schema.Resource { DeleteWithoutTimeout: resourceThingPrincipalAttachmentDelete, Schema: map[string]*schema.Schema{ - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -43,7 +44,7 @@ func resourceThingPrincipalAttachmentCreate(ctx context.Context, d *schema.Resou var diags diag.Diagnostics conn := meta.(*conns.AWSClient).IoTConn(ctx) - principal := d.Get("principal").(string) + principal := d.Get(names.AttrPrincipal).(string) thing := d.Get("thing").(string) _, err := conn.AttachThingPrincipalWithContext(ctx, &iot.AttachThingPrincipalInput{ @@ -82,7 +83,7 @@ func resourceThingPrincipalAttachmentRead(ctx context.Context, d *schema.Resourc var diags diag.Diagnostics conn := meta.(*conns.AWSClient).IoTConn(ctx) - principal := d.Get("principal").(string) + principal := d.Get(names.AttrPrincipal).(string) thing := d.Get("thing").(string) found, err := GetThingPricipalAttachment(ctx, conn, thing, principal) @@ -103,7 +104,7 @@ func resourceThingPrincipalAttachmentDelete(ctx context.Context, d *schema.Resou var diags diag.Diagnostics conn := meta.(*conns.AWSClient).IoTConn(ctx) - principal := d.Get("principal").(string) + principal := d.Get(names.AttrPrincipal).(string) thing := d.Get("thing").(string) _, err := conn.DetachThingPrincipalWithContext(ctx, &iot.DetachThingPrincipalInput{ diff --git a/internal/service/iot/thing_principal_attachment_test.go b/internal/service/iot/thing_principal_attachment_test.go index 56ec1f24c8a..bdd8d587339 100644 --- a/internal/service/iot/thing_principal_attachment_test.go +++ b/internal/service/iot/thing_principal_attachment_test.go @@ -84,7 +84,7 @@ func testAccCheckThingPrincipalAttachmentDestroy(ctx context.Context) resource.T continue } - principal := rs.Primary.Attributes["principal"] + principal := rs.Primary.Attributes[names.AttrPrincipal] thing := rs.Primary.Attributes["thing"] found, err := tfiot.GetThingPricipalAttachment(ctx, conn, thing, principal) @@ -117,7 +117,7 @@ func testAccCheckThingPrincipalAttachmentExists(ctx context.Context, n string) r conn := acctest.Provider.Meta().(*conns.AWSClient).IoTConn(ctx) thing := rs.Primary.Attributes["thing"] - principal := rs.Primary.Attributes["principal"] + principal := rs.Primary.Attributes[names.AttrPrincipal] found, err := tfiot.GetThingPricipalAttachment(ctx, conn, thing, principal) diff --git a/internal/service/iot/thing_type.go b/internal/service/iot/thing_type.go index 36be718c79c..a0d20a4a6ed 100644 --- a/internal/service/iot/thing_type.go +++ b/internal/service/iot/thing_type.go @@ -54,7 +54,7 @@ func ResourceThingType() *schema.Resource { ForceNew: true, ValidateFunc: validThingTypeName, }, - "properties": { + names.AttrProperties: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -99,7 +99,7 @@ func resourceThingTypeCreate(ctx context.Context, d *schema.ResourceData, meta i ThingTypeName: aws.String(name), } - if v, ok := d.GetOk("properties"); ok { + if v, ok := d.GetOk(names.AttrProperties); ok { configs := v.([]interface{}) if config, ok := configs[0].(map[string]interface{}); ok && config != nil { input.ThingTypeProperties = expandThingTypeProperties(config) @@ -150,7 +150,7 @@ func resourceThingTypeRead(ctx context.Context, d *schema.ResourceData, meta int if output.ThingTypeMetadata != nil { d.Set("deprecated", output.ThingTypeMetadata.Deprecated) } - if err := d.Set("properties", flattenThingTypeProperties(output.ThingTypeProperties)); err != nil { + if err := d.Set(names.AttrProperties, flattenThingTypeProperties(output.ThingTypeProperties)); err != nil { return sdkdiag.AppendErrorf(diags, "setting properties: %s", err) } diff --git a/internal/service/iot/topic_rule.go b/internal/service/iot/topic_rule.go index fe26aaa62a9..93294420e06 100644 --- a/internal/service/iot/topic_rule.go +++ b/internal/service/iot/topic_rule.go @@ -88,7 +88,7 @@ func ResourceTopicRule() *schema.Resource { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -294,7 +294,7 @@ func ResourceTopicRule() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, }, @@ -1467,7 +1467,7 @@ func expandCloudWatchMetricAction(tfList []interface{}) *iot.CloudwatchMetricAct apiObject := &iot.CloudwatchMetricAction{} tfMap := tfList[0].(map[string]interface{}) - if v, ok := tfMap["metric_name"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrMetricName].(string); ok && v != "" { apiObject.MetricName = aws.String(v) } @@ -2528,7 +2528,7 @@ func flattenCloudWatchMetricAction(apiObject *iot.CloudwatchMetricAction) []inte tfMap := make(map[string]interface{}) if v := apiObject.MetricName; v != nil { - tfMap["metric_name"] = aws.StringValue(v) + tfMap[names.AttrMetricName] = aws.StringValue(v) } if v := apiObject.MetricNamespace; v != nil { diff --git a/internal/service/iot/topic_rule_test.go b/internal/service/iot/topic_rule_test.go index 83565f75282..f7f568f468d 100644 --- a/internal/service/iot/topic_rule_test.go +++ b/internal/service/iot/topic_rule_test.go @@ -338,10 +338,10 @@ func TestAccIoTTopicRule_cloudWatchMetric(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cloudwatch_logs.#", "0"), resource.TestCheckResourceAttr(resourceName, "cloudwatch_metric.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cloudwatch_metric.*", map[string]string{ - "metric_name": "TestName", - "metric_namespace": "TestNS", - "metric_unit": "s", - "metric_value": "10", + names.AttrMetricName: "TestName", + "metric_namespace": "TestNS", + "metric_unit": "s", + "metric_value": "10", }), resource.TestCheckResourceAttr(resourceName, "dynamodb.#", "0"), resource.TestCheckResourceAttr(resourceName, "dynamodbv2.#", "0"), @@ -370,10 +370,10 @@ func TestAccIoTTopicRule_cloudWatchMetric(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "cloudwatch_logs.#", "0"), resource.TestCheckResourceAttr(resourceName, "cloudwatch_metric.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "cloudwatch_metric.*", map[string]string{ - "metric_name": "OtherName", - "metric_namespace": "TestNS", - "metric_unit": "s", - "metric_value": "10", + names.AttrMetricName: "OtherName", + "metric_namespace": "TestNS", + "metric_unit": "s", + "metric_value": "10", }), resource.TestCheckResourceAttr(resourceName, "dynamodb.#", "0"), resource.TestCheckResourceAttr(resourceName, "dynamodbv2.#", "0"), diff --git a/internal/service/kafka/replicator.go b/internal/service/kafka/replicator.go index f5e684ca077..00be0746a27 100644 --- a/internal/service/kafka/replicator.go +++ b/internal/service/kafka/replicator.go @@ -80,7 +80,7 @@ func resourceReplicator() *schema.Resource { }, }, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -592,7 +592,7 @@ func flattenKafkaClusterDescription(apiObject types.KafkaClusterDescription) map } if v := apiObject.VpcConfig; v != nil { - tfMap["vpc_config"] = []interface{}{flattenKafkaClusterClientVPCConfig(v)} + tfMap[names.AttrVPCConfig] = []interface{}{flattenKafkaClusterClientVPCConfig(v)} } return tfMap @@ -797,7 +797,7 @@ func expandKafkaClusters(tfList []interface{}) []types.KafkaCluster { // nosemgr func expandKafkaCluster(tfMap map[string]interface{}) types.KafkaCluster { // nosemgrep:ci.kafka-in-func-name apiObject := types.KafkaCluster{} - if v, ok := tfMap["vpc_config"].([]interface{}); ok && len(v) > 0 && v[0] != nil { + if v, ok := tfMap[names.AttrVPCConfig].([]interface{}); ok && len(v) > 0 && v[0] != nil { apiObject.VpcConfig = expandKafkaClusterClientVPCConfig(v[0].(map[string]interface{})) } diff --git a/internal/service/kafka/serverless_cluster.go b/internal/service/kafka/serverless_cluster.go index d258070598d..b31cd3db46d 100644 --- a/internal/service/kafka/serverless_cluster.go +++ b/internal/service/kafka/serverless_cluster.go @@ -95,7 +95,7 @@ func resourceServerlessCluster() *schema.Resource { }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Required: true, ForceNew: true, @@ -135,7 +135,7 @@ func resourceServerlessClusterCreate(ctx context.Context, d *schema.ResourceData ClusterName: aws.String(name), Serverless: &types.ServerlessRequest{ ClientAuthentication: expandServerlessClientAuthentication(d.Get("client_authentication").([]interface{})[0].(map[string]interface{})), - VpcConfigs: expandVpcConfigs(d.Get("vpc_config").([]interface{})), + VpcConfigs: expandVpcConfigs(d.Get(names.AttrVPCConfig).([]interface{})), }, Tags: getTagsIn(ctx), } @@ -183,7 +183,7 @@ func resourceServerlessClusterRead(ctx context.Context, d *schema.ResourceData, d.Set("cluster_name", cluster.ClusterName) clusterUUID, _ := clusterUUIDFromARN(clusterARN) d.Set("cluster_uuid", clusterUUID) - if err := d.Set("vpc_config", flattenVpcConfigs(cluster.Serverless.VpcConfigs)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVpcConfigs(cluster.Serverless.VpcConfigs)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } diff --git a/internal/service/kendra/data_source.go b/internal/service/kendra/data_source.go index 099f8d5c620..a1c2e39128c 100644 --- a/internal/service/kendra/data_source.go +++ b/internal/service/kendra/data_source.go @@ -65,7 +65,7 @@ func ResourceDataSource() *schema.Resource { return fmt.Errorf("role_arn must not be set when type is %s", string(types.DataSourceTypeCustom)) } - if schedule, dataSourcetype := diff.Get("schedule").(string), diff.Get(names.AttrType).(string); schedule != "" && dataSourcetype == string(types.DataSourceTypeCustom) { + if schedule, dataSourcetype := diff.Get(names.AttrSchedule).(string), diff.Get(names.AttrType).(string); schedule != "" && dataSourcetype == string(types.DataSourceTypeCustom) { return fmt.Errorf("schedule must not be set when type is %s", string(types.DataSourceTypeCustom)) } @@ -456,7 +456,7 @@ func ResourceDataSource() *schema.Resource { Optional: true, ValidateFunc: verify.ValidARN, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Optional: true, }, @@ -625,7 +625,7 @@ func resourceDataSourceCreate(ctx context.Context, d *schema.ResourceData, meta input.RoleArn = aws.String(v.(string)) } - if v, ok := d.GetOk("schedule"); ok { + if v, ok := d.GetOk(names.AttrSchedule); ok { input.Schedule = aws.String(v.(string)) } @@ -705,7 +705,7 @@ func resourceDataSourceRead(ctx context.Context, d *schema.ResourceData, meta in d.Set("language_code", resp.LanguageCode) d.Set(names.AttrName, resp.Name) d.Set(names.AttrRoleARN, resp.RoleArn) - d.Set("schedule", resp.Schedule) + d.Set(names.AttrSchedule, resp.Schedule) d.Set(names.AttrStatus, resp.Status) d.Set(names.AttrType, resp.Type) d.Set("updated_at", aws.ToTime(resp.UpdatedAt).Format(time.RFC3339)) @@ -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, "schedule") { + if d.HasChanges(names.AttrConfiguration, "custom_document_enrichment_configuration", names.AttrDescription, "language_code", names.AttrName, names.AttrRoleARN, names.AttrSchedule) { id, indexId, err := DataSourceParseResourceID(d.Id()) if err != nil { return sdkdiag.AppendFromErr(diags, err) @@ -761,8 +761,8 @@ func resourceDataSourceUpdate(ctx context.Context, d *schema.ResourceData, meta input.RoleArn = aws.String(d.Get(names.AttrRoleARN).(string)) } - if d.HasChange("schedule") { - input.Schedule = aws.String(d.Get("schedule").(string)) + if d.HasChange(names.AttrSchedule) { + input.Schedule = aws.String(d.Get(names.AttrSchedule).(string)) } log.Printf("[DEBUG] Updating Kendra Data Source (%s): %#v", d.Id(), input) diff --git a/internal/service/kendra/data_source_test.go b/internal/service/kendra/data_source_test.go index 8f1eba75168..23bfdd9cba0 100644 --- a/internal/service/kendra/data_source_test.go +++ b/internal/service/kendra/data_source_test.go @@ -308,7 +308,7 @@ func TestAccKendraDataSource_schedule(t *testing.T) { Config: testAccDataSourceConfig_schedule(rName, rName2, rName3, rName4, rName5, rName6, originalSchedule), Check: resource.ComposeTestCheckFunc( testAccCheckDataSourceExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "schedule", originalSchedule), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, originalSchedule), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(types.DataSourceTypeS3)), ), }, @@ -321,7 +321,7 @@ func TestAccKendraDataSource_schedule(t *testing.T) { Config: testAccDataSourceConfig_schedule(rName, rName2, rName3, rName4, rName5, rName6, updatedSchedule), Check: resource.ComposeTestCheckFunc( testAccCheckDataSourceExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "schedule", updatedSchedule), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, updatedSchedule), resource.TestCheckResourceAttr(resourceName, names.AttrType, string(types.DataSourceTypeS3)), ), }, diff --git a/internal/service/lakeformation/data_lake_settings.go b/internal/service/lakeformation/data_lake_settings.go index d4712576466..24c8fc2048d 100644 --- a/internal/service/lakeformation/data_lake_settings.go +++ b/internal/service/lakeformation/data_lake_settings.go @@ -88,7 +88,7 @@ func ResourceDataLakeSettings() *schema.Resource { ValidateDiagFunc: enum.Validate[awstypes.Permission](), }, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Optional: true, Computed: true, @@ -113,7 +113,7 @@ func ResourceDataLakeSettings() *schema.Resource { ValidateDiagFunc: enum.Validate[awstypes.Permission](), }, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Optional: true, Computed: true, @@ -311,7 +311,7 @@ func expandDataLakeSettingsCreateDefaultPermission(tfMap map[string]interface{}) apiObject := awstypes.PrincipalPermissions{ Permissions: flex.ExpandStringyValueList[awstypes.Permission](tfMap["permissions"].(*schema.Set).List()), Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(tfMap["principal"].(string)), + DataLakePrincipalIdentifier: aws.String(tfMap[names.AttrPrincipal].(string)), }, } @@ -344,7 +344,7 @@ func flattenDataLakeSettingsCreateDefaultPermission(apiObject awstypes.Principal } if v := aws.ToString(apiObject.Principal.DataLakePrincipalIdentifier); v != "" { - tfMap["principal"] = v + tfMap[names.AttrPrincipal] = v } return tfMap diff --git a/internal/service/lakeformation/data_lake_settings_data_source.go b/internal/service/lakeformation/data_lake_settings_data_source.go index cb45f3de5a5..ba3d5484820 100644 --- a/internal/service/lakeformation/data_lake_settings_data_source.go +++ b/internal/service/lakeformation/data_lake_settings_data_source.go @@ -60,7 +60,7 @@ func DataSourceDataLakeSettings() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Computed: true, }, @@ -77,7 +77,7 @@ func DataSourceDataLakeSettings() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/lakeformation/permissions.go b/internal/service/lakeformation/permissions.go index f67a5e69b54..179e7a8610f 100644 --- a/internal/service/lakeformation/permissions.go +++ b/internal/service/lakeformation/permissions.go @@ -218,7 +218,7 @@ func ResourcePermissions() *schema.Resource { Computed: true, ValidateFunc: verify.ValidAccountID, }, - "expression": { + names.AttrExpression: { Type: schema.TypeSet, Required: true, MinItems: 1, @@ -272,7 +272,7 @@ func ResourcePermissions() *schema.Resource { ValidateDiagFunc: enum.Validate[awstypes.Permission](), }, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, ForceNew: true, Required: true, @@ -423,7 +423,7 @@ func resourcePermissionsCreate(ctx context.Context, d *schema.ResourceData, meta input := &lakeformation.GrantPermissionsInput{ Permissions: flex.ExpandStringyValueList[awstypes.Permission](d.Get("permissions").([]interface{})), Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(d.Get("principal").(string)), + DataLakePrincipalIdentifier: aws.String(d.Get(names.AttrPrincipal).(string)), }, Resource: &awstypes.Resource{}, } @@ -517,7 +517,7 @@ func resourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta i input := &lakeformation.ListPermissionsInput{ Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(d.Get("principal").(string)), + DataLakePrincipalIdentifier: aws.String(d.Get(names.AttrPrincipal).(string)), }, Resource: &awstypes.Resource{}, } @@ -632,7 +632,7 @@ func resourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta i log.Printf("[INFO] Resource Lake Formation clean permissions (%d) and all permissions (%d) have different lengths (this is not necessarily a problem): %s", len(cleanPermissions), len(allPermissions), d.Id()) } - d.Set("principal", cleanPermissions[0].Principal.DataLakePrincipalIdentifier) + d.Set(names.AttrPrincipal, cleanPermissions[0].Principal.DataLakePrincipalIdentifier) d.Set("permissions", flattenResourcePermissions(cleanPermissions)) d.Set("permissions_with_grant_option", flattenGrantPermissions(cleanPermissions)) @@ -743,7 +743,7 @@ func resourcePermissionsDelete(ctx context.Context, d *schema.ResourceData, meta Permissions: flex.ExpandStringyValueList[awstypes.Permission](d.Get("permissions").([]interface{})), PermissionsWithGrantOption: flex.ExpandStringyValueList[awstypes.Permission](d.Get("permissions_with_grant_option").([]interface{})), Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(d.Get("principal").(string)), + DataLakePrincipalIdentifier: aws.String(d.Get(names.AttrPrincipal).(string)), }, Resource: &awstypes.Resource{}, } @@ -984,7 +984,7 @@ func ExpandLFTagPolicyResource(tfMap map[string]interface{}) *awstypes.LFTagPoli apiObject.CatalogId = aws.String(v) } - if v, ok := tfMap["expression"].(*schema.Set); ok && v.Len() > 0 { + if v, ok := tfMap[names.AttrExpression].(*schema.Set); ok && v.Len() > 0 { apiObject.Expression = ExpandLFTagExpression(v.List()) } @@ -1023,7 +1023,7 @@ func flattenLFTagPolicyResource(apiObject *awstypes.LFTagPolicyResource) map[str } if v := apiObject.Expression; v != nil { - tfMap["expression"] = flattenLFTagExpression(v) + tfMap[names.AttrExpression] = flattenLFTagExpression(v) } if v := apiObject.ResourceType; v != "" { diff --git a/internal/service/lakeformation/permissions_data_source.go b/internal/service/lakeformation/permissions_data_source.go index 2614c2466d2..eb66cef0376 100644 --- a/internal/service/lakeformation/permissions_data_source.go +++ b/internal/service/lakeformation/permissions_data_source.go @@ -148,7 +148,7 @@ func DataSourcePermissions() *schema.Resource { Computed: true, ValidateFunc: verify.ValidAccountID, }, - "expression": { + names.AttrExpression: { Type: schema.TypeSet, Required: true, MinItems: 1, @@ -193,7 +193,7 @@ func DataSourcePermissions() *schema.Resource { Type: schema.TypeString, }, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validPrincipal, @@ -282,7 +282,7 @@ func dataSourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta input := &lakeformation.ListPermissionsInput{ Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(d.Get("principal").(string)), + DataLakePrincipalIdentifier: aws.String(d.Get(names.AttrPrincipal).(string)), }, Resource: &awstypes.Resource{}, } @@ -367,7 +367,7 @@ func dataSourcePermissionsRead(ctx context.Context, d *schema.ResourceData, meta log.Printf("[INFO] Resource Lake Formation clean permissions (%d) and all permissions (%d) have different lengths (this is not necessarily a problem): %s", len(cleanPermissions), len(allPermissions), d.Id()) } - d.Set("principal", cleanPermissions[0].Principal.DataLakePrincipalIdentifier) + d.Set(names.AttrPrincipal, cleanPermissions[0].Principal.DataLakePrincipalIdentifier) d.Set("permissions", flattenResourcePermissions(cleanPermissions)) d.Set("permissions_with_grant_option", flattenGrantPermissions(cleanPermissions)) diff --git a/internal/service/lakeformation/permissions_data_source_test.go b/internal/service/lakeformation/permissions_data_source_test.go index db8ef040a63..15fa057c84b 100644 --- a/internal/service/lakeformation/permissions_data_source_test.go +++ b/internal/service/lakeformation/permissions_data_source_test.go @@ -29,7 +29,7 @@ func testAccPermissionsDataSource_basic(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_basic(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "permissions.#", dataSourceName, "permissions.#"), resource.TestCheckResourceAttrPair(resourceName, "permissions.0", dataSourceName, "permissions.0"), resource.TestCheckResourceAttrPair(resourceName, "catalog_resource", dataSourceName, "catalog_resource"), @@ -54,7 +54,7 @@ func testAccPermissionsDataSource_dataCellsFilter(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_dataCellsFilter(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "permissions.#", dataSourceName, "permissions.#"), resource.TestCheckResourceAttrPair(resourceName, "permissions.0", dataSourceName, "permissions.0"), resource.TestCheckResourceAttrPair(resourceName, "data_cells_filter.#", dataSourceName, "data_cells_filter.#"), @@ -79,7 +79,7 @@ func testAccPermissionsDataSource_dataLocation(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_dataLocation(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "permissions.#", dataSourceName, "permissions.#"), resource.TestCheckResourceAttrPair(resourceName, "permissions.0", dataSourceName, "permissions.0"), resource.TestCheckResourceAttrPair(resourceName, "data_location.#", dataSourceName, "data_location.#"), @@ -105,7 +105,7 @@ func testAccPermissionsDataSource_database(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_database(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "database.#", dataSourceName, "database.#"), resource.TestCheckResourceAttrPair(resourceName, "database.0.name", dataSourceName, "database.0.name"), resource.TestCheckResourceAttrPair(resourceName, "permissions.#", dataSourceName, "permissions.#"), @@ -135,7 +135,7 @@ func testAccPermissionsDataSource_lfTag(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_lfTag(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "lf_tag.#", dataSourceName, "lf_tag.#"), resource.TestCheckResourceAttrPair(resourceName, "lf_tag.0.key", dataSourceName, "lf_tag.0.key"), resource.TestCheckResourceAttrPair(resourceName, "lf_tag.0.values", dataSourceName, "lf_tag.0.values"), @@ -166,7 +166,7 @@ func testAccPermissionsDataSource_lfTagPolicy(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_lfTagPolicy(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "lf_tag_policy.#", dataSourceName, "lf_tag_policy.#"), resource.TestCheckResourceAttrPair(resourceName, "lf_tag_policy.0.resource_type", dataSourceName, "lf_tag_policy.0.resource_type"), resource.TestCheckResourceAttrPair(resourceName, "lf_tag_policy.0.expression.#", dataSourceName, "lf_tag_policy.0.expression.#"), @@ -199,7 +199,7 @@ func testAccPermissionsDataSource_table(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_table(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "table.#", dataSourceName, "table.#"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", dataSourceName, "table.0.database_name"), resource.TestCheckResourceAttrPair(resourceName, "table.0.name", dataSourceName, "table.0.name"), @@ -226,7 +226,7 @@ func testAccPermissionsDataSource_tableWithColumns(t *testing.T) { { Config: testAccPermissionsDataSourceConfig_tableWithColumns(rName), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(resourceName, "principal", dataSourceName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, dataSourceName, names.AttrPrincipal), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.#", dataSourceName, "table_with_columns.#"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", dataSourceName, "table_with_columns.0.database_name"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", dataSourceName, "table_with_columns.0.name"), diff --git a/internal/service/lakeformation/permissions_test.go b/internal/service/lakeformation/permissions_test.go index bbccbd8cb0f..37372bd1df6 100644 --- a/internal/service/lakeformation/permissions_test.go +++ b/internal/service/lakeformation/permissions_test.go @@ -45,7 +45,7 @@ func testAccPermissions_basic(t *testing.T) { Config: testAccPermissionsConfig_basic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions.0", string(awstypes.PermissionCreateDatabase)), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "true"), @@ -95,9 +95,9 @@ func testAccPermissions_database(t *testing.T) { Config: testAccPermissionsConfig_database(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "database.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "database.0.name", dbName, names.AttrName), resource.TestCheckResourceAttr(resourceName, "permissions.#", "3"), @@ -128,7 +128,7 @@ func testAccPermissions_databaseIAMAllowed(t *testing.T) { Config: testAccPermissionsConfig_databaseIAMAllowed(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "principal", tflakeformation.IAMAllowedPrincipals), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, tflakeformation.IAMAllowedPrincipals), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), resource.TestCheckResourceAttr(resourceName, "database.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "database.0.name", dbName, names.AttrName), @@ -160,9 +160,9 @@ func testAccPermissions_databaseMultiple(t *testing.T) { Config: testAccPermissionsConfig_databaseMultiple(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "database.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "database.0.name", dbName, names.AttrName), resource.TestCheckResourceAttr(resourceName, "permissions.#", "3"), @@ -172,9 +172,9 @@ func testAccPermissions_databaseMultiple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.0", string(awstypes.PermissionCreateTable)), testAccCheckPermissionsExists(ctx, resourceName2), - resource.TestCheckResourceAttrPair(resourceName2, "principal", roleName2, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName2, names.AttrPrincipal, roleName2, names.AttrARN), resource.TestCheckResourceAttr(resourceName2, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName2, "principal", roleName2, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName2, names.AttrPrincipal, roleName2, names.AttrARN), resource.TestCheckResourceAttr(resourceName2, "database.#", "1"), resource.TestCheckResourceAttrPair(resourceName2, "database.0.name", dbName, names.AttrName), resource.TestCheckResourceAttr(resourceName2, "permissions.#", "2"), @@ -203,7 +203,7 @@ func testAccPermissions_dataCellsFilter(t *testing.T) { Config: testAccPermissionsConfig_dataCellsFilter(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions.0", string(awstypes.PermissionDescribe)), resource.TestCheckResourceAttr(resourceName, "data_cells_filter.#", "1"), @@ -230,7 +230,7 @@ func testAccPermissions_dataLocation(t *testing.T) { Config: testAccPermissionsConfig_dataLocation(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions.0", string(awstypes.PermissionDataLocationAccess)), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), @@ -259,9 +259,9 @@ func testAccPermissions_lfTag(t *testing.T) { Config: testAccPermissionsConfig_lfTag(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "lf_tag.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "lf_tag.0.key", tagName, names.AttrKey), resource.TestCheckResourceAttrPair(resourceName, "lf_tag.0.values", tagName, names.AttrValues), @@ -294,9 +294,9 @@ func testAccPermissions_lfTagPolicy(t *testing.T) { Config: testAccPermissionsConfig_lfTagPolicy(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.0.resource_type", "DATABASE"), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.0.expression.#", "1"), @@ -331,9 +331,9 @@ func testAccPermissions_lfTagPolicyMultiple(t *testing.T) { Config: testAccPermissionsConfig_lfTagPolicyMultiple(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.#", "1"), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.0.resource_type", "DATABASE"), resource.TestCheckResourceAttr(resourceName, "lf_tag_policy.0.expression.#", "3"), @@ -378,7 +378,7 @@ func testAccPermissions_tableBasic(t *testing.T) { Config: testAccPermissionsConfig_tableBasic(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, "principal"), + resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, names.AttrPrincipal), resource.TestCheckResourceAttr(resourceName, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table.0.name", tableName, names.AttrName), @@ -408,7 +408,7 @@ func testAccPermissions_tableIAMAllowed(t *testing.T) { Config: testAccPermissionsConfig_tableIAMAllowed(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttr(resourceName, "principal", tflakeformation.IAMAllowedPrincipals), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, tflakeformation.IAMAllowedPrincipals), resource.TestCheckResourceAttr(resourceName, "catalog_resource", "false"), resource.TestCheckResourceAttr(resourceName, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", dbName, names.AttrDatabaseName), @@ -439,7 +439,7 @@ func testAccPermissions_tableImplicit(t *testing.T) { Config: testAccPermissionsConfig_tableImplicit(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table.0.name", tableName, names.AttrName), @@ -470,7 +470,7 @@ func testAccPermissions_tableMultipleRoles(t *testing.T) { Config: testAccPermissionsConfig_tableMultipleRoles(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, "principal"), + resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, names.AttrPrincipal), resource.TestCheckResourceAttr(resourceName, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table.0.name", tableName, names.AttrName), @@ -479,7 +479,7 @@ func testAccPermissions_tableMultipleRoles(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "permissions.1", string(awstypes.PermissionDelete)), resource.TestCheckResourceAttr(resourceName, "permissions.2", string(awstypes.PermissionDescribe)), testAccCheckPermissionsExists(ctx, resourceName2), - resource.TestCheckResourceAttrPair(roleName2, names.AttrARN, resourceName2, "principal"), + resource.TestCheckResourceAttrPair(roleName2, names.AttrARN, resourceName2, names.AttrPrincipal), resource.TestCheckResourceAttr(resourceName2, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName2, "table.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName2, "table.0.name", tableName, names.AttrName), @@ -508,7 +508,7 @@ func testAccPermissions_tableSelectOnly(t *testing.T) { Config: testAccPermissionsConfig_tableSelectOnly(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, "principal"), + resource.TestCheckResourceAttrPair(roleName, names.AttrARN, resourceName, names.AttrPrincipal), resource.TestCheckResourceAttr(resourceName, "table.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table.0.name", tableName, names.AttrName), @@ -536,7 +536,7 @@ func testAccPermissions_tableSelectPlus(t *testing.T) { Config: testAccPermissionsConfig_tableSelectPlus(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "7"), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "7"), ), @@ -586,7 +586,7 @@ func testAccPermissions_tableWildcardSelectOnly(t *testing.T) { Config: testAccPermissionsConfig_tableWildcardSelectOnly(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions.0", string(awstypes.PermissionSelect)), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "0"), @@ -612,7 +612,7 @@ func testAccPermissions_tableWildcardSelectPlus(t *testing.T) { Config: testAccPermissionsConfig_tableWildcardSelectPlus(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "7"), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "7"), ), @@ -638,7 +638,7 @@ func testAccPermissions_twcBasic(t *testing.T) { Config: testAccPermissionsConfig_twcBasic(rName, "\"event\", \"timestamp\""), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -653,7 +653,7 @@ func testAccPermissions_twcBasic(t *testing.T) { Config: testAccPermissionsConfig_twcBasic(rName, "\"timestamp\", \"event\""), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -668,7 +668,7 @@ func testAccPermissions_twcBasic(t *testing.T) { Config: testAccPermissionsConfig_twcBasic(rName, "\"timestamp\", \"event\", \"transactionamount\""), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -684,7 +684,7 @@ func testAccPermissions_twcBasic(t *testing.T) { Config: testAccPermissionsConfig_twcBasic(rName, "\"event\""), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -715,7 +715,7 @@ func testAccPermissions_twcImplicit(t *testing.T) { Config: testAccPermissionsConfig_twcImplicit(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -744,7 +744,7 @@ func testAccPermissions_twcWildcardExcludedColumns(t *testing.T) { Config: testAccPermissionsConfig_twcWildcardExcludedColumns(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "0"), ), @@ -770,7 +770,7 @@ func testAccPermissions_twcWildcardSelectOnly(t *testing.T) { Config: testAccPermissionsConfig_twcWildcardSelectOnly(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "table_with_columns.#", "1"), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.database_name", tableName, names.AttrDatabaseName), resource.TestCheckResourceAttrPair(resourceName, "table_with_columns.0.name", tableName, names.AttrName), @@ -800,7 +800,7 @@ func testAccPermissions_twcWildcardSelectPlus(t *testing.T) { Config: testAccPermissionsConfig_twcWildcardSelectPlus(rName), Check: resource.ComposeTestCheckFunc( testAccCheckPermissionsExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "principal", roleName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, roleName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "permissions.#", "7"), resource.TestCheckResourceAttr(resourceName, "permissions_with_grant_option.#", "0"), ), @@ -862,7 +862,7 @@ func testAccCheckPermissionsExists(ctx context.Context, resourceName string) res func permissionCountForResource(ctx context.Context, conn *lakeformation.Client, rs *terraform.ResourceState) (int, error) { input := &lakeformation.ListPermissionsInput{ Principal: &awstypes.DataLakePrincipal{ - DataLakePrincipalIdentifier: aws.String(rs.Primary.Attributes["principal"]), + DataLakePrincipalIdentifier: aws.String(rs.Primary.Attributes[names.AttrPrincipal]), }, Resource: &awstypes.Resource{}, } @@ -967,7 +967,7 @@ func permissionCountForResource(ctx context.Context, conn *lakeformation.Client, expressionSlice[i] = expression } // The exact details of the set hash function don't matter, elements just have distinct values. - tfMap["expression"] = schema.NewSet(func(_ interface{}) int { return sdkacctest.RandInt() }, expressionSlice) + tfMap[names.AttrExpression] = schema.NewSet(func(_ interface{}) int { return sdkacctest.RandInt() }, expressionSlice) } input.Resource.LFTagPolicy = tflakeformation.ExpandLFTagPolicyResource(tfMap) diff --git a/internal/service/lakeformation/sweep.go b/internal/service/lakeformation/sweep.go index dbd5e36ac7b..9ef7aa9c7d8 100644 --- a/internal/service/lakeformation/sweep.go +++ b/internal/service/lakeformation/sweep.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "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() { @@ -44,7 +45,7 @@ func sweepPermissions(ctx context.Context, client *conns.AWSClient) ([]sweep.Swe for _, v := range page.PrincipalResourcePermissions { d := r.Data(nil) - d.Set("principal", v.Principal.DataLakePrincipalIdentifier) + d.Set(names.AttrPrincipal, v.Principal.DataLakePrincipalIdentifier) d.Set("permissions", flattenResourcePermissions([]types.PrincipalResourcePermissions{v})) d.Set("permissions_with_grant_option", flattenGrantPermissions([]types.PrincipalResourcePermissions{v})) diff --git a/internal/service/lambda/function.go b/internal/service/lambda/function.go index 182c9df541f..d77d9fa8fe2 100644 --- a/internal/service/lambda/function.go +++ b/internal/service/lambda/function.go @@ -405,7 +405,7 @@ func resourceFunction() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -570,7 +570,7 @@ func resourceFunctionCreate(ctx context.Context, d *schema.ResourceData, meta in } } - if v, ok := d.GetOk("vpc_config"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrVPCConfig); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) input.VpcConfig = &awstypes.VpcConfig{ Ipv6AllowedForDualStack: aws.Bool(tfMap["ipv6_allowed_for_dual_stack"].(bool)), @@ -712,7 +712,7 @@ func resourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta inte }); err != nil { return sdkdiag.AppendErrorf(diags, "setting tracing_config: %s", err) } - if err := d.Set("vpc_config", flattenVPCConfigResponse(function.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfigResponse(function.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } @@ -900,7 +900,7 @@ func resourceFunctionUpdate(ctx context.Context, d *schema.ResourceData, meta in } if d.HasChanges("vpc_config.0.security_group_ids", "vpc_config.0.subnet_ids", "vpc_config.0.ipv6_allowed_for_dual_stack") { - if v, ok := d.GetOk("vpc_config"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrVPCConfig); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) input.VpcConfig = &awstypes.VpcConfig{ Ipv6AllowedForDualStack: aws.Bool(tfMap["ipv6_allowed_for_dual_stack"].(bool)), diff --git a/internal/service/lambda/function_data_source.go b/internal/service/lambda/function_data_source.go index 8b28ef798f2..c6e11bc25dd 100644 --- a/internal/service/lambda/function_data_source.go +++ b/internal/service/lambda/function_data_source.go @@ -214,7 +214,7 @@ func dataSourceFunction() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Computed: true, Elem: &schema.Resource{ @@ -349,7 +349,7 @@ func dataSourceFunctionRead(ctx context.Context, d *schema.ResourceData, meta in return sdkdiag.AppendErrorf(diags, "setting tracing_config: %s", err) } d.Set(names.AttrVersion, function.Version) - if err := d.Set("vpc_config", flattenVPCConfigResponse(function.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfigResponse(function.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } diff --git a/internal/service/lambda/layer_version_permission.go b/internal/service/lambda/layer_version_permission.go index 798a14297ba..6bf95b657b4 100644 --- a/internal/service/lambda/layer_version_permission.go +++ b/internal/service/lambda/layer_version_permission.go @@ -67,7 +67,7 @@ func resourceLayerVersionPermission() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -106,7 +106,7 @@ func resourceLayerVersionPermissionCreate(ctx context.Context, d *schema.Resourc input := &lambda.AddLayerVersionPermissionInput{ Action: aws.String(d.Get(names.AttrAction).(string)), LayerName: aws.String(layerName), - Principal: aws.String(d.Get("principal").(string)), + Principal: aws.String(d.Get(names.AttrPrincipal).(string)), StatementId: aws.String(d.Get("statement_id").(string)), VersionNumber: aws.Int64(int64(versionNumber)), } @@ -200,7 +200,7 @@ func resourceLayerVersionPermissionRead(ctx context.Context, d *schema.ResourceD principal = policyPrincipalARN.AccountID } - d.Set("principal", principal) + d.Set(names.AttrPrincipal, principal) } } } diff --git a/internal/service/lambda/layer_version_permission_test.go b/internal/service/lambda/layer_version_permission_test.go index 07012b203f7..624d1d708e1 100644 --- a/internal/service/lambda/layer_version_permission_test.go +++ b/internal/service/lambda/layer_version_permission_test.go @@ -34,7 +34,7 @@ func TestAccLambdaLayerVersionPermission_basic_byARN(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLayerVersionPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:GetLayerVersion"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttr(resourceName, "statement_id", "xaccount"), resource.TestCheckResourceAttrPair(resourceName, "layer_name", "aws_lambda_layer_version.test", "layer_arn"), ), @@ -65,7 +65,7 @@ func TestAccLambdaLayerVersionPermission_basic_byName(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLayerVersionPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:GetLayerVersion"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttr(resourceName, "statement_id", "xaccount"), resource.TestCheckResourceAttrPair(resourceName, "layer_name", "aws_lambda_layer_version.test", "layer_name"), ), @@ -96,7 +96,7 @@ func TestAccLambdaLayerVersionPermission_org(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLayerVersionPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:GetLayerVersion"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttr(resourceName, "statement_id", "xaccount"), resource.TestCheckResourceAttr(resourceName, "organization_id", "o-0123456789"), resource.TestCheckResourceAttrPair(resourceName, "layer_name", "aws_lambda_layer_version.test", "layer_arn"), @@ -128,7 +128,7 @@ func TestAccLambdaLayerVersionPermission_account(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckLayerVersionPermissionExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:GetLayerVersion"), - resource.TestCheckResourceAttrPair(resourceName, "principal", "data.aws_caller_identity.current", names.AttrAccountID), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, "data.aws_caller_identity.current", names.AttrAccountID), resource.TestCheckResourceAttr(resourceName, "statement_id", "xaccount"), resource.TestCheckResourceAttrPair(resourceName, "layer_name", "aws_lambda_layer_version.test", "layer_arn"), ), diff --git a/internal/service/lambda/permission.go b/internal/service/lambda/permission.go index 6d08eb84bed..2b77f8f6b12 100644 --- a/internal/service/lambda/permission.go +++ b/internal/service/lambda/permission.go @@ -65,7 +65,7 @@ func resourcePermission() *schema.Resource { ForceNew: true, ValidateDiagFunc: enum.Validate[awstypes.FunctionUrlAuthType](), }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -129,7 +129,7 @@ func resourcePermissionCreate(ctx context.Context, d *schema.ResourceData, meta input := &lambda.AddPermissionInput{ Action: aws.String(d.Get(names.AttrAction).(string)), FunctionName: aws.String(functionName), - Principal: aws.String(d.Get("principal").(string)), + Principal: aws.String(d.Get(names.AttrPrincipal).(string)), StatementId: aws.String(statementID), } @@ -214,12 +214,12 @@ func resourcePermissionRead(ctx context.Context, d *schema.ResourceData, meta in // Check if the principal is a cross-account IAM role if v, ok := statement.Principal.(map[string]interface{}); ok { if _, ok := v["AWS"]; ok { - d.Set("principal", v["AWS"]) + d.Set(names.AttrPrincipal, v["AWS"]) } else { - d.Set("principal", v["Service"]) + d.Set(names.AttrPrincipal, v["Service"]) } } else if v, ok := statement.Principal.(string); ok { - d.Set("principal", v) + d.Set(names.AttrPrincipal, v) } if v, ok := statement.Condition["StringEquals"]; ok { diff --git a/internal/service/lambda/permission_test.go b/internal/service/lambda/permission_test.go index 0d604621117..48ebcb94456 100644 --- a/internal/service/lambda/permission_test.go +++ b/internal/service/lambda/permission_test.go @@ -243,7 +243,7 @@ func TestAccLambdaPermission_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), resource.TestCheckResourceAttr(resourceName, "event_source_token", "test-event-source-token"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceName, "qualifier", ""), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromCloudWatch"), resource.TestCheckResourceAttr(resourceName, "statement_id_prefix", ""), @@ -278,7 +278,7 @@ func TestAccLambdaPermission_principalOrgID(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttrPair(resourceName, "principal_org_id", "data.aws_organizations_organization.test", names.AttrID), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromCloudWatch"), resource.TestCheckResourceAttr(resourceName, "qualifier", ""), @@ -338,7 +338,7 @@ func TestAccLambdaPermission_rawFunctionName(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceName, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionWithRawFuncName"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), ), @@ -372,7 +372,7 @@ func TestAccLambdaPermission_statementIDPrefix(t *testing.T) { testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), - resource.TestCheckResourceAttr(resourceName, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "events.amazonaws.com"), acctest.CheckResourceAttrNameFromPrefix(resourceName, "statement_id", "AllowExecutionWithStatementIdPrefix-"), resource.TestCheckResourceAttr(resourceName, "statement_id_prefix", "AllowExecutionWithStatementIdPrefix-"), ), @@ -407,7 +407,7 @@ func TestAccLambdaPermission_qualifier(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceName, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionWithQualifier"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "qualifier", rName), @@ -477,13 +477,13 @@ func TestAccLambdaPermission_multiplePerms(t *testing.T) { // 1st testAccCheckPermissionExists(ctx, resourceNameFirst, &firstStatement), resource.TestCheckResourceAttr(resourceNameFirst, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceNameFirst, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceNameFirst, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceNameFirst, "statement_id", "AllowExecutionFirst"), resource.TestCheckResourceAttrPair(resourceNameFirst, "function_name", functionResourceName, names.AttrARN), // 2nd testAccCheckPermissionExists(ctx, resourceNameSecond, &firstStatementModified), resource.TestCheckResourceAttr(resourceNameSecond, names.AttrAction, "lambda:*"), - resource.TestCheckResourceAttr(resourceNameSecond, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceNameSecond, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceNameSecond, "statement_id", "AllowExecutionSecond"), resource.TestCheckResourceAttrPair(resourceNameSecond, "function_name", functionResourceName, names.AttrARN), ), @@ -494,19 +494,19 @@ func TestAccLambdaPermission_multiplePerms(t *testing.T) { // 1st testAccCheckPermissionExists(ctx, resourceNameFirst, &secondStatement), resource.TestCheckResourceAttr(resourceNameFirst, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceNameFirst, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceNameFirst, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceNameFirst, "statement_id", "AllowExecutionFirst"), resource.TestCheckResourceAttrPair(resourceNameFirst, "function_name", functionResourceName, names.AttrARN), // 2nd testAccCheckPermissionExists(ctx, resourceNameSecondModified, &secondStatementModified), resource.TestCheckResourceAttr(resourceNameSecondModified, names.AttrAction, "lambda:*"), - resource.TestCheckResourceAttr(resourceNameSecondModified, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceNameSecondModified, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceNameSecondModified, "statement_id", "AllowExecutionSec0nd"), resource.TestCheckResourceAttrPair(resourceNameSecondModified, "function_name", functionResourceName, names.AttrARN), // 3rd testAccCheckPermissionExists(ctx, resourceNameThird, &thirdStatement), resource.TestCheckResourceAttr(resourceNameThird, names.AttrAction, "lambda:*"), - resource.TestCheckResourceAttr(resourceNameThird, "principal", "events.amazonaws.com"), + resource.TestCheckResourceAttr(resourceNameThird, names.AttrPrincipal, "events.amazonaws.com"), resource.TestCheckResourceAttr(resourceNameThird, "statement_id", "AllowExecutionThird"), resource.TestCheckResourceAttrPair(resourceNameThird, "function_name", functionResourceName, names.AttrARN), ), @@ -548,7 +548,7 @@ func TestAccLambdaPermission_s3(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceName, "principal", "s3.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "s3.amazonaws.com"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromS3"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "source_arn", bucketResourceName, names.AttrARN), @@ -585,7 +585,7 @@ func TestAccLambdaPermission_sns(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttr(resourceName, "principal", "sns.amazonaws.com"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "sns.amazonaws.com"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromSNS"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), resource.TestCheckResourceAttrPair(resourceName, "source_arn", snsTopicResourceName, names.AttrARN), @@ -622,7 +622,7 @@ func TestAccLambdaPermission_iamRole(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunction"), - resource.TestCheckResourceAttrPair(resourceName, "principal", iamRoleResourceName, names.AttrARN), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, iamRoleResourceName, names.AttrARN), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromIAMRole"), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), ), @@ -656,7 +656,7 @@ func TestAccLambdaPermission_FunctionURLs_iam(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunctionUrl"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionWithIAM"), resource.TestCheckResourceAttr(resourceName, "qualifier", ""), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), @@ -692,7 +692,7 @@ func TestAccLambdaPermission_FunctionURLs_none(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckPermissionExists(ctx, resourceName, &statement), resource.TestCheckResourceAttr(resourceName, names.AttrAction, "lambda:InvokeFunctionUrl"), - resource.TestCheckResourceAttr(resourceName, "principal", "*"), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, "*"), resource.TestCheckResourceAttr(resourceName, "statement_id", "AllowExecutionFromWithoutAuth"), resource.TestCheckResourceAttr(resourceName, "qualifier", ""), resource.TestCheckResourceAttrPair(resourceName, "function_name", functionResourceName, names.AttrARN), diff --git a/internal/service/licensemanager/grant.go b/internal/service/licensemanager/grant.go index 2fa45f80f23..9be2d055d87 100644 --- a/internal/service/licensemanager/grant.go +++ b/internal/service/licensemanager/grant.go @@ -76,7 +76,7 @@ func ResourceGrant() *schema.Resource { Computed: true, Description: "Parent ARN.", }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -108,7 +108,7 @@ func resourceGrantCreate(ctx context.Context, d *schema.ResourceData, meta inter GrantName: aws.String(d.Get(names.AttrName).(string)), HomeRegion: aws.String(meta.(*conns.AWSClient).Region), LicenseArn: aws.String(d.Get("license_arn").(string)), - Principals: aws.StringSlice([]string{d.Get("principal").(string)}), + Principals: aws.StringSlice([]string{d.Get(names.AttrPrincipal).(string)}), } out, err := conn.CreateGrantWithContext(ctx, in) @@ -145,7 +145,7 @@ func resourceGrantRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set("license_arn", out.LicenseArn) d.Set(names.AttrName, out.GrantName) d.Set("parent_arn", out.ParentArn) - d.Set("principal", out.GranteePrincipalArn) + d.Set(names.AttrPrincipal, out.GranteePrincipalArn) d.Set(names.AttrStatus, out.GrantStatus) d.Set(names.AttrVersion, out.Version) diff --git a/internal/service/licensemanager/grant_accepter.go b/internal/service/licensemanager/grant_accepter.go index 91894e6d43e..63f9bd6a2af 100644 --- a/internal/service/licensemanager/grant_accepter.go +++ b/internal/service/licensemanager/grant_accepter.go @@ -70,7 +70,7 @@ func ResourceGrantAccepter() *schema.Resource { Computed: true, Description: "Parent ARN.", }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Computed: true, Description: "The grantee principal ARN.", @@ -132,7 +132,7 @@ func resourceGrantAccepterRead(ctx context.Context, d *schema.ResourceData, meta d.Set("license_arn", out.LicenseArn) d.Set(names.AttrName, out.GrantName) d.Set("parent_arn", out.ParentArn) - d.Set("principal", out.GranteePrincipalArn) + d.Set(names.AttrPrincipal, out.GranteePrincipalArn) d.Set(names.AttrStatus, out.GrantStatus) d.Set(names.AttrVersion, out.Version) diff --git a/internal/service/licensemanager/grant_accepter_test.go b/internal/service/licensemanager/grant_accepter_test.go index dc39018d803..5bda8a4f9f3 100644 --- a/internal/service/licensemanager/grant_accepter_test.go +++ b/internal/service/licensemanager/grant_accepter_test.go @@ -50,7 +50,7 @@ func testAccGrantAccepter_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "license_arn", licenseARN), resource.TestCheckResourceAttrPair(resourceName, names.AttrName, resourceGrantName, names.AttrName), resource.TestCheckResourceAttrPair(resourceName, "parent_arn", resourceGrantName, "parent_arn"), - resource.TestCheckResourceAttrPair(resourceName, "principal", resourceGrantName, "principal"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrPrincipal, resourceGrantName, names.AttrPrincipal), resource.TestCheckResourceAttrSet(resourceName, names.AttrStatus), resource.TestCheckResourceAttrSet(resourceName, names.AttrVersion), ), diff --git a/internal/service/licensemanager/grant_test.go b/internal/service/licensemanager/grant_test.go index f0658404038..9cd4c367aa6 100644 --- a/internal/service/licensemanager/grant_test.go +++ b/internal/service/licensemanager/grant_test.go @@ -81,7 +81,7 @@ func testAccGrant_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "license_arn", licenseARN), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttrSet(resourceName, "parent_arn"), - resource.TestCheckResourceAttr(resourceName, "principal", principal), + resource.TestCheckResourceAttr(resourceName, names.AttrPrincipal, principal), resource.TestCheckResourceAttr(resourceName, names.AttrStatus, "PENDING_ACCEPT"), resource.TestCheckResourceAttr(resourceName, names.AttrVersion, "1"), ), diff --git a/internal/service/lightsail/key_pair.go b/internal/service/lightsail/key_pair.go index 57016f55d2b..eaaa4c982e5 100644 --- a/internal/service/lightsail/key_pair.go +++ b/internal/service/lightsail/key_pair.go @@ -73,7 +73,7 @@ func ResourceKeyPair() *schema.Resource { Optional: true, ForceNew: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Computed: true, }, @@ -138,7 +138,7 @@ func resourceKeyPairCreate(ctx context.Context, d *schema.ResourceData, meta int d.Set("encrypted_fingerprint", fingerprint) d.Set("encrypted_private_key", encrypted) } else { - d.Set("private_key", resp.PrivateKeyBase64) + d.Set(names.AttrPrivateKey, resp.PrivateKeyBase64) } op = resp.Operation diff --git a/internal/service/lightsail/key_pair_test.go b/internal/service/lightsail/key_pair_test.go index 35a4327a1d2..f69395a1ad9 100644 --- a/internal/service/lightsail/key_pair_test.go +++ b/internal/service/lightsail/key_pair_test.go @@ -45,7 +45,7 @@ func TestAccLightsailKeyPair_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "fingerprint"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrNamePrefix, ""), - resource.TestCheckResourceAttrSet(resourceName, "private_key"), + resource.TestCheckResourceAttrSet(resourceName, names.AttrPrivateKey), resource.TestCheckResourceAttrSet(resourceName, "public_key"), ), }, @@ -83,7 +83,7 @@ func TestAccLightsailKeyPair_publicKey(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "public_key"), resource.TestCheckNoResourceAttr(resourceName, "encrypted_fingerprint"), resource.TestCheckNoResourceAttr(resourceName, "encrypted_private_key"), - resource.TestCheckNoResourceAttr(resourceName, "private_key"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), ), }, }, @@ -115,7 +115,7 @@ func TestAccLightsailKeyPair_encrypted(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "encrypted_fingerprint"), resource.TestCheckResourceAttrSet(resourceName, "encrypted_private_key"), resource.TestCheckResourceAttrSet(resourceName, "public_key"), - resource.TestCheckNoResourceAttr(resourceName, "private_key"), + resource.TestCheckNoResourceAttr(resourceName, names.AttrPrivateKey), ), }, }, diff --git a/internal/service/lightsail/static_ip.go b/internal/service/lightsail/static_ip.go index 00ffa45188e..b4a49423b3b 100644 --- a/internal/service/lightsail/static_ip.go +++ b/internal/service/lightsail/static_ip.go @@ -29,7 +29,7 @@ func ResourceStaticIP() *schema.Resource { Required: true, ForceNew: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -82,7 +82,7 @@ func resourceStaticIPRead(ctx context.Context, d *schema.ResourceData, meta inte } d.Set(names.AttrARN, out.StaticIp.Arn) - d.Set("ip_address", out.StaticIp.IpAddress) + d.Set(names.AttrIPAddress, out.StaticIp.IpAddress) d.Set("support_code", out.StaticIp.SupportCode) return diags diff --git a/internal/service/lightsail/static_ip_attachment.go b/internal/service/lightsail/static_ip_attachment.go index 5ee8a4244e0..34e4007aaa6 100644 --- a/internal/service/lightsail/static_ip_attachment.go +++ b/internal/service/lightsail/static_ip_attachment.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_lightsail_static_ip_attachment") @@ -33,7 +34,7 @@ func ResourceStaticIPAttachment() *schema.Resource { Required: true, ForceNew: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -84,7 +85,7 @@ func resourceStaticIPAttachmentRead(ctx context.Context, d *schema.ResourceData, } d.Set("instance_name", out.StaticIp.AttachedTo) - d.Set("ip_address", out.StaticIp.IpAddress) + d.Set(names.AttrIPAddress, out.StaticIp.IpAddress) return diags } diff --git a/internal/service/lightsail/static_ip_attachment_test.go b/internal/service/lightsail/static_ip_attachment_test.go index 86e82cddfd0..f3f7bcb46d5 100644 --- a/internal/service/lightsail/static_ip_attachment_test.go +++ b/internal/service/lightsail/static_ip_attachment_test.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" tflightsail "github.com/hashicorp/terraform-provider-aws/internal/service/lightsail" + "github.com/hashicorp/terraform-provider-aws/names" ) func TestAccLightsailStaticIPAttachment_basic(t *testing.T) { @@ -36,7 +37,7 @@ func TestAccLightsailStaticIPAttachment_basic(t *testing.T) { Config: testAccStaticIPAttachmentConfig_basic(staticIpName, instanceName, keypairName), Check: resource.ComposeAggregateTestCheckFunc( testAccCheckStaticIPAttachmentExists(ctx, "aws_lightsail_static_ip_attachment.test"), - resource.TestCheckResourceAttrSet("aws_lightsail_static_ip_attachment.test", "ip_address"), + resource.TestCheckResourceAttrSet("aws_lightsail_static_ip_attachment.test", names.AttrIPAddress), ), }, }, diff --git a/internal/service/mq/broker.go b/internal/service/mq/broker.go index 764a17a7cbf..14e52180aba 100644 --- a/internal/service/mq/broker.go +++ b/internal/service/mq/broker.go @@ -185,7 +185,7 @@ func resourceBroker() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -1128,7 +1128,7 @@ func flattenBrokerInstances(instances []types.BrokerInstance) []interface{} { m[names.AttrEndpoints] = instance.Endpoints } if instance.IpAddress != nil { - m["ip_address"] = aws.ToString(instance.IpAddress) + m[names.AttrIPAddress] = aws.ToString(instance.IpAddress) } l[i] = m } diff --git a/internal/service/mq/broker_data_source.go b/internal/service/mq/broker_data_source.go index d2a85990d0e..9771baa7ff9 100644 --- a/internal/service/mq/broker_data_source.go +++ b/internal/service/mq/broker_data_source.go @@ -112,7 +112,7 @@ func dataSourceBroker() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/opsworks/application.go b/internal/service/opsworks/application.go index 2f322954df1..8b02ae82602 100644 --- a/internal/service/opsworks/application.go +++ b/internal/service/opsworks/application.go @@ -187,7 +187,7 @@ func ResourceApplication() *schema.Resource { } }, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Required: true, Sensitive: true, @@ -545,7 +545,7 @@ func resourceSetApplicationSSL(d *schema.ResourceData, v *opsworks.SslConfigurat if v != nil { m := make(map[string]interface{}) if v.PrivateKey != nil { - m["private_key"] = aws.StringValue(v.PrivateKey) + m[names.AttrPrivateKey] = aws.StringValue(v.PrivateKey) set = true } if v.Certificate != nil { diff --git a/internal/service/pinpoint/adm_channel.go b/internal/service/pinpoint/adm_channel.go index 69771bc4604..b16bbf07be3 100644 --- a/internal/service/pinpoint/adm_channel.go +++ b/internal/service/pinpoint/adm_channel.go @@ -34,7 +34,7 @@ func ResourceADMChannel() *schema.Resource { Required: true, ForceNew: true, }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, Sensitive: true, @@ -61,7 +61,7 @@ func resourceADMChannelUpsert(ctx context.Context, d *schema.ResourceData, meta params := &pinpoint.ADMChannelRequest{} - params.ClientId = aws.String(d.Get("client_id").(string)) + params.ClientId = aws.String(d.Get(names.AttrClientID).(string)) params.ClientSecret = aws.String(d.Get("client_secret").(string)) params.Enabled = aws.Bool(d.Get(names.AttrEnabled).(bool)) diff --git a/internal/service/pinpoint/adm_channel_test.go b/internal/service/pinpoint/adm_channel_test.go index 45d67604c71..755b77c8c4a 100644 --- a/internal/service/pinpoint/adm_channel_test.go +++ b/internal/service/pinpoint/adm_channel_test.go @@ -72,7 +72,7 @@ func TestAccPinpointADMChannel_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"client_id", "client_secret"}, + ImportStateVerifyIgnore: []string{names.AttrClientID, "client_secret"}, }, { Config: testAccADMChannelConfig_basic(config), diff --git a/internal/service/pinpoint/apns_channel.go b/internal/service/pinpoint/apns_channel.go index d4486409200..eb64b8a3a65 100644 --- a/internal/service/pinpoint/apns_channel.go +++ b/internal/service/pinpoint/apns_channel.go @@ -53,7 +53,7 @@ func ResourceAPNSChannel() *schema.Resource { Optional: true, Default: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, Sensitive: true, @@ -80,7 +80,7 @@ func ResourceAPNSChannel() *schema.Resource { func resourceAPNSChannelUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics certificate, certificateOk := d.GetOk(names.AttrCertificate) - privateKey, privateKeyOk := d.GetOk("private_key") + privateKey, privateKeyOk := d.GetOk(names.AttrPrivateKey) bundleId, bundleIdOk := d.GetOk("bundle_id") teamId, teamIdOk := d.GetOk("team_id") diff --git a/internal/service/pinpoint/apns_channel_test.go b/internal/service/pinpoint/apns_channel_test.go index 87e88cd0486..442bd28bed5 100644 --- a/internal/service/pinpoint/apns_channel_test.go +++ b/internal/service/pinpoint/apns_channel_test.go @@ -118,7 +118,7 @@ func TestAccPinpointAPNSChannel_basicCertificate(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{names.AttrCertificate, "private_key"}, + ImportStateVerifyIgnore: []string{names.AttrCertificate, names.AttrPrivateKey}, }, { Config: testAccAPNSChannelConfig_basicCertificate(configuration), diff --git a/internal/service/pinpoint/apns_sandbox_channel.go b/internal/service/pinpoint/apns_sandbox_channel.go index 3d182e62b3a..3a7ed6ec1a5 100644 --- a/internal/service/pinpoint/apns_sandbox_channel.go +++ b/internal/service/pinpoint/apns_sandbox_channel.go @@ -53,7 +53,7 @@ func ResourceAPNSSandboxChannel() *schema.Resource { Optional: true, Default: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, Sensitive: true, @@ -80,7 +80,7 @@ func ResourceAPNSSandboxChannel() *schema.Resource { func resourceAPNSSandboxChannelUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics certificate, certificateOk := d.GetOk(names.AttrCertificate) - privateKey, privateKeyOk := d.GetOk("private_key") + privateKey, privateKeyOk := d.GetOk(names.AttrPrivateKey) bundleId, bundleIdOk := d.GetOk("bundle_id") teamId, teamIdOk := d.GetOk("team_id") diff --git a/internal/service/pinpoint/apns_sandbox_channel_test.go b/internal/service/pinpoint/apns_sandbox_channel_test.go index 91bc549d777..18f7b99c906 100644 --- a/internal/service/pinpoint/apns_sandbox_channel_test.go +++ b/internal/service/pinpoint/apns_sandbox_channel_test.go @@ -118,7 +118,7 @@ func TestAccPinpointAPNSSandboxChannel_basicCertificate(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{names.AttrCertificate, "private_key"}, + ImportStateVerifyIgnore: []string{names.AttrCertificate, names.AttrPrivateKey}, }, { Config: testAccAPNSSandboxChannelConfig_basicCertificate(configuration), diff --git a/internal/service/pinpoint/apns_voip_channel.go b/internal/service/pinpoint/apns_voip_channel.go index 4d8b96a4546..9e855cadf5e 100644 --- a/internal/service/pinpoint/apns_voip_channel.go +++ b/internal/service/pinpoint/apns_voip_channel.go @@ -53,7 +53,7 @@ func ResourceAPNSVoIPChannel() *schema.Resource { Optional: true, Default: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, Sensitive: true, @@ -80,7 +80,7 @@ func ResourceAPNSVoIPChannel() *schema.Resource { func resourceAPNSVoIPChannelUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics certificate, certificateOk := d.GetOk(names.AttrCertificate) - privateKey, privateKeyOk := d.GetOk("private_key") + privateKey, privateKeyOk := d.GetOk(names.AttrPrivateKey) bundleId, bundleIdOk := d.GetOk("bundle_id") teamId, teamIdOk := d.GetOk("team_id") diff --git a/internal/service/pinpoint/apns_voip_channel_test.go b/internal/service/pinpoint/apns_voip_channel_test.go index e178caf849e..2bf8e651c76 100644 --- a/internal/service/pinpoint/apns_voip_channel_test.go +++ b/internal/service/pinpoint/apns_voip_channel_test.go @@ -118,7 +118,7 @@ func TestAccPinpointAPNSVoIPChannel_basicCertificate(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{names.AttrCertificate, "private_key"}, + ImportStateVerifyIgnore: []string{names.AttrCertificate, names.AttrPrivateKey}, }, { Config: testAccAPNSVoIPChannelConfig_basicCertificate(configuration), diff --git a/internal/service/pinpoint/apns_voip_sandbox_channel.go b/internal/service/pinpoint/apns_voip_sandbox_channel.go index 4a9c893274a..e2e1c26ed7d 100644 --- a/internal/service/pinpoint/apns_voip_sandbox_channel.go +++ b/internal/service/pinpoint/apns_voip_sandbox_channel.go @@ -53,7 +53,7 @@ func ResourceAPNSVoIPSandboxChannel() *schema.Resource { Optional: true, Default: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, Sensitive: true, @@ -80,7 +80,7 @@ func ResourceAPNSVoIPSandboxChannel() *schema.Resource { func resourceAPNSVoIPSandboxChannelUpsert(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics certificate, certificateOk := d.GetOk(names.AttrCertificate) - privateKey, privateKeyOk := d.GetOk("private_key") + privateKey, privateKeyOk := d.GetOk(names.AttrPrivateKey) bundleId, bundleIdOk := d.GetOk("bundle_id") teamId, teamIdOk := d.GetOk("team_id") diff --git a/internal/service/pinpoint/apns_voip_sandbox_channel_test.go b/internal/service/pinpoint/apns_voip_sandbox_channel_test.go index 3a5e6de6c0f..d569278a53a 100644 --- a/internal/service/pinpoint/apns_voip_sandbox_channel_test.go +++ b/internal/service/pinpoint/apns_voip_sandbox_channel_test.go @@ -118,7 +118,7 @@ func TestAccPinpointAPNSVoIPSandboxChannel_basicCertificate(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{names.AttrCertificate, "private_key"}, + ImportStateVerifyIgnore: []string{names.AttrCertificate, names.AttrPrivateKey}, }, { Config: testAccAPNSVoIPSandboxChannelConfig_basicCertificate(configuration), diff --git a/internal/service/pipes/target_parameters.go b/internal/service/pipes/target_parameters.go index be3bc17a731..549f1c76a08 100644 --- a/internal/service/pipes/target_parameters.go +++ b/internal/service/pipes/target_parameters.go @@ -443,7 +443,7 @@ func targetParametersSchema() *schema.Schema { MaxItems: 10, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 2000), @@ -1573,7 +1573,7 @@ func expandPlacementConstraint(tfMap map[string]interface{}) *types.PlacementCon apiObject := &types.PlacementConstraint{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { apiObject.Expression = aws.String(v) } @@ -2462,7 +2462,7 @@ func flattenPlacementConstraint(apiObject types.PlacementConstraint) map[string] tfMap := map[string]interface{}{} if v := apiObject.Expression; v != nil { - tfMap["expression"] = aws.ToString(v) + tfMap[names.AttrExpression] = aws.ToString(v) } if v := apiObject.Type; v != "" { diff --git a/internal/service/quicksight/analysis.go b/internal/service/quicksight/analysis.go index e4d5fc1e9af..f85e3fa5ebd 100644 --- a/internal/service/quicksight/analysis.go +++ b/internal/service/quicksight/analysis.go @@ -105,7 +105,7 @@ func ResourceAnalysis() *schema.Resource { MaxItems: 16, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), diff --git a/internal/service/quicksight/analysis_test.go b/internal/service/quicksight/analysis_test.go index 434cacc72d6..0193cc92b41 100644 --- a/internal/service/quicksight/analysis_test.go +++ b/internal/service/quicksight/analysis_test.go @@ -252,12 +252,12 @@ func TestAccQuickSightAnalysis_Definition_calculatedFields(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "definition.0.calculated_fields.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "definition.0.calculated_fields.*", map[string]string{ "data_set_identifier": "1", - "expression": "1", + names.AttrExpression: "1", names.AttrName: "test1", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "definition.0.calculated_fields.*", map[string]string{ "data_set_identifier": "1", - "expression": "2", + names.AttrExpression: "2", names.AttrName: "test2", }), ), diff --git a/internal/service/quicksight/dashboard.go b/internal/service/quicksight/dashboard.go index 0d31e0d0a13..9312acd3667 100644 --- a/internal/service/quicksight/dashboard.go +++ b/internal/service/quicksight/dashboard.go @@ -98,7 +98,7 @@ func ResourceDashboard() *schema.Resource { MaxItems: 16, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), diff --git a/internal/service/quicksight/data_set.go b/internal/service/quicksight/data_set.go index d11638f6b9f..51383720e65 100644 --- a/internal/service/quicksight/data_set.go +++ b/internal/service/quicksight/data_set.go @@ -212,7 +212,7 @@ func ResourceDataSet() *schema.Resource { MaxItems: 20, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), @@ -437,7 +437,7 @@ func logicalTableMapSchema() *schema.Resource { Required: true, ValidateFunc: validation.StringLenBetween(1, 128), }, - "expression": { + names.AttrExpression: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 4096), @@ -1496,7 +1496,7 @@ func expandDataSetCalculatedColumn(tfMap map[string]interface{}) *quicksight.Cal if v, ok := tfMap["column_name"].(string); ok { calculatedColumn.ColumnName = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok { + if v, ok := tfMap[names.AttrExpression].(string); ok { calculatedColumn.Expression = aws.String(v) } @@ -2246,7 +2246,7 @@ func flattenCalculatedColumns(apiObject []*quicksight.CalculatedColumn) interfac tfMap["column_name"] = aws.StringValue(column.ColumnName) } if column.Expression != nil { - tfMap["expression"] = aws.StringValue(column.Expression) + tfMap[names.AttrExpression] = aws.StringValue(column.Expression) } tfList = append(tfList, tfMap) diff --git a/internal/service/quicksight/data_set_data_source.go b/internal/service/quicksight/data_set_data_source.go index 74da5696b7a..dec3736cdde 100644 --- a/internal/service/quicksight/data_set_data_source.go +++ b/internal/service/quicksight/data_set_data_source.go @@ -147,7 +147,7 @@ func DataSourceDataSet() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Computed: true, }, @@ -286,7 +286,7 @@ func logicalTableMapDataSourceSchema() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "expression": { + names.AttrExpression: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/quicksight/data_set_test.go b/internal/service/quicksight/data_set_test.go index 20835144b55..8d0c1c49cc1 100644 --- a/internal/service/quicksight/data_set_test.go +++ b/internal/service/quicksight/data_set_test.go @@ -281,7 +281,7 @@ func TestAccQuickSightDataSet_permissions(t *testing.T) { testAccCheckDataSetExists(ctx, resourceName, &dataSet), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permissions.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSet"), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSetPermissions"), @@ -301,7 +301,7 @@ func TestAccQuickSightDataSet_permissions(t *testing.T) { testAccCheckDataSetExists(ctx, resourceName, &dataSet), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permissions.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSet"), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSetPermissions"), @@ -350,7 +350,7 @@ func TestAccQuickSightDataSet_permissionsMultiple(t *testing.T) { testAccCheckDataSetExists(ctx, resourceName, &dataSet), resource.TestCheckResourceAttr(resourceName, "permissions.#", "3"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permissions.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSet"), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeDataSetPermissions"), diff --git a/internal/service/quicksight/data_source.go b/internal/service/quicksight/data_source.go index 0119895b9b9..b6e8483f024 100644 --- a/internal/service/quicksight/data_source.go +++ b/internal/service/quicksight/data_source.go @@ -555,7 +555,7 @@ func ResourceDataSource() *schema.Resource { MinItems: 1, MaxItems: 16, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: verify.ValidARN, diff --git a/internal/service/quicksight/data_source_test.go b/internal/service/quicksight/data_source_test.go index ce95d8ef471..5644bb05a61 100644 --- a/internal/service/quicksight/data_source_test.go +++ b/internal/service/quicksight/data_source_test.go @@ -151,7 +151,7 @@ func TestAccQuickSightDataSource_permissions(t *testing.T) { testAccCheckDataSourceExists(ctx, resourceName, &dataSource), resource.TestCheckResourceAttr(resourceName, "permission.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permission.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permission.*.actions.*", "quicksight:DescribeDataSource"), resource.TestCheckTypeSetElemAttr(resourceName, "permission.*.actions.*", "quicksight:DescribeDataSourcePermissions"), @@ -169,7 +169,7 @@ func TestAccQuickSightDataSource_permissions(t *testing.T) { testAccCheckDataSourceExists(ctx, resourceName, &dataSource), resource.TestCheckResourceAttr(resourceName, "permission.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permission.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permission.*.actions.*", "quicksight:DescribeDataSource"), resource.TestCheckTypeSetElemAttr(resourceName, "permission.*.actions.*", "quicksight:DescribeDataSourcePermissions"), diff --git a/internal/service/quicksight/flex.go b/internal/service/quicksight/flex.go index f0ad9ed6d66..0d4c13ed34f 100644 --- a/internal/service/quicksight/flex.go +++ b/internal/service/quicksight/flex.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/service/quicksight" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/flex" + "github.com/hashicorp/terraform-provider-aws/names" ) func expandResourcePermissions(tfList []interface{}) []*quicksight.ResourcePermission { @@ -18,7 +19,7 @@ func expandResourcePermissions(tfList []interface{}) []*quicksight.ResourcePermi permission := &quicksight.ResourcePermission{ Actions: flex.ExpandStringSet(tfMap["actions"].(*schema.Set)), - Principal: aws.String(tfMap["principal"].(string)), + Principal: aws.String(tfMap[names.AttrPrincipal].(string)), } permissions[i] = permission @@ -103,7 +104,7 @@ func flattenPermissions(perms []*quicksight.ResourcePermission) []interface{} { perm := make(map[string]interface{}) if p.Principal != nil { - perm["principal"] = aws.StringValue(p.Principal) + perm[names.AttrPrincipal] = aws.StringValue(p.Principal) } if p.Actions != nil { diff --git a/internal/service/quicksight/flex_test.go b/internal/service/quicksight/flex_test.go index ad97db5ed58..4a12f747403 100644 --- a/internal/service/quicksight/flex_test.go +++ b/internal/service/quicksight/flex_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go/service/quicksight" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" tfquicksight "github.com/hashicorp/terraform-provider-aws/internal/service/quicksight" + "github.com/hashicorp/terraform-provider-aws/names" ) func TestDataSourcePermissionsDiff(t *testing.T) { @@ -34,7 +35,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { name: "no changes;same", oldPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", @@ -43,7 +44,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { }, newPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", @@ -58,7 +59,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { oldPermissions: []interface{}{}, newPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", @@ -77,7 +78,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { name: "revoke only", oldPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", @@ -97,7 +98,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { name: "grant new action", oldPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", }), @@ -105,7 +106,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { }, newPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", @@ -124,7 +125,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { name: "revoke old action", oldPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "oldAction", "onlyOldAction", @@ -133,7 +134,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { }, newPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "oldAction", }), @@ -156,14 +157,14 @@ func TestDataSourcePermissionsDiff(t *testing.T) { name: "multiple permissions", oldPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", }), }, map[string]interface{}{ - "principal": "principal2", + names.AttrPrincipal: "principal2", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action3", @@ -171,7 +172,7 @@ func TestDataSourcePermissionsDiff(t *testing.T) { }), }, map[string]interface{}{ - "principal": "principal3", + names.AttrPrincipal: "principal3", "actions": schema.NewSet(schema.HashString, []interface{}{ "action5", }), @@ -179,14 +180,14 @@ func TestDataSourcePermissionsDiff(t *testing.T) { }, newPermissions: []interface{}{ map[string]interface{}{ - "principal": "principal1", + names.AttrPrincipal: "principal1", "actions": schema.NewSet(schema.HashString, []interface{}{ "action1", "action2", }), }, map[string]interface{}{ - "principal": "principal2", + names.AttrPrincipal: "principal2", "actions": schema.NewSet(schema.HashString, []interface{}{ "action3", "action5", diff --git a/internal/service/quicksight/folder.go b/internal/service/quicksight/folder.go index 29c9a3c169c..0e51a52b346 100644 --- a/internal/service/quicksight/folder.go +++ b/internal/service/quicksight/folder.go @@ -117,7 +117,7 @@ func ResourceFolder() *schema.Resource { MaxItems: 16, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), diff --git a/internal/service/quicksight/folder_test.go b/internal/service/quicksight/folder_test.go index 3cb0cce8d07..f33e4b77f9f 100644 --- a/internal/service/quicksight/folder_test.go +++ b/internal/service/quicksight/folder_test.go @@ -105,7 +105,7 @@ func TestAccQuickSightFolder_permissions(t *testing.T) { testAccCheckFolderExists(ctx, resourceName, &folder), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permissions.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeFolder"), ), @@ -121,7 +121,7 @@ func TestAccQuickSightFolder_permissions(t *testing.T) { testAccCheckFolderExists(ctx, resourceName, &folder), resource.TestCheckResourceAttr(resourceName, "permissions.#", "1"), resource.TestMatchTypeSetElemNestedAttrs(resourceName, "permissions.*", map[string]*regexp.Regexp{ - "principal": regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), + names.AttrPrincipal: regexache.MustCompile(fmt.Sprintf(`user/default/%s`, rName)), }), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:CreateFolder"), resource.TestCheckTypeSetElemAttr(resourceName, "permissions.*.actions.*", "quicksight:DescribeFolder"), diff --git a/internal/service/quicksight/group.go b/internal/service/quicksight/group.go index 916d6ee933b..4c40113a756 100644 --- a/internal/service/quicksight/group.go +++ b/internal/service/quicksight/group.go @@ -56,7 +56,7 @@ func ResourceGroup() *schema.Resource { Optional: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -91,7 +91,7 @@ func resourceGroupCreate(ctx context.Context, d *schema.ResourceData, meta inter createOpts := &quicksight.CreateGroupInput{ AwsAccountId: aws.String(awsAccountID), Namespace: aws.String(namespace), - GroupName: aws.String(d.Get("group_name").(string)), + GroupName: aws.String(d.Get(names.AttrGroupName).(string)), } if v, ok := d.GetOk(names.AttrDescription); ok { @@ -135,7 +135,7 @@ func resourceGroupRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set(names.AttrARN, resp.Group.Arn) d.Set("aws_account_id", awsAccountID) - d.Set("group_name", resp.Group.GroupName) + d.Set(names.AttrGroupName, resp.Group.GroupName) d.Set(names.AttrDescription, resp.Group.Description) d.Set(names.AttrNamespace, namespace) diff --git a/internal/service/quicksight/group_data_source.go b/internal/service/quicksight/group_data_source.go index d814e5ace7b..e4e4c31f6fb 100644 --- a/internal/service/quicksight/group_data_source.go +++ b/internal/service/quicksight/group_data_source.go @@ -39,7 +39,7 @@ func DataSourceGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, }, @@ -69,7 +69,7 @@ func dataSourceGroupRead(ctx context.Context, d *schema.ResourceData, meta inter if v, ok := d.GetOk("aws_account_id"); ok { awsAccountID = v.(string) } - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) namespace := d.Get(names.AttrNamespace).(string) in := &quicksight.DescribeGroupInput{ GroupName: aws.String(groupName), @@ -90,7 +90,7 @@ func dataSourceGroupRead(ctx context.Context, d *schema.ResourceData, meta inter d.Set(names.AttrARN, group.Arn) d.Set("aws_account_id", awsAccountID) d.Set(names.AttrDescription, group.Description) - d.Set("group_name", group.GroupName) + d.Set(names.AttrGroupName, group.GroupName) d.Set("principal_id", group.PrincipalId) return diags diff --git a/internal/service/quicksight/group_data_source_test.go b/internal/service/quicksight/group_data_source_test.go index 1f2a866ce36..82700992d95 100644 --- a/internal/service/quicksight/group_data_source_test.go +++ b/internal/service/quicksight/group_data_source_test.go @@ -30,7 +30,7 @@ func TestAccQuickSightGroupDataSource_basic(t *testing.T) { { Config: testAccGroupDataSourceConfig(rName, "text1"), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrPair(dataSourceName, "group_name", resourceName, "group_name"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrGroupName, resourceName, names.AttrGroupName), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrARN, resourceName, names.AttrARN), resource.TestCheckResourceAttr(dataSourceName, names.AttrDescription, "text1"), resource.TestCheckResourceAttr(dataSourceName, names.AttrNamespace, tfquicksight.DefaultUserNamespace), diff --git a/internal/service/quicksight/group_membership.go b/internal/service/quicksight/group_membership.go index 1cf19152fc6..36009ff9029 100644 --- a/internal/service/quicksight/group_membership.go +++ b/internal/service/quicksight/group_membership.go @@ -43,7 +43,7 @@ func ResourceGroupMembership() *schema.Resource { Computed: true, ForceNew: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -73,7 +73,7 @@ func resourceGroupMembershipCreate(ctx context.Context, d *schema.ResourceData, awsAccountID := meta.(*conns.AWSClient).AccountID namespace := d.Get(names.AttrNamespace).(string) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) memberName := d.Get("member_name").(string) if v, ok := d.GetOk("aws_account_id"); ok { @@ -125,7 +125,7 @@ func resourceGroupMembershipRead(ctx context.Context, d *schema.ResourceData, me d.Set("aws_account_id", awsAccountID) d.Set(names.AttrNamespace, namespace) d.Set("member_name", userName) - d.Set("group_name", groupName) + d.Set(names.AttrGroupName, groupName) return nil } diff --git a/internal/service/quicksight/group_membership_test.go b/internal/service/quicksight/group_membership_test.go index e7bae54aa9e..95f9d8e7af1 100644 --- a/internal/service/quicksight/group_membership_test.go +++ b/internal/service/quicksight/group_membership_test.go @@ -65,7 +65,7 @@ func TestAccQuickSightGroupMembership_withNamespace(t *testing.T) { Config: testAccGroupMembershipConfig_withNamespace(rName), Check: resource.ComposeTestCheckFunc( testAccCheckGroupMembershipExists(ctx, resourceName), - resource.TestCheckResourceAttrPair(resourceName, "group_name", groupResourceName, "group_name"), + resource.TestCheckResourceAttrPair(resourceName, names.AttrGroupName, groupResourceName, names.AttrGroupName), resource.TestCheckResourceAttrPair(resourceName, "member_name", userResourceName, names.AttrUserName), resource.TestCheckResourceAttrPair(resourceName, names.AttrNamespace, namespaceResourceName, names.AttrNamespace), ), diff --git a/internal/service/quicksight/group_test.go b/internal/service/quicksight/group_test.go index bcd322aa89a..ff4819294b0 100644 --- a/internal/service/quicksight/group_test.go +++ b/internal/service/quicksight/group_test.go @@ -39,7 +39,7 @@ func TestAccQuickSightGroup_basic(t *testing.T) { Config: testAccGroupConfig_basic(rName1), Check: resource.ComposeTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &group), - resource.TestCheckResourceAttr(resourceName, "group_name", rName1), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, rName1), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "quicksight", fmt.Sprintf("group/default/%s", rName1)), ), }, @@ -47,7 +47,7 @@ func TestAccQuickSightGroup_basic(t *testing.T) { Config: testAccGroupConfig_basic(rName2), Check: resource.ComposeTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &group), - resource.TestCheckResourceAttr(resourceName, "group_name", rName2), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, rName2), acctest.CheckResourceAttrRegionalARN(resourceName, names.AttrARN, "quicksight", fmt.Sprintf("group/default/%s", rName2)), ), }, diff --git a/internal/service/quicksight/refresh_schedule.go b/internal/service/quicksight/refresh_schedule.go index b381934dba5..4d6889c1409 100644 --- a/internal/service/quicksight/refresh_schedule.go +++ b/internal/service/quicksight/refresh_schedule.go @@ -83,7 +83,7 @@ func (r *resourceRefreshSchedule) Schema(ctx context.Context, req resource.Schem }, }, Blocks: map[string]schema.Block{ - "schedule": schema.ListNestedBlock{ + names.AttrSchedule: schema.ListNestedBlock{ Validators: []validator.List{ listvalidator.SizeAtMost(1), listvalidator.IsRequired(), @@ -422,7 +422,7 @@ func (r *resourceRefreshSchedule) ValidateConfig(ctx context.Context, req resour return } - basePath := path.Root("schedule").AtName("schedule_frequency").AtName("refresh_on_day") + basePath := path.Root(names.AttrSchedule).AtName("schedule_frequency").AtName("refresh_on_day") switch *apiObj.ScheduleFrequency.Interval { case quicksight.RefreshIntervalWeekly: diff --git a/internal/service/quicksight/schema/template.go b/internal/service/quicksight/schema/template.go index 874381af28a..d530bf66e51 100644 --- a/internal/service/quicksight/schema/template.go +++ b/internal/service/quicksight/schema/template.go @@ -174,7 +174,7 @@ func calculatedFieldsSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "data_set_identifier": stringSchema(true, validation.StringLenBetween(1, 2048)), - "expression": stringSchema(true, validation.StringLenBetween(1, 32000)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 32000)), names.AttrName: stringSchema(true, validation.StringLenBetween(1, 128)), }, }, @@ -323,7 +323,7 @@ func rollingDateConfigurationSchema() *schema.Schema { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "data_set_identifier": stringSchema(false, validation.StringLenBetween(1, 2048)), - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), }, }, } @@ -535,7 +535,7 @@ func expandCalculatedField(tfMap map[string]interface{}) *quicksight.CalculatedF if v, ok := tfMap["data_set_identifier"].(string); ok && v != "" { field.DataSetIdentifier = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { field.Expression = aws.String(v) } if v, ok := tfMap[names.AttrName].(string); ok && v != "" { @@ -950,7 +950,7 @@ func expandRollingDateConfiguration(tfList []interface{}) *quicksight.RollingDat if v, ok := tfMap["data_set_identifier"].(string); ok && v != "" { config.DataSetIdentifier = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok { + if v, ok := tfMap[names.AttrExpression].(string); ok { config.Expression = aws.String(v) } @@ -1073,7 +1073,7 @@ func flattenCalculatedFields(apiObject []*quicksight.CalculatedField) []interfac tfMap["data_set_identifier"] = aws.StringValue(field.DataSetIdentifier) } if field.Expression != nil { - tfMap["expression"] = aws.StringValue(field.Expression) + tfMap[names.AttrExpression] = aws.StringValue(field.Expression) } if field.Name != nil { tfMap[names.AttrName] = aws.StringValue(field.Name) @@ -1330,7 +1330,7 @@ func flattenRollingDateConfiguration(apiObject *quicksight.RollingDateConfigurat tfMap["data_set_identifier"] = aws.StringValue(apiObject.DataSetIdentifier) } if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } return []interface{}{tfMap} diff --git a/internal/service/quicksight/schema/template_sheet.go b/internal/service/quicksight/schema/template_sheet.go index bec291d2728..9e011263318 100644 --- a/internal/service/quicksight/schema/template_sheet.go +++ b/internal/service/quicksight/schema/template_sheet.go @@ -508,7 +508,7 @@ func freeFormLayoutElementsSchema() *schema.Schema { }, }, }, - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), }, }, }, @@ -1193,7 +1193,7 @@ func expandSheetElementRenderingRule(tfMap map[string]interface{}) *quicksight.S layout := &quicksight.SheetElementRenderingRule{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { layout.Expression = aws.String(v) } if v, ok := tfMap["configuration_overrides"].([]interface{}); ok && len(v) > 0 { @@ -2046,7 +2046,7 @@ func flattenSheetElementRenderingRule(apiObject []*quicksight.SheetElementRender tfMap["configuration_overrides"] = flattenSheetElementConfigurationOverrides(config.ConfigurationOverrides) } if config.Expression != nil { - tfMap["expression"] = aws.StringValue(config.Expression) + tfMap[names.AttrExpression] = aws.StringValue(config.Expression) } tfList = append(tfList, tfMap) } diff --git a/internal/service/quicksight/schema/visual_conditional_formatting.go b/internal/service/quicksight/schema/visual_conditional_formatting.go index 7891715bffc..b079b7d5cb2 100644 --- a/internal/service/quicksight/schema/visual_conditional_formatting.go +++ b/internal/service/quicksight/schema/visual_conditional_formatting.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/quicksight" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-provider-aws/names" ) func conditionalFormattingColorSchema() *schema.Schema { @@ -55,7 +56,7 @@ func conditionalFormattingColorSchema() *schema.Schema { }, }, }, - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), }, }, }, @@ -66,8 +67,8 @@ func conditionalFormattingColorSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), }, }, }, @@ -91,8 +92,8 @@ func conditionalFormattingIconSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), + "color": stringSchema(false, validation.StringMatch(regexache.MustCompile(`^#[0-9A-F]{6}$`), "")), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), "icon_options": { // https://docs.aws.amazon.com/quicksight/latest/APIReference/API_ConditionalFormattingCustomIconOptions.html Type: schema.TypeList, Required: true, @@ -125,8 +126,8 @@ func conditionalFormattingIconSchema() *schema.Schema { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), - "icon_set_type": stringSchema(false, validation.StringInSlice(quicksight.ConditionalFormattingIconSetType_Values(), false)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), + "icon_set_type": stringSchema(false, validation.StringInSlice(quicksight.ConditionalFormattingIconSetType_Values(), false)), }, }, }, @@ -169,7 +170,7 @@ func expandConditionalFormattingGradientColor(tfList []interface{}) *quicksight. color := &quicksight.ConditionalFormattingGradientColor{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { color.Expression = aws.String(v) } if v, ok := tfMap["color"].([]interface{}); ok && len(v) > 0 { @@ -256,7 +257,7 @@ func expandConditionalFormattingSolidColor(tfList []interface{}) *quicksight.Con if v, ok := tfMap["color"].(string); ok && v != "" { color.Color = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { color.Expression = aws.String(v) } @@ -300,7 +301,7 @@ func expandConditionalFormattingCustomIconCondition(tfList []interface{}) *quick if v, ok := tfMap["color"].(string); ok && v != "" { icon.Color = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { icon.Expression = aws.String(v) } if v, ok := tfMap["icon_options"].([]interface{}); ok && len(v) > 0 { @@ -366,7 +367,7 @@ func expandConditionalFormattingIconSet(tfList []interface{}) *quicksight.Condit options := &quicksight.ConditionalFormattingIconSet{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { options.Expression = aws.String(v) } if v, ok := tfMap["icon_set_type"].(string); ok && v != "" { @@ -427,7 +428,7 @@ func flattenConditionalFormattingGradientColor(apiObject *quicksight.Conditional tfMap["color"] = flattenGradientColor(apiObject.Color) } if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } return []interface{}{tfMap} @@ -484,7 +485,7 @@ func flattenConditionalFormattingSolidColor(apiObject *quicksight.ConditionalFor tfMap["color"] = aws.StringValue(apiObject.Color) } if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } return []interface{}{tfMap} @@ -516,7 +517,7 @@ func flattenConditionalFormattingCustomIconCondition(apiObject *quicksight.Condi tfMap["color"] = aws.StringValue(apiObject.Color) } if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } if apiObject.IconOptions != nil { tfMap["icon_options"] = flattenConditionalFormattingCustomIconOptions(apiObject.IconOptions) @@ -564,7 +565,7 @@ func flattenConditionalFormattingIconSet(apiObject *quicksight.ConditionalFormat tfMap := map[string]interface{}{} if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } if apiObject.IconSetType != nil { tfMap["icon_set_type"] = aws.StringValue(apiObject.IconSetType) diff --git a/internal/service/quicksight/schema/visual_fields.go b/internal/service/quicksight/schema/visual_fields.go index 668ecd50404..02a01887cad 100644 --- a/internal/service/quicksight/schema/visual_fields.go +++ b/internal/service/quicksight/schema/visual_fields.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go/service/quicksight" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" + "github.com/hashicorp/terraform-provider-aws/names" ) const measureFieldsMaxItems5 = 5 @@ -89,8 +90,8 @@ func measureFieldSchema(maxItems int) *schema.Schema { Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": stringSchema(true, validation.StringLenBetween(1, 4096)), - "field_id": stringSchema(true, validation.StringLenBetween(1, 512)), + names.AttrExpression: stringSchema(true, validation.StringLenBetween(1, 4096)), + "field_id": stringSchema(true, validation.StringLenBetween(1, 512)), }, }, }, @@ -362,7 +363,7 @@ func expandCalculatedMeasureField(tfList []interface{}) *quicksight.CalculatedMe if v, ok := tfMap["field_id"].(string); ok && v != "" { field.FieldId = aws.String(v) } - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { field.Expression = aws.String(v) } @@ -632,7 +633,7 @@ func flattenCalculatedMeasureField(apiObject *quicksight.CalculatedMeasureField) tfMap["field_id"] = aws.StringValue(apiObject.FieldId) } if apiObject.Expression != nil { - tfMap["expression"] = aws.StringValue(apiObject.Expression) + tfMap[names.AttrExpression] = aws.StringValue(apiObject.Expression) } return []interface{}{tfMap} diff --git a/internal/service/quicksight/template.go b/internal/service/quicksight/template.go index 642b78d7116..c32b9db3cf9 100644 --- a/internal/service/quicksight/template.go +++ b/internal/service/quicksight/template.go @@ -86,7 +86,7 @@ func ResourceTemplate() *schema.Resource { MaxItems: 16, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), diff --git a/internal/service/quicksight/theme.go b/internal/service/quicksight/theme.go index 780eefdc8ec..8000dfb6f80 100644 --- a/internal/service/quicksight/theme.go +++ b/internal/service/quicksight/theme.go @@ -315,7 +315,7 @@ func ResourceTheme() *schema.Resource { MaxItems: 16, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 256), diff --git a/internal/service/quicksight/theme_data_source.go b/internal/service/quicksight/theme_data_source.go index 25831db8595..f21b2917ab4 100644 --- a/internal/service/quicksight/theme_data_source.go +++ b/internal/service/quicksight/theme_data_source.go @@ -251,7 +251,7 @@ func DataSourceTheme() *schema.Resource { Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/ram/principal_association.go b/internal/service/ram/principal_association.go index dd3fb3cdbf3..0a043df29e4 100644 --- a/internal/service/ram/principal_association.go +++ b/internal/service/ram/principal_association.go @@ -25,6 +25,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/tfresource" itypes "github.com/hashicorp/terraform-provider-aws/internal/types" "github.com/hashicorp/terraform-provider-aws/internal/verify" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_ram_principal_association", name="Principal Association") @@ -39,7 +40,7 @@ func resourcePrincipalAssociation() *schema.Resource { }, Schema: map[string]*schema.Schema{ - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -66,7 +67,7 @@ func resourcePrincipalAssociationCreate(ctx context.Context, d *schema.ResourceD var diags diag.Diagnostics conn := meta.(*conns.AWSClient).RAMConn(ctx) - resourceShareARN, principal := d.Get("resource_share_arn").(string), d.Get("principal").(string) + resourceShareARN, principal := d.Get("resource_share_arn").(string), d.Get(names.AttrPrincipal).(string) id := errs.Must(flex.FlattenResourceId([]string{resourceShareARN, principal}, principalAssociationResourceIDPartCount, false)) _, err := findPrincipalAssociationByTwoPartKey(ctx, conn, resourceShareARN, principal) @@ -127,7 +128,7 @@ func resourcePrincipalAssociationRead(ctx context.Context, d *schema.ResourceDat return sdkdiag.AppendErrorf(diags, "reading RAM Resource Association (%s): %s", d.Id(), err) } - d.Set("principal", principalAssociation.AssociatedEntity) + d.Set(names.AttrPrincipal, principalAssociation.AssociatedEntity) d.Set("resource_share_arn", principalAssociation.ResourceShareArn) return diags diff --git a/internal/service/ram/principal_association_test.go b/internal/service/ram/principal_association_test.go index d17b95fd087..383bcc0ee7c 100644 --- a/internal/service/ram/principal_association_test.go +++ b/internal/service/ram/principal_association_test.go @@ -149,7 +149,7 @@ func testAccCheckPrincipalAssociationExists(ctx context.Context, n string, v *ra conn := acctest.Provider.Meta().(*conns.AWSClient).RAMConn(ctx) - output, err := tfram.FindPrincipalAssociationByTwoPartKey(ctx, conn, rs.Primary.Attributes["resource_share_arn"], rs.Primary.Attributes["principal"]) + output, err := tfram.FindPrincipalAssociationByTwoPartKey(ctx, conn, rs.Primary.Attributes["resource_share_arn"], rs.Primary.Attributes[names.AttrPrincipal]) if err != nil { return err @@ -170,7 +170,7 @@ func testAccCheckPrincipalAssociationDestroy(ctx context.Context) resource.TestC continue } - _, err := tfram.FindPrincipalAssociationByTwoPartKey(ctx, conn, rs.Primary.Attributes["resource_share_arn"], rs.Primary.Attributes["principal"]) + _, err := tfram.FindPrincipalAssociationByTwoPartKey(ctx, conn, rs.Primary.Attributes["resource_share_arn"], rs.Primary.Attributes[names.AttrPrincipal]) if tfresource.NotFound(err) { continue diff --git a/internal/service/redshift/scheduled_action.go b/internal/service/redshift/scheduled_action.go index 1fe58ef1c8b..2da6cb33f18 100644 --- a/internal/service/redshift/scheduled_action.go +++ b/internal/service/redshift/scheduled_action.go @@ -58,7 +58,7 @@ func resourceScheduledAction() *schema.Resource { ForceNew: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z-]{1,63}$`), ""), }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Required: true, }, @@ -159,7 +159,7 @@ func resourceScheduledActionCreate(ctx context.Context, d *schema.ResourceData, input := &redshift.CreateScheduledActionInput{ Enable: aws.Bool(d.Get("enable").(bool)), IamRole: aws.String(d.Get("iam_role").(string)), - Schedule: aws.String(d.Get("schedule").(string)), + Schedule: aws.String(d.Get(names.AttrSchedule).(string)), ScheduledActionName: aws.String(name), TargetAction: expandScheduledActionType(d.Get("target_action").([]interface{})[0].(map[string]interface{})), } @@ -232,7 +232,7 @@ func resourceScheduledActionRead(ctx context.Context, d *schema.ResourceData, me } d.Set("iam_role", scheduledAction.IamRole) d.Set(names.AttrName, scheduledAction.ScheduledActionName) - d.Set("schedule", scheduledAction.Schedule) + d.Set(names.AttrSchedule, scheduledAction.Schedule) if scheduledAction.StartTime != nil { d.Set("start_time", aws.TimeValue(scheduledAction.StartTime).Format(time.RFC3339)) } else { @@ -276,8 +276,8 @@ func resourceScheduledActionUpdate(ctx context.Context, d *schema.ResourceData, input.IamRole = aws.String(d.Get("iam_role").(string)) } - if d.HasChange("schedule") { - input.Schedule = aws.String(d.Get("schedule").(string)) + if d.HasChange(names.AttrSchedule) { + input.Schedule = aws.String(d.Get(names.AttrSchedule).(string)) } if hasChange, v := d.HasChange("start_time"), d.Get("start_time").(string); hasChange && v != "" { diff --git a/internal/service/redshift/scheduled_action_test.go b/internal/service/redshift/scheduled_action_test.go index 2fed03a10d3..33eb12f45de 100644 --- a/internal/service/redshift/scheduled_action_test.go +++ b/internal/service/redshift/scheduled_action_test.go @@ -42,7 +42,7 @@ func TestAccRedshiftScheduledAction_basicPauseCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(00 23 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(00 23 * * ? *)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "1"), @@ -64,7 +64,7 @@ func TestAccRedshiftScheduledAction_basicPauseCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "at(2060-03-04T17:27:00)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "at(2060-03-04T17:27:00)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "1"), @@ -99,7 +99,7 @@ func TestAccRedshiftScheduledAction_pauseClusterWithOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", endTime), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(00 * * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(00 * * * ? *)"), resource.TestCheckResourceAttr(resourceName, "start_time", startTime), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "1"), @@ -137,7 +137,7 @@ func TestAccRedshiftScheduledAction_basicResumeCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(00 23 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(00 23 * * ? *)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "0"), @@ -159,7 +159,7 @@ func TestAccRedshiftScheduledAction_basicResumeCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "at(2060-03-04T17:27:00)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "at(2060-03-04T17:27:00)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "0"), @@ -192,7 +192,7 @@ func TestAccRedshiftScheduledAction_basicResizeCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(00 23 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(00 23 * * ? *)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "0"), @@ -214,7 +214,7 @@ func TestAccRedshiftScheduledAction_basicResizeCluster(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "at(2060-03-04T17:27:00)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "at(2060-03-04T17:27:00)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "0"), @@ -247,7 +247,7 @@ func TestAccRedshiftScheduledAction_resizeClusterWithOptions(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "enable", "true"), resource.TestCheckResourceAttr(resourceName, "end_time", ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(00 23 * * ? *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(00 23 * * ? *)"), resource.TestCheckResourceAttr(resourceName, "start_time", ""), resource.TestCheckResourceAttr(resourceName, "target_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "target_action.0.pause_cluster.#", "0"), diff --git a/internal/service/route53/health_check.go b/internal/service/route53/health_check.go index f13fa05dc3b..6f6253b7818 100644 --- a/internal/service/route53/health_check.go +++ b/internal/service/route53/health_check.go @@ -98,7 +98,7 @@ func ResourceHealthCheck() *schema.Resource { Type: schema.TypeBool, Optional: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Optional: true, ValidateFunc: validation.IsIPAddress, @@ -206,7 +206,7 @@ func resourceHealthCheckCreate(ctx context.Context, d *schema.ResourceData, meta healthCheckConfig.Inverted = aws.Bool(v.(bool)) } - if v, ok := d.GetOk("ip_address"); ok { + if v, ok := d.GetOk(names.AttrIPAddress); ok { healthCheckConfig.IPAddress = aws.String(v.(string)) } if v, ok := d.GetOk(names.AttrPort); ok { @@ -325,7 +325,7 @@ func resourceHealthCheckRead(ctx context.Context, d *schema.ResourceData, meta i d.Set("fqdn", healthCheckConfig.FullyQualifiedDomainName) d.Set("insufficient_data_health_status", healthCheckConfig.InsufficientDataHealthStatus) d.Set("invert_healthcheck", healthCheckConfig.Inverted) - d.Set("ip_address", healthCheckConfig.IPAddress) + d.Set(names.AttrIPAddress, healthCheckConfig.IPAddress) d.Set("measure_latency", healthCheckConfig.MeasureLatency) d.Set(names.AttrPort, healthCheckConfig.Port) d.Set("regions", aws.StringValueSlice(healthCheckConfig.Regions)) @@ -388,8 +388,8 @@ func resourceHealthCheckUpdate(ctx context.Context, d *schema.ResourceData, meta input.Inverted = aws.Bool(d.Get("invert_healthcheck").(bool)) } - if d.HasChange("ip_address") { - input.IPAddress = aws.String(d.Get("ip_address").(string)) + if d.HasChange(names.AttrIPAddress) { + input.IPAddress = aws.String(d.Get(names.AttrIPAddress).(string)) } if d.HasChange(names.AttrPort) { diff --git a/internal/service/route53/health_check_test.go b/internal/service/route53/health_check_test.go index 150d8d939a3..fd1cc851cb4 100644 --- a/internal/service/route53/health_check_test.go +++ b/internal/service/route53/health_check_test.go @@ -212,7 +212,7 @@ func TestAccRoute53HealthCheck_ip(t *testing.T) { Config: testAccHealthCheckConfig_ip("1.2.3.4"), Check: resource.ComposeTestCheckFunc( testAccCheckHealthCheckExists(ctx, resourceName, &check), - resource.TestCheckResourceAttr(resourceName, "ip_address", "1.2.3.4"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "1.2.3.4"), ), }, { @@ -224,7 +224,7 @@ func TestAccRoute53HealthCheck_ip(t *testing.T) { Config: testAccHealthCheckConfig_ip("1.2.3.5"), Check: resource.ComposeTestCheckFunc( testAccCheckHealthCheckExists(ctx, resourceName, &check), - resource.TestCheckResourceAttr(resourceName, "ip_address", "1.2.3.5"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "1.2.3.5"), ), }, }, @@ -246,7 +246,7 @@ func TestAccRoute53HealthCheck_ipv6(t *testing.T) { Config: testAccHealthCheckConfig_ip("1234:5678:9abc:6811:0:0:0:4"), Check: resource.ComposeTestCheckFunc( testAccCheckHealthCheckExists(ctx, resourceName, &check), - resource.TestCheckResourceAttr(resourceName, "ip_address", "1234:5678:9abc:6811:0:0:0:4"), + resource.TestCheckResourceAttr(resourceName, names.AttrIPAddress, "1234:5678:9abc:6811:0:0:0:4"), ), }, { diff --git a/internal/service/route53resolver/endpoint.go b/internal/service/route53resolver/endpoint.go index 7866fd640c3..2531180774d 100644 --- a/internal/service/route53resolver/endpoint.go +++ b/internal/service/route53resolver/endpoint.go @@ -56,7 +56,7 @@ func ResourceEndpoint() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeSet, Required: true, MinItems: 2, @@ -131,7 +131,7 @@ func resourceEndpointCreate(ctx context.Context, d *schema.ResourceData, meta in input := &route53resolver.CreateResolverEndpointInput{ CreatorRequestId: aws.String(id.PrefixedUniqueId("tf-r53-resolver-endpoint-")), Direction: aws.String(d.Get("direction").(string)), - IpAddresses: expandEndpointIPAddresses(d.Get("ip_address").(*schema.Set)), + IpAddresses: expandEndpointIPAddresses(d.Get(names.AttrIPAddress).(*schema.Set)), SecurityGroupIds: flex.ExpandStringSet(d.Get(names.AttrSecurityGroupIDs).(*schema.Set)), Tags: getTagsIn(ctx), } @@ -193,7 +193,7 @@ func resourceEndpointRead(ctx context.Context, d *schema.ResourceData, meta inte return diag.Errorf("listing Route53 Resolver Endpoint (%s) IP addresses: %s", d.Id(), err) } - if err := d.Set("ip_address", schema.NewSet(endpointHashIPAddress, flattenEndpointIPAddresses(ipAddresses))); err != nil { + if err := d.Set(names.AttrIPAddress, schema.NewSet(endpointHashIPAddress, flattenEndpointIPAddresses(ipAddresses))); err != nil { return diag.Errorf("setting ip_address: %s", err) } @@ -231,8 +231,8 @@ func resourceEndpointUpdate(ctx context.Context, d *schema.ResourceData, meta in } } - if d.HasChange("ip_address") { - oraw, nraw := d.GetChange("ip_address") + if d.HasChange(names.AttrIPAddress) { + oraw, nraw := d.GetChange(names.AttrIPAddress) o := oraw.(*schema.Set) n := nraw.(*schema.Set) del := o.Difference(n).List() diff --git a/internal/service/s3/bucket_inventory.go b/internal/service/s3/bucket_inventory.go index 84becdecba5..df5b41a3750 100644 --- a/internal/service/s3/bucket_inventory.go +++ b/internal/service/s3/bucket_inventory.go @@ -154,7 +154,7 @@ func resourceBucketInventory() *schema.Resource { ValidateDiagFunc: enum.Validate[types.InventoryOptionalField](), }, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, Required: true, MaxItems: 1, @@ -202,7 +202,7 @@ func resourceBucketInventoryPut(ctx context.Context, d *schema.ResourceData, met inventoryConfiguration.OptionalFields = flex.ExpandStringyValueSet[types.InventoryOptionalField](v.(*schema.Set)) } - if v, ok := d.GetOk("schedule"); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { + if v, ok := d.GetOk(names.AttrSchedule); ok && len(v.([]interface{})) > 0 && v.([]interface{})[0] != nil { tfMap := v.([]interface{})[0].(map[string]interface{}) inventoryConfiguration.Schedule = &types.InventorySchedule{ Frequency: types.InventoryFrequency(tfMap["frequency"].(string)), @@ -280,7 +280,7 @@ func resourceBucketInventoryRead(ctx context.Context, d *schema.ResourceData, me d.Set("included_object_versions", ic.IncludedObjectVersions) d.Set(names.AttrName, name) d.Set("optional_fields", ic.OptionalFields) - if err := d.Set("schedule", flattenInventorySchedule(ic.Schedule)); err != nil { + if err := d.Set(names.AttrSchedule, flattenInventorySchedule(ic.Schedule)); err != nil { return sdkdiag.AppendErrorf(diags, "setting schedule: %s", err) } diff --git a/internal/service/sagemaker/data_quality_job_definition.go b/internal/service/sagemaker/data_quality_job_definition.go index f1d749a66ba..ac50b0a0d02 100644 --- a/internal/service/sagemaker/data_quality_job_definition.go +++ b/internal/service/sagemaker/data_quality_job_definition.go @@ -395,7 +395,7 @@ func ResourceDataQualityJobDefinition() *schema.Resource { Optional: true, ForceNew: true, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -908,7 +908,7 @@ func flattenMonitoringNetworkConfig(config *sagemaker.MonitoringNetworkConfig) [ } if config.VpcConfig != nil { - m["vpc_config"] = flattenVPCConfig(config.VpcConfig) + m[names.AttrVPCConfig] = flattenVPCConfig(config.VpcConfig) } return []map[string]interface{}{m} @@ -1284,7 +1284,7 @@ func expandMonitoringNetworkConfig(configured []interface{}) *sagemaker.Monitori c.EnableNetworkIsolation = aws.Bool(v.(bool)) } - if v, ok := m["vpc_config"].([]interface{}); ok && len(v) > 0 { + if v, ok := m[names.AttrVPCConfig].([]interface{}); ok && len(v) > 0 { c.VpcConfig = expandVPCConfig(v) } diff --git a/internal/service/sagemaker/model.go b/internal/service/sagemaker/model.go index bf69f55eb0a..f512f94c99d 100644 --- a/internal/service/sagemaker/model.go +++ b/internal/service/sagemaker/model.go @@ -303,7 +303,7 @@ func ResourceModel() *schema.Resource { }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, Optional: true, MaxItems: 1, @@ -359,7 +359,7 @@ func resourceModelCreate(ctx context.Context, d *schema.ResourceData, meta inter createOpts.ExecutionRoleArn = aws.String(v.(string)) } - if v, ok := d.GetOk("vpc_config"); ok { + if v, ok := d.GetOk(names.AttrVPCConfig); ok { createOpts.VpcConfig = expandVPCConfigRequest(v.([]interface{})) } @@ -429,7 +429,7 @@ func resourceModelRead(ctx context.Context, d *schema.ResourceData, meta interfa return sdkdiag.AppendErrorf(diags, "setting container: %s", err) } - if err := d.Set("vpc_config", flattenVPCConfigResponse(model.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenVPCConfigResponse(model.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc_config: %s", err) } diff --git a/internal/service/sagemaker/workforce.go b/internal/service/sagemaker/workforce.go index 1e1c5099b3d..08f6ff8ab19 100644 --- a/internal/service/sagemaker/workforce.go +++ b/internal/service/sagemaker/workforce.go @@ -45,7 +45,7 @@ func ResourceWorkforce() *schema.Resource { ExactlyOneOf: []string{"oidc_config", "cognito_config"}, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, }, @@ -71,7 +71,7 @@ func ResourceWorkforce() *schema.Resource { validation.IsURLWithHTTPS, ), }, - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, ValidateFunc: validation.StringLenBetween(1, 1024), @@ -358,7 +358,7 @@ func expandWorkforceCognitoConfig(l []interface{}) *sagemaker.CognitoConfig { m := l[0].(map[string]interface{}) config := &sagemaker.CognitoConfig{ - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), UserPool: aws.String(m["user_pool"].(string)), } @@ -371,8 +371,8 @@ func flattenWorkforceCognitoConfig(config *sagemaker.CognitoConfig) []map[string } m := map[string]interface{}{ - "client_id": aws.StringValue(config.ClientId), - "user_pool": aws.StringValue(config.UserPool), + names.AttrClientID: aws.StringValue(config.ClientId), + "user_pool": aws.StringValue(config.UserPool), } return []map[string]interface{}{m} @@ -387,7 +387,7 @@ func expandWorkforceOIDCConfig(l []interface{}) *sagemaker.OidcConfig { config := &sagemaker.OidcConfig{ AuthorizationEndpoint: aws.String(m["authorization_endpoint"].(string)), - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), ClientSecret: aws.String(m["client_secret"].(string)), Issuer: aws.String(m["issuer"].(string)), JwksUri: aws.String(m["jwks_uri"].(string)), @@ -406,7 +406,7 @@ func flattenWorkforceOIDCConfig(config *sagemaker.OidcConfigForResponse, clientS m := map[string]interface{}{ "authorization_endpoint": aws.StringValue(config.AuthorizationEndpoint), - "client_id": aws.StringValue(config.ClientId), + names.AttrClientID: aws.StringValue(config.ClientId), "client_secret": clientSecret, "issuer": aws.StringValue(config.Issuer), "jwks_uri": aws.StringValue(config.JwksUri), diff --git a/internal/service/sagemaker/workteam.go b/internal/service/sagemaker/workteam.go index c5e30cfbda3..0cc33951e8b 100644 --- a/internal/service/sagemaker/workteam.go +++ b/internal/service/sagemaker/workteam.go @@ -60,7 +60,7 @@ func ResourceWorkteam() *schema.Resource { MaxItems: 1, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "client_id": { + names.AttrClientID: { Type: schema.TypeString, Required: true, }, @@ -303,7 +303,7 @@ func expandWorkteamCognitoMemberDefinition(l []interface{}) *sagemaker.CognitoMe m := l[0].(map[string]interface{}) config := &sagemaker.CognitoMemberDefinition{ - ClientId: aws.String(m["client_id"].(string)), + ClientId: aws.String(m[names.AttrClientID].(string)), UserPool: aws.String(m["user_pool"].(string)), UserGroup: aws.String(m["user_group"].(string)), } @@ -317,9 +317,9 @@ func flattenWorkteamCognitoMemberDefinition(config *sagemaker.CognitoMemberDefin } m := map[string]interface{}{ - "client_id": aws.StringValue(config.ClientId), - "user_pool": aws.StringValue(config.UserPool), - "user_group": aws.StringValue(config.UserGroup), + names.AttrClientID: aws.StringValue(config.ClientId), + "user_pool": aws.StringValue(config.UserPool), + "user_group": aws.StringValue(config.UserGroup), } return []map[string]interface{}{m} diff --git a/internal/service/scheduler/flex.go b/internal/service/scheduler/flex.go index 0a291b97981..a1fb92eaea5 100644 --- a/internal/service/scheduler/flex.go +++ b/internal/service/scheduler/flex.go @@ -415,7 +415,7 @@ func expandPlacementConstraint(tfMap map[string]interface{}) types.PlacementCons a := types.PlacementConstraint{} - if v, ok := tfMap["expression"].(string); ok && v != "" { + if v, ok := tfMap[names.AttrExpression].(string); ok && v != "" { a.Expression = aws.String(v) } @@ -430,7 +430,7 @@ func flattenPlacementConstraint(apiObject types.PlacementConstraint) map[string] m := map[string]interface{}{} if v := apiObject.Expression; v != nil { - m["expression"] = aws.ToString(v) + m[names.AttrExpression] = aws.ToString(v) } if v := string(apiObject.Type); v != "" { diff --git a/internal/service/scheduler/schedule.go b/internal/service/scheduler/schedule.go index 967a917f4ed..930f135c854 100644 --- a/internal/service/scheduler/schedule.go +++ b/internal/service/scheduler/schedule.go @@ -78,7 +78,7 @@ func resourceSchedule() *schema.Resource { }, }, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Optional: true, Computed: true, @@ -241,7 +241,7 @@ func resourceSchedule() *schema.Resource { Set: placementConstraintHash, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ - "expression": { + names.AttrExpression: { Type: schema.TypeString, Optional: true, ValidateDiagFunc: validation.ToDiagFunc(validation.StringLenBetween(1, 2000)), @@ -454,7 +454,7 @@ func resourceScheduleCreate(ctx context.Context, d *schema.ResourceData, meta in in.FlexibleTimeWindow = expandFlexibleTimeWindow(v[0].(map[string]interface{})) } - if v, ok := d.Get("group_name").(string); ok && v != "" { + if v, ok := d.Get(names.AttrGroupName).(string); ok && v != "" { in.GroupName = aws.String(v) } @@ -543,7 +543,7 @@ func resourceScheduleRead(ctx context.Context, d *schema.ResourceData, meta inte return create.DiagError(names.Scheduler, create.ErrActionSetting, ResNameSchedule, d.Id(), err) } - d.Set("group_name", out.GroupName) + d.Set(names.AttrGroupName, out.GroupName) d.Set(names.AttrKMSKeyARN, out.KmsKeyArn) d.Set(names.AttrName, out.Name) d.Set(names.AttrNamePrefix, create.NamePrefixFromName(aws.ToString(out.Name))) @@ -570,7 +570,7 @@ func resourceScheduleUpdate(ctx context.Context, d *schema.ResourceData, meta in in := &scheduler.UpdateScheduleInput{ FlexibleTimeWindow: expandFlexibleTimeWindow(d.Get("flexible_time_window").([]interface{})[0].(map[string]interface{})), - GroupName: aws.String(d.Get("group_name").(string)), + GroupName: aws.String(d.Get(names.AttrGroupName).(string)), Name: aws.String(d.Get(names.AttrName).(string)), ScheduleExpression: aws.String(d.Get(names.AttrScheduleExpression).(string)), Target: expandTarget(ctx, d.Get(names.AttrTarget).([]interface{})[0].(map[string]interface{})), @@ -724,7 +724,7 @@ func placementConstraintHash(v interface{}) int { var buf bytes.Buffer m := v.(map[string]interface{}) - if v, ok := m["expression"]; ok { + if v, ok := m[names.AttrExpression]; ok { buf.WriteString(fmt.Sprintf("%s-", v)) } diff --git a/internal/service/scheduler/schedule_test.go b/internal/service/scheduler/schedule_test.go index e7bb6037bb7..0877a7af6f1 100644 --- a/internal/service/scheduler/schedule_test.go +++ b/internal/service/scheduler/schedule_test.go @@ -207,7 +207,7 @@ func TestAccSchedulerSchedule_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "end_date", ""), resource.TestCheckResourceAttr(resourceName, "flexible_time_window.0.maximum_window_in_minutes", "0"), resource.TestCheckResourceAttr(resourceName, "flexible_time_window.0.mode", "OFF"), - resource.TestCheckResourceAttr(resourceName, "group_name", "default"), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, "default"), resource.TestCheckResourceAttr(resourceName, names.AttrID, fmt.Sprintf("default/%s", name)), resource.TestCheckResourceAttr(resourceName, names.AttrKMSKeyARN, ""), resource.TestCheckResourceAttr(resourceName, names.AttrName, name), @@ -476,7 +476,7 @@ func TestAccSchedulerSchedule_groupName(t *testing.T) { Config: testAccScheduleConfig_groupName(name), Check: resource.ComposeTestCheckFunc( testAccCheckScheduleExists(ctx, t, resourceName, &schedule), - resource.TestCheckResourceAttrPair(resourceName, "group_name", "aws_scheduler_schedule_group.test", names.AttrName), + resource.TestCheckResourceAttrPair(resourceName, names.AttrGroupName, "aws_scheduler_schedule_group.test", names.AttrName), ), }, { @@ -1026,8 +1026,8 @@ func TestAccSchedulerSchedule_targetECSParameters(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "target.0.ecs_parameters.0.network_configuration.0.subnets.#", "1"), resource.TestCheckTypeSetElemAttr(resourceName, "target.0.ecs_parameters.0.network_configuration.0.subnets.*", "subnet-11111111"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "target.0.ecs_parameters.0.placement_constraints.*", map[string]string{ - names.AttrType: "memberOf", - "expression": "attribute:ecs.os-family in [LINUX]", + names.AttrType: "memberOf", + names.AttrExpression: "attribute:ecs.os-family in [LINUX]", }), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "target.0.ecs_parameters.0.placement_strategy.*", map[string]string{ names.AttrType: "binpack", diff --git a/internal/service/securitylake/custom_log_source.go b/internal/service/securitylake/custom_log_source.go index 91aa84e6e81..9f1fa1287fd 100644 --- a/internal/service/securitylake/custom_log_source.go +++ b/internal/service/securitylake/custom_log_source.go @@ -157,7 +157,7 @@ func (r *customLogSourceResource) Schema(ctx context.Context, request resource.S stringplanmodifier.RequiresReplace(), }, }, - "principal": schema.StringAttribute{ + names.AttrPrincipal: schema.StringAttribute{ Required: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.RequiresReplace(), diff --git a/internal/service/securitylake/subscriber.go b/internal/service/securitylake/subscriber.go index cd32a0aeeb2..0286e7eb95e 100644 --- a/internal/service/securitylake/subscriber.go +++ b/internal/service/securitylake/subscriber.go @@ -183,7 +183,7 @@ func (r *subscriberResource) Schema(ctx context.Context, request resource.Schema "external_id": schema.StringAttribute{ Required: true, }, - "principal": schema.StringAttribute{ + names.AttrPrincipal: schema.StringAttribute{ Required: true, }, }, diff --git a/internal/service/servicequotas/service_quota.go b/internal/service/servicequotas/service_quota.go index 0f4b50da79b..0bb42e3fa3d 100644 --- a/internal/service/servicequotas/service_quota.go +++ b/internal/service/servicequotas/service_quota.go @@ -111,7 +111,7 @@ func ResourceServiceQuota() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Computed: true, }, diff --git a/internal/service/servicequotas/service_quota_data_source.go b/internal/service/servicequotas/service_quota_data_source.go index f21a19a0420..9a365de5afb 100644 --- a/internal/service/servicequotas/service_quota_data_source.go +++ b/internal/service/servicequotas/service_quota_data_source.go @@ -87,7 +87,7 @@ func DataSourceServiceQuota() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Computed: true, }, @@ -130,7 +130,7 @@ func flattenUsageMetric(usageMetric *types.MetricInfo) []interface{} { } usageMetrics = append(usageMetrics, map[string]interface{}{ - "metric_name": usageMetric.MetricName, + names.AttrMetricName: usageMetric.MetricName, "metric_namespace": usageMetric.MetricNamespace, "metric_statistic_recommendation": usageMetric.MetricStatisticRecommendation, "metric_dimensions": metricDimensions, diff --git a/internal/service/signer/signing_profile_permission.go b/internal/service/signer/signing_profile_permission.go index 92436e37fe6..c5b8f55cc78 100644 --- a/internal/service/signer/signing_profile_permission.go +++ b/internal/service/signer/signing_profile_permission.go @@ -49,7 +49,7 @@ func ResourceSigningProfilePermission() *schema.Resource { "signer:SignPayload", }, false), }, - "principal": { + names.AttrPrincipal: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -110,7 +110,7 @@ func resourceSigningProfilePermissionCreate(ctx context.Context, d *schema.Resou statementID := create.Name(d.Get("statement_id").(string), d.Get("statement_id_prefix").(string)) input := &signer.AddProfilePermissionInput{ Action: aws.String(d.Get(names.AttrAction).(string)), - Principal: aws.String(d.Get("principal").(string)), + Principal: aws.String(d.Get(names.AttrPrincipal).(string)), ProfileName: aws.String(profileName), RevisionId: aws.String(revisionID), StatementId: aws.String(statementID), @@ -170,7 +170,7 @@ func resourceSigningProfilePermissionRead(ctx context.Context, d *schema.Resourc } d.Set(names.AttrAction, permission.Action) - d.Set("principal", permission.Principal) + d.Set(names.AttrPrincipal, permission.Principal) d.Set("profile_version", permission.ProfileVersion) d.Set("statement_id", permission.StatementId) d.Set("statement_id_prefix", create.NamePrefixFromName(aws.ToString(permission.StatementId))) diff --git a/internal/service/ssm/maintenance_window.go b/internal/service/ssm/maintenance_window.go index 67df3e6f67e..9f615db0ce7 100644 --- a/internal/service/ssm/maintenance_window.go +++ b/internal/service/ssm/maintenance_window.go @@ -66,7 +66,7 @@ func ResourceMaintenanceWindow() *schema.Resource { Type: schema.TypeString, Required: true, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeString, Required: true, }, @@ -101,7 +101,7 @@ func resourceMaintenanceWindowCreate(ctx context.Context, d *schema.ResourceData Cutoff: aws.Int64(int64(d.Get("cutoff").(int))), Duration: aws.Int64(int64(d.Get("duration").(int))), Name: aws.String(name), - Schedule: aws.String(d.Get("schedule").(string)), + Schedule: aws.String(d.Get(names.AttrSchedule).(string)), Tags: getTagsIn(ctx), } @@ -172,7 +172,7 @@ func resourceMaintenanceWindowRead(ctx context.Context, d *schema.ResourceData, d.Set(names.AttrEnabled, output.Enabled) d.Set("end_date", output.EndDate) d.Set(names.AttrName, output.Name) - d.Set("schedule", output.Schedule) + d.Set(names.AttrSchedule, output.Schedule) d.Set("schedule_offset", output.ScheduleOffset) d.Set("schedule_timezone", output.ScheduleTimezone) d.Set("start_date", output.StartDate) @@ -194,7 +194,7 @@ func resourceMaintenanceWindowUpdate(ctx context.Context, d *schema.ResourceData Enabled: aws.Bool(d.Get(names.AttrEnabled).(bool)), Name: aws.String(d.Get(names.AttrName).(string)), Replace: aws.Bool(true), - Schedule: aws.String(d.Get("schedule").(string)), + Schedule: aws.String(d.Get(names.AttrSchedule).(string)), WindowId: aws.String(d.Id()), } diff --git a/internal/service/ssm/maintenance_window_test.go b/internal/service/ssm/maintenance_window_test.go index 8af689499bf..029b725a229 100644 --- a/internal/service/ssm/maintenance_window_test.go +++ b/internal/service/ssm/maintenance_window_test.go @@ -43,7 +43,7 @@ func TestAccSSMMaintenanceWindow_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "schedule_timezone", ""), resource.TestCheckResourceAttr(resourceName, "schedule_offset", "0"), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 16 ? * TUE *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * TUE *)"), resource.TestCheckResourceAttr(resourceName, "start_date", ""), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), @@ -185,7 +185,7 @@ func TestAccSSMMaintenanceWindow_multipleUpdates(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "duration", "3"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "true"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName1), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 16 ? * TUE *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * TUE *)"), ), }, { @@ -196,7 +196,7 @@ func TestAccSSMMaintenanceWindow_multipleUpdates(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "duration", "10"), resource.TestCheckResourceAttr(resourceName, names.AttrEnabled, "false"), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName2), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 16 ? * WED *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * WED *)"), ), }, }, @@ -368,7 +368,7 @@ func TestAccSSMMaintenanceWindow_schedule(t *testing.T) { Config: testAccMaintenanceWindowConfig_schedule(rName, "cron(0 16 ? * TUE *)"), Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow1), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 16 ? * TUE *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * TUE *)"), ), }, { @@ -380,7 +380,7 @@ func TestAccSSMMaintenanceWindow_schedule(t *testing.T) { Config: testAccMaintenanceWindowConfig_schedule(rName, "cron(0 16 ? * WED *)"), Check: resource.ComposeTestCheckFunc( testAccCheckMaintenanceWindowExists(ctx, resourceName, &maintenanceWindow2), - resource.TestCheckResourceAttr(resourceName, "schedule", "cron(0 16 ? * WED *)"), + resource.TestCheckResourceAttr(resourceName, names.AttrSchedule, "cron(0 16 ? * WED *)"), ), }, }, diff --git a/internal/service/synthetics/canary.go b/internal/service/synthetics/canary.go index af2f369885f..73e767e9104 100644 --- a/internal/service/synthetics/canary.go +++ b/internal/service/synthetics/canary.go @@ -173,7 +173,7 @@ func ResourceCanary() *schema.Resource { Optional: true, ConflictsWith: []string{"zip_file"}, }, - "schedule": { + names.AttrSchedule: { Type: schema.TypeList, MaxItems: 1, Required: true, @@ -183,7 +183,7 @@ func ResourceCanary() *schema.Resource { Type: schema.TypeInt, Optional: true, }, - "expression": { + names.AttrExpression: { Type: schema.TypeString, Required: true, DiffSuppressFunc: func(k, old, new string, d *schema.ResourceData) bool { @@ -238,7 +238,7 @@ func ResourceCanary() *schema.Resource { }, }, }, - "vpc_config": { + names.AttrVPCConfig: { Type: schema.TypeList, MaxItems: 1, Optional: true, @@ -299,11 +299,11 @@ func resourceCanaryCreate(ctx context.Context, d *schema.ResourceData, meta inte input.ArtifactConfig = expandCanaryArtifactConfig(v.([]interface{})) } - if v, ok := d.GetOk("schedule"); ok { + if v, ok := d.GetOk(names.AttrSchedule); ok { input.Schedule = expandCanarySchedule(v.([]interface{})) } - if v, ok := d.GetOk("vpc_config"); ok { + if v, ok := d.GetOk(names.AttrVPCConfig); ok { input.VpcConfig = expandCanaryVPCConfig(v.([]interface{})) } @@ -394,7 +394,7 @@ func resourceCanaryRead(ctx context.Context, d *schema.ResourceData, meta interf d.Set(names.AttrStatus, canary.Status.State) d.Set("success_retention_period", canary.SuccessRetentionPeriodInDays) - if err := d.Set("vpc_config", flattenCanaryVPCConfig(canary.VpcConfig)); err != nil { + if err := d.Set(names.AttrVPCConfig, flattenCanaryVPCConfig(canary.VpcConfig)); err != nil { return sdkdiag.AppendErrorf(diags, "setting vpc config: %s", err) } @@ -407,7 +407,7 @@ func resourceCanaryRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "setting run config: %s", err) } - if err := d.Set("schedule", flattenCanarySchedule(canary.Schedule)); err != nil { + if err := d.Set(names.AttrSchedule, flattenCanarySchedule(canary.Schedule)); err != nil { return sdkdiag.AppendErrorf(diags, "setting schedule: %s", err) } @@ -433,8 +433,8 @@ func resourceCanaryUpdate(ctx context.Context, d *schema.ResourceData, meta inte Name: aws.String(d.Id()), } - if d.HasChange("vpc_config") { - input.VpcConfig = expandCanaryVPCConfig(d.Get("vpc_config").([]interface{})) + if d.HasChange(names.AttrVPCConfig) { + input.VpcConfig = expandCanaryVPCConfig(d.Get(names.AttrVPCConfig).([]interface{})) } if d.HasChange("artifact_config") { @@ -461,8 +461,8 @@ func resourceCanaryUpdate(ctx context.Context, d *schema.ResourceData, meta inte input.ArtifactS3Location = aws.String(d.Get("artifact_s3_location").(string)) } - if d.HasChange("schedule") { - input.Schedule = expandCanarySchedule(d.Get("schedule").([]interface{})) + if d.HasChange(names.AttrSchedule) { + input.Schedule = expandCanarySchedule(d.Get(names.AttrSchedule).([]interface{})) } if d.HasChange("success_retention_period") { @@ -664,7 +664,7 @@ func expandCanarySchedule(l []interface{}) *awstypes.CanaryScheduleInput { m := l[0].(map[string]interface{}) codeConfig := &awstypes.CanaryScheduleInput{ - Expression: aws.String(m["expression"].(string)), + Expression: aws.String(m[names.AttrExpression].(string)), } if v, ok := m["duration_in_seconds"]; ok { @@ -680,7 +680,7 @@ func flattenCanarySchedule(canarySchedule *awstypes.CanaryScheduleOutput) []inte } m := map[string]interface{}{ - "expression": aws.ToString(canarySchedule.Expression), + names.AttrExpression: aws.ToString(canarySchedule.Expression), "duration_in_seconds": aws.ToInt64(canarySchedule.DurationInSeconds), } diff --git a/internal/service/synthetics/group_association.go b/internal/service/synthetics/group_association.go index 36d3dca38e3..fc6c96c7b48 100644 --- a/internal/service/synthetics/group_association.go +++ b/internal/service/synthetics/group_association.go @@ -18,6 +18,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" + "github.com/hashicorp/terraform-provider-aws/names" ) // @SDKResource("aws_synthetics_group_association", name="Group Association") @@ -45,7 +46,7 @@ func ResourceGroupAssociation() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -59,7 +60,7 @@ func resourceGroupAssociationCreate(ctx context.Context, d *schema.ResourceData, conn := meta.(*conns.AWSClient).SyntheticsClient(ctx) canaryArn := d.Get("canary_arn").(string) - groupName := d.Get("group_name").(string) + groupName := d.Get(names.AttrGroupName).(string) in := &synthetics.AssociateResourceInput{ ResourceArn: aws.String(canaryArn), @@ -106,7 +107,7 @@ func resourceGroupAssociationRead(ctx context.Context, d *schema.ResourceData, m d.Set("canary_arn", canaryArn) d.Set("group_arn", group.Arn) d.Set("group_id", group.Id) - d.Set("group_name", group.Name) + d.Set(names.AttrGroupName, group.Name) return diags } diff --git a/internal/service/synthetics/group_association_test.go b/internal/service/synthetics/group_association_test.go index d37384df9d0..f761b9fa371 100644 --- a/internal/service/synthetics/group_association_test.go +++ b/internal/service/synthetics/group_association_test.go @@ -38,7 +38,7 @@ func TestAccSyntheticsGroupAssociation_basic(t *testing.T) { testAccCheckGroupAssociationExists(ctx, resourceName, &groupSummary), acctest.MatchResourceAttrRegionalARN(resourceName, "canary_arn", "synthetics", regexache.MustCompile(`canary:.+`)), acctest.MatchResourceAttrRegionalARN(resourceName, "group_arn", "synthetics", regexache.MustCompile(`group:.+`)), - resource.TestCheckResourceAttr(resourceName, "group_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, rName), resource.TestCheckResourceAttrSet(resourceName, "group_id"), ), }, diff --git a/internal/service/transfer/certificate.go b/internal/service/transfer/certificate.go index 97e45d4b2e9..9d052f07811 100644 --- a/internal/service/transfer/certificate.go +++ b/internal/service/transfer/certificate.go @@ -71,7 +71,7 @@ func ResourceCertificate() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "private_key": { + names.AttrPrivateKey: { Type: schema.TypeString, Optional: true, ForceNew: true, @@ -111,7 +111,7 @@ func resourceCertificateCreate(ctx context.Context, d *schema.ResourceData, meta input.Description = aws.String(v.(string)) } - if v, ok := d.GetOk("private_key"); ok { + if v, ok := d.GetOk(names.AttrPrivateKey); ok { input.PrivateKey = aws.String(v.(string)) } diff --git a/internal/service/transfer/certificate_test.go b/internal/service/transfer/certificate_test.go index 962a41e9126..ce9098a5e4f 100644 --- a/internal/service/transfer/certificate_test.go +++ b/internal/service/transfer/certificate_test.go @@ -54,7 +54,7 @@ func TestAccTransferCertificate_basic(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, }, }) @@ -91,7 +91,7 @@ func TestAccTransferCertificate_certificate(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, }, }) @@ -132,7 +132,7 @@ func TestAccTransferCertificate_certificateChain(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, }, }) @@ -169,7 +169,7 @@ func TestAccTransferCertificate_certificateKey(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, }, }) @@ -233,7 +233,7 @@ func TestAccTransferCertificate_tags(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, { Config: testAccCertificateConfig_tags2(certificate, "key1", "value1updated", "key2", "value2"), @@ -284,7 +284,7 @@ func TestAccTransferCertificate_description(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, - ImportStateVerifyIgnore: []string{"private_key", names.AttrCertificate, "certificate_chain"}, + ImportStateVerifyIgnore: []string{names.AttrPrivateKey, names.AttrCertificate, "certificate_chain"}, }, { Config: testAccCertificateConfig_description(certificate, "desc2"), diff --git a/internal/service/verifiedpermissions/policy.go b/internal/service/verifiedpermissions/policy.go index 8a563350675..939a0ae4ac7 100644 --- a/internal/service/verifiedpermissions/policy.go +++ b/internal/service/verifiedpermissions/policy.go @@ -122,7 +122,7 @@ func (r *resourcePolicy) Schema(ctx context.Context, req resource.SchemaRequest, }, }, Blocks: map[string]schema.Block{ - "principal": schema.ListNestedBlock{ + names.AttrPrincipal: schema.ListNestedBlock{ CustomType: fwtypes.NewListNestedObjectTypeOf[templateLinkedPrincipal](ctx), Validators: []validator.List{ listvalidator.SizeAtMost(1), diff --git a/internal/service/waf/rate_based_rule.go b/internal/service/waf/rate_based_rule.go index 7f54c277d19..740c5d1b2a2 100644 --- a/internal/service/waf/rate_based_rule.go +++ b/internal/service/waf/rate_based_rule.go @@ -42,7 +42,7 @@ func ResourceRateBasedRule() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -98,7 +98,7 @@ func resourceRateBasedRuleCreate(ctx context.Context, d *schema.ResourceData, me name := d.Get(names.AttrName).(string) input := &waf.CreateRateBasedRuleInput{ - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), RateKey: aws.String(d.Get("rate_key").(string)), RateLimit: aws.Int64(int64(d.Get("rate_limit").(int))), @@ -156,7 +156,7 @@ func resourceRateBasedRuleRead(ctx context.Context, d *schema.ResourceData, meta }.String() d.Set(names.AttrARN, arn) d.Set(names.AttrName, rule.Name) - d.Set("metric_name", rule.MetricName) + d.Set(names.AttrMetricName, rule.MetricName) d.Set("rate_key", rule.RateKey) d.Set("rate_limit", rule.RateLimit) diff --git a/internal/service/waf/rate_based_rule_test.go b/internal/service/waf/rate_based_rule_test.go index 436401efd38..a438e42f285 100644 --- a/internal/service/waf/rate_based_rule_test.go +++ b/internal/service/waf/rate_based_rule_test.go @@ -59,7 +59,7 @@ func testAccWAFRateBasedRule_basic(t *testing.T) { acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "waf", regexache.MustCompile(`ratebasedrule/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -90,7 +90,7 @@ func testAccWAFRateBasedRule_changeNameForceNew(t *testing.T) { testAccCheckRateBasedRuleExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -99,7 +99,7 @@ func testAccWAFRateBasedRule_changeNameForceNew(t *testing.T) { testAccCheckRateBasedRuleExists(ctx, resourceName, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleNewName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleNewName), ), }, { diff --git a/internal/service/waf/rule.go b/internal/service/waf/rule.go index 1271f2f6e17..60a027046d5 100644 --- a/internal/service/waf/rule.go +++ b/internal/service/waf/rule.go @@ -48,7 +48,7 @@ func ResourceRule() *schema.Resource { Required: true, ForceNew: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -96,7 +96,7 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, meta interf out, err := wr.RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateRuleInput{ ChangeToken: token, - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(d.Get(names.AttrName).(string)), Tags: getTagsIn(ctx), } @@ -172,7 +172,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac d.Set(names.AttrARN, arn) d.Set("predicates", predicates) d.Set(names.AttrName, resp.Rule.Name) - d.Set("metric_name", resp.Rule.MetricName) + d.Set(names.AttrMetricName, resp.Rule.MetricName) return diags } diff --git a/internal/service/waf/rule_group.go b/internal/service/waf/rule_group.go index 622401953e1..8f430cc289f 100644 --- a/internal/service/waf/rule_group.go +++ b/internal/service/waf/rule_group.go @@ -39,7 +39,7 @@ func ResourceRuleGroup() *schema.Resource { Required: true, ForceNew: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -99,7 +99,7 @@ func resourceRuleGroupCreate(ctx context.Context, d *schema.ResourceData, meta i out, err := wr.RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateRuleGroupInput{ ChangeToken: token, - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(d.Get(names.AttrName).(string)), Tags: getTagsIn(ctx), } @@ -160,7 +160,7 @@ func resourceRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta int d.Set(names.AttrARN, arn) d.Set("activated_rule", FlattenActivatedRules(rResp.ActivatedRules)) d.Set(names.AttrName, resp.RuleGroup.Name) - d.Set("metric_name", resp.RuleGroup.MetricName) + d.Set(names.AttrMetricName, resp.RuleGroup.MetricName) return diags } diff --git a/internal/service/waf/rule_group_test.go b/internal/service/waf/rule_group_test.go index 77eb8d3cad2..016af8da1fe 100644 --- a/internal/service/waf/rule_group_test.go +++ b/internal/service/waf/rule_group_test.go @@ -45,7 +45,7 @@ func TestAccWAFRuleGroup_basic(t *testing.T) { testAccCheckRuleGroupExists(ctx, resourceName, &group), resource.TestCheckResourceAttr(resourceName, names.AttrName, groupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", groupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, groupName), computeActivatedRuleWithRuleId(&rule, "COUNT", 50, &idx), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "activated_rule.*", map[string]string{ "action.0.type": "COUNT", @@ -85,7 +85,7 @@ func TestAccWAFRuleGroup_changeNameForceNew(t *testing.T) { testAccCheckRuleGroupExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, groupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", groupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, groupName), ), }, { @@ -94,7 +94,7 @@ func TestAccWAFRuleGroup_changeNameForceNew(t *testing.T) { testAccCheckRuleGroupExists(ctx, resourceName, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, newGroupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", newGroupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, newGroupName), ), }, { diff --git a/internal/service/waf/rule_test.go b/internal/service/waf/rule_test.go index e954dc1f6f3..64a9570795c 100644 --- a/internal/service/waf/rule_test.go +++ b/internal/service/waf/rule_test.go @@ -38,7 +38,7 @@ func TestAccWAFRule_basic(t *testing.T) { testAccCheckRuleExists(ctx, resourceName, &v), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), acctest.MatchResourceAttrGlobalARN(resourceName, names.AttrARN, "waf", regexache.MustCompile(`rule/.+`)), ), }, @@ -70,7 +70,7 @@ func TestAccWAFRule_changeNameForceNew(t *testing.T) { testAccCheckRuleExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -79,7 +79,7 @@ func TestAccWAFRule_changeNameForceNew(t *testing.T) { testAccCheckRuleExists(ctx, resourceName, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleNewName), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleNewName), ), }, }, @@ -254,7 +254,7 @@ func TestAccWAFRule_tags(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRuleExists(ctx, resourceName, &rule), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", ruleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, ruleName), resource.TestCheckResourceAttr(resourceName, names.AttrName, ruleName), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), @@ -265,7 +265,7 @@ func TestAccWAFRule_tags(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRuleExists(ctx, resourceName, &rule), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", ruleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, ruleName), resource.TestCheckResourceAttr(resourceName, names.AttrName, ruleName), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), @@ -277,7 +277,7 @@ func TestAccWAFRule_tags(t *testing.T) { Check: resource.ComposeTestCheckFunc( testAccCheckRuleExists(ctx, resourceName, &rule), resource.TestCheckResourceAttr(resourceName, "predicates.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", ruleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, ruleName), resource.TestCheckResourceAttr(resourceName, names.AttrName, ruleName), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), diff --git a/internal/service/waf/subscribed_rule_group.go b/internal/service/waf/subscribed_rule_group.go index 8d198d73171..5f956b26fe3 100644 --- a/internal/service/waf/subscribed_rule_group.go +++ b/internal/service/waf/subscribed_rule_group.go @@ -29,7 +29,7 @@ func DataSourceSubscribedRuleGroup() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Optional: true, }, @@ -40,7 +40,7 @@ func DataSourceSubscribedRuleGroup() *schema.Resource { func dataSourceSubscribedRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).WAFConn(ctx) name, nameOk := d.Get(names.AttrName).(string) - metricName, metricNameOk := d.Get("metric_name").(string) + metricName, metricNameOk := d.Get(names.AttrMetricName).(string) // Error out if string-assertion fails for either name or metricName if !nameOk || !metricNameOk { @@ -59,7 +59,7 @@ func dataSourceSubscribedRuleGroupRead(ctx context.Context, d *schema.ResourceDa } d.SetId(aws.StringValue(output.RuleGroupId)) - d.Set("metric_name", output.MetricName) + d.Set(names.AttrMetricName, output.MetricName) d.Set(names.AttrName, output.Name) return nil diff --git a/internal/service/waf/subscribed_rule_group_test.go b/internal/service/waf/subscribed_rule_group_test.go index d18b13962a7..20625e0b774 100644 --- a/internal/service/waf/subscribed_rule_group_test.go +++ b/internal/service/waf/subscribed_rule_group_test.go @@ -45,21 +45,21 @@ func TestAccWAFSubscribedRuleGroupDataSource_basic(t *testing.T) { Config: testAccSubscribedRuleGroupDataSourceConfig_name(ruleGroupName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { Config: testAccSubscribedRuleGroupDataSourceConfig_metricName(metricName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { Config: testAccSubscribedRuleGroupDataSourceConfig_nameAndMetricName(ruleGroupName, metricName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { diff --git a/internal/service/waf/web_acl.go b/internal/service/waf/web_acl.go index ded5e8d8d8b..da954fced6b 100644 --- a/internal/service/waf/web_acl.go +++ b/internal/service/waf/web_acl.go @@ -58,7 +58,7 @@ func ResourceWebACL() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -167,7 +167,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte input := &waf.CreateWebACLInput{ ChangeToken: token, DefaultAction: ExpandAction(d.Get("default_action").([]interface{})), - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(d.Get(names.AttrName).(string)), Tags: getTagsIn(ctx), } @@ -257,7 +257,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set(names.AttrName, resp.WebACL.Name) - d.Set("metric_name", resp.WebACL.MetricName) + d.Set(names.AttrMetricName, resp.WebACL.MetricName) if err := d.Set("rules", FlattenWebACLRules(resp.WebACL.Rules)); err != nil { return sdkdiag.AppendErrorf(diags, "setting rules: %s", err) } diff --git a/internal/service/waf/web_acl_test.go b/internal/service/waf/web_acl_test.go index 10a67ef6d6f..012c66f9bff 100644 --- a/internal/service/waf/web_acl_test.go +++ b/internal/service/waf/web_acl_test.go @@ -40,7 +40,7 @@ func TestAccWAFWebACL_basic(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "rules.#", "0"), @@ -75,7 +75,7 @@ func TestAccWAFWebACL_changeNameForceNew(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName1), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName1), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName1), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "rules.#", "0"), @@ -87,7 +87,7 @@ func TestAccWAFWebACL_changeNameForceNew(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName2), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName2), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName2), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), resource.TestCheckResourceAttr(resourceName, "rules.#", "0"), @@ -280,7 +280,7 @@ func TestAccWAFWebACL_tags(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1"), @@ -293,7 +293,7 @@ func TestAccWAFWebACL_tags(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "2"), resource.TestCheckResourceAttr(resourceName, "tags.key1", "value1updated"), @@ -307,7 +307,7 @@ func TestAccWAFWebACL_tags(t *testing.T) { testAccCheckWebACLExists(ctx, resourceName, &webACL), resource.TestCheckResourceAttr(resourceName, "default_action.#", "1"), resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), - resource.TestCheckResourceAttr(resourceName, "metric_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, rName), resource.TestCheckResourceAttr(resourceName, names.AttrName, rName), resource.TestCheckResourceAttr(resourceName, "tags.%", "1"), resource.TestCheckResourceAttr(resourceName, "tags.key2", "value2"), diff --git a/internal/service/wafregional/rate_based_rule.go b/internal/service/wafregional/rate_based_rule.go index 06b59205b17..0f831f9af3a 100644 --- a/internal/service/wafregional/rate_based_rule.go +++ b/internal/service/wafregional/rate_based_rule.go @@ -43,7 +43,7 @@ func resourceRateBasedRule() *schema.Resource { Required: true, ForceNew: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -101,7 +101,7 @@ func resourceRateBasedRuleCreate(ctx context.Context, d *schema.ResourceData, me outputRaw, err := NewRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateRateBasedRuleInput{ ChangeToken: token, - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), RateKey: aws.String(d.Get("rate_key").(string)), RateLimit: aws.Int64(int64(d.Get("rate_limit").(int))), @@ -166,7 +166,7 @@ func resourceRateBasedRuleRead(ctx context.Context, d *schema.ResourceData, meta d.Set(names.AttrARN, arn) d.Set("predicate", predicates) d.Set(names.AttrName, resp.Rule.Name) - d.Set("metric_name", resp.Rule.MetricName) + d.Set(names.AttrMetricName, resp.Rule.MetricName) d.Set("rate_key", resp.Rule.RateKey) d.Set("rate_limit", resp.Rule.RateLimit) diff --git a/internal/service/wafregional/rate_based_rule_test.go b/internal/service/wafregional/rate_based_rule_test.go index c3c47d5e42a..aacb6aee182 100644 --- a/internal/service/wafregional/rate_based_rule_test.go +++ b/internal/service/wafregional/rate_based_rule_test.go @@ -40,7 +40,7 @@ func TestAccWAFRegionalRateBasedRule_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "waf-regional", regexache.MustCompile(`ratebasedrule/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -116,7 +116,7 @@ func TestAccWAFRegionalRateBasedRule_changeNameForceNew(t *testing.T) { testAccCheckRateBasedRuleExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -126,7 +126,7 @@ func TestAccWAFRegionalRateBasedRule_changeNameForceNew(t *testing.T) { testAccCheckRateBasedRuleIdDiffers(&before, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleNewName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleNewName), ), }, { diff --git a/internal/service/wafregional/rule.go b/internal/service/wafregional/rule.go index bd6e4294c05..ba549735680 100644 --- a/internal/service/wafregional/rule.go +++ b/internal/service/wafregional/rule.go @@ -43,7 +43,7 @@ func resourceRule() *schema.Resource { Required: true, ForceNew: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -91,7 +91,7 @@ func resourceRuleCreate(ctx context.Context, d *schema.ResourceData, meta interf outputRaw, err := NewRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateRuleInput{ ChangeToken: token, - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), Tags: getTagsIn(ctx), } @@ -145,7 +145,7 @@ func resourceRuleRead(ctx context.Context, d *schema.ResourceData, meta interfac d.Set(names.AttrARN, arn) d.Set("predicate", flattenPredicates(resp.Rule.Predicates)) d.Set(names.AttrName, resp.Rule.Name) - d.Set("metric_name", resp.Rule.MetricName) + d.Set(names.AttrMetricName, resp.Rule.MetricName) return diags } diff --git a/internal/service/wafregional/rule_group.go b/internal/service/wafregional/rule_group.go index 6f5edfbd068..784ffddf2a5 100644 --- a/internal/service/wafregional/rule_group.go +++ b/internal/service/wafregional/rule_group.go @@ -42,7 +42,7 @@ func resourceRuleGroup() *schema.Resource { Required: true, ForceNew: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -103,7 +103,7 @@ func resourceRuleGroupCreate(ctx context.Context, d *schema.ResourceData, meta i outputRaw, err := NewRetryer(conn, region).RetryWithToken(ctx, func(token *string) (interface{}, error) { input := &waf.CreateRuleGroupInput{ ChangeToken: token, - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(name), Tags: getTagsIn(ctx), } @@ -165,7 +165,7 @@ func resourceRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta int d.Set(names.AttrARN, arn) d.Set("activated_rule", tfwaf.FlattenActivatedRules(rResp.ActivatedRules)) d.Set(names.AttrName, resp.RuleGroup.Name) - d.Set("metric_name", resp.RuleGroup.MetricName) + d.Set(names.AttrMetricName, resp.RuleGroup.MetricName) return diags } diff --git a/internal/service/wafregional/rule_group_test.go b/internal/service/wafregional/rule_group_test.go index 108a56e3a83..7f86c2624f1 100644 --- a/internal/service/wafregional/rule_group_test.go +++ b/internal/service/wafregional/rule_group_test.go @@ -47,7 +47,7 @@ func TestAccWAFRegionalRuleGroup_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "waf-regional", regexache.MustCompile(`rulegroup/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrName, groupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", groupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, groupName), computeActivatedRuleWithRuleId(&rule, "COUNT", 50, &idx), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "activated_rule.*", map[string]string{ "action.0.type": "COUNT", @@ -138,7 +138,7 @@ func TestAccWAFRegionalRuleGroup_changeNameForceNew(t *testing.T) { testAccCheckRuleGroupExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, groupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", groupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, groupName), ), }, { @@ -147,7 +147,7 @@ func TestAccWAFRegionalRuleGroup_changeNameForceNew(t *testing.T) { testAccCheckRuleGroupExists(ctx, resourceName, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, newGroupName), resource.TestCheckResourceAttr(resourceName, "activated_rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", newGroupName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, newGroupName), ), }, { diff --git a/internal/service/wafregional/rule_test.go b/internal/service/wafregional/rule_test.go index 9cacf5bb3cd..d2cb9cc4ace 100644 --- a/internal/service/wafregional/rule_test.go +++ b/internal/service/wafregional/rule_test.go @@ -42,7 +42,7 @@ func TestAccWAFRegionalRule_basic(t *testing.T) { acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "waf-regional", regexache.MustCompile(`rule/.+`)), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -119,7 +119,7 @@ func TestAccWAFRegionalRule_changeNameForceNew(t *testing.T) { testAccCheckRuleExists(ctx, resourceName, &before), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleName), ), }, { @@ -128,7 +128,7 @@ func TestAccWAFRegionalRule_changeNameForceNew(t *testing.T) { testAccCheckRuleExists(ctx, resourceName, &after), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafRuleNewName), resource.TestCheckResourceAttr(resourceName, "predicate.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafRuleNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafRuleNewName), ), }, { diff --git a/internal/service/wafregional/subscribed_rule_group_data_source.go b/internal/service/wafregional/subscribed_rule_group_data_source.go index 20151fecd7f..efae5be2152 100644 --- a/internal/service/wafregional/subscribed_rule_group_data_source.go +++ b/internal/service/wafregional/subscribed_rule_group_data_source.go @@ -29,7 +29,7 @@ func dataSourceSubscribedRuleGroup() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Optional: true, }, @@ -40,7 +40,7 @@ func dataSourceSubscribedRuleGroup() *schema.Resource { func dataSourceSubscribedRuleGroupRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { conn := meta.(*conns.AWSClient).WAFRegionalConn(ctx) name, nameOk := d.Get(names.AttrName).(string) - metricName, metricNameOk := d.Get("metric_name").(string) + metricName, metricNameOk := d.Get(names.AttrMetricName).(string) // Error out if string-assertion fails for either name or metricName if !nameOk || !metricNameOk { @@ -59,7 +59,7 @@ func dataSourceSubscribedRuleGroupRead(ctx context.Context, d *schema.ResourceDa } d.SetId(aws.StringValue(output.RuleGroupId)) - d.Set("metric_name", output.MetricName) + d.Set(names.AttrMetricName, output.MetricName) d.Set(names.AttrName, output.Name) return nil diff --git a/internal/service/wafregional/subscribed_rule_group_data_source_test.go b/internal/service/wafregional/subscribed_rule_group_data_source_test.go index 59db35c4131..de79944f7e3 100644 --- a/internal/service/wafregional/subscribed_rule_group_data_source_test.go +++ b/internal/service/wafregional/subscribed_rule_group_data_source_test.go @@ -45,21 +45,21 @@ func TestAccWAFRegionalSubscribedRuleGroupDataSource_basic(t *testing.T) { Config: testAccSubscribedRuleGroupDataSourceConfig_name(ruleGroupName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { Config: testAccSubscribedRuleGroupDataSourceConfig_metricName(metricName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { Config: testAccSubscribedRuleGroupDataSourceConfig_nameAndMetricName(ruleGroupName, metricName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourceName, names.AttrName, ruleGroupName), - resource.TestCheckResourceAttr(datasourceName, "metric_name", metricName), + resource.TestCheckResourceAttr(datasourceName, names.AttrMetricName, metricName), ), }, { diff --git a/internal/service/wafregional/web_acl.go b/internal/service/wafregional/web_acl.go index 3f1ee00208c..363efcc9c22 100644 --- a/internal/service/wafregional/web_acl.go +++ b/internal/service/wafregional/web_acl.go @@ -105,7 +105,7 @@ func resourceWebACL() *schema.Resource { }, }, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -189,7 +189,7 @@ func resourceWebACLCreate(ctx context.Context, d *schema.ResourceData, meta inte input := &waf.CreateWebACLInput{ ChangeToken: token, DefaultAction: tfwaf.ExpandAction(d.Get("default_action").([]interface{})), - MetricName: aws.String(d.Get("metric_name").(string)), + MetricName: aws.String(d.Get(names.AttrMetricName).(string)), Name: aws.String(d.Get(names.AttrName).(string)), Tags: getTagsIn(ctx), } @@ -289,7 +289,7 @@ func resourceWebACLRead(ctx context.Context, d *schema.ResourceData, meta interf return sdkdiag.AppendErrorf(diags, "setting default_action: %s", err) } d.Set(names.AttrName, resp.WebACL.Name) - d.Set("metric_name", resp.WebACL.MetricName) + d.Set(names.AttrMetricName, resp.WebACL.MetricName) if err := d.Set("rule", tfwaf.FlattenWebACLRules(resp.WebACL.Rules)); err != nil { return sdkdiag.AppendErrorf(diags, "setting rule: %s", err) } diff --git a/internal/service/wafregional/web_acl_test.go b/internal/service/wafregional/web_acl_test.go index c435dd700b0..0215de02552 100644 --- a/internal/service/wafregional/web_acl_test.go +++ b/internal/service/wafregional/web_acl_test.go @@ -44,7 +44,7 @@ func TestAccWAFRegionalWebACL_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclName), resource.TestCheckResourceAttr(resourceName, "logging_configuration.#", "0"), ), }, @@ -123,7 +123,7 @@ func TestAccWAFRegionalWebACL_createRateBased(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclName), ), }, { @@ -155,7 +155,7 @@ func TestAccWAFRegionalWebACL_createGroup(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclName), ), }, { @@ -188,7 +188,7 @@ func TestAccWAFRegionalWebACL_changeNameForceNew(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclName), ), }, { @@ -199,7 +199,7 @@ func TestAccWAFRegionalWebACL_changeNameForceNew(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclNewName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclNewName), ), }, { @@ -232,7 +232,7 @@ func TestAccWAFRegionalWebACL_changeDefaultAction(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "ALLOW"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclName), ), }, { @@ -243,7 +243,7 @@ func TestAccWAFRegionalWebACL_changeDefaultAction(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "default_action.0.type", "BLOCK"), resource.TestCheckResourceAttr(resourceName, names.AttrName, wafAclNewName), resource.TestCheckResourceAttr(resourceName, "rule.#", "1"), - resource.TestCheckResourceAttr(resourceName, "metric_name", wafAclNewName), + resource.TestCheckResourceAttr(resourceName, names.AttrMetricName, wafAclNewName), ), }, { diff --git a/internal/service/wafv2/flex.go b/internal/service/wafv2/flex.go index 305e1316090..8d276f77027 100644 --- a/internal/service/wafv2/flex.go +++ b/internal/service/wafv2/flex.go @@ -402,7 +402,7 @@ func expandVisibilityConfig(l []interface{}) *awstypes.VisibilityConfig { configuration.CloudWatchMetricsEnabled = v.(bool) } - if v, ok := m["metric_name"]; ok && len(v.(string)) > 0 { + if v, ok := m[names.AttrMetricName]; ok && len(v.(string)) > 0 { configuration.MetricName = aws.String(v.(string)) } @@ -2348,7 +2348,7 @@ func flattenVisibilityConfig(config *awstypes.VisibilityConfig) interface{} { m := map[string]interface{}{ "cloudwatch_metrics_enabled": aws.Bool(config.CloudWatchMetricsEnabled), - "metric_name": aws.ToString(config.MetricName), + names.AttrMetricName: aws.ToString(config.MetricName), "sampled_requests_enabled": aws.Bool(config.SampledRequestsEnabled), } diff --git a/internal/service/wafv2/schemas.go b/internal/service/wafv2/schemas.go index 2e368e7c35b..1fb6ef0b01f 100644 --- a/internal/service/wafv2/schemas.go +++ b/internal/service/wafv2/schemas.go @@ -503,7 +503,7 @@ func visibilityConfigSchema() *schema.Schema { Type: schema.TypeBool, Required: true, }, - "metric_name": { + names.AttrMetricName: { Type: schema.TypeString, Required: true, ValidateFunc: validation.All( diff --git a/internal/service/workspaces/workspace.go b/internal/service/workspaces/workspace.go index 2a117b8993e..4a4667b5939 100644 --- a/internal/service/workspaces/workspace.go +++ b/internal/service/workspaces/workspace.go @@ -45,7 +45,7 @@ func ResourceWorkspace() *schema.Resource { Required: true, ForceNew: true, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -207,7 +207,7 @@ func resourceWorkspaceRead(ctx context.Context, d *schema.ResourceData, meta int workspace := rawOutput.(types.Workspace) d.Set("bundle_id", workspace.BundleId) d.Set("directory_id", workspace.DirectoryId) - d.Set("ip_address", workspace.IpAddress) + d.Set(names.AttrIPAddress, workspace.IpAddress) d.Set("computer_name", workspace.ComputerName) d.Set(names.AttrState, workspace.State) d.Set("root_volume_encryption_enabled", workspace.RootVolumeEncryptionEnabled) diff --git a/internal/service/workspaces/workspace_data_source.go b/internal/service/workspaces/workspace_data_source.go index c04235cc541..e67d3cc02e6 100644 --- a/internal/service/workspaces/workspace_data_source.go +++ b/internal/service/workspaces/workspace_data_source.go @@ -35,7 +35,7 @@ func DataSourceWorkspace() *schema.Resource { RequiredWith: []string{names.AttrUserName}, ConflictsWith: []string{"workspace_id"}, }, - "ip_address": { + names.AttrIPAddress: { Type: schema.TypeString, Computed: true, }, @@ -155,7 +155,7 @@ func dataSourceWorkspaceRead(ctx context.Context, d *schema.ResourceData, meta i d.SetId(aws.ToString(workspace.WorkspaceId)) d.Set("bundle_id", workspace.BundleId) d.Set("directory_id", workspace.DirectoryId) - d.Set("ip_address", workspace.IpAddress) + d.Set(names.AttrIPAddress, workspace.IpAddress) d.Set("computer_name", workspace.ComputerName) d.Set(names.AttrState, workspace.State) d.Set("root_volume_encryption_enabled", workspace.RootVolumeEncryptionEnabled) diff --git a/internal/service/workspaces/workspace_data_source_test.go b/internal/service/workspaces/workspace_data_source_test.go index 64cae5e72d5..86f02cbf503 100644 --- a/internal/service/workspaces/workspace_data_source_test.go +++ b/internal/service/workspaces/workspace_data_source_test.go @@ -32,7 +32,7 @@ func testAccWorkspaceDataSource_byWorkspaceID(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, "directory_id", resourceName, "directory_id"), resource.TestCheckResourceAttrPair(dataSourceName, "bundle_id", resourceName, "bundle_id"), - resource.TestCheckResourceAttrPair(dataSourceName, "ip_address", resourceName, "ip_address"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrState, resourceName, names.AttrState), resource.TestCheckResourceAttrPair(dataSourceName, "root_volume_encryption_enabled", resourceName, "root_volume_encryption_enabled"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrUserName, resourceName, names.AttrUserName), @@ -67,7 +67,7 @@ func testAccWorkspaceDataSource_byDirectoryID_userName(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( resource.TestCheckResourceAttrPair(dataSourceName, "directory_id", resourceName, "directory_id"), resource.TestCheckResourceAttrPair(dataSourceName, "bundle_id", resourceName, "bundle_id"), - resource.TestCheckResourceAttrPair(dataSourceName, "ip_address", resourceName, "ip_address"), + resource.TestCheckResourceAttrPair(dataSourceName, names.AttrIPAddress, resourceName, names.AttrIPAddress), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrState, resourceName, names.AttrState), resource.TestCheckResourceAttrPair(dataSourceName, "root_volume_encryption_enabled", resourceName, "root_volume_encryption_enabled"), resource.TestCheckResourceAttrPair(dataSourceName, names.AttrUserName, resourceName, names.AttrUserName), diff --git a/internal/service/workspaces/workspace_test.go b/internal/service/workspaces/workspace_test.go index 91dc1ce7f8f..05908676054 100644 --- a/internal/service/workspaces/workspace_test.go +++ b/internal/service/workspaces/workspace_test.go @@ -52,7 +52,7 @@ func testAccWorkspace_basic(t *testing.T) { testAccCheckWorkspaceExists(ctx, resourceName, &v), resource.TestCheckResourceAttrPair(resourceName, "directory_id", directoryResourceName, names.AttrID), resource.TestCheckResourceAttrPair(resourceName, "bundle_id", bundleDataSourceName, names.AttrID), - resource.TestMatchResourceAttr(resourceName, "ip_address", regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), + resource.TestMatchResourceAttr(resourceName, names.AttrIPAddress, regexache.MustCompile(`\d+\.\d+\.\d+\.\d+`)), resource.TestCheckResourceAttr(resourceName, names.AttrState, string(types.WorkspaceStateAvailable)), resource.TestCheckResourceAttr(resourceName, "root_volume_encryption_enabled", "false"), resource.TestCheckResourceAttr(resourceName, names.AttrUserName, "Administrator"), diff --git a/internal/service/xray/group.go b/internal/service/xray/group.go index 3ae540932e9..51f1f7c442a 100644 --- a/internal/service/xray/group.go +++ b/internal/service/xray/group.go @@ -43,7 +43,7 @@ func resourceGroup() *schema.Resource { Type: schema.TypeString, Computed: true, }, - "group_name": { + names.AttrGroupName: { Type: schema.TypeString, Required: true, ForceNew: true, @@ -81,7 +81,7 @@ func resourceGroupCreate(ctx context.Context, d *schema.ResourceData, meta inter var diags diag.Diagnostics conn := meta.(*conns.AWSClient).XRayClient(ctx) - name := d.Get("group_name").(string) + name := d.Get(names.AttrGroupName).(string) input := &xray.CreateGroupInput{ GroupName: aws.String(name), FilterExpression: aws.String(d.Get("filter_expression").(string)), @@ -121,7 +121,7 @@ func resourceGroupRead(ctx context.Context, d *schema.ResourceData, meta interfa d.Set(names.AttrARN, group.GroupARN) d.Set("filter_expression", group.FilterExpression) - d.Set("group_name", group.GroupName) + d.Set(names.AttrGroupName, group.GroupName) if err := d.Set("insights_configuration", flattenInsightsConfig(group.InsightsConfiguration)); err != nil { return sdkdiag.AppendErrorf(diags, "setting insights_configuration: %s", err) } diff --git a/internal/service/xray/group_test.go b/internal/service/xray/group_test.go index 93cc279ddae..c2e2f99a8bd 100644 --- a/internal/service/xray/group_test.go +++ b/internal/service/xray/group_test.go @@ -37,7 +37,7 @@ func TestAccXRayGroup_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "xray", regexache.MustCompile(`group/.+`)), - resource.TestCheckResourceAttr(resourceName, "group_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, rName), resource.TestCheckResourceAttr(resourceName, "filter_expression", "responsetime > 5"), resource.TestCheckResourceAttr(resourceName, "insights_configuration.#", "1"), // Computed. ), @@ -52,7 +52,7 @@ func TestAccXRayGroup_basic(t *testing.T) { Check: resource.ComposeAggregateTestCheckFunc( testAccCheckGroupExists(ctx, resourceName, &v), acctest.MatchResourceAttrRegionalARN(resourceName, names.AttrARN, "xray", regexache.MustCompile(`group/.+`)), - resource.TestCheckResourceAttr(resourceName, "group_name", rName), + resource.TestCheckResourceAttr(resourceName, names.AttrGroupName, rName), resource.TestCheckResourceAttr(resourceName, "filter_expression", "responsetime > 10"), resource.TestCheckResourceAttr(resourceName, "insights_configuration.#", "1"), ), diff --git a/names/attr_constants.csv b/names/attr_constants.csv index 78f59151502..cfb7e91ad30 100644 --- a/names/attr_constants.csv +++ b/names/attr_constants.csv @@ -14,6 +14,7 @@ bucket_prefix,BucketPrefix catalog_id,CatalogID certificate,Certificate certificate_arn,CertificateARN +client_id,ClientID cluster_identifier,ClusterIdentifier configuration,Configuration content_type,ContentType @@ -37,21 +38,25 @@ endpoint_type,EndpointType endpoints,Endpoints engine_version,EngineVersion execution_role_arn,ExecutionRoleARN +expression,Expression file_system_id,FileSystemID filter,Filter force_destroy,ForceDestroy format,Format +group_name,GroupName hosted_zone_id,HostedZoneID id,ID identifier,Identifier instance_id,InstanceID instance_type,InstanceType +ip_address,IPAddress key,Key kms_key_arn,KMSKeyARN kms_key_id,KMSKeyID last_updated_date,LastUpdatedDate log_group_name,LogGroupName max,Max +metric_name,MetricName min,Min mode,Mode name,Name @@ -68,8 +73,11 @@ policy,Policy port,Port preferred_maintenance_window,PreferredMaintenanceWindow prefix,Prefix +principal,Principal priority,Priority +private_key,PrivateKey profile,Profile +properties,Properties protocol,Protocol publicly_accessible,PubliclyAccessible region,Region @@ -77,6 +85,7 @@ resource_arn,ResourceARN resource_type,ResourceType role_arn,RoleARN s3_bucket_name,S3BucketName +schedule,Schedule schedule_expression,ScheduleExpression secret_key,SecretKey security_group_ids,SecurityGroupIDs @@ -107,5 +116,6 @@ username,Username value,Value values,Values version,Version +vpc_config,VPCConfig vpc_id,VPCID vpc_security_group_ids,VPCSecurityGroupIDs diff --git a/names/attr_consts_gen.go b/names/attr_consts_gen.go index 1b8d880c57f..bebaaddaf4e 100644 --- a/names/attr_consts_gen.go +++ b/names/attr_consts_gen.go @@ -25,6 +25,7 @@ const ( AttrCatalogID = "catalog_id" AttrCertificate = "certificate" AttrCertificateARN = "certificate_arn" + AttrClientID = "client_id" AttrClusterIdentifier = "cluster_identifier" AttrConfiguration = "configuration" AttrContentType = "content_type" @@ -48,12 +49,15 @@ const ( AttrEndpoints = "endpoints" AttrEngineVersion = "engine_version" AttrExecutionRoleARN = "execution_role_arn" + AttrExpression = "expression" AttrFileSystemID = "file_system_id" AttrFilter = "filter" AttrForceDestroy = "force_destroy" AttrFormat = "format" + AttrGroupName = "group_name" AttrHostedZoneID = "hosted_zone_id" AttrID = "id" + AttrIPAddress = "ip_address" AttrIdentifier = "identifier" AttrInstanceID = "instance_id" AttrInstanceType = "instance_type" @@ -63,6 +67,7 @@ const ( AttrLastUpdatedDate = "last_updated_date" AttrLogGroupName = "log_group_name" AttrMax = "max" + AttrMetricName = "metric_name" AttrMin = "min" AttrMode = "mode" AttrName = "name" @@ -79,8 +84,11 @@ const ( AttrPort = "port" AttrPreferredMaintenanceWindow = "preferred_maintenance_window" AttrPrefix = "prefix" + AttrPrincipal = "principal" AttrPriority = "priority" + AttrPrivateKey = "private_key" AttrProfile = "profile" + AttrProperties = "properties" AttrProtocol = "protocol" AttrPubliclyAccessible = "publicly_accessible" AttrRegion = "region" @@ -89,6 +97,7 @@ const ( AttrRoleARN = "role_arn" AttrS3BucketName = "s3_bucket_name" AttrSNSTopicARN = "sns_topic_arn" + AttrSchedule = "schedule" AttrScheduleExpression = "schedule_expression" AttrSecretKey = "secret_key" AttrSecurityGroupIDs = "security_group_ids" @@ -115,6 +124,7 @@ const ( AttrUnit = "unit" AttrUserName = "user_name" AttrUsername = "username" + AttrVPCConfig = "vpc_config" AttrVPCID = "vpc_id" AttrVPCSecurityGroupIDs = "vpc_security_group_ids" AttrValue = "value" @@ -143,6 +153,7 @@ func ConstOrQuote(constant string) string { "catalog_id": "AttrCatalogID", "certificate": "AttrCertificate", "certificate_arn": "AttrCertificateARN", + "client_id": "AttrClientID", "cluster_identifier": "AttrClusterIdentifier", "configuration": "AttrConfiguration", "content_type": "AttrContentType", @@ -166,12 +177,15 @@ func ConstOrQuote(constant string) string { "endpoints": "AttrEndpoints", "engine_version": "AttrEngineVersion", "execution_role_arn": "AttrExecutionRoleARN", + "expression": "AttrExpression", "file_system_id": "AttrFileSystemID", "filter": "AttrFilter", "force_destroy": "AttrForceDestroy", "format": "AttrFormat", + "group_name": "AttrGroupName", "hosted_zone_id": "AttrHostedZoneID", "id": "AttrID", + "ip_address": "AttrIPAddress", "identifier": "AttrIdentifier", "instance_id": "AttrInstanceID", "instance_type": "AttrInstanceType", @@ -181,6 +195,7 @@ func ConstOrQuote(constant string) string { "last_updated_date": "AttrLastUpdatedDate", "log_group_name": "AttrLogGroupName", "max": "AttrMax", + "metric_name": "AttrMetricName", "min": "AttrMin", "mode": "AttrMode", "name": "AttrName", @@ -197,8 +212,11 @@ func ConstOrQuote(constant string) string { "port": "AttrPort", "preferred_maintenance_window": "AttrPreferredMaintenanceWindow", "prefix": "AttrPrefix", + "principal": "AttrPrincipal", "priority": "AttrPriority", + "private_key": "AttrPrivateKey", "profile": "AttrProfile", + "properties": "AttrProperties", "protocol": "AttrProtocol", "publicly_accessible": "AttrPubliclyAccessible", "region": "AttrRegion", @@ -207,6 +225,7 @@ func ConstOrQuote(constant string) string { "role_arn": "AttrRoleARN", "s3_bucket_name": "AttrS3BucketName", "sns_topic_arn": "AttrSNSTopicARN", + "schedule": "AttrSchedule", "schedule_expression": "AttrScheduleExpression", "secret_key": "AttrSecretKey", "security_group_ids": "AttrSecurityGroupIDs", @@ -233,6 +252,7 @@ func ConstOrQuote(constant string) string { "unit": "AttrUnit", "user_name": "AttrUserName", "username": "AttrUsername", + "vpc_config": "AttrVPCConfig", "vpc_id": "AttrVPCID", "vpc_security_group_ids": "AttrVPCSecurityGroupIDs", "value": "AttrValue",