如何解决CloudFormation 模板中待纠正的错误
我的应用程序负载均衡器的 AWS CloudFormation 模板抛出此错误:无法检索外部值。 需要帮助来纠正这个问题。我不确定错误是从哪里发生的。 我猜错误可能出在证书参数部分或标签中,也许 !Sub 值没有包含在该值中。
AWstemplateFormatVersion: '2010-09-09'
Parameters:
Name:
Description: Name of the project
Type: String
EnvironmentName:
Description: Environment of the Application Load balancer
Type: String
Publicsubnet:
Description: subnet for creating the Application Load balancer
Type: List<AWS::EC2::subnet::Id>
Vpc:
Description: VPC in which the resources are present
Type: AWS::EC2::VPC::Id
Certificate:
Description: Arn of the ssl certificate for HTTPS listener
Type: AWS::CertificateManager::Certificate::Arn
Resources:
SecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: ALB Security Group
VpcId: !Ref Vpc
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: "80"
ToPort: "80"
CidrIp: "0.0.0.0/0"
- IpProtocol: tcp
FromPort: "443"
ToPort: "443"
CidrIp: "0.0.0.0/0"
Tags:
-
Key: Name
Value: !Sub ${EnvironmentName}-SG
ApplicationLB:
Type: 'AWS::ElasticLoadBalancingV2::LoadBalancer'
Properties:
IpAddresstype: ipv4
Name: Test-ALB
Scheme: internet-facing
SecurityGroups:
- !Ref SecurityGroup
subnets: !Ref Publicsubnet
Tags:
- Key: Name
Value: !Sub ${EnvironmentName}-ALB
Type: application
HTTPSListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLB
Port: 443
Protocol: "HTTPS"
SslPolicy: "ELBSecurityPolicy-2016-08"
Certificates:
-
CertificateArn: !Ref Certificate
DefaultActions:
-
Order: 1
Type: "fixed-response"
FixedResponseConfig:
ContentType: "text/plain"
MessageBody: "Please enter proper domain"
StatusCode: "200"
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLB
Port: 80
Protocol: "HTTP"
DefaultActions:
-
Order: 1
RedirectConfig:
Protocol: "HTTPS"
Port: "443"
Host: "#{host}"
Path: "/#{path}"
Query: "#{query}"
StatusCode: "HTTP_301"
Type: "redirect"
ALBTargetGroup:
Type: 'AWS::ElasticLoadBalancingV2::TargetGroup'
Properties:
HealthCheckIntervalSeconds: 30
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 3
Port: 80
Protocol: HTTP
UnhealthyThresholdCount: 5
VpcId: !Ref Vpc
需要澄清。
解决方法
该错误与证书参数中提到的类型有关。
将其更改为如下字符串,并将证书 Arn 作为值传递。
Certificate:
Description: Arn of the ssl certificate for HTTPS listener
Type: String
示例参数.json 文件
[
{
"ParameterKey": "EnvironmentName","ParameterValue": "dev"
},{
"ParameterKey": "Name","ParameterValue": "stackoverflow"
},{
"ParameterKey": "Vpc","ParameterValue": "vpc-0e104f6ad273a6648"
},{
"ParameterKey": "PublicSubnet","ParameterValue": "subnet-0c2fc6571a7a6db2e,subnet-05a36fdef379c4fcd"
},{
"ParameterKey": "Certificate","ParameterValue": "arn:aws:acm:us-east-1:111111111111:certificate/11ad06f1-b625-44b2-9797-4ecd81451af2"
}
]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。