Skip to main content
Knowledge Base

Automatically create S3 backend bucket from pipeline

Answer

I'm running a new plan on a dev branch that will create a new VPC in another region using the github action pipeline. I notice that isn't able to create the corresponding S3 bucket and the plan failed. Should I have to run terragrunt init manually on that resource in order to get the bucket created ? See log below: . . [ecs-deploy-runner][2023-06-13T21:42:20+0000] [INFO] [infrastructure-deploy-script] 2023-06-13 21:42:20 Running command "terragrunt plan -input=false" [ecs-deploy-runner][2023-06-13T21:42:23+0000] Remote state S3 bucket lunasolutions-dev-us-east-2-tf-state does not exist or you don't have permissions to access it. Would you like Terragrunt to create it? (y/n) time=2023-06-13T21:42:23Z level=error msg=EOF [ecs-deploy-runner][2023-06-13T21:42:23+0000] time=2023-06-13T21:42:23Z level=error msg=Unable to determine underlying exit code, so Terragrunt will exit with error code 1 [ecs-deploy-runner][2023-06-13T21:42:23+0000] [INFO] [infrastructure-deploy-script] 2023-06-13 21:42:23 "terragrunt plan" exited with code 1 [ecs-deploy-runner][2023-06-13T21:42:23+0000] Error: Could not run "terragrunt plan". Error=Remote state S3 bucket lunasolutions-dev-us-east-2-tf-state does not exist or you don't have permissions to access it. Would you like Terragrunt to create it? (y/n) time=2023-06-13T21:42:23Z level=error msg=EOF [ecs-deploy-runner][2023-06-13T21:42:23+0000] time=2023-06-13T21:42:23Z level=error msg=Unable to determine underlying exit code, so Terragrunt will exit with error code 1 [ecs-deploy-runner][2023-06-13T21:42:23+0000] exit status 1 . . Please, advice. --- <ins datetime="2023-06-13T22:06:29Z"> <p><a href="https://support.gruntwork.io/hc/requests/110254">Tracked in ticket #110254</a></p> </ins>

Ah, I think I understand what's happening @gberlot-luna. It looks like your ecs-deploy-runner is on `v0.45.11`, this can be checked by looking at the `build_deploy_runner_image.sh` build arguments. Looking at your `infrastructure-live` repo I can see this being passed in: `--build-arg 'terragrunt_version=v0.45.11' \` along with terraform version `1.1.9` from `--build-arg 'terraform_version=1.1.9' \` What is likely happening is you deployed locally using `v0.36.0`, which is over a year old. This also explains the ACL error you were seeing (as this was fixed in terragrunt `v0.45.4`). Terragrunt state currently is expecting `v0.36.0` since that's what it was created with, but the ecs-deploy-runner is on a much newer version. If you update your local version of terragrunt to `v0.45.11` to match what the ecs-deploy-runner is using, along with your local version of terraform to `1.1.9` I suspect you will see the `out of date` error with the state bucket, and you'll be prompted to update it. Once you update it locally and let terragrunt update the state, you can try re-running the ecs-deploy-runner and it should hopefully work.