Terraform-provider-aws: version 2.28.0 return errors

Created on 12 Sep 2019  ·  16Comments  ·  Source: hashicorp/terraform-provider-aws

When I run the terraform plan command and the aws provider version property version = 2.27.0 is not set, it returns that error because by default the version 2.28.0 has a bug

Terraform Version

0.12.8

Affected Resource(s)

  • aws provider version: 2.28.0

Panic Output

Error: missing expected [

Actual Behavior

Error: missing expected [

Steps to Reproduce

terraform init && terraform plan

  1. terraform plan
    Error: missing expected [
bug regression serviccloudfront

Most helpful comment

Hi folks 👋 Sorry for the trouble here.

The change from https://github.com/terraform-providers/terraform-provider-aws/pull/10013 will require additional work (e.g. state migration) before it can be merged in. I submitted #10093 to revert it and we should be able to cut a 2.28.1 bug fix release today or tomorrow.

All 16 comments

Also experiencing this...

I am also experiencing this. It happens during the state refresh.

To provide a bit more context, it seems to be with the aws_cloudfront_distribution resource.
I believe the recent change to the schema, here https://github.com/terraform-providers/terraform-provider-aws/commit/ebdc976ec075ce924a580207b62502c418f26156#diff-a9d90d298f8013ea41caa2d4f3b886a2R698 is causing the state refresh to break.

To reproduce this, I created the above TF resource in our dev env with the 2.27 version of the AWS provider, then updated to the 2.28 and ran the terraform plan command. I was able to create a new resource using 2.28 without issue, and refresh the state.

@erumble good find, it's definitely only happening with apps of ours that use cloudfront as well.

Me to :( Just started happening.

$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

data.terraform_remote_state.product-infrastructure: Refreshing state...
aws_iam_role.cloudfront-lambda-role: Refreshing state... [id=cloudfront-lambda-role-production]
aws_s3_bucket.portal-redirection: Refreshing state... [id=www.mydomain.com]
aws_s3_bucket.portal: Refreshing state... [id=mydomain.com]
aws_lambda_function.rewrite-lambda: Refreshing state... [id=cloudfront-behavior-path-rewrite-production]
data.aws_lambda_function.rewrite-lambda: Refreshing state...

Error: missing expected [



Error: missing expected [

I commented out except the terraform and provider blocks, re-ran terraform plan, and it still happens. It seems the problem is with the tfstate stored in the remote backend. I had even locked in my provider version (so this shouldn't be happening, right?):

provider "aws" {
  version = "~> 2.21"
  region  = "us-east-1"
}

Why is this happening? This is a major blocker...

@chaddjohnson - Wouldn't your version line still use the newer provider?

From the doc

~> 1.2: any non-beta version >= 1.2.0 and < 2.0.0, e.g. 1.X.Y

I think you might want
version = "~> 2.21.0" or just version = "2.21"

@chaddjohnson - Wouldn't your version line still use the newer provider?

From the doc

~> 1.2: any non-beta version >= 1.2.0 and < 2.0.0, e.g. 1.X.Y

I think you might want
version = "~> 2.21.0"

Thank you! This fixed it:

provider "aws" {
  version = "= 2.21"
  region  = "us-east-1"
}

Downgrading the aws provider to 2.27 fixed it for my project.

provider "aws" {
  version = "= 2.27"
  region  = "us-east-1"
}

Hi folks 👋 Sorry for the trouble here.

The change from https://github.com/terraform-providers/terraform-provider-aws/pull/10013 will require additional work (e.g. state migration) before it can be merged in. I submitted #10093 to revert it and we should be able to cut a 2.28.1 bug fix release today or tomorrow.

This has been released in version 2.28.1 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

@bflad

Seeing similar issues even with 2.28.1, still cloudfront but instead:

Error: missing expected {

this time it is a { instead of a [

I tried downgrading but it did not fix the issue.

Thanks!

@MarkKewley that'll be an error in your tf in that case most likely imo.

@matthewduren Interesting considering there weren't any changes within my cloudfront module. I just reset the bad state to fix it. Might've been issues moving between 28.0 and 28.1.

@MarkKewley Could you tell me how you "reset the bad state"? (I see to have run into the same issue.)

@jsaito
You won't like it...but I removed my cloudfront instance and did a terraform state rm for each affected distribution. Really would not recommend it by any means but so far I haven't been running into any issues since.

I believe there are commands to repair your state as well, didn't look into it further since we are in a bit of a rush.

@MarkKewley I see. Thank you!

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!

Was this page helpful?
0 / 5 - 0 ratings