Security group doesn't exist but I know it exists

0

I created a CFN stack for Kubernetes cluster and then deleted it and noticed that the VPC and ENI were left undeleted so wanted to remove the ENI but couldn't because a security group is attached to it. Tried to remove the SG and assign a default VPS SG but it says I don't have permissions to do that. I tried looking up the SG using aws cli but it says that the SG doesn't exist. I can see it right now in my console so why does it say it doesn't exist? I'm stuck. Please help me. How do I remove the ENI, VPC and the SG. Thank you in advance.

  • Search for the ENI to get the subnet and security group(s) it uses with the below command. Ensure you replace <ENI> and <REGION> placeholders with respective values. The output of the below command will be json which you can parse with something like jq. This should align with what you see in the console

    aws ec2 describe-network-interfaces --network-interface-ids <ENI> --filters Name=network-interface-id,Values=ENI --region <REGION> --output json --query 'NetworkInterfaces[0].{Subnet:SubnetId,SecurityGroups:Groups[*].GroupId}')

已提問 2 年前檢視次數 3569 次
2 個答案
2

Are you in the same region using CLI?

profile picture
MG
已回答 2 年前
  • AWS CLI does not have the option to specify the region

    aws ec2 describe-security-groups --filters Name=vpc-id,Values=... --group-ids ...
    

    An error occurred (InvalidGroup.NotFound) when calling the DescribeSecurityGroups operation: The security group '...' does not exist But I am on the security group page in the console now as we speak so it does exist.

2

Try adding in --region at the end of your CLI command to whatever region you see the Security Group in.

For example:

aws ec2 describe-security-groups ... --group-ids --region us-east-1

You can also run an aws configure get region to get the region of what region your CLI is setup for.

That would be my first look - ensure where you are looking in console matches the region in your CLI.

jsonc
已回答 2 年前
  • You are a genius! Bullseye! That solved my problem. Thank you very much!

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南