Skip to content

bug: AWS_REGION not respected in startup script #11387

@DsMaccy

Description

@DsMaccy

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Description

AWS_REGION environment variable is overwritten and unusable in the docker-compose. This is noticeable when trying to run the startup script. When echo-ing the AWS_REGION, it gets overwritten to us-east-1. Once the region is hard-coded to the appropriate region, it works fine

localstack_setup.sh

#!/usr/bin/env bash

set -euo pipefail

# enable debug
# set -x

echo "configuring sqs"
echo "==================="
LOCALSTACK_HOST=localhost
echo $AWS_REGION  # NOTE: The environment variable is getting overridden as us-east-1.  Ignore this environment variable here
AWS_REGION=us-east-2

create_queue() {
    local QUEUE_NAME_TO_CREATE=$1
    awslocal --endpoint-url=http://${LOCALSTACK_HOST}:4566 sqs create-queue --queue-name ${QUEUE_NAME_TO_CREATE} --region $AWS_REGION --attributes VisibilityTimeout=30
}

create_queue "test"

docker-compose.yaml

    image: localstack/localstack
    ports:
      - "4566:4566"
    environment:
      AWS_REGION: us-east-2 # This is ignored at point of the script, but I expect that this is a temporary bug
      SERVICES: sqs
    volumes:
      # Container startup script
      - ./local_setup_config/localstack_setup.sh:/etc/localstack/init/ready.d/script.sh

Resources

  1. Similar issue here which is marked as resolved: Lambda AWS_REGION not provided in Go docker container. #2951
  2. Startup script found here: https://stackoverflow.com/questions/68131349/automatically-create-sqs-queue-using-localstack-and-docker-compose

Expected Behavior

The AWS_REGION should be respected in the docker compose. If us-east-1 is needed for particular AWS resources like those that are region agnostic, this should be handled with either a separate environment variable or individually for those particular services.

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

How are you starting localstack (e.g., bin/localstack command, arguments, or docker-compose.yml)

  1. Add the startup script provided
  2. chmod +x <script>
  3. docker-compose up

Client commands (e.g., AWS SDK code snippet, or sequence of "awslocal" commands)

See startup script provided (main issue is the environment variable, not any particular command)

Environment

- OS: Windows 11 using WSL running Ubuntu 20.04
- LocalStack:
  LocalStack version: 3.6.1.dev
  LocalStack Docker image sha: d0e2402471a1debcc516f02dcd209c2bdbb38d93baf5bf16bfe32a62f16ef386
  LocalStack build date: 2024-08-20
  LocalStack build git hash: 93f611975


LocalStack build date:

Anything else?

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions