调用时ECS CLI密钥对错误

ECS CLI key pair error when calling up

我正在尝试使用 Amazon 的 ECS cli 创建集群。我一直收到错误消息:

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

我也有运行:

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

我已将我的密钥对添加到 ECS 和 EC2。

完整日志为:

~ $ 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'

这意味着密钥对名称在您的 EC2 帐户中不存在。

Simply create it with s per the aws guide

我运行进入同样的问题。我的问题是我给它的是 pem 文件的完整路径,而不是 key on EC2 (link to Ohio region) 的名称。转向

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

进入

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

只要 EC2 上有一个名为 keyPair

的密钥对就可以工作

您的密钥可能位于与您尝试创建映像的区域不同的区域。 Jeff 的回答让我知道我的密钥对在默认实例(俄亥俄州)中,但我是在我的本地区域创建我的实例。

我的问题是我传递的是文件名 (keypair.pem) 而不是 AWS 上的密钥对名称。确保您传递的是您在 AWS 上看到的密钥对名称,而不是文件名。

我一直在学习本教程,直到发现同样的问题: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-cli-tutorial-ec2.html

和地区无关,问题是我的Key-Pair没有上传到ECS。也许这是显而易见的,但如果你像我一样是 AWS 初学者,教程说明对此并不清楚。

上一步:创建密钥对

如果您还没有这样做,首先您必须创建存储在 ".pem" 文件中的密钥对。使用 AWS 控制台按照此说明进行操作非常简单:https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html

解法:

必须上传 ".pem" 文件。可以使用 AWS 控制台完成,按照菜单: EC2 > 网络与安全 > 密钥对 >“创建密钥对”

菜单 URL:https://eu-central-1.console.aws.amazon.com/ec2/v2/home?region=eu-central-1#CreateKeyPair: (注意在此 URL 上定义的 2 个区域)

如上所述: https://www.cloudbooklet.com/how-to-add-new-user-with-key-pair-in-aws-ec2/