Open wellsiau-aws opened 4 days ago
Debug logs detected changes to the following attributes:
Which I believe related to issue reported on #1216
However, changes detected on key_schema
are different because Terraform thinks that key_schema doesn't exist in the previous state
# awscc_dynamodb_table.table_name will be updated in-place
~ resource "awscc_dynamodb_table" "table_name" {
+ global_secondary_indexes = (known after apply)
id = "table-name"
+ import_source_specification = (known after apply)
+ key_schema = jsonencode(
[
+ {
+ AttributeName = "id"
+ KeyType = "HASH"
},
]
)
Additional debug logs
State file (redacted)
key_schema
is available in the statefile, as well as CCAPI GetResource.
{
"mode": "managed",
"type": "awscc_dynamodb_table",
"name": "table_name",
"provider": "provider[\"registry.terraform.io/hashicorp/awscc\"]",
"instances": [
{
"schema_version": 1,
"attributes": {
"arn": "arn:aws:dynamodb:us-east-1:204034886740:table/table-name",
"attribute_definitions": [
{
"attribute_name": "id",
"attribute_type": "S"
}
],
"id": "table-name",
"key_schema": "[{\"AttributeName\":\"id\",\"KeyType\":\"HASH\"}]",
. . .
}
PlanResourceChange_Request_PriorState.msgpack
Terraform consider that the prior state for the key_schema
is null, which is incorrect.
{
"arn": "arn:aws:dynamodb:us-east-1:204034886740:table/table-name",
"attribute_definitions": [
{
"attribute_name": "id",
"attribute_type": "S"
}
],
"billing_mode": "PAY_PER_REQUEST",
"contributor_insights_specification": {
"enabled": false
},
"deletion_protection_enabled": false,
"global_secondary_indexes": null,
"id": "table-name",
"import_source_specification": null,
"key_schema": null,
"kinesis_stream_specification": null,
"local_secondary_indexes": null,
"on_demand_throughput": {
"max_read_request_units": 10,
"max_write_request_units": 10
},
"point_in_time_recovery_specification": {
"point_in_time_recovery_enabled": false
},
"provisioned_throughput": null,
"resource_policy": null,
"sse_specification": {
"kms_master_key_id": null,
"sse_enabled": false,
"sse_type": null
},
"stream_arn": null,
"stream_specification": null,
"table_class": null,
"table_name": "table-name",
"tags": null,
"time_to_live_specification": {
"attribute_name": null,
"enabled": false
}
}
PlanResourceChange_Request_ProposedNewState.msgpack
Proposed new state recovers the configuration for key_schema
{
"arn": "arn:aws:dynamodb:us-east-1:204034886740:table/table-name",
"attribute_definitions": [
{
"attribute_name": "id",
"attribute_type": "S"
}
],
"billing_mode": "PAY_PER_REQUEST",
"contributor_insights_specification": null,
"deletion_protection_enabled": false,
"global_secondary_indexes": null,
"id": "table-name",
"import_source_specification": null,
"key_schema": "[{\"AttributeName\":\"id\",\"KeyType\":\"HASH\"}]",
"kinesis_stream_specification": null,
"local_secondary_indexes": null,
"on_demand_throughput": {
"max_read_request_units": 10,
"max_write_request_units": 10
},
"point_in_time_recovery_specification": {
"point_in_time_recovery_enabled": false
},
"provisioned_throughput": null,
"resource_policy": null,
"sse_specification": null,
"stream_arn": null,
"stream_specification": null,
"table_class": null,
"table_name": "table-name",
"tags": null,
"time_to_live_specification": null
}
I suspect the problem occurs before PlanResourceChange is called.
Further investigation led to the following:
ReadResource_Request_CurrentState.msgpack
key_schema
is still available on this stage:
{
"arn": "arn:aws:dynamodb:us-east-1:204034886740:table/table-name",
"attribute_definitions": [
{
"attribute_name": "id",
"attribute_type": "S"
}
],
"billing_mode": "PAY_PER_REQUEST",
"contributor_insights_specification": {
"enabled": false
},
"deletion_protection_enabled": false,
"global_secondary_indexes": null,
"id": "table-name",
"import_source_specification": null,
"key_schema": "[{\"AttributeName\":\"id\",\"KeyType\":\"HASH\"}]",
"kinesis_stream_specification": null,
"local_secondary_indexes": null,
"on_demand_throughput": {
"max_read_request_units": 10,
"max_write_request_units": 10
},
"point_in_time_recovery_specification": {
"point_in_time_recovery_enabled": false
},
"provisioned_throughput": null,
"resource_policy": null,
"sse_specification": {
"kms_master_key_id": null,
"sse_enabled": false,
"sse_type": null
},
"stream_arn": null,
"stream_specification": null,
"table_class": null,
"table_name": "table-name",
"tags": null,
"time_to_live_specification": {
"attribute_name": null,
"enabled": false
}
}
ReadResource_Response_NewState.msgpack And then disappear after ReadResponse is called
{
"arn": "arn:aws:dynamodb:us-east-1:204034886740:table/table-name",
"attribute_definitions": [
{
"attribute_name": "id",
"attribute_type": "S"
}
],
"billing_mode": "PAY_PER_REQUEST",
"contributor_insights_specification": {
"enabled": false
},
"deletion_protection_enabled": false,
"global_secondary_indexes": null,
"id": "table-name",
"import_source_specification": null,
"key_schema": null,
"kinesis_stream_specification": null,
"local_secondary_indexes": null,
"on_demand_throughput": {
"max_read_request_units": 10,
"max_write_request_units": 10
},
"point_in_time_recovery_specification": {
"point_in_time_recovery_enabled": false
},
"provisioned_throughput": null,
"resource_policy": null,
"sse_specification": {
"kms_master_key_id": null,
"sse_enabled": false,
"sse_type": null
},
"stream_arn": null,
"stream_specification": null,
"table_class": null,
"table_name": "table-name",
"tags": null,
"time_to_live_specification": {
"attribute_name": null,
"enabled": false
}
}
Community Note
Terraform CLI and Terraform AWS Cloud Control Provider Version
Affected Resource(s)
Terraform Configuration Files
Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.
Debug Output
Expected Behavior
Subsequent
terraform plan
after the firstterraform apply
should not register any driftActual Behavior
Subsequent
terraform plan
after the firstterraform apply
detected a driftSteps to Reproduce
terraform apply
terraform plan
Important Factoids
References