terraform v1.1.7
terraform-aws-provider v4.5.0
I have a simple KMS key resource:
output "key" {
value = aws_kms_key.key.id
}
resource "aws_kms_key" "key" {
description = "Test"
is_enabled = true
deletion_window_in_days = 7
}
And when I apply ititialized project it is giving me the output, but when I am importing it with terraform import
I have the following behavior:
$ tf init
$ tf import aws_km_key.key 11bcda7c-6f9e-4edf-94d1-273eedt3be28
$tf plan
...
Changes to Outputs:
+ key = "11bcda7c-6f9e-4edf-94d1-273eedt3be28"
$tf output
╷
│ Warning: No outputs found
│
│ The state file either has no outputs defined, or all the defined outputs are empty. Please define an output in your configuration with the
│ `output` keyword and run `terraform refresh` for it to become available. If you are using interpolation, please verify the interpolated value
│ is not empty. You can use the `terraform console` command to assist.
It gets even weirder - if you add to the config above s3 bucket config
resource "aws_s3_bucket" "test" {
bucket = "test-bucket"
}
output "test_bucket" {
value = aws_s3_bucket.test.bucket
}
with aws_s3_bucket.test.bucket
output
You’ll get this output:
$ tf plan
...
Changes to Outputs:
+ test_bucket = "test-bucket"
$ tf output
key = "85bcda7c-6f9e-4edf-94d1-253edde3be28"
Is it expected behavior?