From bff648037a700a37205911475c3a7f2358298554 Mon Sep 17 00:00:00 2001 From: Doug Bridgens Date: Thu, 19 Sep 2024 07:39:06 +0100 Subject: [PATCH 1/3] Fix for panic when attempting to read resource identifier after creating resource has failed. --- internal/generic/resource.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/generic/resource.go b/internal/generic/resource.go index 7ebe244ac7..24653e09b9 100644 --- a/internal/generic/resource.go +++ b/internal/generic/resource.go @@ -394,7 +394,11 @@ func (r *genericResource) Create(ctx context.Context, request resource.CreateReq err = waiter.Wait(ctx, &cloudcontrol.GetResourceRequestStatusInput{RequestToken: output.ProgressEvent.RequestToken}, r.createTimeout) - id := aws.ToString(progressEvent.Identifier) + // If the resource failed to create, then Identifier may be a nil ptr + var id string + if progressEvent.Identifier != nil { + id = aws.ToString(progressEvent.Identifier) + } if err != nil { response.Diagnostics.Append(ServiceOperationWaiterErrorDiag("Cloud Control API", "CreateResource", err)) From febc30f2f1e8ff74ab9fe9ae606f805432efa786 Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Wed, 9 Oct 2024 14:15:46 -0400 Subject: [PATCH 2/3] internal/generic: check for nil `progressEvent` before dereference --- internal/generic/resource.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/internal/generic/resource.go b/internal/generic/resource.go index 24653e09b9..750a2856ed 100644 --- a/internal/generic/resource.go +++ b/internal/generic/resource.go @@ -394,9 +394,8 @@ func (r *genericResource) Create(ctx context.Context, request resource.CreateReq err = waiter.Wait(ctx, &cloudcontrol.GetResourceRequestStatusInput{RequestToken: output.ProgressEvent.RequestToken}, r.createTimeout) - // If the resource failed to create, then Identifier may be a nil ptr var id string - if progressEvent.Identifier != nil { + if progressEvent != nil { id = aws.ToString(progressEvent.Identifier) } From 3755f380d9913361b09479c77c8744979123811f Mon Sep 17 00:00:00 2001 From: Jared Baker Date: Wed, 9 Oct 2024 14:17:54 -0400 Subject: [PATCH 3/3] chore: changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 620975ec7f..c91f2d74d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## 1.17.0 (Unreleased) -## 1.17.0 (September 27, 2024) + +BUG FIXES: + +* provider: Prevent crash when create waiter returns a nil progress event ([#2027](https://github.com/hashicorp/terraform-provider-awscc/pull/2027)) ## 1.16.1 (September 27, 2024)