When running terraform import
on any of the resources below, the command succeeds with Import successful! message even that these resources don’t exist.
resource "aws_s3_bucket" "mybucket" {
bucket = "none"
}
resource "aws_elasticache_replication_group" "myreplica" {
replication_group_description = "none"
replication_group_id = "none"
}
When turning debug log on, it seems the AWS API return 404 but still it doesn’t propagate as failure.
e.g. (same flow happen with S3 import):
2021-05-03T12:30:13.043+0300 [INFO] provider.terraform-provider-aws_v3.38.0_x5: 2021/05/03 12:30:13 [DEBUG] [aws-sdk-go] DEBUG: Response elasticache/DescribeReplicationGroups Details:
---[ RESPONSE ]--------------------------------------
HTTP/1.1 404 Not Found
Connection: close
Content-Length: 306
Content-Type: text/xml
Date: Mon, 03 May 2021 09:30:12 GMT
X-Amzn-Requestid: 4967f5a3-c11a-4110-9afa-aaa8ba9a31d8
-----------------------------------------------------: timestamp=2021-05-03T12:30:13.043+0300
2021-05-03T12:30:13.044+0300 [INFO] provider.terraform-provider-aws_v3.38.0_x5: 2021/05/03 12:30:13 [DEBUG] [aws-sdk-go] <ErrorResponse xmlns="http://elasticache.amazonaws.com/doc/2015-02-02/">
<Error>
<Type>Sender</Type>
<Code>ReplicationGroupNotFoundFault</Code>
<Message>ReplicationGroup none not found.</Message>
</Error>
<RequestId>4967f5a3-c11a-4110-9afa-aaa8ba9a31d8</RequestId>
</ErrorResponse>: timestamp=2021-05-03T12:30:13.043+0300
2021-05-03T12:30:13.044+0300 [INFO] provider.terraform-provider-aws_v3.38.0_x5: 2021/05/03 12:30:13 [DEBUG] [aws-sdk-go] DEBUG: Validate Response elasticache/DescribeReplicationGroups failed, attempt 0/25, error ReplicationGroupNotFoundFault: ReplicationGroup none not found.
status code: 404, request id: 4967f5a3-c11a-4110-9afa-aaa8ba9a31d8: timestamp=2021-05-03T12:30:13.043+0300
2021-05-03T12:30:13.044+0300 [INFO] provider.terraform-provider-aws_v3.38.0_x5: 2021/05/03 12:30:13 [WARN] ElastiCache Replication Group (none) not found, removing from state: timestamp=2021-05-03T12:30:13.044+0300
2021-05-03T12:30:13.044+0300 [WARN] Provider "registry.terraform.io/hashicorp/aws" produced an unexpected new value for aws_elasticache_replication_group.none during refresh.
- Root resource was present, but now absent
2021-05-03T12:30:13.045+0300 [DEBUG] provider.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021-05-03T12:30:13.053+0300 [DEBUG] provider: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/aws/3.38.0/darwin_amd64/terraform-provider-aws_v3.38.0_x5 pid=96648
2021-05-03T12:30:13.053+0300 [DEBUG] provider: plugin exited
2021-05-03T12:30:13.053+0300 [INFO] Writing state output to:
Import successful!
Is this expected or something is missing from my side?
The idea for me was to attempt an import and if it fails - create a resource (e.g. create S3 bucket and DynamoDB table before using remote state).