如何使用 ApplicationLoadBalancedFargateService cdk 构造为负载均衡器启用删除保护
How do I enable deletion protection for load balancer using ApplicationLoadBalancedFargateService cdk construct
我使用 ApplicationLoadBalancedFargateService CDK 构造在应用程序负载均衡器前端的 ECS 集群上创建了 Fargate 服务 运行。
cluster,
memoryLimitMiB: 1024,
desiredCount: 1,
cpu: 512,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
},
});
没有启用删除保护的道具。谁能说说他的经历?
CDK 提供 Escape Hatches 功能以在任何 High-level 构造没有参数的情况下使用 Clouformation Props。
// Create a load-balanced Fargate service and make it public
var loadBalancedService = new ecs_patterns.ApplicationLoadBalancedFargateService(this, `${ENV_NAME}-pgadmin4`, {
cluster: cluster, // Required
cpu: 512, // Default is 256
desiredCount: 1, // Default is 1
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry('image'),
environment: {}
},
memoryLimitMiB: 1024, // Default is 512
assignPublicIp: true
});
// Get the CloudFormation resource
const cfnLB = loadBalancedService.loadBalancer.node.defaultChild as elbv2.CfnLoadBalancer;
cfnLB.loadBalancerAttributes = [{
key: 'deletion_protection.enabled',
value: 'true',
},
];
我使用 ApplicationLoadBalancedFargateService CDK 构造在应用程序负载均衡器前端的 ECS 集群上创建了 Fargate 服务 运行。
cluster,
memoryLimitMiB: 1024,
desiredCount: 1,
cpu: 512,
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
},
});
没有启用删除保护的道具。谁能说说他的经历?
CDK 提供 Escape Hatches 功能以在任何 High-level 构造没有参数的情况下使用 Clouformation Props。
// Create a load-balanced Fargate service and make it public
var loadBalancedService = new ecs_patterns.ApplicationLoadBalancedFargateService(this, `${ENV_NAME}-pgadmin4`, {
cluster: cluster, // Required
cpu: 512, // Default is 256
desiredCount: 1, // Default is 1
taskImageOptions: {
image: ecs.ContainerImage.fromRegistry('image'),
environment: {}
},
memoryLimitMiB: 1024, // Default is 512
assignPublicIp: true
});
// Get the CloudFormation resource
const cfnLB = loadBalancedService.loadBalancer.node.defaultChild as elbv2.CfnLoadBalancer;
cfnLB.loadBalancerAttributes = [{
key: 'deletion_protection.enabled',
value: 'true',
},
];