Skip to content
This repository was archived by the owner on Nov 27, 2023. It is now read-only.

ECS Cluster created in wrong region (us-east-1) #1050

Closed
gorrog opened this issue Dec 11, 2020 · 2 comments
Closed

ECS Cluster created in wrong region (us-east-1) #1050

gorrog opened this issue Dec 11, 2020 · 2 comments
Assignees
Labels
bug 🐞 App is not working correctly. ecs

Comments

@gorrog
Copy link

gorrog commented Dec 11, 2020


BUG REPORT INFORMATION

Use the commands below to provide key information from your environment:
You do NOT have to include this information if this is a FEATURE REQUEST
-->

Description

Preface:
I am an AWS novice, so there is a chance that this is not an actual bug, however after quite a bit of research and investigaiton I do not know what I am doing wrong.

Every time I create an ECS cluster with docker compose -f production.yml up the cluster is created in region us-east-1, despite having region = eu-west-2 in my ~/.aws/config file, and "Profile": "default" in the ecs context I'm using to create the cluster.

Things I have tried to resolve this.

  1. Removing my ecs context and adding it again using the docker context rm and docker context create ecs myecscontext commands.
  2. Installing the latest version of the cli
  3. Manually checking both my ~/.aws/config and /home/roger/.docker/contexts/meta/48f62a86e3f14dab7bbecff064a56ea130fac8dc96b1a1442e5019bdc724be7a/meta.json files for any issues.

Steps to reproduce the issue:

  1. Create a new ecs context with the docker context create ecs myecscontext command
  2. Select 'An existing AWS profile' when asked what credentials to use.
  3. Switch to the context with docker context use myecscontext.
  4. Create a cluster with docker compose -f production.yml up.
  5. See that the cluster is being created in AWS in the us-east-1 region.
  6. Inspect the generated Cloudformation code with docker compose -f production.yml convert.
  7. Notice a number of occurrences of us-east-1 in the generated YAML as per below
  SomeTaskDefinition:
    Properties:
      ContainerDefinitions:
      - Command:
        - us-east-1.compute.internal
        - myproject.local

Describe the results you received:

See above, the cluster is created in region us-east-1

Describe the results you expected:

The cluster is created in region eu-west-2 as per my AWS CLI settings.

Additional information you deem important (e.g. issue happens only occasionally):

I have a feeling that upstream something is failing and us-east-1 is being selected because it's an AWS default region.

Output of docker version:

Client: Docker Engine - Community
 Cloud integration: 1.0.4
 Version:           19.03.14
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        5eb3275d40
 Built:             Tue Dec  1 19:20:26 2020
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.14
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       5eb3275d40
  Built:            Tue Dec  1 19:18:53 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.3.9
  GitCommit:        ea765aba0d05254012b0b9e595e995c09186427f
 runc:
  Version:          1.0.0-rc10
  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

Output of docker context show:
You can also run docker context inspect context-name to give us more details but don't forget to remove sensitive content.

[
    {
        "Name": "brsk_ecs",
        "Metadata": {
            "Type": "ecs"
        },
        "Endpoints": {
            "docker": {
                "SkipTLSVerify": false
            },
            "ecs": {
                "Profile": "default"
            }
        },
        "TLSMaterial": {},
        "Storage": {
            "MetadataPath": "/home/roger/.docker/contexts/meta/48f62a86e3f14dab7bbecff064a56ea130fac8dc96b1a1442e5019bdc724be7a",
            "TLSPath": "/home/roger/.docker/contexts/tls/48f62a86e3f14dab7bbecff064a56ea130fac8dc96b1a1442e5019bdc724be7a"
        }
    }
]

Output of docker info:

Client:
 Debug Mode: false

Server:
 Containers: 9
  Running: 0
  Paused: 0
  Stopped: 9
 Images: 147
 Server Version: 19.03.14
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: ea765aba0d05254012b0b9e595e995c09186427f
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  apparmor
  seccomp
   Profile: default
 Kernel Version: 5.4.0-56-generic
 Operating System: Ubuntu 20.04.1 LTS
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 15.3GiB
 Name: bobobo
 ID: B3CI:DMI2:WXWA:RLNF:DA7D:4WAP:VOF4:E6FO:CS7H:XICD:JDT7:CUH6
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Username: gorrog
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Live Restore Enabled: false

WARNING: No swap limit support

Additional environment details (AWS ECS, Azure ACI, local, etc.):

> cat ~/.aws/config
[profile default]
region = eu-west-2

> env | rg AWS
AWS_DEFAULT_REGION=eu-west-2
@gorrog
Copy link
Author

gorrog commented Dec 11, 2020

UPDATE: Adding the following to my .zshrc seems to have fixed the issue:

export AWS_REGION="eu-west-2"
export AWS_PROFILE="default"

I have a feeling that there's something funny going on with fetching the correct ENV vars. Previously I only had export AWS_DEFAULT_REGION="eu-west-2" in my .zshrc.

@gorrog gorrog closed this as completed Dec 11, 2020
@ndeloof ndeloof self-assigned this Dec 14, 2020
@ndeloof ndeloof added ecs bug 🐞 App is not working correctly. labels Dec 14, 2020
@alramalho
Copy link

alramalho commented Jan 20, 2023

The error is still hapenning for me, even despite the workaround of setting AWS_REGION and AWS_PROFILE envs. Wtf? Pretty broken behaviour for something that is displayed in the docs...
I was able to fix it using

aws configure set default.region eu-central-1

It seems the all "select a profile" thing ain't properly working

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐞 App is not working correctly. ecs
Projects
None yet
Development

No branches or pull requests

3 participants