Terraform and AWS Provider Version
Terraform v1.11.0
on darwin_arm64
Affected Resource(s) or Data Source(s)
All resources using Terraform Plugin Framework that have region attributes
Expected Behavior
When a resource is deleted outside of Terraform (resource disappears), the next terraform plan should detect the resource as missing and propose to recreate it with action [create].
Actual Behavior
When a resource is deleted outside of Terraform, the resource appears to still exist in state with null values instead of being properly detected as missing. This causes incorrect plan actions showing [destroy, create] instead of just [create].
Relevant Error/Panic Output
Sample Terraform Configuration
Click to expand configuration
resource "aws_s3tables_namespace" "example" {
namespace = "example_namespace"
table_bucket_arn = aws_s3tables_table_bucket.example.arn
}
resource "aws_s3tables_table_bucket" "example" {
name = "example-bucket"
}
func TestAccS3TablesTable_disappears(t *testing.T) {
ctx := acctest.Context(t)
var table s3tables.GetTableOutput
bucketName := sdkacctest.RandomWithPrefix(acctest.ResourcePrefix)
namespace := strings.ReplaceAll(sdkacctest.RandomWithPrefix(acctest.ResourcePrefix), "-", "_")
rName := strings.ReplaceAll(sdkacctest.RandomWithPrefix(acctest.ResourcePrefix), "-", "_")
resourceName := "aws_s3tables_table.test"
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() {
acctest.PreCheck(ctx, t)
testAccPreCheck(ctx, t)
},
ErrorCheck: acctest.ErrorCheck(t, names.S3TablesServiceID),
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories,
CheckDestroy: testAccCheckTableDestroy(ctx),
Steps: []resource.TestStep{
{
Config: testAccTableConfig_basic(rName, namespace, bucketName),
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckTableExists(ctx, resourceName, &table),
acctest.CheckFrameworkResourceDisappears(ctx, acctest.Provider, tfs3tables.NewResourceTable, resourceName),
),
ExpectNonEmptyPlan: true,
// Add this recommended plan check to trigger the error
ConfigPlanChecks: resource.ConfigPlanChecks{
PostApplyPostRefresh: []plancheck.PlanCheck{
plancheck.ExpectResourceAction(resourceName, plancheck.ResourceActionCreate),
},
},
},
},
})
}
Steps to Reproduce
- Amend
TestAccS3TablesTable_disappears acceptance test enabling the recommended plancheck.ResourceActionCreate
- Run the test
- Observe failed test:
=== RUN TestAccS3TablesTable_disappears
=== PAUSE TestAccS3TablesTable_disappears
=== CONT TestAccS3TablesTable_disappears
table_test.go:116: Step 1/1 error: Post-apply refresh plan check(s) failed:
'aws_s3tables_table.test' - expected Create, got action(s): [delete create]
--- FAIL: TestAccS3TablesTable_disappears (26.54s)
Debug Logging
No response
GenAI / LLM Assisted Development
not super helpful tbh ;-)
Important Facts and References
No response
Would you like to implement a fix?
Yes
Terraform and AWS Provider Version
Affected Resource(s) or Data Source(s)
All resources using Terraform Plugin Framework that have region attributes
Expected Behavior
When a resource is deleted outside of Terraform (resource disappears), the next terraform plan should detect the resource as missing and propose to recreate it with action [create].
Actual Behavior
When a resource is deleted outside of Terraform, the resource appears to still exist in state with null values instead of being properly detected as missing. This causes incorrect plan actions showing [destroy, create] instead of just [create].
Relevant Error/Panic Output
Sample Terraform Configuration
Click to expand configuration
Steps to Reproduce
TestAccS3TablesTable_disappearsacceptance test enabling the recommendedplancheck.ResourceActionCreate=== RUN TestAccS3TablesTable_disappears
=== PAUSE TestAccS3TablesTable_disappears
=== CONT TestAccS3TablesTable_disappears
table_test.go:116: Step 1/1 error: Post-apply refresh plan check(s) failed:
'aws_s3tables_table.test' - expected Create, got action(s): [delete create]
--- FAIL: TestAccS3TablesTable_disappears (26.54s)
Debug Logging
No response
GenAI / LLM Assisted Development
not super helpful tbh ;-)
Important Facts and References
No response
Would you like to implement a fix?
Yes