Skip to content

s3 backend bootstrap - unclear error when s3 bucket name invalid #5106

@DonClaveau3

Description

@DonClaveau3

Error Message Details

If the remote_state is configured with an invalid s3 bucket name, we are told that the bucket doesn't exist and we should try to bootstrap.

The Error Message

v.0.93.8

Remote state S3 bucket tfstate_aws does not exist or you don't have permissions to access it. Would you like Terragrunt to create it? (y/n) y
15:25:42.971 ERROR  error checking access to S3 bucket tfstate_aws: operation error S3: GetObject, https response error StatusCode: 404, RequestID: ..., HostID: ..., api error NoSuchBucket: The specified bucket does not exist
15:25:43.171 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1
15:25:43.173 ERROR  Suggested fixes: 
Remote state bucket not found, create it manually or rerun with --backend-bootstrap to provision automatically.

Why This Error Message is Unhelpful

Current Problems

A common mistake makes it seem like backend bootstrapping just doesn't work.
The guidance to "rerun with --backend-bootstrap" is confusing when you are already running with --backend-bootstrap

Recommended Improvement

What the Error Message Should Say

I ultimately figured out my issue by trying earlier versions of terragrunt (prior to the backend command)

v0.76.0

Remote state S3 bucket tfstate_aws does not exist or you don't have permissions to access it. Would you like Terragrunt to create it? (y/n) y
15:36:19.371 ERROR  InvalidBucketName: The specified bucket is not valid.
        status code: 400, request id: ..., host id: ...
15:36:19.614 ERROR  Unable to determine underlying exit code, so Terragrunt will exit with error code 1

Error Reproduction Steps

remote_state {
  backend = "s3"
  generate = {
    path      = "backend.tf"
    if_exists = "overwrite_terragrunt"
  }
  config = {
    bucket = "tfstate_aws"
    key    = "${path_relative_to_include()}/terraform.tfstate"

    region = local.aws_region
  }
}

Steps to Reproduce

  1. terragrunt backend bootstrap

Environment Information

  • Terragrunt version: 0.98.3
  • OpenTofu/Terraform version: 1.13.5
  • Operating system: mac Sequoia 15.5 (24F74)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingerror-messageRelates to an error message in Terragrunt.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions