gpt4 book ai didi

aws-cloudformation - 无法使用 CloudFormation 删除 Amazon ECS 集群

转载 作者:行者123 更新时间:2023-12-04 15:40:05 24 4
gpt4 key购买 nike

我正在使用以下 CloudFormation 模板来创建 ECS 集群。

AWSTemplateFormatVersion: '2010-09-09'
Description: 'AWS Cloudformation Template to create the Infrastructure'
Resources:
ECSCluster:
Type: AWS::ECS::Cluster
Properties:
ClusterName: 'Blog-iac-test-1'
EC2InstanceProfile:
Type: AWS::IAM::InstanceProfile
Properties:
Path: /
Roles: [!Ref 'EC2Role']
ECSAutoScalingGroup:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
VPCZoneIdentifier:
- subnet-****
LaunchConfigurationName: !Ref 'ECSAutoscalingLC'
MinSize: '1'
MaxSize: '2'
DesiredCapacity: '1'
ECSAutoscalingLC:
Type: AWS::AutoScaling::LaunchConfiguration
Properties:
AssociatePublicIpAddress: true
ImageId: 'ami-b743bed1'
SecurityGroups:
- sg-****
InstanceType: 't2.micro'
IamInstanceProfile: !Ref 'EC2InstanceProfile'
KeyName: 'test'
UserData:
Fn::Base64: !Sub |
#!/bin/bash -xe
echo ECS_CLUSTER=Blog-iac-test-1 >> /etc/ecs/ecs.config
EC2Role:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Effect: Allow
Principal:
Service: [ec2.amazonaws.com]
Action: ['sts:AssumeRole']
Path: /
ECSServicePolicy:
Type: "AWS::IAM::Policy"
Properties:
PolicyName: "root"
PolicyDocument:
Version: "2012-10-17"
Statement:
- Effect: Allow
Action: ['ecs:*', 'logs:*', 'ecr:*', 's3:*']
Resource: '*'
Roles: [!Ref 'EC2Role']

堆栈已成功创建,但在销毁时出现以下错误:
当容器实例处于事件状态或耗尽状态时,无法删除集群。

我之前能够删除堆栈,这个问题最近开始出现。有什么解决方法可以避免这个问题?我是否需要添加一些依赖项?

最佳答案

this AWS Documentation Link 中所述,您是否也尝试过注销实例?:

Deregister Container Instances: Before you can delete a cluster, you must deregister the container instances inside that cluster. For each container instance inside your cluster, follow the procedures in Deregister a Container Instance to deregister it.

Alternatively, you can use the following AWS CLI command to deregister your container instances. Be sure to substitute the Region, cluster name, and container instance ID for each container instance that you are deregistering.

aws ecs deregister-container-instance --cluster default
--container-instance container_instance_id --region us-west-2 --force

关于aws-cloudformation - 无法使用 CloudFormation 删除 Amazon ECS 集群,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46280080/

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