要使用AWS CloudFormation创建网络负载均衡器目标组,您可以按照以下步骤操作:
AWSTemplateFormatVersion: '2010-09-09'
Resources:
MyLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: MyLoadBalancer
Subnets:
- subnet-abc123
- subnet-def456
SecurityGroups:
- sg-123abc
- sg-456def
Type: application
MyTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: MyTargetGroup
Port: 80
Protocol: HTTP
VpcId: vpc-123456
aws cloudformation create-stack --stack-name MyStack --template-body file://path/to/template.yaml
确保将 MyStack 替换为您想要为堆栈指定的名称,并将 path/to/template.yaml 替换为您保存模板的路径。
这样,您就使用 CloudFormation 创建了一个包含网络负载均衡器和目标组的堆栈。您可以根据需要对模板进行进一步的自定义和配置。