From 3de1393da1ca0d2a30c531d0acec06b84315eb08 Mon Sep 17 00:00:00 2001 From: naruse666 Date: Sat, 28 Oct 2023 01:03:52 +0900 Subject: [PATCH 1/6] resource/aws_amplify_branch: fix forces replacement --- internal/service/amplify/branch.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/service/amplify/branch.go b/internal/service/amplify/branch.go index a59abdd5d28..bb8c2b18629 100644 --- a/internal/service/amplify/branch.go +++ b/internal/service/amplify/branch.go @@ -126,7 +126,6 @@ func ResourceBranch() *schema.Resource { "enable_performance_mode": { Type: schema.TypeBool, Optional: true, - ForceNew: true, }, "enable_pull_request_preview": { From 1bb77fd6e6d8fa34140e082a034f2badc66dbc6c Mon Sep 17 00:00:00 2001 From: naruse666 Date: Sat, 28 Oct 2023 01:59:06 +0900 Subject: [PATCH 2/6] add: CHANGELOG --- .changelog/34141.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/34141.txt diff --git a/.changelog/34141.txt b/.changelog/34141.txt new file mode 100644 index 00000000000..46bc1e8d7e0 --- /dev/null +++ b/.changelog/34141.txt @@ -0,0 +1,3 @@ +```release-note:bug +resource/aws_amplify_branch: Fix forces replacement when enable_performance_mode has changed +``` From 856aede4a348b020da5ddd12af263809851f4b46 Mon Sep 17 00:00:00 2001 From: naruse666 Date: Sat, 28 Oct 2023 07:19:24 +0900 Subject: [PATCH 3/6] fix: update enable_performance_mode --- internal/service/amplify/branch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/service/amplify/branch.go b/internal/service/amplify/branch.go index bb8c2b18629..536a9341c0a 100644 --- a/internal/service/amplify/branch.go +++ b/internal/service/amplify/branch.go @@ -362,7 +362,7 @@ func resourceBranchUpdate(ctx context.Context, d *schema.ResourceData, meta inte } if d.HasChange("enable_performance_mode") { - input.EnablePullRequestPreview = aws.Bool(d.Get("enable_performance_mode").(bool)) + input.EnablePerformanceMode = aws.Bool(d.Get("enable_performance_mode").(bool)) } if d.HasChange("enable_pull_request_preview") { From 247d318ea3d79681e3f40ff23c29b261cceeda26 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 14:05:30 -0400 Subject: [PATCH 4/6] Tweak CHANGELOG entry. --- .changelog/34141.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changelog/34141.txt b/.changelog/34141.txt index 46bc1e8d7e0..3498e51acae 100644 --- a/.changelog/34141.txt +++ b/.changelog/34141.txt @@ -1,3 +1,3 @@ ```release-note:bug -resource/aws_amplify_branch: Fix forces replacement when enable_performance_mode has changed +resource/aws_amplify_branch: Remove [ForceNew](https://developer.hashicorp.com/terraform/plugin/sdkv2/schemas/schema-behaviors#forcenew) from `enable_performance_mode` ``` From 75a92b604e953a1f3da68049812636d2d1fe3e9a Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 14:08:18 -0400 Subject: [PATCH 5/6] r/aws_amplify_branch: Cosmetics. --- internal/service/amplify/branch.go | 33 ++++-------------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/internal/service/amplify/branch.go b/internal/service/amplify/branch.go index 536a9341c0a..5a55c086e66 100644 --- a/internal/service/amplify/branch.go +++ b/internal/service/amplify/branch.go @@ -31,6 +31,7 @@ func ResourceBranch() *schema.Resource { ReadWithoutTimeout: resourceBranchRead, UpdateWithoutTimeout: resourceBranchUpdate, DeleteWithoutTimeout: resourceBranchDelete, + Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -43,24 +44,20 @@ func ResourceBranch() *schema.Resource { Required: true, ForceNew: true, }, - "arn": { Type: schema.TypeString, Computed: true, }, - "associated_resources": { Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "backend_environment_arn": { Type: schema.TypeString, Optional: true, ValidateFunc: verify.ValidARN, }, - "basic_auth_credentials": { Type: schema.TypeString, Optional: true, @@ -75,87 +72,72 @@ func ResourceBranch() *schema.Resource { return true }, }, - "branch_name": { Type: schema.TypeString, Required: true, ForceNew: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9A-Za-z/_.-]{1,255}$`), "should be not be more than 255 letters, numbers, and the symbols /_.-"), }, - "custom_domains": { Type: schema.TypeList, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "description": { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 1000), }, - "destination_branch": { Type: schema.TypeString, Computed: true, }, - "display_name": { Type: schema.TypeString, Optional: true, Computed: true, ValidateFunc: validation.StringMatch(regexache.MustCompile(`^[0-9a-z-]{1,255}$`), "should be not be more than 255 lowercase alphanumeric or hyphen characters"), }, - "enable_auto_build": { Type: schema.TypeBool, Optional: true, Default: true, }, - "enable_basic_auth": { Type: schema.TypeBool, Optional: true, }, - "enable_notification": { Type: schema.TypeBool, Optional: true, }, - "enable_performance_mode": { Type: schema.TypeBool, Optional: true, }, - "enable_pull_request_preview": { Type: schema.TypeBool, Optional: true, }, - "environment_variables": { Type: schema.TypeMap, Optional: true, Elem: &schema.Schema{Type: schema.TypeString}, }, - "framework": { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 255), }, - "pull_request_environment_name": { Type: schema.TypeString, Optional: true, ValidateFunc: validation.StringLenBetween(1, 20), }, - "source_branch": { Type: schema.TypeString, Computed: true, }, - "stage": { Type: schema.TypeString, Optional: true, @@ -169,7 +151,6 @@ func ResourceBranch() *schema.Resource { return old == new }, }, - "ttl": { Type: schema.TypeString, Optional: true, @@ -182,7 +163,6 @@ func ResourceBranch() *schema.Resource { return old == new }, }, - names.AttrTags: tftags.TagsSchema(), names.AttrTagsAll: tftags.TagsSchemaComputed(), }, @@ -196,7 +176,6 @@ func resourceBranchCreate(ctx context.Context, d *schema.ResourceData, meta inte appID := d.Get("app_id").(string) branchName := d.Get("branch_name").(string) id := BranchCreateResourceID(appID, branchName) - input := &lify.CreateBranchInput{ AppId: aws.String(appID), BranchName: aws.String(branchName), @@ -256,7 +235,6 @@ func resourceBranchCreate(ctx context.Context, d *schema.ResourceData, meta inte input.Ttl = aws.String(v.(string)) } - log.Printf("[DEBUG] Creating Amplify Branch: %s", input) _, err := conn.CreateBranchWithContext(ctx, input) if err != nil { @@ -273,9 +251,8 @@ func resourceBranchRead(ctx context.Context, d *schema.ResourceData, meta interf conn := meta.(*conns.AWSClient).AmplifyConn(ctx) appID, branchName, err := BranchParseResourceID(d.Id()) - if err != nil { - return sdkdiag.AppendErrorf(diags, "parsing Amplify Branch ID: %s", err) + return sdkdiag.AppendFromErr(diags, err) } branch, err := FindBranchByAppIDAndBranchName(ctx, conn, appID, branchName) @@ -323,9 +300,8 @@ func resourceBranchUpdate(ctx context.Context, d *schema.ResourceData, meta inte if d.HasChangesExcept("tags", "tags_all") { appID, branchName, err := BranchParseResourceID(d.Id()) - if err != nil { - return sdkdiag.AppendErrorf(diags, "parsing Amplify Branch ID: %s", err) + return sdkdiag.AppendFromErr(diags, err) } input := &lify.UpdateBranchInput{ @@ -408,9 +384,8 @@ func resourceBranchDelete(ctx context.Context, d *schema.ResourceData, meta inte conn := meta.(*conns.AWSClient).AmplifyConn(ctx) appID, branchName, err := BranchParseResourceID(d.Id()) - if err != nil { - return sdkdiag.AppendErrorf(diags, "parsing Amplify Branch ID: %s", err) + return sdkdiag.AppendFromErr(diags, err) } log.Printf("[DEBUG] Deleting Amplify Branch: %s", d.Id()) From 2c61b47c633259f12bda7d28fa3d89dbda5dd586 Mon Sep 17 00:00:00 2001 From: Kit Ewbank Date: Mon, 30 Oct 2023 14:09:54 -0400 Subject: [PATCH 6/6] Tweak 'testAccBranch_OptionalArguments'. --- internal/service/amplify/branch_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/service/amplify/branch_test.go b/internal/service/amplify/branch_test.go index b950dc3959c..28565bdc8c6 100644 --- a/internal/service/amplify/branch_test.go +++ b/internal/service/amplify/branch_test.go @@ -278,7 +278,7 @@ func testAccBranch_OptionalArguments(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "display_name", "testdisplayname2"), resource.TestCheckResourceAttr(resourceName, "enable_auto_build", "true"), resource.TestCheckResourceAttr(resourceName, "enable_notification", "false"), - resource.TestCheckResourceAttr(resourceName, "enable_performance_mode", "true"), + resource.TestCheckResourceAttr(resourceName, "enable_performance_mode", "false"), resource.TestCheckResourceAttr(resourceName, "enable_pull_request_preview", "true"), resource.TestCheckResourceAttr(resourceName, "framework", "Angular"), resource.TestCheckResourceAttr(resourceName, "pull_request_environment_name", "testpr2"), @@ -512,7 +512,7 @@ resource "aws_amplify_branch" "test" { display_name = "testdisplayname2" enable_auto_build = true enable_notification = false - enable_performance_mode = true + enable_performance_mode = false enable_pull_request_preview = true framework = "Angular" pull_request_environment_name = "testpr2"