英文:
Security group 'ALB-sg' is not valid
问题
我通过Cfn创建了一个ALB,但是我遇到了一个错误,错误信息如下:
安全组 'ALB-sg' 无效(服务:AmazonElasticLoadBalancing;状态码:400;错误代码:ValidationError;请求ID:6ec8a268-80cc-4a3e-9477-809dba8a00c7;代理:null)
英文:
I create an ALB by Cfn, but I got the error called
Security group 'ALB-sg' is not valid (Service: AmazonElasticLoadBalancing; Status Code: 400; Error Code: ValidationError; Request ID: 6ec8a268-80cc-4a3e-9477-809dba8a00c7; Proxy: null)
AWSTemplateFormatVersion: 2010-09-09
Description: AWS CloudFormation Sample Template for creating LoadBalancer
Parameters:
VPC:
Description: VPCId of your existing Virtual Private Cloud (VPC)
Type: String
Default: vpc-0c9a732125ac08541
PublicSubnet:
Description: SubnetId of an existing subnet (for the primary network in your Virtual Private Cloud VPC)
Type: String
Default: subnet-0787f34404852ceb9
Resources:
ApplicationLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: MyApplicationLoadBalancer
Type: application
IpAddressType: ipv4
Scheme: internet-facing
SecurityGroups:
- !Ref Albsg
Subnets:
- !Ref PublicSubnet
Tags:
- Key: Name
Value: ALB
HTTPListener:
Type: "AWS::ElasticLoadBalancingV2::Listener"
Properties:
LoadBalancerArn: !Ref ApplicationLoadBalancer
Port: 80
Protocol: "HTTP"
DefaultActions:
- Type: forward
TargetGroupArn: !Ref ALBTargetGroup
ALBTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
HealthCheckIntervalSeconds: 10
HealthCheckPath: /
HealthCheckTimeoutSeconds: 5
HealthyThresholdCount: 2
Matcher:
HttpCode: 200,302
Name: MyWebServers
Port: 80
Protocol: HTTP
TargetType: instance
UnhealthyThresholdCount: 5
VpcId: !Ref VPC
Albsg:
Type: 'AWS::EC2::SecurityGroup'
Properties:
GroupName: ALB-sg
GroupDescription: Security group for Load balancer
SecurityGroupIngress:
- CidrIp: 0.0.0.0/0
FromPort: '80'
IpProtocol: tcp
ToPort: '80'
Tags:
- Key: Name
Value: ALB_SG
Outputs:
TargetGroupName:
Value: !Ref ALBTargetGroup
Description: Name of Target ARN
I am not sure what else to try. Here is the template I am working with..
答案1
得分: 1
在Albsg
的SecurityGroupIngress
中,FromPort
和ToPort
字段必须是整数,而不是字符串。
英文:
In the SecurityGroupIngress
of the Albsg
, the fields FromPort
and ToPort
have to be integers, not strings.
答案2
得分: 0
字符串 ALB-sg
只在你的模板中出现一次,所以错误显然就在那里:
GroupName: ALB-sg
我觉得是 -
字符导致的问题。你应该简单地将该值用引号括起来:
GroupName: "ALB-sg"
英文:
The string ALB-sg
only appears one place in your template, so that is obviously where the error is:
GroupName: ALB-sg
I'm thinking the -
character is throwing it off. You should simply wrap the value in quotes:
GroupName: "ALB-sg"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论