Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ECS CLI key pair error when calling up

I am trying to use Amazon's ECS cli to create a cluster. I keep getting the error:

 reason="The key pair 'my-key-pair' does not exist" resourceType="AWS::AutoScaling::LaunchConfiguration"

I have also run:

ecs-cli configure profile --profile-name grantspilsbury --access-key foo --secret-key bar
ecs-cli configure --cluster cluster_test --region us-east-1 --config-name myclusterconfig

I have added my-key-pair to ECS and to EC2.

The full log is:

~ $ ecs-cli up --keypair my-key-pair --capability-iam --size 2 --instance-type t2.small --force
INFO[0002] Created cluster                               cluster=default region=us-east-1
INFO[0003] Waiting for your CloudFormation stack resources to be deleted...
INFO[0003] Cloudformation stack status                   stackStatus="DELETE_IN_PROGRESS"
INFO[0038] Waiting for your cluster resources to be created...
INFO[0038] Cloudformation stack status                   stackStatus="CREATE_IN_PROGRESS"
INFO[0101] Cloudformation stack status                   stackStatus="CREATE_IN_PROGRESS"
INFO[0164] Cloudformation stack status                   stackStatus="CREATE_IN_PROGRESS"
ERRO[0197] Failure event                                 reason="The key pair 'my-key-pair' does not exist" resourceType="AWS::AutoScaling::LaunchConfiguration"
FATA[0197] Error executing 'up': Cloudformation failure waiting for 'CREATE_COMPLETE'. State is 'ROLLBACK_IN_PROGRESS'
like image 484
grabury Avatar asked Mar 08 '23 01:03

grabury


2 Answers

I ran into the same issue. My issue was I was giving it the full path to the pem file rather than the name of the key on EC2 (link to Ohio region). Turning

ecs-cli up --keypair /home/me/keyPair.pem --capability-iam --size 2 --instance-type t2.medium --cluster-config ec2-tutorial --force

into

ecs-cli up --keypair keyPair --capability-iam --size 2 --instance-type t2.medium --cluster-config ec2-tutorial --force

works as long as there is a key pair on EC2 named keyPair

like image 133
Jeff Diederiks Avatar answered Mar 17 '23 04:03

Jeff Diederiks


My problem was that I was passing the filename (keypair.pem) instead of the name of the keypair on AWS. Make sure you pass the keypair name as you see on AWS and not the name of the file.

like image 43
AndyFaizan Avatar answered Mar 17 '23 03:03

AndyFaizan