【发布时间】:2023-02-03 15:43:54
【问题描述】:
我有一个有效的 cloudFormation yaml 模板。我知道它的工作原理,因为当我转到 aws 门户并通过单击创建堆栈时,堆栈就会被创建。
但是,当我尝试在命令行上使用 cloudformation 时,出现相同的 yaml 错误。
我不知道是什么导致了这个问题。有谁知道可能导致失败的原因是什么?
这是我正在调用的命令
aws cloudformation create-stack --stack-name ${stack_name} --template-body file://template.yaml --region ${region}
其中区域与我在 aws 门户中的区域相同。这是template.yaml
---
AWSTemplateFormatVersion: 2010-09-09
Description: EC2 example instance
Resources:
TestEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-01ec0fa63b2042232
InstanceType: t3.medium
SubnetId: subnet-*********
UserData:
Fn::Base64:
!Sub |
#!/bin/bash -xe
echo "Running apt install -y git nfs-common binutils jq"
apt-get install -y git nfs-common binutils jq
当我运行命令时,我看到堆栈开始在门户上创建,并发生以下事件
ec2-boilerplate ROLLBACK_COMPLETE -
TestEC2Instance DELETE_COMPLETE -
TestEC2Instance DELETE_IN_PROGRESS -
ec2-boilerplate ROLLBACK_IN_PROGRESS The following resource(s) failed to create: [TestEC2Instance]. Rollback requested by user.
TestEC2Instance CREATE_FAILED Instance i-0bdd3e7ee34edf1ef failed to stabilize. Current state: shutting-down. Reason: Client.InternalError: Client error on launch
TestEC2Instance CREATE_IN_PROGRESS Resource creation Initiated
TestEC2Instance CREATE_IN_PROGRESS -
ec2-boilerplate CREATE_IN_PROGRESS User Initiated
是关于我的 template.yaml 的吗?关于我的命令行调用?一些环境变量?
【问题讨论】:
-
您是否有任何未能稳定的 EC2 日志?
-
如何访问 EC2 实例的日志?它在我的 ec2 仪表板中显示为已终止。当我尝试系统日志时,它显示为空
-
您使用的是什么操作系统?什么是
ami-01ec0fa63b2042232? -
只是猜测,但是您用于从控制台登录/创建的用户与 aws CLI 用于命令行的用户之间是否存在权限差异?比如说,可以使用 AMI 或 KMS 的许可。
标签: amazon-web-services amazon-ec2 amazon-cloudformation