aws-containers / amazon-ecs-exec-checker

🚀 Pre-flight checks for ECS Exec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue ?

yellow-sock opened this issue · comments

ubuntu@DESKTOP-I7DBFAI:~$ aws ecs describe-tasks --profile=dma --region=eu-west-1 --cluster=mps-corporate-web --tasks=2fb8c764dcaf4b819f51d2c2b6fbcf70
{
    "tasks": [
        {
            "attachments": [
                {
                    "id": "af9341d2-fa6c-4af2-9964-1e40007caeed",
                    "type": "ElasticNetworkInterface",
                    "status": "ATTACHED",
                    "details": [
                        {
                            "name": "subnetId",
                            "value": "subnet-0a7ce6575e6d811ff"
                        },
... etc

so that command is working, but:

ubuntu@DESKTOP-I7DBFAI:~$ export AWS_PROFILE=dma
ubuntu@DESKTOP-I7DBFAI:~$ export AWS_REGION=eu-west-1
ubuntu@DESKTOP-I7DBFAI:~$ check-ecs-exec.sh mps-corporate-web 2fb8c764dcaf4b819f51d2c2b6fbcf70
-------------------------------------------------------------
Prerequisites for check-ecs-exec.sh v0.7
-------------------------------------------------------------
  jq      | OK (/usr/bin/jq)
  AWS CLI | OK (/usr/local/bin/aws)

-------------------------------------------------------------
Prerequisites for the AWS CLI to use ECS Exec
-------------------------------------------------------------

An error occurred (ClusterNotFoundException) when calling the DescribeTasks operation: Cluster not found.
ubuntu@DESKTOP-I7DBFAI:~$

Am I doing something wrong?

We use several aws accounts: the subaccount (in which the cluster is) is accessed with a role as can be seen in the aws config

ubuntu@DESKTOP-I7DBFAI:~/.aws$ cat config
[default]
[profile dma]
role_arn = arn:aws:iam::059416150415:role/DMAAccessRole
source_profile = default
ubuntu@DESKTOP-I7DBFAI:~/.aws$

check-ecs-exec.sh works if I test a cluster in our main aws account in the same region - basically ignoring export AWS_PROFILE=dma.

Ran into this same problem. The tool is reading the region from ~/.aws/config for the profile given (or default if non provided).

ENH: CLI argument --region to explicitly set the region targeted.