我有一些用于网络负载平衡器的CloudFormation。
PrivateNetworkLoadBalancerSG:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: Access to the internal network load balancer
VpcId: !Ref 'VPC'
PrivateNetworkLoadBalancerIngressFromECS:
Type: AWS::EC2::SecurityGroupIngress
Properties:
Description: Only accept traffic from a container in the container host security group
GroupId: !Ref 'PrivateNetworkLoadBalancerSG'
IpProtocol: -1
SourceSecurityGroupId: !Ref 'EcsHostSecurityGroup'
PrivateNetworkLoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Type: network
Scheme: internal
Subnets:
- !Ref PrivateSubnetOne
- !Ref PrivateSubnetTwo
DummyTargetGroupPrivateNetwork:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
Name: !Join ['-', [!Ref 'AWS::StackName', 'drop-3']]
Port: 6379
Protocol: TCP
# UnhealthyThresholdCount: 2
VpcId: !Ref 'VPC'
还有一些用于在ECS中设置Redis docker容器的
RedisService:
Type: AWS::ECS::Service
Properties:
Cluster: !ImportValue "privatevpc:ClusterName"
DesiredCount: 1
TaskDefinition: !Ref RedisTaskDefinition
RedisTaskDefinition:
Type: AWS::ECS::TaskDefinition
Properties:
Family: redis
ContainerDefinitions:
- Name: redis
Essential: true
Image: "redis:latest"
Memory: 512
PortMappings:
- ContainerPort: 6379
HostPort: 6379
LogConfiguration:
LogDriver: awslogs
Options:
awslogs-group: !Ref CloudWatchLogsGroup
awslogs-region: !Ref AWS::Region
RedisTargetGroup:
Type: AWS::ElasticLoadBalancingV2::TargetGroup
Properties:
VpcId: !ImportValue "privatevpc:VPCId"
Port: 6379
Protocol: TCP
HealthCheckProtocol: TCP
RedisLoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
DefaultActions:
- Type: forward
TargetGroupArn: !Ref RedisTargetGroup
LoadBalancerArn: !ImportValue "privatevpc:PrivateNetworkLoadBalancer"
Port: 6379
Protocol: TCP
但是我必须手动添加要通过AWS Web控制台将RedisService部署到的EC2实例,作为RedisTargetGroup的目标。知道我如何拥有CloudFormation可以为我做到吗?
答案 0 :(得分:2)
我认为您需要将let alert = NSAlert()
alert.messageText = question
alert.informativeText = text
alert.alertStyle = .critical
let deleteButton = alert.addButton(withTitle: "Delete")
let cancelButton = alert.addButton(withTitle: "Cancel")
deleteButton.keyEquivalent = ""
cancelButton.keyEquivalent = "\r"
属性添加到LoadBalancers
。 ECS应该将正确的EC2实例自动添加到指定的目标组。
例如:
RedisService