Ich möchte eine CloudFormation Vorlage erstellen, deren Instanztyp "t2.micro" ist. Ich konnte jedoch kein Beispiel für diesen Instanztyp finden. Ec2, deren Typ "t2.micro" ist, benötigt VPC, etc.Create Aws Wolkenbildung Ec2 t2.micro Template
Danke.
Ich möchte eine CloudFormation Vorlage erstellen, deren Instanztyp "t2.micro" ist. Ich konnte jedoch kein Beispiel für diesen Instanztyp finden. Ec2, deren Typ "t2.micro" ist, benötigt VPC, etc.Create Aws Wolkenbildung Ec2 t2.micro Template
Danke.
Sie können das folgende Vorlagen-Snippet verwenden.
Es wird der öffentliche DNS-Name der EC2-Instanz ausgegeben.
Hinweis: Ich habe diese Vorlage nicht getestet!
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "CloudFormation template for creating an ec2 instance",
"Parameters": {
"KeyName": {
"Description": "Key Pair name",
"Type": "AWS::EC2::KeyPair::KeyName",
"Default": "my_keypair_name"
},
"VPC": {
"Type": "AWS::EC2::VPC",
"Properties":{
"CidrBlock": "10.0.0.0/16",
"EnableDnsHostnames": "true"
}
},
"Subnet":{
"Type": "AWS::EC2::Subnet",
"Properties": {
"VpcId": {"Ref": "VPC"},
"CidrBlock": "10.0.0.0/24",
"AvailabilityZone": "us-east-1a"
}
},
"InstanceType": {
"Description": "Select one of the possible instance types",
"Type": "String",
"Default": "t2.micro",
"AllowedValues": ["t2.micro", "t2.small", "t2.medium"]
}
},
"Resources":{
"SecurityGroup":{
"Type": "AWS::EC2::SecurityGroup",
"Properties": {
"GroupDescription": "My security group",
"VpcId": {"Ref": "VPC"},
"SecurityGroupIngress": [{
"CidrIp": "0.0.0.0/0",
"FromPort": 22,
"IpProtocol": "tcp",
"ToPort": 22
}]
}
},
"Server": {
"Type": "AWS::EC2::Instance",
"Properties": {
"ImageId": "ami-123456",
"InstanceType": {"Ref": "InstanceType"},
"KeyName": {"Ref": "KeyName"},
"SecurityGroupIds": [{"Ref": "SecurityGroup"}],
"SubnetId": {"Ref": "Subnet"}
}
}
},
"Outputs": {
"PublicName": {
"Value": {"Fn::GetAtt": ["Server", "PublicDnsName"]},
"Description": "Public name (connect via SSH)"
}
}
}
Weitere Informationen finden Sie unter: http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-template-resource-type-ref.html