Hi Here,
I’ve an issue with my terraform not sync state from s3, apply will create all resources as new
I haven’t do any changed on my terraform code, just to make plan and found alot of resource will be created. if I apply it will create all resources as new. Can anyone expert share any idea how to resolve this? Thanks in advance,
So you are using S3 remote state? Has anything changed with the backend block in your code? Could you show some code? Are there any errors when you run a terraform refresh
? Can you see the state object in the S3 bucket?
Hi @stuart-c ,
Thanks for cm, btw i haven’t do any change on backend block. its seem like it not sync latest state from s3, and will create new resource if we do terraform apply. from the terraform refresh, you have mention what u meant?
below is my backend block:
terraform {
backend “s3” {
}
}
data “terraform_remote_state” “app” {
backend = “s3”
workspace = terraform.workspace
config = {
bucket = var.tf_bucket_name
key = “terraform-app.tfstate”
region = var.tf_region
encrypt = true
dynamodb_table = “terraform-state”
profile = var.profile
workspace_key_prefix = “environment”
}
}
As there isn’t anything listed in the backend s3 block that suggests you are using -backend-config
and/or environment variables to set things like the bucket name, region, key, etc.
How are you doing that, and are you sure they haven’t been adjusted in any way?