ljfranklin / terraform-resource

A concourse resource to create infrastructure via Terraform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error refreshing state error

SagarDamu opened this issue · comments

Hi,
Currently, I'm facing an issue, they are while trying to trigger the terraform-plan a second time after a successful build in concourse getting the error refresh state error, attached the error message below for your reference

Successfully configured the backend "s3"! Terraform will automatically
use this backend unless the backend configuration changes.
Error refreshing state: state snapshot was created by Terraform v1.1.8, which is newer than current v0.13.5; upgrade to Terraform v1.1.8 or greater to work with this state

and also I'm having a doubt that is there any way to create a terraform workspace through concourse pipeline and in that workspace to plan, apply and destroy our change.
Thanks in advance.

What version of the terraform-resource are you using (check resource_types.terraform.source.tag)? Sounds like you're trying to interact with an existing workspace that was created outside your CI pipeline using a newer version of Terraform but your current CI pipeline is using an older version of the terraform-resource. Updating the tag value of the terraform-resource in your pipeline config should fix it.

also I'm having a doubt that is there any way to create a terraform workspace through concourse pipeline

The terraform-resource will automatically create a workspace based on the env_name you set in your pipeline config: https://github.com/ljfranklin/terraform-resource#put-parameters.

What version of the terraform-resource are you using (check resource_types.terraform.source.tag)? Sounds like you're trying to interact with an existing workspace that was created outside your CI pipeline using a newer version of Terraform but your current CI pipeline is using an older version of the terraform-resource. Updating the tag value of the terraform-resource in your pipeline config should fix it.

Actually, no change in the version of the terraform while trying to trigger another time after the successful build without any change gave me the above-mentioned error, and also tried to change the tag version which is giving me another error

Error: Unsupported Terraform Core version

  on .terraform/modules/ci-west-prefDS/terraform/modules/dataService/main.tf line 4, in terraform:
   4:   required_version = ">= 1.1.8"

Module module.ci-west-prefDS (from
git::ssh://git@github.comcast.com/appds-tools/coast-infrastructure//terraform/modules/dataService/?ref=ICSPS-674_TEL)
does not support Terraform version 0.13.5. To proceed, either choose another
supported Terraform version or update this version constraint. Version
constraints are normally set for good reason, so updating the constraint may
lead to other errors or unexpected behavior.

The error says does not support Terraform version 0.13.5 which sounds like your terraform-resource tag is still set to 0.13.5. The latest tag contains Terraform version v1.1.9:

$ docker pull ljfranklin/terraform-resource:latest
$ docker run -it ljfranklin/terraform-resource:latest terraform -v
Terraform v1.1.9
on linux_amd64

Double-check that your resource_types.terraform.source.tag value is set to 1.1.8 or higher. If that's correct then something about your Concourse installation is broken because it should be pulling new images.