gpt4 book ai didi

amazon-web-services - AWS云信息错误: Deploy error with ImageID

转载 作者:行者123 更新时间:2023-12-03 07:26:17 25 4
gpt4 key购买 nike

我无法使模板工作。 cloudformation 中的事件说这是因为 de ImageID,但我不知道出了什么问题。

这是 YAML 中的模板。

AWSTemplateFormatVersion: 2010-09-09
Description: Cafe application

Parameters:

InstanceTypeParameter:
Type: String
Default: t2.small
AllowedValues:
- t2.micro
- t2.small
- t3.micro
- t3.small
Description: Default is t2.small. Choose t2.micro, t2.small, t3.small or t3.micro.

LatestAmiId:
Type: 'AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>'
Default: '/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2'

CafeNetworkParameter:
Type: String
Default: update-cafe-network

Mappings:

RegionMap:
us-east-1:
"keypair": "vockey"
us-west-2:
"keypair": "cafe-oregon"

Resources:

CafeSG:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupDescription: Enable SSH, HTTP access
VpcId: !ImportValue
'Fn::Sub': '${CafeNetworkParameter}-VpcID'
Tags:
- Key: Name
Value: CafeSG
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '80'
ToPort: '80'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0

CafeInstance:
Type: 'AWS::EC2::Instance'
InstanceType: !Ref InstanceTypeParameter
Properties:
ImageID: !Ref LatestAmiId
IamInstanceProfile: "CafeRole"
KeyName: !FindInMap [RegionMap, !Ref "AWS::Region", keypair]
NetworkInterfaces:
- DeviceIndex: '0'
AssociatePublicIpAddress: true
SubnetId: !ImportValue
'Fn::Sub': '${CafeNetworkParameter}-SubnetID'
GroupSet:
- !Ref CafeSG
Tags:
- Key: Name
Value: Cafe Web Server

UserData:
Fn::Base64:
!Sub |
#!/bin/bash
yum -y update
yum install -y httpd mariadb-server wget
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
systemctl enable httpd
systemctl start httpd
systemctl enable mariadb
systemctl start mariadb
wget https://aws-tc-largeobjects.s3.us-west-2.amazonaws.com/CUR-TF-200-ACACAD-2-16750/14-lab-mod10-challenge-CFn/s3/cafe-app.sh
chmod +x cafe-app.sh
./cafe-app.sh

Outputs:
WebServerPublicIP:
Value: !GetAtt 'CafeInstance.PublicIp'

我学习 AWS 已经两个月了,所以尝试解释一下。谢谢

我尝试更改模板的格式,因为并尝试使用此命令“调试”:

aws cloudformation validate-template --template-body file:///home/ec2-user/environment/CFTemplatesRepo/templates/cafe-app.yaml

最佳答案

它应该是ImageId,而不是ImageID。另外 InstanceType: !Ref InstanceTypeParameter 应位于 Properties:

  CafeInstance:
Type: 'AWS::EC2::Instance'

Properties:
ImageId: !Ref LatestAmiId
IamInstanceProfile: "CafeRole"
InstanceType: !Ref InstanceTypeParameter
KeyName: !FindInMap [RegionMap, !Ref "AWS::Region", keypair]
NetworkInterfaces:
- DeviceIndex: '0'
AssociatePublicIpAddress: true
SubnetId: !ImportValue
'Fn::Sub': '${CafeNetworkParameter}-SubnetID'
GroupSet:
- !Ref CafeSG
Tags:
- Key: Name
Value: Cafe Web Server

UserData:
Fn::Base64:
!Sub |
#!/bin/bash
yum -y update
yum install -y httpd mariadb-server wget
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
systemctl enable httpd
systemctl start httpd
systemctl enable mariadb
systemctl start mariadb
wget https://aws-tc-largeobjects.s3.us-west-2.amazonaws.com/CUR-TF-200-ACACAD-2-16750/14-lab-mod10-challenge-CFn/s3/cafe-app.sh
chmod +x cafe-app.sh
./cafe-app.sh

关于amazon-web-services - AWS云信息错误: Deploy error with ImageID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74538053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com