查看网络接口的信息
aws ec2 describe-network-interfaces --network-interface-ids eni-XXX
尝试分离网络接口:
aws ec2 detach-network-interface --attachment-id ela-attach-XXX
出现以下报错:
An error occurred (OperationNotPermitted) when calling the DetachNetworkInterface operation: You are not allowed to manage 'ela-attach' attachments.
尝试删除网络接口:
aws ec2 delete-network-interface --network-interface-id eni-XXX
出现以下报错:
An error occurred (InvalidParameterValue) when calling the DeleteNetworkInterface operation: Network interface 'eni-XXX' is currently in use.
解决方法:
1、通过 ENI ID 配合搜索 CloudTrail 日志,确认到目标 ENI 是通过 Amazon Managed Prometheus 建置。
2、 尝试通过 AWS CLI 搜索相关资源可以看到确实有 Scrapers 残余:
aws amp list-scrapers
{
"Scrapers": [
{
"Alias": "XXXXXX",
...
"ScraperId": "s-XXX", # 残余资源相应的 ID。
"Source": {
"EksConfiguration": {
"ClusterArn": "arn:aws:eks:XXXXX:XXX:cluster/XXX"# <--------- 可以看到这是与 Amazon EKS 资源相关联。推测是误操作而建立。
...
}
},
"Status": {
"StatusCode": "ACTIVE"
},
...
}
]
}
3、由于目标是清除所有 VPC 资源。使用如下命令:
aws amp delete-scraper --scraper-id "s-XXX"
4、确认 Scrapers 资源呈现 DELETING 状态:
aws amp list-scrapers
{
"Scrapers": [{
...
"ScraperId": "s-XXX",
...
"Status": {
"StatusCode": "DELETING"
},
...
}]
}
5、最后,目标 VPC 顺利清除。