From 77ed655bfab5ef564b35508d4dfa49c15b800dd6 Mon Sep 17 00:00:00 2001 From: Matt Burgess <549318+mattburgess@users.noreply.github.com> Date: Sat, 23 Mar 2024 18:05:39 +0000 Subject: [PATCH 1/4] appconfig: Migrate to AWS SDK v2 --- internal/conns/awsclient_gen.go | 5 - internal/service/appconfig/application.go | 33 +- .../service/appconfig/application_test.go | 17 +- .../appconfig/configuration_profile.go | 75 ++--- .../configuration_profile_data_source.go | 10 +- .../configuration_profile_data_source_test.go | 6 +- .../appconfig/configuration_profile_test.go | 27 +- .../configuration_profiles_data_source.go | 26 +- ...configuration_profiles_data_source_test.go | 3 +- internal/service/appconfig/deployment.go | 30 +- .../service/appconfig/deployment_strategy.go | 66 ++-- .../appconfig/deployment_strategy_test.go | 19 +- internal/service/appconfig/deployment_test.go | 10 +- internal/service/appconfig/environment.go | 2 +- .../appconfig/environment_data_source.go | 27 +- .../appconfig/environment_data_source_test.go | 3 +- .../service/appconfig/environment_test.go | 17 +- .../appconfig/environments_data_source.go | 29 +- .../environments_data_source_test.go | 3 +- internal/service/appconfig/extension.go | 67 ++-- .../appconfig/extension_association.go | 24 +- internal/service/appconfig/extension_test.go | 17 +- .../appconfig/extenstion_association_test.go | 17 +- internal/service/appconfig/find.go | 19 +- internal/service/appconfig/generate.go | 2 +- .../appconfig/hosted_configuration_version.go | 31 +- .../hosted_configuration_version_test.go | 21 +- .../appconfig/service_endpoints_gen_test.go | 41 +-- internal/service/appconfig/service_package.go | 29 -- .../service/appconfig/service_package_gen.go | 10 - internal/service/appconfig/sweep.go | 288 +++++++++--------- internal/service/appconfig/tags_gen.go | 33 +- names/data/names_data.csv | 2 +- names/names.go | 1 + 34 files changed, 457 insertions(+), 553 deletions(-) delete mode 100644 internal/service/appconfig/service_package.go diff --git a/internal/conns/awsclient_gen.go b/internal/conns/awsclient_gen.go index 9ee9450d11ff..461f63739e1b 100644 --- a/internal/conns/awsclient_gen.go +++ b/internal/conns/awsclient_gen.go @@ -147,7 +147,6 @@ import ( amplify_sdkv1 "github.com/aws/aws-sdk-go/service/amplify" apigateway_sdkv1 "github.com/aws/aws-sdk-go/service/apigateway" apigatewayv2_sdkv1 "github.com/aws/aws-sdk-go/service/apigatewayv2" - appconfig_sdkv1 "github.com/aws/aws-sdk-go/service/appconfig" appintegrationsservice_sdkv1 "github.com/aws/aws-sdk-go/service/appintegrationsservice" applicationautoscaling_sdkv1 "github.com/aws/aws-sdk-go/service/applicationautoscaling" applicationinsights_sdkv1 "github.com/aws/aws-sdk-go/service/applicationinsights" @@ -288,10 +287,6 @@ func (c *AWSClient) AppAutoScalingConn(ctx context.Context) *applicationautoscal return errs.Must(conn[*applicationautoscaling_sdkv1.ApplicationAutoScaling](ctx, c, names.AppAutoScaling, make(map[string]any))) } -func (c *AWSClient) AppConfigConn(ctx context.Context) *appconfig_sdkv1.AppConfig { - return errs.Must(conn[*appconfig_sdkv1.AppConfig](ctx, c, names.AppConfig, make(map[string]any))) -} - func (c *AWSClient) AppConfigClient(ctx context.Context) *appconfig_sdkv2.Client { return errs.Must(client[*appconfig_sdkv2.Client](ctx, c, names.AppConfig, make(map[string]any))) } diff --git a/internal/service/appconfig/application.go b/internal/service/appconfig/application.go index 01f19d2af5af..3636a320977b 100644 --- a/internal/service/appconfig/application.go +++ b/internal/service/appconfig/application.go @@ -8,14 +8,15 @@ import ( "fmt" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -58,7 +59,7 @@ func ResourceApplication() *schema.Resource { func resourceApplicationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) applicationName := d.Get("name").(string) input := &appconfig.CreateApplicationInput{ @@ -70,7 +71,7 @@ func resourceApplicationCreate(ctx context.Context, d *schema.ResourceData, meta input.Description = aws.String(v.(string)) } - app, err := conn.CreateApplicationWithContext(ctx, input) + app, err := conn.CreateApplication(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating AppConfig Application (%s): %s", applicationName, err) @@ -80,22 +81,22 @@ func resourceApplicationCreate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "creating AppConfig Application (%s): empty response", applicationName) } - d.SetId(aws.StringValue(app.Id)) + d.SetId(aws.ToString(app.Id)) return append(diags, resourceApplicationRead(ctx, d, meta)...) } func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetApplicationInput{ ApplicationId: aws.String(d.Id()), } - output, err := conn.GetApplicationWithContext(ctx, input) + output, err := conn.GetApplication(ctx, input) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Appconfig Application (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -113,7 +114,7 @@ func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta i AccountID: meta.(*conns.AWSClient).AccountID, Partition: meta.(*conns.AWSClient).Partition, Region: meta.(*conns.AWSClient).Region, - Resource: fmt.Sprintf("application/%s", aws.StringValue(output.Id)), + Resource: fmt.Sprintf("application/%s", aws.ToString(output.Id)), Service: "appconfig", }.String() @@ -126,7 +127,7 @@ func resourceApplicationRead(ctx context.Context, d *schema.ResourceData, meta i func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) if d.HasChangesExcept("tags", "tags_all") { updateInput := &appconfig.UpdateApplicationInput{ @@ -141,7 +142,7 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta updateInput.Name = aws.String(d.Get("name").(string)) } - _, err := conn.UpdateApplicationWithContext(ctx, updateInput) + _, err := conn.UpdateApplication(ctx, updateInput) if err != nil { return sdkdiag.AppendErrorf(diags, "updating AppConfig Application(%s): %s", d.Id(), err) @@ -153,14 +154,14 @@ func resourceApplicationUpdate(ctx context.Context, d *schema.ResourceData, meta func resourceApplicationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) log.Printf("[INFO] Deleting AppConfig Application: %s", d.Id()) - _, err := conn.DeleteApplicationWithContext(ctx, &appconfig.DeleteApplicationInput{ + _, err := conn.DeleteApplication(ctx, &appconfig.DeleteApplicationInput{ ApplicationId: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } diff --git a/internal/service/appconfig/application_test.go b/internal/service/appconfig/application_test.go index f467b7120405..8d6a4079d215 100644 --- a/internal/service/appconfig/application_test.go +++ b/internal/service/appconfig/application_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -201,7 +202,7 @@ func TestAccAppConfigApplication_tags(t *testing.T) { func testAccCheckApplicationDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_application" { @@ -212,9 +213,9 @@ func testAccCheckApplicationDestroy(ctx context.Context) resource.TestCheckFunc ApplicationId: aws.String(rs.Primary.ID), } - output, err := conn.GetApplicationWithContext(ctx, input) + output, err := conn.GetApplication(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -242,13 +243,13 @@ func testAccCheckApplicationExists(ctx context.Context, resourceName string) res return fmt.Errorf("Resource (%s) ID not set", resourceName) } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetApplicationInput{ ApplicationId: aws.String(rs.Primary.ID), } - output, err := conn.GetApplicationWithContext(ctx, input) + output, err := conn.GetApplication(ctx, input) if err != nil { return fmt.Errorf("error reading AppConfig Application (%s): %w", rs.Primary.ID, err) diff --git a/internal/service/appconfig/configuration_profile.go b/internal/service/appconfig/configuration_profile.go index 11e2f70bd1bc..7d2cd3c427a6 100644 --- a/internal/service/appconfig/configuration_profile.go +++ b/internal/service/appconfig/configuration_profile.go @@ -10,14 +10,16 @@ import ( "strings" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/enum" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -105,9 +107,9 @@ func ResourceConfigurationProfile() *schema.Resource { DiffSuppressFunc: verify.SuppressEquivalentJSONDiffs, }, "type": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(appconfig.ValidatorType_Values(), false), + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[awstypes.ValidatorType](), }, }, }, @@ -119,7 +121,7 @@ func ResourceConfigurationProfile() *schema.Resource { func resourceConfigurationProfileCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appId := d.Get("application_id").(string) name := d.Get("name").(string) @@ -150,7 +152,7 @@ func resourceConfigurationProfileCreate(ctx context.Context, d *schema.ResourceD input.Validators = expandValidators(v.(*schema.Set).List()) } - profile, err := conn.CreateConfigurationProfileWithContext(ctx, input) + profile, err := conn.CreateConfigurationProfile(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating AppConfig Configuration Profile (%s) for Application (%s): %s", name, appId, err) @@ -160,14 +162,14 @@ func resourceConfigurationProfileCreate(ctx context.Context, d *schema.ResourceD return sdkdiag.AppendErrorf(diags, "creating AppConfig Configuration Profile (%s) for Application (%s): empty response", name, appId) } - d.SetId(fmt.Sprintf("%s:%s", aws.StringValue(profile.Id), aws.StringValue(profile.ApplicationId))) + d.SetId(fmt.Sprintf("%s:%s", aws.ToString(profile.Id), aws.ToString(profile.ApplicationId))) return append(diags, resourceConfigurationProfileRead(ctx, d, meta)...) } func resourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) confProfID, appID, err := ConfigurationProfileParseID(d.Id()) @@ -180,9 +182,9 @@ func resourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceDat ConfigurationProfileId: aws.String(confProfID), } - output, err := conn.GetConfigurationProfileWithContext(ctx, input) + output, err := conn.GetConfigurationProfile(ctx, input) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] AppConfig Configuration Profile (%s) for Application (%s) not found, removing from state", confProfID, appID) d.SetId("") return diags @@ -223,7 +225,7 @@ func resourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceDat func resourceConfigurationProfileUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) if d.HasChangesExcept("tags", "tags_all") { confProfID, appID, err := ConfigurationProfileParseID(d.Id()) @@ -257,7 +259,7 @@ func resourceConfigurationProfileUpdate(ctx context.Context, d *schema.ResourceD updateInput.Validators = expandValidators(d.Get("validator").(*schema.Set).List()) } - _, err = conn.UpdateConfigurationProfileWithContext(ctx, updateInput) + _, err = conn.UpdateConfigurationProfile(ctx, updateInput) if err != nil { return sdkdiag.AppendErrorf(diags, "updating AppConfig Configuration Profile (%s) for Application (%s): %s", confProfID, appID, err) @@ -269,7 +271,7 @@ func resourceConfigurationProfileUpdate(ctx context.Context, d *schema.ResourceD func resourceConfigurationProfileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) confProfID, appID, err := ConfigurationProfileParseID(d.Id()) if err != nil { @@ -277,12 +279,12 @@ func resourceConfigurationProfileDelete(ctx context.Context, d *schema.ResourceD } log.Printf("[INFO] Deleting AppConfig Configuration Profile: %s", d.Id()) - _, err = conn.DeleteConfigurationProfileWithContext(ctx, &appconfig.DeleteConfigurationProfileInput{ + _, err = conn.DeleteConfigurationProfile(ctx, &appconfig.DeleteConfigurationProfileInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), }) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } @@ -303,12 +305,8 @@ func ConfigurationProfileParseID(id string) (string, string, error) { return parts[0], parts[1], nil } -func expandValidator(tfMap map[string]interface{}) *appconfig.Validator { - if tfMap == nil { - return nil - } - - validator := &appconfig.Validator{} +func expandValidator(tfMap map[string]interface{}) awstypes.Validator { + validator := awstypes.Validator{} // AppConfig API supports empty content if v, ok := tfMap["content"].(string); ok { @@ -316,16 +314,16 @@ func expandValidator(tfMap map[string]interface{}) *appconfig.Validator { } if v, ok := tfMap["type"].(string); ok && v != "" { - validator.Type = aws.String(v) + validator.Type = awstypes.ValidatorType(v) } return validator } -func expandValidators(tfList []interface{}) []*appconfig.Validator { +func expandValidators(tfList []interface{}) []awstypes.Validator { // AppConfig API requires a 0 length slice instead of a nil value // when updating from N validators to 0/nil validators - validators := make([]*appconfig.Validator, 0) + validators := make([]awstypes.Validator, 0) for _, tfMapRaw := range tfList { tfMap, ok := tfMapRaw.(map[string]interface{}) @@ -335,36 +333,25 @@ func expandValidators(tfList []interface{}) []*appconfig.Validator { } validator := expandValidator(tfMap) - - if validator == nil { - continue - } - validators = append(validators, validator) } return validators } -func flattenValidator(validator *appconfig.Validator) map[string]interface{} { - if validator == nil { - return nil - } - +func flattenValidator(validator awstypes.Validator) map[string]interface{} { tfMap := map[string]interface{}{} if v := validator.Content; v != nil { - tfMap["content"] = aws.StringValue(v) + tfMap["content"] = aws.ToString(v) } - if v := validator.Type; v != nil { - tfMap["type"] = aws.StringValue(v) - } + tfMap["type"] = string(validator.Type) return tfMap } -func flattenValidators(validators []*appconfig.Validator) []interface{} { +func flattenValidators(validators []awstypes.Validator) []interface{} { if len(validators) == 0 { return nil } @@ -372,10 +359,6 @@ func flattenValidators(validators []*appconfig.Validator) []interface{} { var tfList []interface{} for _, validator := range validators { - if validator == nil { - continue - } - tfList = append(tfList, flattenValidator(validator)) } diff --git a/internal/service/appconfig/configuration_profile_data_source.go b/internal/service/appconfig/configuration_profile_data_source.go index 1ab63ea8bdb5..5d26eaaa017d 100644 --- a/internal/service/appconfig/configuration_profile_data_source.go +++ b/internal/service/appconfig/configuration_profile_data_source.go @@ -9,8 +9,8 @@ import ( "github.com/YakDriver/regexache" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -91,7 +91,7 @@ const ( func dataSourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appId := d.Get("application_id").(string) profileId := d.Get("configuration_profile_id").(string) @@ -143,8 +143,8 @@ func dataSourceConfigurationProfileRead(ctx context.Context, d *schema.ResourceD return diags } -func findConfigurationProfileByApplicationAndProfile(ctx context.Context, conn *appconfig.AppConfig, appId string, cpId string) (*appconfig.GetConfigurationProfileOutput, error) { - res, err := conn.GetConfigurationProfileWithContext(ctx, &appconfig.GetConfigurationProfileInput{ +func findConfigurationProfileByApplicationAndProfile(ctx context.Context, conn *appconfig.Client, appId string, cpId string) (*appconfig.GetConfigurationProfileOutput, error) { + res, err := conn.GetConfigurationProfile(ctx, &appconfig.GetConfigurationProfileInput{ ApplicationId: aws.String(appId), ConfigurationProfileId: aws.String(cpId), }) diff --git a/internal/service/appconfig/configuration_profile_data_source_test.go b/internal/service/appconfig/configuration_profile_data_source_test.go index d599748fe9cb..a0bb8b4dd4e0 100644 --- a/internal/service/appconfig/configuration_profile_data_source_test.go +++ b/internal/service/appconfig/configuration_profile_data_source_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -25,7 +25,7 @@ func TestAccAppConfigConfigurationProfileDataSource_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, appconfig.EndpointsID) + acctest.PreCheckPartitionHasService(t, names.AppConfigEndpointID) }, ErrorCheck: acctest.ErrorCheck(t, names.AppConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, @@ -46,7 +46,7 @@ func TestAccAppConfigConfigurationProfileDataSource_basic(t *testing.T) { resource.TestCheckResourceAttr(dataSourceName, "type", "AWS.Freeform"), resource.TestCheckTypeSetElemNestedAttrs(dataSourceName, "validator.*", map[string]string{ "content": "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", - "type": appconfig.ValidatorTypeJsonSchema, + "type": string(awstypes.ValidatorTypeJsonSchema), }), ), }, diff --git a/internal/service/appconfig/configuration_profile_test.go b/internal/service/appconfig/configuration_profile_test.go index 667301107e9f..1d6708c400dc 100644 --- a/internal/service/appconfig/configuration_profile_test.go +++ b/internal/service/appconfig/configuration_profile_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -118,7 +119,7 @@ func TestAccAppConfigConfigurationProfile_Validators_json(t *testing.T) { testAccCheckConfigurationProfileExists(ctx, resourceName), resource.TestCheckResourceAttr(resourceName, "validator.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ - "type": appconfig.ValidatorTypeJsonSchema, + "type": string(awstypes.ValidatorTypeJsonSchema), }), ), }, @@ -134,7 +135,7 @@ func TestAccAppConfigConfigurationProfile_Validators_json(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "validator.#", "1"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ "content": "", - "type": appconfig.ValidatorTypeJsonSchema, + "type": string(awstypes.ValidatorTypeJsonSchema), }), ), }, @@ -173,7 +174,7 @@ func TestAccAppConfigConfigurationProfile_Validators_lambda(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "validator.#", "1"), resource.TestCheckTypeSetElemAttrPair(resourceName, "validator.*.content", "aws_lambda_function.test", "arn"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ - "type": appconfig.ValidatorTypeLambda, + "type": string(awstypes.ValidatorTypeLambda), }), ), }, @@ -212,11 +213,11 @@ func TestAccAppConfigConfigurationProfile_Validators_multiple(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "validator.#", "2"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ "content": "{\"$schema\":\"http://json-schema.org/draft-05/schema#\",\"description\":\"BasicFeatureToggle-1\",\"title\":\"$id$\"}", - "type": appconfig.ValidatorTypeJsonSchema, + "type": string(awstypes.ValidatorTypeJsonSchema), }), resource.TestCheckTypeSetElemAttrPair(resourceName, "validator.*.content", "aws_lambda_function.test", "arn"), resource.TestCheckTypeSetElemNestedAttrs(resourceName, "validator.*", map[string]string{ - "type": appconfig.ValidatorTypeLambda, + "type": string(awstypes.ValidatorTypeLambda), }), ), }, @@ -351,7 +352,7 @@ func TestAccAppConfigConfigurationProfile_tags(t *testing.T) { func testAccCheckConfigurationProfileDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_configuration_profile" { @@ -369,9 +370,9 @@ func testAccCheckConfigurationProfileDestroy(ctx context.Context) resource.TestC ConfigurationProfileId: aws.String(confProfID), } - output, err := conn.GetConfigurationProfileWithContext(ctx, input) + output, err := conn.GetConfigurationProfile(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -405,9 +406,9 @@ func testAccCheckConfigurationProfileExists(ctx context.Context, resourceName st return err } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) - output, err := conn.GetConfigurationProfileWithContext(ctx, &appconfig.GetConfigurationProfileInput{ + output, err := conn.GetConfigurationProfile(ctx, &appconfig.GetConfigurationProfileInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), }) diff --git a/internal/service/appconfig/configuration_profiles_data_source.go b/internal/service/appconfig/configuration_profiles_data_source.go index 799564b6010c..8b5c10d82636 100644 --- a/internal/service/appconfig/configuration_profiles_data_source.go +++ b/internal/service/appconfig/configuration_profiles_data_source.go @@ -6,8 +6,9 @@ package appconfig import ( "context" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -40,7 +41,7 @@ const ( func dataSourceConfigurationProfilesRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appId := d.Get("application_id").(string) out, err := findConfigurationProfileSummariesByApplication(ctx, conn, appId) @@ -55,22 +56,23 @@ func dataSourceConfigurationProfilesRead(ctx context.Context, d *schema.Resource configIds = append(configIds, v.Id) } - d.Set("configuration_profile_ids", aws.StringValueSlice(configIds)) + d.Set("configuration_profile_ids", aws.ToStringSlice(configIds)) return diags } -func findConfigurationProfileSummariesByApplication(ctx context.Context, conn *appconfig.AppConfig, applicationId string) ([]*appconfig.ConfigurationProfileSummary, error) { - var outputs []*appconfig.ConfigurationProfileSummary - err := conn.ListConfigurationProfilesPagesWithContext(ctx, &appconfig.ListConfigurationProfilesInput{ +func findConfigurationProfileSummariesByApplication(ctx context.Context, conn *appconfig.Client, applicationId string) ([]awstypes.ConfigurationProfileSummary, error) { + var outputs []awstypes.ConfigurationProfileSummary + pages := appconfig.NewListConfigurationProfilesPaginator(conn, &appconfig.ListConfigurationProfilesInput{ ApplicationId: aws.String(applicationId), - }, func(output *appconfig.ListConfigurationProfilesOutput, lastPage bool) bool { - outputs = append(outputs, output.Items...) - return !lastPage }) - if err != nil { - return nil, err + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + if err != nil { + return nil, err + } + outputs = append(outputs, page.Items...) } return outputs, nil diff --git a/internal/service/appconfig/configuration_profiles_data_source_test.go b/internal/service/appconfig/configuration_profiles_data_source_test.go index 08d709eafb4e..09d70044d877 100644 --- a/internal/service/appconfig/configuration_profiles_data_source_test.go +++ b/internal/service/appconfig/configuration_profiles_data_source_test.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/appconfig" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -24,7 +23,7 @@ func TestAccAppConfigConfigurationProfilesDataSource_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, appconfig.EndpointsID) + acctest.PreCheckPartitionHasService(t, names.AppConfigEndpointID) }, ErrorCheck: acctest.ErrorCheck(t, names.AppConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/appconfig/deployment.go b/internal/service/appconfig/deployment.go index b917ca019f1e..07844d6b163f 100644 --- a/internal/service/appconfig/deployment.go +++ b/internal/service/appconfig/deployment.go @@ -11,14 +11,15 @@ import ( "strings" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -107,7 +108,7 @@ func ResourceDeployment() *schema.Resource { func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.StartDeploymentInput{ ApplicationId: aws.String(d.Get("application_id").(string)), @@ -123,7 +124,7 @@ func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta input.KmsKeyIdentifier = aws.String(v.(string)) } - output, err := conn.StartDeploymentWithContext(ctx, input) + output, err := conn.StartDeployment(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "starting AppConfig Deployment: %s", err) @@ -133,18 +134,17 @@ func resourceDeploymentCreate(ctx context.Context, d *schema.ResourceData, meta return sdkdiag.AppendErrorf(diags, "starting AppConfig Deployment: empty response") } - appID := aws.StringValue(output.ApplicationId) - envID := aws.StringValue(output.EnvironmentId) - deployNum := aws.Int64Value(output.DeploymentNumber) + appID := aws.ToString(output.ApplicationId) + envID := aws.ToString(output.EnvironmentId) - d.SetId(fmt.Sprintf("%s/%s/%d", appID, envID, deployNum)) + d.SetId(fmt.Sprintf("%s/%s/%d", appID, envID, output.DeploymentNumber)) return append(diags, resourceDeploymentRead(ctx, d, meta)...) } func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID, envID, deploymentNum, err := DeploymentParseID(d.Id()) @@ -154,13 +154,13 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta in input := &appconfig.GetDeploymentInput{ ApplicationId: aws.String(appID), - DeploymentNumber: aws.Int64(int64(deploymentNum)), + DeploymentNumber: aws.Int32(int32(deploymentNum)), EnvironmentId: aws.String(envID), } - output, err := conn.GetDeploymentWithContext(ctx, input) + output, err := conn.GetDeployment(ctx, input) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Appconfig Deployment (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -178,7 +178,7 @@ func resourceDeploymentRead(ctx context.Context, d *schema.ResourceData, meta in AccountID: meta.(*conns.AWSClient).AccountID, Partition: meta.(*conns.AWSClient).Partition, Region: meta.(*conns.AWSClient).Region, - Resource: fmt.Sprintf("application/%s/environment/%s/deployment/%d", aws.StringValue(output.ApplicationId), aws.StringValue(output.EnvironmentId), aws.Int64Value(output.DeploymentNumber)), + Resource: fmt.Sprintf("application/%s/environment/%s/deployment/%d", aws.ToString(output.ApplicationId), aws.ToString(output.EnvironmentId), output.DeploymentNumber), Service: "appconfig", }.String() diff --git a/internal/service/appconfig/deployment_strategy.go b/internal/service/appconfig/deployment_strategy.go index bf6e354e1052..7c558b74b2af 100644 --- a/internal/service/appconfig/deployment_strategy.go +++ b/internal/service/appconfig/deployment_strategy.go @@ -8,14 +8,16 @@ import ( "fmt" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/enum" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -60,10 +62,10 @@ func ResourceDeploymentStrategy() *schema.Resource { ValidateFunc: validation.FloatBetween(1.0, 100.0), }, "growth_type": { - Type: schema.TypeString, - Optional: true, - Default: appconfig.GrowthTypeLinear, - ValidateFunc: validation.StringInSlice(appconfig.GrowthType_Values(), false), + Type: schema.TypeString, + Optional: true, + Default: string(awstypes.GrowthTypeLinear), + ValidateDiagFunc: enum.Validate[awstypes.GrowthType](), }, "name": { Type: schema.TypeString, @@ -72,10 +74,10 @@ func ResourceDeploymentStrategy() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 64), }, "replicate_to": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringInSlice(appconfig.ReplicateTo_Values(), false), + Type: schema.TypeString, + Required: true, + ForceNew: true, + ValidateDiagFunc: enum.Validate[awstypes.ReplicateTo](), }, names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), @@ -86,15 +88,15 @@ func ResourceDeploymentStrategy() *schema.Resource { func resourceDeploymentStrategyCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) name := d.Get("name").(string) input := &appconfig.CreateDeploymentStrategyInput{ - DeploymentDurationInMinutes: aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))), - GrowthFactor: aws.Float64(d.Get("growth_factor").(float64)), - GrowthType: aws.String(d.Get("growth_type").(string)), + DeploymentDurationInMinutes: aws.Int32(int32(d.Get("deployment_duration_in_minutes").(int))), + GrowthFactor: aws.Float32(d.Get("growth_factor").(float32)), + GrowthType: awstypes.GrowthType(d.Get("growth_type").(string)), Name: aws.String(name), - ReplicateTo: aws.String(d.Get("replicate_to").(string)), + ReplicateTo: awstypes.ReplicateTo(d.Get("replicate_to").(string)), Tags: getTagsIn(ctx), } @@ -103,31 +105,31 @@ func resourceDeploymentStrategyCreate(ctx context.Context, d *schema.ResourceDat } if v, ok := d.GetOk("final_bake_time_in_minutes"); ok { - input.FinalBakeTimeInMinutes = aws.Int64(int64(v.(int))) + input.FinalBakeTimeInMinutes = int32(v.(int)) } - strategy, err := conn.CreateDeploymentStrategyWithContext(ctx, input) + strategy, err := conn.CreateDeploymentStrategy(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating AppConfig Deployment Strategy (%s): %s", name, err) } - d.SetId(aws.StringValue(strategy.Id)) + d.SetId(aws.ToString(strategy.Id)) return append(diags, resourceDeploymentStrategyRead(ctx, d, meta)...) } func resourceDeploymentStrategyRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetDeploymentStrategyInput{ DeploymentStrategyId: aws.String(d.Id()), } - output, err := conn.GetDeploymentStrategyWithContext(ctx, input) + output, err := conn.GetDeploymentStrategy(ctx, input) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Appconfig Deployment Strategy (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -163,7 +165,7 @@ func resourceDeploymentStrategyRead(ctx context.Context, d *schema.ResourceData, func resourceDeploymentStrategyUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) if d.HasChangesExcept("tags", "tags_all") { updateInput := &appconfig.UpdateDeploymentStrategyInput{ @@ -171,7 +173,7 @@ func resourceDeploymentStrategyUpdate(ctx context.Context, d *schema.ResourceDat } if d.HasChange("deployment_duration_in_minutes") { - updateInput.DeploymentDurationInMinutes = aws.Int64(int64(d.Get("deployment_duration_in_minutes").(int))) + updateInput.DeploymentDurationInMinutes = aws.Int32(int32(d.Get("deployment_duration_in_minutes").(int))) } if d.HasChange("description") { @@ -179,18 +181,18 @@ func resourceDeploymentStrategyUpdate(ctx context.Context, d *schema.ResourceDat } if d.HasChange("final_bake_time_in_minutes") { - updateInput.FinalBakeTimeInMinutes = aws.Int64(int64(d.Get("final_bake_time_in_minutes").(int))) + updateInput.FinalBakeTimeInMinutes = aws.Int32(int32(d.Get("final_bake_time_in_minutes").(int))) } if d.HasChange("growth_factor") { - updateInput.GrowthFactor = aws.Float64(d.Get("growth_factor").(float64)) + updateInput.GrowthFactor = aws.Float32(d.Get("growth_factor").(float32)) } if d.HasChange("growth_type") { - updateInput.GrowthType = aws.String(d.Get("growth_type").(string)) + updateInput.GrowthType = awstypes.GrowthType(d.Get("growth_type").(string)) } - _, err := conn.UpdateDeploymentStrategyWithContext(ctx, updateInput) + _, err := conn.UpdateDeploymentStrategy(ctx, updateInput) if err != nil { return sdkdiag.AppendErrorf(diags, "updating AppConfig Deployment Strategy (%s): %s", d.Id(), err) @@ -202,14 +204,14 @@ func resourceDeploymentStrategyUpdate(ctx context.Context, d *schema.ResourceDat func resourceDeploymentStrategyDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) log.Printf("[INFO] Deleting AppConfig Deployment Strategy: %s", d.Id()) - _, err := conn.DeleteDeploymentStrategyWithContext(ctx, &appconfig.DeleteDeploymentStrategyInput{ + _, err := conn.DeleteDeploymentStrategy(ctx, &appconfig.DeleteDeploymentStrategyInput{ DeploymentStrategyId: aws.String(d.Id()), }) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } diff --git a/internal/service/appconfig/deployment_strategy_test.go b/internal/service/appconfig/deployment_strategy_test.go index 11220efd624e..395c3b7a81fb 100644 --- a/internal/service/appconfig/deployment_strategy_test.go +++ b/internal/service/appconfig/deployment_strategy_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -40,7 +41,7 @@ func TestAccAppConfigDeploymentStrategy_basic(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "deployment_duration_in_minutes", "3"), resource.TestCheckResourceAttr(resourceName, "growth_factor", "10"), resource.TestCheckResourceAttr(resourceName, "name", rName), - resource.TestCheckResourceAttr(resourceName, "replicate_to", appconfig.ReplicateToNone), + resource.TestCheckResourceAttr(resourceName, "replicate_to", string(awstypes.ReplicateToNone)), resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), ), }, @@ -204,7 +205,7 @@ func TestAccAppConfigDeploymentStrategy_tags(t *testing.T) { func testAccCheckDeploymentStrategyDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_deployment_strategy" { @@ -215,9 +216,9 @@ func testAccCheckDeploymentStrategyDestroy(ctx context.Context) resource.TestChe DeploymentStrategyId: aws.String(rs.Primary.ID), } - output, err := conn.GetDeploymentStrategyWithContext(ctx, input) + output, err := conn.GetDeploymentStrategy(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -245,13 +246,13 @@ func testAccCheckDeploymentStrategyExists(ctx context.Context, resourceName stri return fmt.Errorf("Resource (%s) ID not set", resourceName) } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetDeploymentStrategyInput{ DeploymentStrategyId: aws.String(rs.Primary.ID), } - output, err := conn.GetDeploymentStrategyWithContext(ctx, input) + output, err := conn.GetDeploymentStrategy(ctx, input) if err != nil { return fmt.Errorf("error getting Appconfig Deployment Strategy (%s): %w", rs.Primary.ID, err) diff --git a/internal/service/appconfig/deployment_test.go b/internal/service/appconfig/deployment_test.go index f9fc93ae9c38..a801ab316fc6 100644 --- a/internal/service/appconfig/deployment_test.go +++ b/internal/service/appconfig/deployment_test.go @@ -9,8 +9,8 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" @@ -199,15 +199,15 @@ func testAccCheckDeploymentExists(ctx context.Context, resourceName string) reso return err } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetDeploymentInput{ ApplicationId: aws.String(appID), - DeploymentNumber: aws.Int64(int64(deploymentNum)), + DeploymentNumber: aws.Int32(int32(deploymentNum)), EnvironmentId: aws.String(envID), } - output, err := conn.GetDeploymentWithContext(ctx, input) + output, err := conn.GetDeployment(ctx, input) if err != nil { return fmt.Errorf("error getting Appconfig Deployment (%s): %w", rs.Primary.ID, err) diff --git a/internal/service/appconfig/environment.go b/internal/service/appconfig/environment.go index e5ca16ef4935..96ee77124c2a 100644 --- a/internal/service/appconfig/environment.go +++ b/internal/service/appconfig/environment.go @@ -157,7 +157,7 @@ func (r *resourceEnvironment) Create(ctx context.Context, request resource.Creat input := &appconfig.CreateEnvironmentInput{ Name: aws.String(plan.Name.ValueString()), ApplicationId: aws.String(appId), - Tags: aws.ToStringMap(getTagsIn(ctx)), + Tags: getTagsIn(ctx), Monitors: expandMonitors(monitors), } diff --git a/internal/service/appconfig/environment_data_source.go b/internal/service/appconfig/environment_data_source.go index 45f047146c7a..6c6a0daafc11 100644 --- a/internal/service/appconfig/environment_data_source.go +++ b/internal/service/appconfig/environment_data_source.go @@ -8,8 +8,9 @@ import ( "fmt" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -78,7 +79,7 @@ const ( func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID := d.Get("application_id").(string) envID := d.Get("environment_id").(string) @@ -122,8 +123,8 @@ func dataSourceEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta return diags } -func findEnvironmentByApplicationAndEnvironment(ctx context.Context, conn *appconfig.AppConfig, appId string, envId string) (*appconfig.GetEnvironmentOutput, error) { - res, err := conn.GetEnvironmentWithContext(ctx, &appconfig.GetEnvironmentInput{ +func findEnvironmentByApplicationAndEnvironment(ctx context.Context, conn *appconfig.Client, appId string, envId string) (*appconfig.GetEnvironmentOutput, error) { + res, err := conn.GetEnvironment(ctx, &appconfig.GetEnvironmentInput{ ApplicationId: aws.String(appId), EnvironmentId: aws.String(envId), }) @@ -135,7 +136,7 @@ func findEnvironmentByApplicationAndEnvironment(ctx context.Context, conn *appco return res, nil } -func flattenEnvironmentMonitors(monitors []*appconfig.Monitor) []interface{} { +func flattenEnvironmentMonitors(monitors []awstypes.Monitor) []interface{} { if len(monitors) == 0 { return nil } @@ -143,29 +144,21 @@ func flattenEnvironmentMonitors(monitors []*appconfig.Monitor) []interface{} { var tfList []interface{} for _, monitor := range monitors { - if monitor == nil { - continue - } - tfList = append(tfList, flattenEnvironmentMonitor(monitor)) } return tfList } -func flattenEnvironmentMonitor(monitor *appconfig.Monitor) map[string]interface{} { - if monitor == nil { - return nil - } - +func flattenEnvironmentMonitor(monitor awstypes.Monitor) map[string]interface{} { tfMap := map[string]interface{}{} if v := monitor.AlarmArn; v != nil { - tfMap["alarm_arn"] = aws.StringValue(v) + tfMap["alarm_arn"] = aws.ToString(v) } if v := monitor.AlarmRoleArn; v != nil { - tfMap["alarm_role_arn"] = aws.StringValue(v) + tfMap["alarm_role_arn"] = aws.ToString(v) } return tfMap diff --git a/internal/service/appconfig/environment_data_source_test.go b/internal/service/appconfig/environment_data_source_test.go index 111a05493233..abaa73ee6ec9 100644 --- a/internal/service/appconfig/environment_data_source_test.go +++ b/internal/service/appconfig/environment_data_source_test.go @@ -8,7 +8,6 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/service/appconfig" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -25,7 +24,7 @@ func TestAccAppConfigEnvironmentDataSource_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, appconfig.EndpointsID) + acctest.PreCheckPartitionHasService(t, names.AppConfigEndpointID) }, ErrorCheck: acctest.ErrorCheck(t, names.AppConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/appconfig/environment_test.go b/internal/service/appconfig/environment_test.go index bf54b4e0eae1..8e0846f2e431 100644 --- a/internal/service/appconfig/environment_test.go +++ b/internal/service/appconfig/environment_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -400,7 +401,7 @@ func TestAccAppConfigEnvironment_frameworkMigration_monitors(t *testing.T) { func testAccCheckEnvironmentDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_environment" { @@ -415,9 +416,9 @@ func testAccCheckEnvironmentDestroy(ctx context.Context) resource.TestCheckFunc EnvironmentId: aws.String(envID), } - output, err := conn.GetEnvironmentWithContext(ctx, input) + output, err := conn.GetEnvironment(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -448,14 +449,14 @@ func testAccCheckEnvironmentExists(ctx context.Context, resourceName string) res appID := rs.Primary.Attributes["application_id"] envID := rs.Primary.Attributes["environment_id"] - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) input := &appconfig.GetEnvironmentInput{ ApplicationId: aws.String(appID), EnvironmentId: aws.String(envID), } - output, err := conn.GetEnvironmentWithContext(ctx, input) + output, err := conn.GetEnvironment(ctx, input) if err != nil { return fmt.Errorf("reading AppConfig Environment (%s) for Application (%s): %w", envID, appID, err) diff --git a/internal/service/appconfig/environments_data_source.go b/internal/service/appconfig/environments_data_source.go index 32d6d0cce7c1..5eddc29fba92 100644 --- a/internal/service/appconfig/environments_data_source.go +++ b/internal/service/appconfig/environments_data_source.go @@ -7,8 +7,9 @@ import ( "context" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -43,7 +44,7 @@ const ( func dataSourceEnvironmentsRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID := d.Get("application_id").(string) out, err := findEnvironmentsByApplication(ctx, conn, appID) @@ -57,23 +58,25 @@ func dataSourceEnvironmentsRead(ctx context.Context, d *schema.ResourceData, met for _, v := range out { environmentIds = append(environmentIds, v.Id) } - d.Set("environment_ids", aws.StringValueSlice(environmentIds)) + d.Set("environment_ids", aws.ToStringSlice(environmentIds)) return diags } -func findEnvironmentsByApplication(ctx context.Context, conn *appconfig.AppConfig, appId string) ([]*appconfig.Environment, error) { - var outputs []*appconfig.Environment - err := conn.ListEnvironmentsPagesWithContext(ctx, &appconfig.ListEnvironmentsInput{ - ApplicationId: aws.String(appId), - }, func(output *appconfig.ListEnvironmentsOutput, lastPage bool) bool { - outputs = append(outputs, output.Items...) +func findEnvironmentsByApplication(ctx context.Context, conn *appconfig.Client, appId string) ([]awstypes.Environment, error) { + var outputs []awstypes.Environment - return !lastPage + pages := appconfig.NewListEnvironmentsPaginator(conn, &appconfig.ListEnvironmentsInput{ + ApplicationId: aws.String(appId), }) - if err != nil { - return nil, err + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + if err != nil { + return nil, err + } + + outputs = append(outputs, page.Items...) } return outputs, nil diff --git a/internal/service/appconfig/environments_data_source_test.go b/internal/service/appconfig/environments_data_source_test.go index e03add2d7500..30914f24b469 100644 --- a/internal/service/appconfig/environments_data_source_test.go +++ b/internal/service/appconfig/environments_data_source_test.go @@ -7,7 +7,6 @@ import ( "fmt" "testing" - "github.com/aws/aws-sdk-go/service/appconfig" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/acctest" @@ -24,7 +23,7 @@ func TestAccAppConfigEnvironmentsDataSource_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(ctx, t) - acctest.PreCheckPartitionHasService(t, appconfig.EndpointsID) + acctest.PreCheckPartitionHasService(t, names.AppConfigEndpointID) }, ErrorCheck: acctest.ErrorCheck(t, names.AppConfigServiceID), ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories, diff --git a/internal/service/appconfig/extension.go b/internal/service/appconfig/extension.go index 73c4905ca6cc..e89c0ca3a8cf 100644 --- a/internal/service/appconfig/extension.go +++ b/internal/service/appconfig/extension.go @@ -7,13 +7,14 @@ import ( "context" "errors" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/enum" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -49,9 +50,9 @@ func ResourceExtension() *schema.Resource { Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "point": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice(appconfig.ActionPoint_Values(), false), + Type: schema.TypeString, + Required: true, + ValidateDiagFunc: enum.Validate[awstypes.ActionPoint](), }, "action": { Type: schema.TypeSet, @@ -126,7 +127,7 @@ func ResourceExtension() *schema.Resource { func resourceExtensionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) in := appconfig.CreateExtensionInput{ Actions: expandExtensionActionPoints(d.Get("action_point").(*schema.Set).List()), @@ -142,7 +143,7 @@ func resourceExtensionCreate(ctx context.Context, d *schema.ResourceData, meta i in.Parameters = expandExtensionParameters(v.(*schema.Set).List()) } - out, err := conn.CreateExtensionWithContext(ctx, &in) + out, err := conn.CreateExtension(ctx, &in) if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionCreating, ResExtension, d.Get("name").(string), err) @@ -152,7 +153,7 @@ func resourceExtensionCreate(ctx context.Context, d *schema.ResourceData, meta i return create.AppendDiagError(diags, names.AppConfig, create.ErrActionCreating, ResExtension, d.Get("name").(string), errors.New("No Extension returned with create request.")) } - d.SetId(aws.StringValue(out.Id)) + d.SetId(aws.ToString(out.Id)) return append(diags, resourceExtensionRead(ctx, d, meta)...) } @@ -160,7 +161,7 @@ func resourceExtensionCreate(ctx context.Context, d *schema.ResourceData, meta i func resourceExtensionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) out, err := FindExtensionById(ctx, conn, d.Id()) @@ -187,7 +188,7 @@ func resourceExtensionRead(ctx context.Context, d *schema.ResourceData, meta int func resourceExtensionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) requestUpdate := false in := &appconfig.UpdateExtensionInput{ @@ -210,7 +211,7 @@ func resourceExtensionUpdate(ctx context.Context, d *schema.ResourceData, meta i } if requestUpdate { - out, err := conn.UpdateExtensionWithContext(ctx, in) + out, err := conn.UpdateExtension(ctx, in) if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionWaitingForUpdate, ResExtension, d.Get("name").(string), err) @@ -227,9 +228,9 @@ func resourceExtensionUpdate(ctx context.Context, d *schema.ResourceData, meta i func resourceExtensionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) - _, err := conn.DeleteExtensionWithContext(ctx, &appconfig.DeleteExtensionInput{ + _, err := conn.DeleteExtension(ctx, &appconfig.DeleteExtensionInput{ ExtensionIdentifier: aws.String(d.Id()), }) @@ -240,8 +241,8 @@ func resourceExtensionDelete(ctx context.Context, d *schema.ResourceData, meta i return diags } -func expandExtensionActions(actionsListRaw interface{}) []*appconfig.Action { - var actions []*appconfig.Action +func expandExtensionActions(actionsListRaw interface{}) []awstypes.Action { + var actions []awstypes.Action for _, actionRaw := range actionsListRaw.(*schema.Set).List() { actionMap, ok := actionRaw.(map[string]interface{}) @@ -249,7 +250,7 @@ func expandExtensionActions(actionsListRaw interface{}) []*appconfig.Action { continue } - action := &appconfig.Action{ + action := awstypes.Action{ Description: aws.String(actionMap["description"].(string)), Name: aws.String(actionMap["name"].(string)), RoleArn: aws.String(actionMap["role_arn"].(string)), @@ -262,12 +263,12 @@ func expandExtensionActions(actionsListRaw interface{}) []*appconfig.Action { return actions } -func expandExtensionActionPoints(actionsPointListRaw []interface{}) map[string][]*appconfig.Action { +func expandExtensionActionPoints(actionsPointListRaw []interface{}) map[string][]awstypes.Action { if len(actionsPointListRaw) == 0 { - return map[string][]*appconfig.Action{} + return map[string][]awstypes.Action{} } - actionsMap := make(map[string][]*appconfig.Action) + actionsMap := make(map[string][]awstypes.Action) for _, actionPointRaw := range actionsPointListRaw { actionPointMap := actionPointRaw.(map[string]interface{}) actionsMap[actionPointMap["point"].(string)] = expandExtensionActions(actionPointMap["action"]) @@ -276,12 +277,12 @@ func expandExtensionActionPoints(actionsPointListRaw []interface{}) map[string][ return actionsMap } -func expandExtensionParameters(rawParameters []interface{}) map[string]*appconfig.Parameter { +func expandExtensionParameters(rawParameters []interface{}) map[string]awstypes.Parameter { if rawParameters == nil { return nil } - parameters := make(map[string]*appconfig.Parameter) + parameters := make(map[string]awstypes.Parameter) for _, rawParameterMap := range rawParameters { parameterMap, ok := rawParameterMap.(map[string]interface{}) @@ -290,9 +291,9 @@ func expandExtensionParameters(rawParameters []interface{}) map[string]*appconfi continue } - parameter := &appconfig.Parameter{ + parameter := awstypes.Parameter{ Description: aws.String(parameterMap["description"].(string)), - Required: aws.Bool(parameterMap["required"].(bool)), + Required: parameterMap["required"].(bool), } parameters[parameterMap["name"].(string)] = parameter } @@ -300,21 +301,21 @@ func expandExtensionParameters(rawParameters []interface{}) map[string]*appconfi return parameters } -func flattenExtensionActions(actions []*appconfig.Action) []interface{} { +func flattenExtensionActions(actions []awstypes.Action) []interface{} { var rawActions []interface{} for _, action := range actions { rawAction := map[string]interface{}{ - "name": aws.StringValue(action.Name), - "description": aws.StringValue(action.Description), - "role_arn": aws.StringValue(action.RoleArn), - "uri": aws.StringValue(action.Uri), + "name": aws.ToString(action.Name), + "description": aws.ToString(action.Description), + "role_arn": aws.ToString(action.RoleArn), + "uri": aws.ToString(action.Uri), } rawActions = append(rawActions, rawAction) } return rawActions } -func flattenExtensionActionPoints(actionPointsMap map[string][]*appconfig.Action) []interface{} { +func flattenExtensionActionPoints(actionPointsMap map[string][]awstypes.Action) []interface{} { if len(actionPointsMap) == 0 { return nil } @@ -331,7 +332,7 @@ func flattenExtensionActionPoints(actionPointsMap map[string][]*appconfig.Action return rawActionPoints } -func flattenExtensionParameters(parameters map[string]*appconfig.Parameter) []interface{} { +func flattenExtensionParameters(parameters map[string]awstypes.Parameter) []interface{} { if len(parameters) == 0 { return nil } @@ -340,8 +341,8 @@ func flattenExtensionParameters(parameters map[string]*appconfig.Parameter) []in for key, parameter := range parameters { rawParameter := map[string]interface{}{ "name": key, - "description": aws.StringValue(parameter.Description), - "required": aws.BoolValue(parameter.Required), + "description": aws.ToString(parameter.Description), + "required": parameter.Required, } rawParameters = append(rawParameters, rawParameter) diff --git a/internal/service/appconfig/extension_association.go b/internal/service/appconfig/extension_association.go index a6c0ff819ee1..7b1af0f8a4b6 100644 --- a/internal/service/appconfig/extension_association.go +++ b/internal/service/appconfig/extension_association.go @@ -8,8 +8,8 @@ import ( "errors" "log" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" @@ -66,7 +66,7 @@ func ResourceExtensionAssociation() *schema.Resource { func resourceExtensionAssociationCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) in := appconfig.CreateExtensionAssociationInput{ ExtensionIdentifier: aws.String(d.Get("extension_arn").(string)), @@ -74,10 +74,10 @@ func resourceExtensionAssociationCreate(ctx context.Context, d *schema.ResourceD } if v, ok := d.GetOk("parameters"); ok { - in.Parameters = flex.ExpandStringMap(v.(map[string]interface{})) + in.Parameters = flex.ExpandStringValueMap(v.(map[string]interface{})) } - out, err := conn.CreateExtensionAssociationWithContext(ctx, &in) + out, err := conn.CreateExtensionAssociation(ctx, &in) if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionCreating, ResExtensionAssociation, d.Get("extension_arn").(string), err) @@ -87,7 +87,7 @@ func resourceExtensionAssociationCreate(ctx context.Context, d *schema.ResourceD return create.AppendDiagError(diags, names.AppConfig, create.ErrActionCreating, ResExtensionAssociation, d.Get("extension_arn").(string), errors.New("No Extension Association returned with create request.")) } - d.SetId(aws.StringValue(out.Id)) + d.SetId(aws.ToString(out.Id)) return append(diags, resourceExtensionAssociationRead(ctx, d, meta)...) } @@ -95,7 +95,7 @@ func resourceExtensionAssociationCreate(ctx context.Context, d *schema.ResourceD func resourceExtensionAssociationRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) out, err := FindExtensionAssociationById(ctx, conn, d.Id()) @@ -121,7 +121,7 @@ func resourceExtensionAssociationRead(ctx context.Context, d *schema.ResourceDat func resourceExtensionAssociationUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) requestUpdate := false in := &appconfig.UpdateExtensionAssociationInput{ @@ -129,12 +129,12 @@ func resourceExtensionAssociationUpdate(ctx context.Context, d *schema.ResourceD } if d.HasChange("parameters") { - in.Parameters = flex.ExpandStringMap(d.Get("parameters").(map[string]interface{})) + in.Parameters = flex.ExpandStringValueMap(d.Get("parameters").(map[string]interface{})) requestUpdate = true } if requestUpdate { - out, err := conn.UpdateExtensionAssociationWithContext(ctx, in) + out, err := conn.UpdateExtensionAssociation(ctx, in) if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionWaitingForUpdate, ResExtensionAssociation, d.Id(), err) @@ -151,10 +151,10 @@ func resourceExtensionAssociationUpdate(ctx context.Context, d *schema.ResourceD func resourceExtensionAssociationDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) log.Printf("[INFO] Deleting AppConfig Hosted Extension Association: %s", d.Id()) - _, err := conn.DeleteExtensionAssociationWithContext(ctx, &appconfig.DeleteExtensionAssociationInput{ + _, err := conn.DeleteExtensionAssociation(ctx, &appconfig.DeleteExtensionAssociationInput{ ExtensionAssociationId: aws.String(d.Id()), }) diff --git a/internal/service/appconfig/extension_test.go b/internal/service/appconfig/extension_test.go index 5ee62529614e..cf2da8eb22cb 100644 --- a/internal/service/appconfig/extension_test.go +++ b/internal/service/appconfig/extension_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -326,7 +327,7 @@ func TestAccAppConfigExtension_disappears(t *testing.T) { func testAccCheckExtensionDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_environment" { @@ -337,9 +338,9 @@ func testAccCheckExtensionDestroy(ctx context.Context) resource.TestCheckFunc { ExtensionIdentifier: aws.String(rs.Primary.ID), } - output, err := conn.GetExtensionWithContext(ctx, input) + output, err := conn.GetExtension(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -367,13 +368,13 @@ func testAccCheckExtensionExists(ctx context.Context, resourceName string) resou return fmt.Errorf("Resource (%s) ID not set", resourceName) } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) in := &appconfig.GetExtensionInput{ ExtensionIdentifier: aws.String(rs.Primary.ID), } - output, err := conn.GetExtensionWithContext(ctx, in) + output, err := conn.GetExtension(ctx, in) if err != nil { return fmt.Errorf("error reading AppConfig Extension (%s): %w", rs.Primary.ID, err) diff --git a/internal/service/appconfig/extenstion_association_test.go b/internal/service/appconfig/extenstion_association_test.go index 318e7145a9b7..49d65dbfb403 100644 --- a/internal/service/appconfig/extenstion_association_test.go +++ b/internal/service/appconfig/extenstion_association_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -134,7 +135,7 @@ func TestAccAppConfigExtensionAssociation_disappears(t *testing.T) { func testAccCheckExtensionAssociationDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_environment" { @@ -145,9 +146,9 @@ func testAccCheckExtensionAssociationDestroy(ctx context.Context) resource.TestC ExtensionAssociationId: aws.String(rs.Primary.ID), } - output, err := conn.GetExtensionAssociationWithContext(ctx, input) + output, err := conn.GetExtensionAssociation(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -175,13 +176,13 @@ func testAccCheckExtensionAssociationExists(ctx context.Context, resourceName st return fmt.Errorf("Resource (%s) ID not set", resourceName) } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) in := &appconfig.GetExtensionAssociationInput{ ExtensionAssociationId: aws.String(rs.Primary.ID), } - output, err := conn.GetExtensionAssociationWithContext(ctx, in) + output, err := conn.GetExtensionAssociation(ctx, in) if err != nil { return fmt.Errorf("error reading AppConfig ExtensionAssociation (%s): %w", rs.Primary.ID, err) diff --git a/internal/service/appconfig/find.go b/internal/service/appconfig/find.go index baf17375f816..597ade47c4ce 100644 --- a/internal/service/appconfig/find.go +++ b/internal/service/appconfig/find.go @@ -6,18 +6,19 @@ package appconfig import ( "context" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" ) -func FindExtensionById(ctx context.Context, conn *appconfig.AppConfig, id string) (*appconfig.GetExtensionOutput, error) { +func FindExtensionById(ctx context.Context, conn *appconfig.Client, id string) (*appconfig.GetExtensionOutput, error) { in := &appconfig.GetExtensionInput{ExtensionIdentifier: aws.String(id)} - out, err := conn.GetExtensionWithContext(ctx, in) + out, err := conn.GetExtension(ctx, in) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return nil, &retry.NotFoundError{ LastError: err, LastRequest: in, @@ -35,11 +36,11 @@ func FindExtensionById(ctx context.Context, conn *appconfig.AppConfig, id string return out, nil } -func FindExtensionAssociationById(ctx context.Context, conn *appconfig.AppConfig, id string) (*appconfig.GetExtensionAssociationOutput, error) { +func FindExtensionAssociationById(ctx context.Context, conn *appconfig.Client, id string) (*appconfig.GetExtensionAssociationOutput, error) { in := &appconfig.GetExtensionAssociationInput{ExtensionAssociationId: aws.String(id)} - out, err := conn.GetExtensionAssociationWithContext(ctx, in) + out, err := conn.GetExtensionAssociation(ctx, in) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return nil, &retry.NotFoundError{ LastError: err, LastRequest: in, diff --git a/internal/service/appconfig/generate.go b/internal/service/appconfig/generate.go index ced958f80c8c..5f3d0d0434ec 100644 --- a/internal/service/appconfig/generate.go +++ b/internal/service/appconfig/generate.go @@ -1,7 +1,7 @@ // Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: MPL-2.0 -//go:generate go run ../../generate/tags/main.go -ListTags -ServiceTagsMap -UpdateTags +//go:generate go run ../../generate/tags/main.go -AWSSDKVersion=2 -ListTags -ServiceTagsMap -UpdateTags -KVTValues -SkipTypesImp //go:generate go run ../../generate/servicepackage/main.go // ONLY generate directives and package declaration! Do not add anything else to this file. diff --git a/internal/service/appconfig/hosted_configuration_version.go b/internal/service/appconfig/hosted_configuration_version.go index b3a38d1c248a..eaa0e05ff676 100644 --- a/internal/service/appconfig/hosted_configuration_version.go +++ b/internal/service/appconfig/hosted_configuration_version.go @@ -11,14 +11,15 @@ import ( "strings" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/aws/arn" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/arn" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "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" "github.com/hashicorp/terraform-provider-aws/internal/errs/sdkdiag" ) @@ -77,7 +78,7 @@ func ResourceHostedConfigurationVersion() *schema.Resource { func resourceHostedConfigurationVersionCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID := d.Get("application_id").(string) profileID := d.Get("configuration_profile_id").(string) @@ -93,20 +94,20 @@ func resourceHostedConfigurationVersionCreate(ctx context.Context, d *schema.Res input.Description = aws.String(v.(string)) } - output, err := conn.CreateHostedConfigurationVersionWithContext(ctx, input) + output, err := conn.CreateHostedConfigurationVersion(ctx, input) if err != nil { return sdkdiag.AppendErrorf(diags, "creating AppConfig HostedConfigurationVersion for Application (%s): %s", appID, err) } - d.SetId(fmt.Sprintf("%s/%s/%d", aws.StringValue(output.ApplicationId), aws.StringValue(output.ConfigurationProfileId), aws.Int64Value(output.VersionNumber))) + d.SetId(fmt.Sprintf("%s/%s/%d", aws.ToString(output.ApplicationId), aws.ToString(output.ConfigurationProfileId), output.VersionNumber)) return append(diags, resourceHostedConfigurationVersionRead(ctx, d, meta)...) } func resourceHostedConfigurationVersionRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID, confProfID, versionNumber, err := HostedConfigurationVersionParseID(d.Id()) @@ -117,12 +118,12 @@ func resourceHostedConfigurationVersionRead(ctx context.Context, d *schema.Resou input := &appconfig.GetHostedConfigurationVersionInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), - VersionNumber: aws.Int64(int64(versionNumber)), + VersionNumber: aws.Int32(int32(versionNumber)), } - output, err := conn.GetHostedConfigurationVersionWithContext(ctx, input) + output, err := conn.GetHostedConfigurationVersion(ctx, input) - if !d.IsNewResource() && tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if !d.IsNewResource() && errs.IsA[*awstypes.ResourceNotFoundException](err) { log.Printf("[WARN] Appconfig Hosted Configuration Version (%s) not found, removing from state", d.Id()) d.SetId("") return diags @@ -158,7 +159,7 @@ func resourceHostedConfigurationVersionRead(ctx context.Context, d *schema.Resou func resourceHostedConfigurationVersionDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { var diags diag.Diagnostics - conn := meta.(*conns.AWSClient).AppConfigConn(ctx) + conn := meta.(*conns.AWSClient).AppConfigClient(ctx) appID, confProfID, versionNumber, err := HostedConfigurationVersionParseID(d.Id()) if err != nil { @@ -166,13 +167,13 @@ func resourceHostedConfigurationVersionDelete(ctx context.Context, d *schema.Res } log.Printf("[INFO] Deleting AppConfig Hosted Configuration Version: %s", d.Id()) - _, err = conn.DeleteHostedConfigurationVersionWithContext(ctx, &appconfig.DeleteHostedConfigurationVersionInput{ + _, err = conn.DeleteHostedConfigurationVersion(ctx, &appconfig.DeleteHostedConfigurationVersionInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), - VersionNumber: aws.Int64(int64(versionNumber)), + VersionNumber: aws.Int32(int32(versionNumber)), }) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { return diags } diff --git a/internal/service/appconfig/hosted_configuration_version_test.go b/internal/service/appconfig/hosted_configuration_version_test.go index 58377dd68dda..b2c4f24713a5 100644 --- a/internal/service/appconfig/hosted_configuration_version_test.go +++ b/internal/service/appconfig/hosted_configuration_version_test.go @@ -9,14 +9,15 @@ import ( "testing" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" sdkacctest "github.com/hashicorp/terraform-plugin-testing/helper/acctest" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" "github.com/hashicorp/terraform-provider-aws/internal/acctest" "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tfappconfig "github.com/hashicorp/terraform-provider-aws/internal/service/appconfig" "github.com/hashicorp/terraform-provider-aws/names" ) @@ -79,7 +80,7 @@ func TestAccAppConfigHostedConfigurationVersion_disappears(t *testing.T) { func testAccCheckHostedConfigurationVersionDestroy(ctx context.Context) resource.TestCheckFunc { return func(s *terraform.State) error { - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) for _, rs := range s.RootModule().Resources { if rs.Type != "aws_appconfig_hosted_configuration_version" { @@ -95,12 +96,12 @@ func testAccCheckHostedConfigurationVersionDestroy(ctx context.Context) resource input := &appconfig.GetHostedConfigurationVersionInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), - VersionNumber: aws.Int64(int64(versionNumber)), + VersionNumber: aws.Int32(int32(versionNumber)), } - output, err := conn.GetHostedConfigurationVersionWithContext(ctx, input) + output, err := conn.GetHostedConfigurationVersion(ctx, input) - if tfawserr.ErrCodeEquals(err, appconfig.ErrCodeResourceNotFoundException) { + if errs.IsA[*awstypes.ResourceNotFoundException](err) { continue } @@ -134,12 +135,12 @@ func testAccCheckHostedConfigurationVersionExists(ctx context.Context, resourceN return err } - conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigConn(ctx) + conn := acctest.Provider.Meta().(*conns.AWSClient).AppConfigClient(ctx) - output, err := conn.GetHostedConfigurationVersionWithContext(ctx, &appconfig.GetHostedConfigurationVersionInput{ + output, err := conn.GetHostedConfigurationVersion(ctx, &appconfig.GetHostedConfigurationVersionInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(confProfID), - VersionNumber: aws.Int64(int64(versionNumber)), + VersionNumber: aws.Int32(int32(versionNumber)), }) if err != nil { diff --git a/internal/service/appconfig/service_endpoints_gen_test.go b/internal/service/appconfig/service_endpoints_gen_test.go index f6e53b7c48e9..6f94e38d2abb 100644 --- a/internal/service/appconfig/service_endpoints_gen_test.go +++ b/internal/service/appconfig/service_endpoints_gen_test.go @@ -15,7 +15,6 @@ import ( aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" appconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/appconfig" - appconfig_sdkv1 "github.com/aws/aws-sdk-go/service/appconfig" "github.com/aws/smithy-go/middleware" smithyhttp "github.com/aws/smithy-go/transport/http" "github.com/google/go-cmp/cmp" @@ -203,25 +202,13 @@ func TestEndpointConfiguration(t *testing.T) { //nolint:paralleltest // uses t.S }, } - t.Run("v1", func(t *testing.T) { - for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv - testcase := testcase + for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv + testcase := testcase - t.Run(name, func(t *testing.T) { - testEndpointCase(t, region, testcase, callServiceV1) - }) - } - }) - - t.Run("v2", func(t *testing.T) { - for name, testcase := range testcases { //nolint:paralleltest // uses t.Setenv - testcase := testcase - - t.Run(name, func(t *testing.T) { - testEndpointCase(t, region, testcase, callServiceV2) - }) - } - }) + t.Run(name, func(t *testing.T) { + testEndpointCase(t, region, testcase, callService) + }) + } } func defaultEndpoint(region string) string { @@ -241,7 +228,7 @@ func defaultEndpoint(region string) string { return ep.URI.String() } -func callServiceV2(ctx context.Context, t *testing.T, meta *conns.AWSClient) string { +func callService(ctx context.Context, t *testing.T, meta *conns.AWSClient) string { t.Helper() var endpoint string @@ -265,20 +252,6 @@ func callServiceV2(ctx context.Context, t *testing.T, meta *conns.AWSClient) str return endpoint } -func callServiceV1(ctx context.Context, t *testing.T, meta *conns.AWSClient) string { - t.Helper() - - client := meta.AppConfigConn(ctx) - - req, _ := client.ListApplicationsRequest(&appconfig_sdkv1.ListApplicationsInput{}) - - req.HTTPRequest.URL.Path = "/" - - endpoint := req.HTTPRequest.URL.String() - - return endpoint -} - func withNoConfig(_ *caseSetup) { // no-op } diff --git a/internal/service/appconfig/service_package.go b/internal/service/appconfig/service_package.go deleted file mode 100644 index 528eec7bd425..000000000000 --- a/internal/service/appconfig/service_package.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: MPL-2.0 - -package appconfig - -import ( - "context" - - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - request_sdkv1 "github.com/aws/aws-sdk-go/aws/request" - appconfig_sdkv1 "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr" -) - -// CustomizeConn customizes a new AWS SDK for Go v1 client for this service package's AWS API. -func (p *servicePackage) CustomizeConn(ctx context.Context, conn *appconfig_sdkv1.AppConfig) (*appconfig_sdkv1.AppConfig, error) { - // StartDeployment operations can return a ConflictException - // if ongoing deployments are in-progress, thus we handle them - // here for the service client. - conn.Handlers.Retry.PushBack(func(r *request_sdkv1.Request) { - if r.Operation.Name == "StartDeployment" { - if tfawserr.ErrCodeEquals(r.Error, appconfig_sdkv1.ErrCodeConflictException) { - r.Retryable = aws_sdkv1.Bool(true) - } - } - }) - - return conn, nil -} diff --git a/internal/service/appconfig/service_package_gen.go b/internal/service/appconfig/service_package_gen.go index a0a1217a35cf..b8aa48189fdd 100644 --- a/internal/service/appconfig/service_package_gen.go +++ b/internal/service/appconfig/service_package_gen.go @@ -7,9 +7,6 @@ import ( aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" appconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/appconfig" - aws_sdkv1 "github.com/aws/aws-sdk-go/aws" - session_sdkv1 "github.com/aws/aws-sdk-go/aws/session" - appconfig_sdkv1 "github.com/aws/aws-sdk-go/service/appconfig" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/types" "github.com/hashicorp/terraform-provider-aws/names" @@ -110,13 +107,6 @@ func (p *servicePackage) ServicePackageName() string { return names.AppConfig } -// NewConn returns a new AWS SDK for Go v1 client for this service package's AWS API. -func (p *servicePackage) NewConn(ctx context.Context, config map[string]any) (*appconfig_sdkv1.AppConfig, error) { - sess := config["session"].(*session_sdkv1.Session) - - return appconfig_sdkv1.New(sess.Copy(&aws_sdkv1.Config{Endpoint: aws_sdkv1.String(config["endpoint"].(string))})), nil -} - // NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API. func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*appconfig_sdkv2.Client, error) { cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) diff --git a/internal/service/appconfig/sweep.go b/internal/service/appconfig/sweep.go index 29c2db845ee1..9d9728daf85a 100644 --- a/internal/service/appconfig/sweep.go +++ b/internal/service/appconfig/sweep.go @@ -8,12 +8,12 @@ import ( "log" "github.com/YakDriver/regexache" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" "github.com/hashicorp/go-multierror" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-provider-aws/internal/sweep" - "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv1" + "github.com/hashicorp/terraform-provider-aws/internal/sweep/awsv2" "github.com/hashicorp/terraform-provider-aws/internal/sweep/framework" ) @@ -67,33 +67,31 @@ func sweepApplications(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListApplicationsInput{} sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListApplicationsPagesWithContext(ctx, input, func(page *appconfig.ListApplicationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListApplicationsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Application sweep for %s: %s", region, err) + return nil + } + + if err != nil { + return fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err) } for _, v := range page.Items { r := ResourceApplication() d := r.Data(nil) - d.SetId(aws.StringValue(v.Id)) + d.SetId(aws.ToString(v.Id)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Application sweep for %s: %s", region, err) - return nil - } - - if err != nil { - return fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -111,53 +109,53 @@ func sweepConfigurationProfiles(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListApplicationsInput{} sweepResources := make([]sweep.Sweepable, 0) var sweeperErrs *multierror.Error - err = conn.ListApplicationsPagesWithContext(ctx, input, func(page *appconfig.ListApplicationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListApplicationsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Configuration Profile sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Configuration Profiles (%s): %w", region, err)) } for _, v := range page.Items { - appID := aws.StringValue(v.Id) + appID := aws.ToString(v.Id) input := &appconfig.ListConfigurationProfilesInput{ ApplicationId: aws.String(appID), } - err := conn.ListConfigurationProfilesPagesWithContext(ctx, input, func(page *appconfig.ListConfigurationProfilesOutput, lastPage bool) bool { + pages := appconfig.NewListConfigurationProfilesPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + for _, v := range page.Items { r := ResourceConfigurationProfile() d := r.Data(nil) - d.SetId(fmt.Sprintf("%s:%s", aws.StringValue(v.Id), appID)) + d.SetId(fmt.Sprintf("%s:%s", aws.ToString(v.Id), appID)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } + if awsv2.SkipSweepError(err) { + continue + } - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Configuration Profiles (%s): %w", region, err)) + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Configuration Profiles (%s): %w", region, err)) + } } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Configuration Profile sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -175,17 +173,26 @@ func sweepDeploymentStrategies(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListDeploymentStrategiesInput{} sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListDeploymentStrategiesPagesWithContext(ctx, input, func(page *appconfig.ListDeploymentStrategiesOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListDeploymentStrategiesPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Deployment Strategy sweep for %s: %s", region, err) + return nil + } + + if err != nil { + return fmt.Errorf("error listing AppConfig Deployment Strategies (%s): %w", region, err) } for _, v := range page.Items { - id := aws.StringValue(v.Id) + id := aws.ToString(v.Id) // Deleting AppConfig Predefined Strategies is not supported; returns BadRequestException if regexache.MustCompile(`^AppConfig\.[0-9A-Za-z]{9,40}$`).MatchString(id) { @@ -199,17 +206,6 @@ func sweepDeploymentStrategies(region string) error { sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Deployment Strategy sweep for %s: %s", region, err) - return nil - } - - if err != nil { - return fmt.Errorf("error listing AppConfig Deployment Strategies (%s): %w", region, err) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -227,56 +223,52 @@ func sweepEnvironments(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListApplicationsInput{} sweepResources := make([]sweep.Sweepable, 0) var sweeperErrs *multierror.Error - err = conn.ListApplicationsPagesWithContext(ctx, input, func(page *appconfig.ListApplicationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListApplicationsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Environment sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err)) } for _, v := range page.Items { - appID := aws.StringValue(v.Id) + appID := aws.ToString(v.Id) input := &appconfig.ListEnvironmentsInput{ ApplicationId: aws.String(appID), } - err := conn.ListEnvironmentsPagesWithContext(ctx, input, func(page *appconfig.ListEnvironmentsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListEnvironmentsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Environments (%s): %w", region, err)) } for _, v := range page.Items { sweepResources = append(sweepResources, framework.NewSweepResource(newResourceEnvironment, client, - framework.NewAttribute("application_id", aws.StringValue(v.ApplicationId)), - framework.NewAttribute("environment_id", aws.StringValue(v.Id)), + framework.NewAttribute("application_id", aws.ToString(v.ApplicationId)), + framework.NewAttribute("environment_id", aws.ToString(v.Id)), )) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Environments (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Environment sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -294,81 +286,75 @@ func sweepHostedConfigurationVersions(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListApplicationsInput{} sweepResources := make([]sweep.Sweepable, 0) var sweeperErrs *multierror.Error - err = conn.ListApplicationsPagesWithContext(ctx, input, func(page *appconfig.ListApplicationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListApplicationsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Hosted Configuration Version sweep for %s: %s", region, err) + return sweeperErrs.ErrorOrNil() + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err)) } for _, v := range page.Items { - appID := aws.StringValue(v.Id) + appID := aws.ToString(v.Id) input := &appconfig.ListConfigurationProfilesInput{ ApplicationId: aws.String(appID), } - err := conn.ListConfigurationProfilesPagesWithContext(ctx, input, func(page *appconfig.ListConfigurationProfilesOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListConfigurationProfilesPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Hosted Configuration Versions (%s): %w", region, err)) } for _, v := range page.Items { - profileID := aws.StringValue(v.Id) + profileID := aws.ToString(v.Id) input := &appconfig.ListHostedConfigurationVersionsInput{ ApplicationId: aws.String(appID), ConfigurationProfileId: aws.String(profileID), } - err := conn.ListHostedConfigurationVersionsPagesWithContext(ctx, input, func(page *appconfig.ListHostedConfigurationVersionsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListHostedConfigurationVersionsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + continue + } + + if err != nil { + sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Configuration Versions (%s): %w", region, err)) } for _, v := range page.Items { r := ResourceHostedConfigurationVersion() d := r.Data(nil) - d.SetId(fmt.Sprintf("%s/%s/%d", appID, profileID, aws.Int64Value(v.VersionNumber))) + d.SetId(fmt.Sprintf("%s/%s/%d", appID, profileID, v.VersionNumber)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Hosted Configuration Versions (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - continue - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Configuration Profiles (%s): %w", region, err)) } } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Hosted Configuration Version sweep for %s: %s", region, err) - return sweeperErrs.ErrorOrNil() - } - - if err != nil { - sweeperErrs = multierror.Append(sweeperErrs, fmt.Errorf("error listing AppConfig Applications (%s): %w", region, err)) } err = sweep.SweepOrchestrator(ctx, sweepResources) @@ -386,33 +372,31 @@ func sweepExtensionAssociations(region string) error { if err != nil { return fmt.Errorf("error getting client: %w", err) } - conn := client.AppConfigConn(ctx) + conn := client.AppConfigClient(ctx) input := &appconfig.ListExtensionAssociationsInput{} sweepResources := make([]sweep.Sweepable, 0) - err = conn.ListExtensionAssociationsPagesWithContext(ctx, input, func(page *appconfig.ListExtensionAssociationsOutput, lastPage bool) bool { - if page == nil { - return !lastPage + pages := appconfig.NewListExtensionAssociationsPaginator(conn, input) + + for pages.HasMorePages() { + page, err := pages.NextPage(ctx) + + if awsv2.SkipSweepError(err) { + log.Printf("[WARN] Skipping AppConfig Extension Association sweep for %s: %s", region, err) + return nil + } + + if err != nil { + return fmt.Errorf("error listing AppConfig Extension Associations (%s): %w", region, err) } for _, v := range page.Items { r := ResourceExtensionAssociation() d := r.Data(nil) - d.SetId(aws.StringValue(v.Id)) + d.SetId(aws.ToString(v.Id)) sweepResources = append(sweepResources, sweep.NewSweepResource(r, d, client)) } - - return !lastPage - }) - - if awsv1.SkipSweepError(err) { - log.Printf("[WARN] Skipping AppConfig Extension Association sweep for %s: %s", region, err) - return nil - } - - if err != nil { - return fmt.Errorf("error listing AppConfig Extension Associations (%s): %w", region, err) } err = sweep.SweepOrchestrator(ctx, sweepResources) diff --git a/internal/service/appconfig/tags_gen.go b/internal/service/appconfig/tags_gen.go index 4e791b86cc17..53ea408f8b81 100644 --- a/internal/service/appconfig/tags_gen.go +++ b/internal/service/appconfig/tags_gen.go @@ -5,9 +5,8 @@ import ( "context" "fmt" - "github.com/aws/aws-sdk-go/aws" - "github.com/aws/aws-sdk-go/service/appconfig" - "github.com/aws/aws-sdk-go/service/appconfig/appconfigiface" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/appconfig" "github.com/hashicorp/terraform-plugin-log/tflog" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/logging" @@ -19,12 +18,12 @@ import ( // listTags lists appconfig service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. -func listTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifier string) (tftags.KeyValueTags, error) { +func listTags(ctx context.Context, conn *appconfig.Client, identifier string, optFns ...func(*appconfig.Options)) (tftags.KeyValueTags, error) { input := &appconfig.ListTagsForResourceInput{ ResourceArn: aws.String(identifier), } - output, err := conn.ListTagsForResourceWithContext(ctx, input) + output, err := conn.ListTagsForResource(ctx, input, optFns...) if err != nil { return tftags.New(ctx, nil), err @@ -36,7 +35,7 @@ func listTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifier // ListTags lists appconfig service tags and set them in Context. // It is called from outside this package. func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier string) error { - tags, err := listTags(ctx, meta.(*conns.AWSClient).AppConfigConn(ctx), identifier) + tags, err := listTags(ctx, meta.(*conns.AWSClient).AppConfigClient(ctx), identifier) if err != nil { return err @@ -49,21 +48,21 @@ func (p *servicePackage) ListTags(ctx context.Context, meta any, identifier stri return nil } -// map[string]*string handling +// map[string]string handling // Tags returns appconfig service tags. -func Tags(tags tftags.KeyValueTags) map[string]*string { - return aws.StringMap(tags.Map()) +func Tags(tags tftags.KeyValueTags) map[string]string { + return tags.Map() } // KeyValueTags creates tftags.KeyValueTags from appconfig service tags. -func KeyValueTags(ctx context.Context, tags map[string]*string) tftags.KeyValueTags { +func KeyValueTags(ctx context.Context, tags map[string]string) tftags.KeyValueTags { return tftags.New(ctx, tags) } // getTagsIn returns appconfig service tags from Context. // nil is returned if there are no input tags. -func getTagsIn(ctx context.Context) map[string]*string { +func getTagsIn(ctx context.Context) map[string]string { if inContext, ok := tftags.FromContext(ctx); ok { if tags := Tags(inContext.TagsIn.UnwrapOrDefault()); len(tags) > 0 { return tags @@ -74,7 +73,7 @@ func getTagsIn(ctx context.Context) map[string]*string { } // setTagsOut sets appconfig service tags in Context. -func setTagsOut(ctx context.Context, tags map[string]*string) { +func setTagsOut(ctx context.Context, tags map[string]string) { if inContext, ok := tftags.FromContext(ctx); ok { inContext.TagsOut = option.Some(KeyValueTags(ctx, tags)) } @@ -83,7 +82,7 @@ func setTagsOut(ctx context.Context, tags map[string]*string) { // updateTags updates appconfig service tags. // The identifier is typically the Amazon Resource Name (ARN), although // it may also be a different identifier depending on the service. -func updateTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifier string, oldTagsMap, newTagsMap any) error { +func updateTags(ctx context.Context, conn *appconfig.Client, identifier string, oldTagsMap, newTagsMap any, optFns ...func(*appconfig.Options)) error { oldTags := tftags.New(ctx, oldTagsMap) newTags := tftags.New(ctx, newTagsMap) @@ -94,10 +93,10 @@ func updateTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifie if len(removedTags) > 0 { input := &appconfig.UntagResourceInput{ ResourceArn: aws.String(identifier), - TagKeys: aws.StringSlice(removedTags.Keys()), + TagKeys: removedTags.Keys(), } - _, err := conn.UntagResourceWithContext(ctx, input) + _, err := conn.UntagResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("untagging resource (%s): %w", identifier, err) @@ -112,7 +111,7 @@ func updateTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifie Tags: Tags(updatedTags), } - _, err := conn.TagResourceWithContext(ctx, input) + _, err := conn.TagResource(ctx, input, optFns...) if err != nil { return fmt.Errorf("tagging resource (%s): %w", identifier, err) @@ -125,5 +124,5 @@ func updateTags(ctx context.Context, conn appconfigiface.AppConfigAPI, identifie // UpdateTags updates appconfig service tags. // It is called from outside this package. func (p *servicePackage) UpdateTags(ctx context.Context, meta any, identifier string, oldTags, newTags any) error { - return updateTags(ctx, meta.(*conns.AWSClient).AppConfigConn(ctx), identifier, oldTags, newTags) + return updateTags(ctx, meta.(*conns.AWSClient).AppConfigClient(ctx), identifier, oldTags, newTags) } diff --git a/names/data/names_data.csv b/names/data/names_data.csv index 05429f0ff460..6a0023e4ddb6 100644 --- a/names/data/names_data.csv +++ b/names/data/names_data.csv @@ -16,7 +16,7 @@ appfabric,appfabric,appfabric,appfabric,,appfabric,,,AppFabric,AppFabric,,,2,,aw appmesh,appmesh,appmesh,appmesh,,appmesh,,,AppMesh,AppMesh,,1,,,aws_appmesh_,,appmesh_,App Mesh,AWS,,,,,,,App Mesh,ListMeshes,, apprunner,apprunner,apprunner,apprunner,,apprunner,,,AppRunner,AppRunner,,,2,,aws_apprunner_,,apprunner_,App Runner,AWS,,,,,,,AppRunner,ListConnections,, ,,,,,,,,,,,,,,,,,App2Container,AWS,x,,,,,,,,,No SDK support -appconfig,appconfig,appconfig,appconfig,,appconfig,,,AppConfig,AppConfig,,1,2,,aws_appconfig_,,appconfig_,AppConfig,AWS,,,,,,,AppConfig,ListApplications,, +appconfig,appconfig,appconfig,appconfig,,appconfig,,,AppConfig,AppConfig,,,2,,aws_appconfig_,,appconfig_,AppConfig,AWS,,,,,,,AppConfig,ListApplications,, appconfigdata,appconfigdata,appconfigdata,appconfigdata,,appconfigdata,,,AppConfigData,AppConfigData,,1,,,aws_appconfigdata_,,appconfigdata_,AppConfig Data,AWS,,x,,,,,AppConfigData,,, appflow,appflow,appflow,appflow,,appflow,,,AppFlow,Appflow,,,2,,aws_appflow_,,appflow_,AppFlow,Amazon,,,,,,,Appflow,ListFlows,, appintegrations,appintegrations,appintegrationsservice,appintegrations,,appintegrations,,appintegrationsservice,AppIntegrations,AppIntegrationsService,,1,,,aws_appintegrations_,,appintegrations_,AppIntegrations,Amazon,,,,,,,AppIntegrations,ListApplications,, diff --git a/names/names.go b/names/names.go index 02adbf742aad..80376e6068f5 100644 --- a/names/names.go +++ b/names/names.go @@ -27,6 +27,7 @@ import ( const ( AccessAnalyzerEndpointID = "access-analyzer" AMPEndpointID = "aps" + AppConfigEndpointID = "appconfig" AthenaEndpointID = "athena" AuditManagerEndpointID = "auditmanager" BatchEndpointID = "batch" From e91b1812ba2fd6ed72df5169dc3d450588b984f4 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 2 Apr 2024 12:56:14 -0500 Subject: [PATCH 2/4] add custom NewClient --- internal/service/appconfig/service_package.go | 41 +++++++++++++++++++ .../service/appconfig/service_package_gen.go | 13 ------ names/data/names_data.csv | 2 +- 3 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 internal/service/appconfig/service_package.go diff --git a/internal/service/appconfig/service_package.go b/internal/service/appconfig/service_package.go new file mode 100644 index 000000000000..05e0fdba7eec --- /dev/null +++ b/internal/service/appconfig/service_package.go @@ -0,0 +1,41 @@ +package appconfig + +import ( + "context" + "errors" + + aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" + retry_sdkv2 "github.com/aws/aws-sdk-go-v2/aws/retry" + appconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" + "github.com/aws/smithy-go" + "github.com/hashicorp/terraform-provider-aws/internal/conns" + "github.com/hashicorp/terraform-provider-aws/internal/errs" +) + +func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*appconfig_sdkv2.Client, error) { + cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) + + return appconfig_sdkv2.NewFromConfig(cfg, func(o *appconfig_sdkv2.Options) { + if endpoint := config["endpoint"].(string); endpoint != "" { + o.BaseEndpoint = aws_sdkv2.String(endpoint) + } + + // StartDeployment operations can return a ConflictException + // if ongoing deployments are in-progress, thus we handle them + // here for the service client. + o.Retryer = conns.AddIsErrorRetryables(cfg.Retryer().(aws_sdkv2.RetryerV2), retry_sdkv2.IsErrorRetryableFunc(func(err error) aws_sdkv2.Ternary { + if err != nil { + var oe *smithy.OperationError + if errors.As(err, &oe) { + if oe.OperationName == "StartDeployment" { + if errs.IsA[*awstypes.ConflictException](err) { + return aws_sdkv2.TrueTernary + } + } + } + } + return aws_sdkv2.UnknownTernary + })) + }), nil +} diff --git a/internal/service/appconfig/service_package_gen.go b/internal/service/appconfig/service_package_gen.go index b8aa48189fdd..36a5da525829 100644 --- a/internal/service/appconfig/service_package_gen.go +++ b/internal/service/appconfig/service_package_gen.go @@ -5,8 +5,6 @@ package appconfig import ( "context" - aws_sdkv2 "github.com/aws/aws-sdk-go-v2/aws" - appconfig_sdkv2 "github.com/aws/aws-sdk-go-v2/service/appconfig" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/types" "github.com/hashicorp/terraform-provider-aws/names" @@ -107,17 +105,6 @@ func (p *servicePackage) ServicePackageName() string { return names.AppConfig } -// NewClient returns a new AWS SDK for Go v2 client for this service package's AWS API. -func (p *servicePackage) NewClient(ctx context.Context, config map[string]any) (*appconfig_sdkv2.Client, error) { - cfg := *(config["aws_sdkv2_config"].(*aws_sdkv2.Config)) - - return appconfig_sdkv2.NewFromConfig(cfg, func(o *appconfig_sdkv2.Options) { - if endpoint := config["endpoint"].(string); endpoint != "" { - o.BaseEndpoint = aws_sdkv2.String(endpoint) - } - }), nil -} - func ServicePackage(ctx context.Context) conns.ServicePackage { return &servicePackage{} } diff --git a/names/data/names_data.csv b/names/data/names_data.csv index 4484c3a177a7..1bac0fa3b774 100644 --- a/names/data/names_data.csv +++ b/names/data/names_data.csv @@ -16,7 +16,7 @@ appfabric,appfabric,appfabric,appfabric,,appfabric,,,AppFabric,AppFabric,,,2,,aw appmesh,appmesh,appmesh,appmesh,,appmesh,,,AppMesh,AppMesh,,1,,,aws_appmesh_,,appmesh_,App Mesh,AWS,,,,,,,App Mesh,ListMeshes,, apprunner,apprunner,apprunner,apprunner,,apprunner,,,AppRunner,AppRunner,,,2,,aws_apprunner_,,apprunner_,App Runner,AWS,,,,,,,AppRunner,ListConnections,, ,,,,,,,,,,,,,,,,,App2Container,AWS,x,,,,,,,,,No SDK support -appconfig,appconfig,appconfig,appconfig,,appconfig,,,AppConfig,AppConfig,,,2,,aws_appconfig_,,appconfig_,AppConfig,AWS,,,,,,,AppConfig,ListApplications,, +appconfig,appconfig,appconfig,appconfig,,appconfig,,,AppConfig,AppConfig,x,,2,,aws_appconfig_,,appconfig_,AppConfig,AWS,,,,,,,AppConfig,ListApplications,, appconfigdata,appconfigdata,appconfigdata,appconfigdata,,appconfigdata,,,AppConfigData,AppConfigData,,1,,,aws_appconfigdata_,,appconfigdata_,AppConfig Data,AWS,,x,,,,,AppConfigData,,, appflow,appflow,appflow,appflow,,appflow,,,AppFlow,Appflow,,,2,,aws_appflow_,,appflow_,AppFlow,Amazon,,,,,,,Appflow,ListFlows,, appintegrations,appintegrations,appintegrationsservice,appintegrations,,appintegrations,,appintegrationsservice,AppIntegrations,AppIntegrationsService,,1,,,aws_appintegrations_,,appintegrations_,AppIntegrations,Amazon,,,,,,,AppIntegrations,ListApplications,, From c10bd2a01522863b10498c15f507ede1fca4abb2 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 2 Apr 2024 13:17:37 -0500 Subject: [PATCH 3/4] fix disappears tests --- internal/service/appconfig/deployment_strategy.go | 4 ++-- internal/service/appconfig/extension.go | 5 +++++ internal/service/appconfig/extension_association.go | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/internal/service/appconfig/deployment_strategy.go b/internal/service/appconfig/deployment_strategy.go index 7c558b74b2af..3241a9828cdc 100644 --- a/internal/service/appconfig/deployment_strategy.go +++ b/internal/service/appconfig/deployment_strategy.go @@ -64,7 +64,7 @@ func ResourceDeploymentStrategy() *schema.Resource { "growth_type": { Type: schema.TypeString, Optional: true, - Default: string(awstypes.GrowthTypeLinear), + Default: awstypes.GrowthTypeLinear, ValidateDiagFunc: enum.Validate[awstypes.GrowthType](), }, "name": { @@ -93,7 +93,7 @@ func resourceDeploymentStrategyCreate(ctx context.Context, d *schema.ResourceDat name := d.Get("name").(string) input := &appconfig.CreateDeploymentStrategyInput{ DeploymentDurationInMinutes: aws.Int32(int32(d.Get("deployment_duration_in_minutes").(int))), - GrowthFactor: aws.Float32(d.Get("growth_factor").(float32)), + GrowthFactor: aws.Float32(float32(d.Get("growth_factor").(float64))), GrowthType: awstypes.GrowthType(d.Get("growth_type").(string)), Name: aws.String(name), ReplicateTo: awstypes.ReplicateTo(d.Get("replicate_to").(string)), diff --git a/internal/service/appconfig/extension.go b/internal/service/appconfig/extension.go index e89c0ca3a8cf..9761e47554ba 100644 --- a/internal/service/appconfig/extension.go +++ b/internal/service/appconfig/extension.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" "github.com/hashicorp/terraform-provider-aws/internal/enum" + "github.com/hashicorp/terraform-provider-aws/internal/errs" tftags "github.com/hashicorp/terraform-provider-aws/internal/tags" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/internal/verify" @@ -234,6 +235,10 @@ func resourceExtensionDelete(ctx context.Context, d *schema.ResourceData, meta i ExtensionIdentifier: aws.String(d.Id()), }) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return diags + } + if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionDeleting, ResExtension, d.Id(), err) } diff --git a/internal/service/appconfig/extension_association.go b/internal/service/appconfig/extension_association.go index 7b1af0f8a4b6..894b23f1f0d5 100644 --- a/internal/service/appconfig/extension_association.go +++ b/internal/service/appconfig/extension_association.go @@ -10,10 +10,12 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/appconfig" + awstypes "github.com/aws/aws-sdk-go-v2/service/appconfig/types" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-provider-aws/internal/conns" "github.com/hashicorp/terraform-provider-aws/internal/create" + "github.com/hashicorp/terraform-provider-aws/internal/errs" "github.com/hashicorp/terraform-provider-aws/internal/flex" "github.com/hashicorp/terraform-provider-aws/internal/tfresource" "github.com/hashicorp/terraform-provider-aws/names" @@ -158,6 +160,10 @@ func resourceExtensionAssociationDelete(ctx context.Context, d *schema.ResourceD ExtensionAssociationId: aws.String(d.Id()), }) + if errs.IsA[*awstypes.ResourceNotFoundException](err) { + return diags + } + if err != nil { return create.AppendDiagError(diags, names.AppConfig, create.ErrActionDeleting, ResExtensionAssociation, d.Id(), err) } From 12fbdba19a4e714e6a1a54d5223a3ebdb6a08776 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Tue, 2 Apr 2024 13:19:51 -0500 Subject: [PATCH 4/4] chore: add copyright header --- internal/service/appconfig/service_package.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/internal/service/appconfig/service_package.go b/internal/service/appconfig/service_package.go index 05e0fdba7eec..fa2742eca403 100644 --- a/internal/service/appconfig/service_package.go +++ b/internal/service/appconfig/service_package.go @@ -1,3 +1,6 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + package appconfig import (