1
votes
    **Dockerfile**:
    
    FROM java:8-jre-alpine
    
    EXPOSE 9911
    
    VOLUME /etc/sns
    
    ENV AWS_DEFAULT_REGION=us-east-2 \
        AWS_ACCESS_KEY_ID=XXXXXXXXXXXXXXXXXX \
        AWS_SECRET_ACCESS_KEY=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
        DB_PATH=/etc/sns/db.json
    
    # aws-cli
    RUN apk -Uuv add python py-pip && \
        pip install awscli && \
        apk --purge -v del py-pip && \
        rm /var/cache/apk/*
    
    ARG VERSION=0.3.0version: "3"
    
    services:
      aws-sns:
        build: .
        image: aws-sns-test:latest
        volumes:
          - ./config:/etc/sns
        expose:
          - 9911
        ports:
         - 9911:9911
        hostname: aws-sns
        enter code here
    
    ADD https://github.com/s12v/sns/releases/download/$VERSION/sns-$VERSION.jar /sns.jar
    
    CMD ["java", "-jar", "/sns.jar"]
    

    **docker-compose.yml:**
    
    version: "3"
    
    services:
      aws-sns:
        build: .
        image: aws-sns-test:latest
        volumes:
          - ./config:/etc/sns
        expose:
          - 9911
        ports:
         - 9911:9911
        hostname: aws-sns
        
 Later I also set the env variables using aws configure but this also didn't work.
aws configure
    AWS Access Key ID [****************XXXX]:
    AWS Secret Access Key [****************XXXX]:
    Default region name [us-east-2]:
    Default output format [None]:

I set these variables in sns conatiner( eg docker exec -it 39cb43921b31(conatinerid) sh) later as well but I didn't get desired output.

OUTPUT:
aws --endpoint-url=http://localhost:9911 sns create-topic --name local_sns { "TopicArn": "arn:aws:sns:us-east-1:123456789012:local_sns" }
EXPECTED OUTPUT:
aws --endpoint-url=http://localhost:9911 sns create-topic --name local_sns { "TopicArn": "arn:aws:sns:us-east-2:123456789012:local_sns" }

1
Are you sure that the region is customizable in this sns docker container?Marcin
yes i am getting like this $ winpty docker exec -it f049dd18f448 sh / # aws configure get region us-east-2 / #Tarun Singh
did you check your ~/.aws/config file?ItayB
Inside container I checked this file was not there? do we need this file in container?Tarun Singh

1 Answers

1
votes

You can't change the region, as it is hard-coded into the source code:

 val topic = Topic(s"arn:aws:sns:us-east-1:123456789012:$name", name)

The AWS credentials that you use have no effect, as they can be anything so that AWS CLI does not complain. You can also use --no-sign-request option for aws cli to eliminate the need for the credentials.