copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

[Bug]: ✘ delete environment stack: ResourceNotReady: failed waiting for successful resource state

Open tyoc213 opened this issue 1 year ago • 2 comments

Description:

I have created a new app, then created some services and configured them to network: vpc: placement: private and then I deleted the services, then when trying to delete the environment it cant finish

Details:

osx Sonoma copilot: tried with v1.33.2 then updated to v1.33.4 same behaviour

Observed result:

$ copilot env delete
Environment: staging
Sure? Yes
✔ Retained IAM roles for the "staging" environment
- Delete environment stack staging-nat-staging                     [delete in progress]  [961.9s]
  - A Virtual Private Cloud to control networking of your AWS resources  [delete in progress]  [961.9s]
✘ delete environment staging stack: wait until stack staging-nat-staging delete is complete: ResourceNotReady: failed waiting for successful resource state

Expected result:

environment deleted completely including vpc et al

Debugging:

I used this script

#!/bin/bash
vpc="vpc-04755196113727xxx"
region="us-east-1"
aws ec2 describe-internet-gateways --region $region --filters 'Name=attachment.vpc-id,Values='$vpc | grep InternetGatewayId
aws ec2 describe-subnets --region $region --filters 'Name=vpc-id,Values='$vpc | grep SubnetId
aws ec2 describe-route-tables --region $region --filters 'Name=vpc-id,Values='$vpc | grep RouteTableId
aws ec2 describe-network-acls --region $region --filters 'Name=vpc-id,Values='$vpc | grep NetworkAclId
aws ec2 describe-vpc-peering-connections --region $region --filters 'Name=requester-vpc-info.vpc-id,Values='$vpc | grep VpcPeeringConnectionId
aws ec2 describe-vpc-endpoints --region $region --filters 'Name=vpc-id,Values='$vpc | grep VpcEndpointId
aws ec2 describe-nat-gateways --region $region --filter 'Name=vpc-id,Values='$vpc | grep NatGatewayId
aws ec2 describe-security-groups --region $region --filters 'Name=vpc-id,Values='$vpc | grep GroupId
aws ec2 describe-instances --region $region --filters 'Name=vpc-id,Values='$vpc | grep InstanceId
aws ec2 describe-vpn-connections --region $region --filters 'Name=vpc-id,Values='$vpc | grep VpnConnectionId
aws ec2 describe-vpn-gateways --region $region --filters 'Name=attachment.vpc-id,Values='$vpc | grep VpnGatewayId
aws ec2 describe-network-interfaces --region $region --filters 'Name=vpc-id,Values='$vpc | grep NetworkInterfaceId
aws ec2 describe-carrier-gateways --region $region --filters Name=vpc-id,Values=$vpc | grep CarrierGatewayId
aws ec2 describe-local-gateway-route-table-vpc-associations --region $region --filters Name=vpc-id,Values=$vpc | grep LocalGatewayRouteTableVpcAssociationId

And got this

$ sh vpc.check.sh
                    "RouteTableId": "rtb-05ed5aee85e1dxxxx",
            "RouteTableId": "rtb-05ed5aee85e1dxxxx",
            "NetworkAclId": "acl-09bc1e79e1e0exxxx",
                            "GroupId": "sg-02b5cbc8db671xxxx",
            "GroupId": "sg-02b5cbc8db671xxxx",
                            "GroupId": "sg-0e9c53f3b6426xxxx",
            "GroupId": "sg-0e9c53f3b6426xxxx",

image

Should I delete from webconsole those elements by hand and then execute again copilot env delete for the environment and it will continue as expected???

tyoc213 avatar Jun 14 '24 03:06 tyoc213

Hi, @tyoc213! Was your VPC created by Copilot when you created the environment? Are any other services or apps deployed in it? If yes and no, then yes, you can try deleting the resources with the console and running copilot env delete again. You should first look at the VPC to try to see what the dependencies mentioned in that "Status reason" are. Hope that helps!

huanjani avatar Jun 14 '24 18:06 huanjani

Yes @huanjani, I used this environment to create a second environment where I imported the vpc+pub&priv-subnets I already removed the other environment but was going to remove this "main environment" and hit this case...

tyoc213 avatar Jun 14 '24 19:06 tyoc213