AWS Install & Configure CLI

Prerequisites

To configure the below you will need the required access key id and secret access key which you can get from the AWS AMI Console (Identity and Access Management) you will need to be logged in. Any commands that point to a .json configuration file are available on github.

AWSCLI

  1. Download and install using the MSI installer for windows.

This will live in C:\Program Files\Amazon\AWSCLI and should then work from any terminal.

  1. Check version
1
aws --version
  1. Configure with the keys you got from the IAM in the amazon console.
1
2
3
4
5
C:\> aws configure
AWS Access Key ID [None]: HOEHOEHOEHOHEOHEOHE
AWS Secret Access Key [None]: HO/hehOehoHEOHEhohEOHeohEOH+EohOEe
Default region name [None]: ap-southeast-2
Default output format [None]:

This creates these files which you can edit with any text editor.

1
2
3
4
5
6
7
8
~ C:\Users\[USERNAME]\.aws\credentials
[default]
aws_access_key_id = HOEHOEHOEHOHEOHEOHE
aws_secret_access_key = HO/hehOehoHEOHEhohEOHeohEOH+EohOEe

~ C:\Users\[USERNAME]\.aws\config
[default]
region = ap-southeast-2
  1. Then you can test it works
1
aws iam list-roles
  1. Create the task execution IAM role
1
2
3
4
5
6
--- Create the task execution role
C:\dev\aws\ami>
aws iam --region ap-southeast-2 create-role --role-name ecsTaskExecutionRole --assume-role-policy-document file://task-execution-assume-role.json

--- Attach the task execution role policy
aws iam --region ap-southeast-2 attach-role-policy --role-name ecsTaskExecutionRole --policy-arn arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy

ECSCLI

This will live in C:\Program Files\Amazon\ECSCLI

  1. Run windows powersell as administrator
1
2
3
4
5
--- create folder
New-Item C:\Program Files\Amazon\ECSCLI -type directory

--- install
Invoke-WebRequest -OutFile ‘C:\Program Files\Amazon\ECSCLI\ecs-cli.exe’ https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-windows-amd64-latest.exe
  1. Edit the environment variables and add C:\Program Files\Amazon\ECSCLI to the PATH variable field

  2. Restart powersell and check version

1
ecs-cli --version
  1. Configure with the same keys used above

I used the profile names carl_ecs_cli_profile and carl_configuration_name below when setting up ECS for the Lexicon via the AWS CLI.

1
2
3
ecs-cli configure profile --profile-name carl_ecs_cli_profile --access-key HOEHOEHOEHOHEOHEOHE --secret-key HO/hehOehoHEOHEhohEOHeohEOH+EohOEe

ecs-cli configure --cluster ClusterName1 --default-launch-type FARGATE --region ap-southeast-2 --config-name carl_configuration_name

Note that --cluster needs to satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*

This creates these files which you can edit with any text editor.

1
2
3
4
5
~ C:\Users\[USERNAME]\AppData\Local\ecs\config
: carl_configuration_name

~ C:\Users\[USERNAME]\AppData\Local\ecs\credentials
: carl_ecs_cli_profile

References