Skip to main content

More Info:

Unused Amazon Virtual Private Gateways should be removed in order to adhere to best practices and to avoid reaching the service limit.

Risk Level

Low

Address

Operational Maturity, Security

Compliance Standards

  • APRA CPS 234 (Australia)
  • AWS Startup Security Baseline
  • BSI C5 (Germany)
  • Brazil LGPD
  • CCPA / CPRA (California)
  • CIS Critical Security Controls v8
  • CMMC 2.0
  • CSA Cloud Controls Matrix v4
  • Cloudanix Best Practice
  • DPDPA
  • Digital Operational Resilience Act (EU)
  • Essential 8
  • ISO/IEC 27017
  • ISO/IEC 27018
  • ISO/IEC 27701
  • KSA PDPL
  • MAS Technology Risk Management (Singapore)
  • MITRE ATT&CK (Cloud)
  • NIS2 Directive
  • NIST SP 800-171
  • NYDFS 23 NYCRR 500
  • SWIFT Customer Security Controls Framework
  • Sarbanes-Oxley IT General Controls
  • UK NCSC Cyber Assessment Framework

Triage and Remediation

Remediation

Using Console

To remediate the issue of Unused Virtual Private Gateways in AWS, you can follow these steps using the AWS Management Console:
  1. Login to AWS Console: Navigate to the AWS Management Console at https://aws.amazon.com/ and login with your credentials.
  2. Access VPC Dashboard: Go to the VPC dashboard by selecting the “Services” dropdown menu at the top left corner, then selecting “VPC” under the Networking & Content Delivery section.
  3. Identify Unused Virtual Private Gateways:
    • In the VPC dashboard, click on “Virtual Private Gateways” on the left-hand side menu.
    • Review the list of Virtual Private Gateways to identify any that are not associated with any VPCs or are no longer in use.
  4. Dissociate and Delete Unused Virtual Private Gateways:
    • Select the unused Virtual Private Gateway that you want to remove.
    • Click on the “Actions” dropdown menu and choose “Detach from VPC” to dissociate the Virtual Private Gateway from the VPC.
    • Once detached, select the Virtual Private Gateway again and click on the “Actions” dropdown menu, then choose “Delete Virtual Private Gateway” to remove it completely.
  5. Confirm Deletion:
    • A confirmation dialog will appear asking you to confirm the deletion of the Virtual Private Gateway. Confirm the action to proceed with the deletion.
  6. Verify Removal:
    • After deleting the Virtual Private Gateway, verify that it has been successfully removed from the list of Virtual Private Gateways in the VPC dashboard.
By following these steps, you can remediate the issue of Unused Virtual Private Gateways in AWS by identifying and removing any Virtual Private Gateways that are no longer in use.

To remediate the issue of unused Virtual Private Gateways in AWS, you can follow the steps below using AWS CLI:
  1. List all the Virtual Private Gateways in your AWS account:
  1. Identify the Virtual Private Gateways that are not associated with any VPC. These are the ones that are unused.
  2. To detach the Virtual Private Gateway from a VPC, you can use the following command:
  1. Once you have detached the Virtual Private Gateway from all VPCs, you can delete the Virtual Private Gateway using the following command:
  1. Confirm that the Virtual Private Gateway has been deleted by listing all the Virtual Private Gateways again:
By following these steps, you can identify and remove any unused Virtual Private Gateways in your AWS account using AWS CLI.
To remediate the issue of unused Virtual Private Gateways in AWS using Python, you can follow these steps:
  1. Use Boto3, the AWS SDK for Python, to list all the Virtual Private Gateways in your AWS account.
  2. Use Boto3 to list all the VPCs in your AWS account.
  3. Compare the Virtual Private Gateways with the VPCs to identify any unused Virtual Private Gateways.
  4. If any Virtual Private Gateways are found to be unused, delete them using Boto3.
Here is a sample Python script to achieve this:
Make sure you have the necessary permissions in your AWS IAM role to delete Virtual Private Gateways before running this script. Also, ensure you have installed the Boto3 library (pip install boto3) and configured your AWS credentials.
This change causes Terraform to detach and delete the unused Virtual Private Gateway and any associated VPN connections; this is a destructive, irreversible action, so only apply it after confirming they are no longer in use.terraform plan should show these resources with -/destroy (or removed from state if you delete the blocks entirely), and no new replacements being created for the unused gateway.

Additional Reading: