Skip to content

tfstate plugin fails with "Invalid region: region was not a valid DNS name" error #855

@a1678991

Description

@a1678991

tfstate plugin fails with "Invalid region: region was not a valid DNS name" error

Environment

  • ecspresso version: v2.5.0
  • Terraform version: v1.12.2
  • OS: Linux

Description

When trying to use the tfstate plugin to read outputs from an S3-backed Terraform state file, ecspresso fails with an error about invalid DNS name for the region. This is my first time setting up ecspresso, so I might be missing something obvious.

Configuration

ecspresso/dev/config.yaml:

# ecspresso configuration for development environment
region: us-west-2
cluster: my-ecs-cluster-dev
service: my-ecs-service-dev
task_definition: task-definition.json
service_definition: service-definition.json
timeout: 10m

plugins:
  - name: tfstate
    config:
      url: s3://my-terraform-state-bucket/terraform.tfstate

Steps to Reproduce

  1. Set up ecspresso configuration with tfstate plugin pointing to S3 backend
  2. Ensure AWS credentials are properly configured
  3. Run ecspresso --config ecspresso/dev/config.yaml diff

Expected Behavior

The tfstate plugin should successfully read the terraform state from S3 and make the outputs available for use in the configuration.

Actual Behavior

The command fails with the following error:

2025-06-17T00:36:28.036+09:00 [INFO] ecspresso version: v2.5.0
2025-06-17T00:36:28.036+09:00 [ERROR] FAILED. failed to load config file ecspresso/dev/config.yaml: failed to setup plugins: failed to read tfstate from s3://my-terraform-state-bucket/terraform.tfstate: operation error S3: HeadBucket, resolve auth scheme: resolve endpoint: endpoint rule error, Invalid region: region was not a valid DNS name.

Additional Context

  1. The S3 bucket exists and is accessible:

    $ aws s3 ls s3://my-terraform-state-bucket/ --region us-west-2
    2025-06-16 22:49:01     733257 terraform.tfstate
  2. AWS credentials are properly configured and work with AWS CLI:

    $ aws sts get-caller-identity
    {
        "UserId": "AIDAXXXXXXXXXXXXXXXXX",
        "Account": "123456789012",
        "Arn": "arn:aws:iam::123456789012:user/myuser"
    }
  3. The same region (us-west-2) works without error for ecspresso diff when the tfstate plugin is disabled.

Related Information

  • We're using a single Terraform state file at the root level
  • The Terraform backend configuration is:
    terraform {
      backend "s3" {
        bucket         = "my-terraform-state-bucket"
        key            = "terraform.tfstate"
        region         = "us-west-2"
        encrypt        = true
        dynamodb_table = "my-terraform-state-lock"
      }
    }

Any guidance would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions