问题描述
尝试使用 AWS Linux AMI 测试 cfn-init。实例正在创建但自动停止。即使我尝试手动启动实例,它也会立即自行停止。不知道我做错了什么,实例就这样停止了。我所做的就是尝试对此进行测试并使用 cfn-init 设置一个文件。这是从我在网上找到的模板中获取的。任何帮助表示赞赏。
{
"AWstemplateFormatVersion": "2010-09-09","Parameters": {
"VPC": {
"Type": "AWS::EC2::VPC::Id","Description": "Select the VPC where the EC2 instances will be created","ConstraintDescription": "must be an existing VPC"
},"Linuxsubnet": {
"Type": "AWS::EC2::subnet::Id","Description": "Select subnet for Linux Instance","ConstraintDescription": "must be an existing subnet"
},"RemoteAccessCIDR": {
"Description": "CIDR block to allow access to linux instances","Type": "String","Default": "10.255.0.0/16","AllowedPattern": "(\\d{1,3})\\.(\\d{1,3})/(\\d{1,2})","ConstraintDescription": "must be a valid IP CIDR range of the form x.x.x.x/x."
},"LinuxInstanceType": {
"Default": "t2.micro","Description": "Amazon EC2 Linux Instance Type","Type": "String"
},"LinuxSecurityGroupIds": {
"Type": "String","Description": "Name of security group to use",},"LinuxSSHPort": {
"Description": "SSH Port Number on Linux client","Type": "Number","Default": 22,"ConstraintDescription": "must be 22 or a number from 1024 to 65535"
},"LinuxVolumeSize": {
"Description": "Size of EBS volume for Linux instance in GB","Default": 8,"ConstraintDescription": "must be 8 or higher"
},"KeyPair": {
"Description": "Name of existing EC2 key pair for Linux Instances","Type": "AWS::EC2::KeyPair::KeyName"
}
},"Resources": {
"TestMachine": {
"Type": "AWS::EC2::Instance","Metadata": {
"AWS::CloudFormation::Init": {
"configSets": {
"CreateStuff": "CreateFile"
},"CreateFile" : {
"files": {
"/tmp/testing.txt": {
"content": "hopefully this works","mode": "0755","owner": "root","group": "root"
}
}
}
}
},"Properties": {
"ImageId": "ami-0533f2ba8a1995cf9","InstanceType": {
"Ref": "LinuxInstanceType"
},"subnetId": {
"Ref": "Linuxsubnet"
},"SecurityGroupIds": [{
"Ref": "LinuxSecurityGroupIds"
}],"KeyName": {
"Ref": "KeyPair"
},"Tags": [
{
"Key": "Automatic Patches","Value": "True"
},{
"Key": "Description","Value": "Service-Catalog-EC2-Reference-Architecture"
},{
"Key": "acr:CostCenter","Value": "986002"
},{
"Key": "acr:Project","Value": "aws infrastructure general"
},{
"Key": "Name","Value": "cfn-init-vm1"
}
],"BlockDeviceMappings": [
{
"DeviceName": "/dev/sda1","Ebs": {
"Encrypted": "true","DeleteOnTermination":"true","VolumeSize": {
"Ref": "LinuxVolumeSize"
}
}
}
],"UserData": {
"Fn::Base64" : { "Fn::Join" : ["",[
"#!/bin/bash -xe\n","yum install -y aws-cfn-bootstrap\n","# Install the files and packages from the Metadata\n","/opt/aws/bin/cfn-init -v "," --stack ",{ "Ref" : "AWS::StackName" }," --resource TestMachine "," --configsets CreateStuff "," --region ","us-east-1","\n"
]]}
}
}
}
},"Outputs": {
}
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)