_This issue was originally opened by @james-robson as hashicorp/terraform#18693. It was migrated here as a result of the provider split. The original body of the issue is below._
0.11.7
resource "aws_cloudfront_distribution" "example_distribution" {
// ...other distribution config
default_cache_behavior {
allowed_methods = ["HEAD", "GET", "OPTIONS"]
cached_methods = ["HEAD", "GET", "OPTIONS"]
compress = true
default_ttl = 86400
forwarded_values {
query_string = false
cookies {
forward = "none"
}
}
max_ttl = 31536000
min_ttl = 0
smooth_streaming = false
target_origin_id = "${local.some_origin_id}"
viewer_protocol_policy = "redirect-to-https"
}
ordered_cache_behavior {
allowed_methods = ["GET", "HEAD"]
cached_methods = ["GET", "HEAD"]
compress = false
default_ttl = 86400
forwarded_values {
query_string = false
cookies {
forward = "none"
}
}
max_ttl = 31536000
min_ttl = 0
path_pattern = "*"
smooth_streaming = false
target_origin_id = "${local.another_origin_id}"
viewer_protocol_policy = "redirect-to-https"
}
// ...the rest of the distribution config
}
Here is an example plan output which shows the issue:
------------------------------------------------------------------------
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
Terraform will perform the following actions:
~ aws_cloudfront_distribution.example_distribution
cache_behavior.#: "1" => "0"
cache_behavior.1293109696.allowed_methods.#: "2" => "0"
cache_behavior.1293109696.allowed_methods.0: "HEAD" => ""
cache_behavior.1293109696.allowed_methods.1: "GET" => ""
// etc...
ordered_cache_behavior.#: "0" => "1"
ordered_cache_behavior.0.allowed_methods.#: "0" => "2"
ordered_cache_behavior.0.allowed_methods.1040875975: "" => "GET"
ordered_cache_behavior.0.allowed_methods.1445840968: "" => "HEAD"
// etc...
N/A
When importing an "aws_cloudfront_distribution" using:
terraform import aws_cloudfront_distribution.example_distribution <DISTRIBUTION_ID>
the correct values should be saved to the state.
The cache behaviour is stored as the deprecated cache_behavior rather than ordered_cache_behavior. This causes the first plan after import to show a change from cache_behaviour to ordered_cache_behaviour.
terraform import aws_cloudfront_distribution.example_distribution <DISTRIBUTION_ID>ordered_cache_behaviour key and matching values to the import.terraform apply.Bug fix pull request submitted: #5586
The fix for this has been merged and will release with version 1.33.0 of the AWS provider, likely later this week.
This has been released in version 1.33.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
Excellent, thanks for the quick turnaround @bflad
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!
Most helpful comment
This has been released in version 1.33.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.