gpt4 book ai didi

amazon-web-services - AWS 云信息 : Security group is not valid

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

提前致谢。

问题:我正在尝试使用 Loadbalancer + Listener + target_group + security-group + ec2-instance 创建堆栈。

堆栈名称:测试堆栈

我在创建堆栈时收到以下错误:

安全组“test-stack-MySecurityGroup-1XYNYTFIAGZKM”无效(服务:AmazonElasticLoadBalancingV2;状态代码:400;错误代码:验证错误;请求 ID:ddef7a0d-7c19-4ec8-ab48-d8aeba9a0956)

配置文件:

Resources:
MyEC2Instance:
Type: AWS::EC2::Instance
Properties:
ImageId: ami-07c8bc5c1ce9598c3
InstanceType: t2.micro
AvailabilityZone: us-east-2a
SecurityGroups:
- !Ref MySecurityGroup

MySecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Opening port 80
SecurityGroupIngress:
- FromPort: 80
ToPort: 80
CidrIp: 0.0.0.0/0
IpProtocol: tcp

ALBListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref EC2TargetGroup
LoadBalancerArn: !Ref ApplicationLoadBalancer
Port: 80
Protocol: HTTP

ApplicationLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Scheme: internet-facing
Subnets:
- us-east-2a
- us-east-2b
SecurityGroups:
- !Ref MySecurityGroup

EC2TargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: EC2TargetGroup
Port: 80
Protocol: HTTP
Targets:
- Id: !Ref MyEC2Instance
Port: 80
VpcId: vpc-a26dcec9
Tags:
- Key: Name
Value: EC2TargetGroup
- Key: Port
Value: 80

我想知道我做错了什么。

最佳答案

SecurityGroups应该是组 ID,而不是组名称:

    ApplicationLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Scheme: internet-facing
Subnets:
- us-east-2a
- us-east-2b
SecurityGroups:
- !GetAtt MySecurityGroup.GroupId

关于amazon-web-services - AWS 云信息 : Security group is not valid,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63678459/

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