Skip to content

Commit 6438c33

Browse files
authored
Fix Missing Resource Identity After Update error for Terraform < 1.12 (#1024)
1 parent 8735e20 commit 6438c33

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
## v2.8.0 (Unreleased)
1+
## v2.9.0 (Unreleased)
2+
3+
BUG FIXES:
4+
- Fix `Missing Resource Identity After Update` error for Terraform versions below 1.12 (GH-1023).
5+
6+
## v2.8.0
27

38
FEATURES:
49
- **New Provider Function**: snake2camel

internal/services/azapi_resource.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,12 @@ func (r *AzapiResource) Update(ctx context.Context, request resource.UpdateReque
723723
if response.Diagnostics.Append(request.State.Get(ctx, &state)...); response.Diagnostics.HasError() {
724724
return
725725
}
726+
// This is a workaround for the issue: https://github.com/Azure/terraform-provider-azapi/issues/1023
727+
// The issue is that the identity is not set in the response when the resource is updated.
728+
// This issue only happens when the terraform version is below 1.12.
729+
if !state.ID.IsNull() {
730+
response.Diagnostics.Append(response.Identity.SetAttribute(ctx, path.Root("id"), state.ID)...)
731+
}
726732
if skip.CanSkipExternalRequest(plan, state, "update") {
727733
response.Diagnostics.Append(response.State.Set(ctx, plan)...)
728734
tflog.Debug(ctx, "azapi_resource.CreateUpdate skipping external request as no unskippable changes were detected")

0 commit comments

Comments
 (0)