skip to Main Content

Im trying to setup Localstack and AWS Cli
I have installed sudo snap install aws-cli --classic to run command
This is my compose:

services:
  localstack:
    image: localstack/localstack
    ports:
      - "4566:4566"
      - "4571:4571"
    environment:
      - AWS_ACCESS_KEY_ID=dummy
      - AWS_SECRET_ACCESS_KEY=dummy
      - AWS_DEFAULT_REGION=us-east-1
      - SERVICES=dynamodb,s3,sns,sqs,kms,lambda,cloudformation,cloudwatch

When i run command aws s3 mb s3://books --endpoint-url=http://localhost:4566 i see on console
make_bucket failed: s3://books Unable to locate credentials
As i understand this env variables available on docker container because previously i set this property from the command aws configure and it works. What i do wrong in my yaml file ?
When i try to open health in browser i see this Error. What i missed ?
enter image description here

I want to set credentials AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION in docker compose file (i don’t know why this set up wrong) and i want to see health on browser

2

Answers


  1. The environement varaiables are only accessible in your Localstack container, not in your local machine but anyway Localstack doesn’t need this ENV varaiables to function but other tools like AWS CLI needs this to be set to function.

    So you can execute your make bucket without signing :

    aws s3 mb s3://books --endpoint-url=http://localhost.localstack.cloud:4566 --no-sign-request
    

    but this doesn’t work for all commands.

    You can also execut your aws cli commands directly in your container :

    docker exec -it <container_id> aws s3 mb s3://books --endpoint-url=http://localhost.localstack.cloud:4566
    

    Or from your local machine :

    AWS_ACCESS_KEY_ID=dummy AWS_SECRET_ACCESS_KEY=dummy AWS_DEFAULT_REGION=us-east-1 aws s3 mb s3://books --endpoint-url=http://localhost.localstack.cloud:4566
    
    Login or Signup to reply.
  2. You need to set some of these configuration variables manually in your shell session, like:

    export AWS_ACCESS_KEY_ID="test"
    export AWS_SECRET_ACCESS_KEY="test"
    export AWS_DEFAULT_REGION="us-east-1"
    

    .. and then run the command:

    aws s3 mb s3://books --endpoint-url=http://localhost:4566
    

    The health endpoint that you are trying to access has been deprecated. The new endpoint is:

    curl -X GET localhost:4566/_localstack/health
    

    Hope this helps!

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search