Learn about the importance of placing EC2 instances within a VPC for security measures.
Rule | EC2 instances should be in a VPC |
Framework | NIST 800-53 Revision 5 |
Severity | ✔ High |
Rule Description:
According to NIST 800-53 Revision 5, all EC2 instances should be deployed within a Virtual Private Cloud (VPC) for enhanced security and network isolation.
Troubleshooting Steps:
If EC2 instances are not deployed within a VPC, follow these troubleshooting steps:
Check VPC Configuration: Verify if a VPC is already created. If not, create a new VPC using the AWS Management Console or AWS Command Line Interface (CLI).
Examine EC2 Instances: Identify any EC2 instances that are not currently assigned to a VPC.
Verify Security Groups: Ensure all EC2 instances are associated with appropriate security groups within the VPC. Review inbound and outbound traffic rules to ensure they comply with the desired security policies.
Check Subnet Associations: Verify that each EC2 instance is associated with a subnet within the VPC. Ensure the subnets adhere to the required IP addressing scheme and are adequately sized.
Review NACLs: Network Access Control Lists (NACLs) define inbound and outbound traffic rules at the subnet level. Ensure that any associated NACLs for each subnet do not interfere with the desired VPC security model.
Validate Route Tables: Verify the correct routing tables are associated with the subnets and VPC. Confirm that routes are properly configured for outgoing and incoming traffic.
Review Internet Gateway: If internet connectivity is required for the EC2 instances, ensure that the VPC is associated with an internet gateway and the proper routing is established.
Check VPN Connections: If secure connectivity to on-premises networks is required, validate the VPN connections within the VPC.
Necessary Codes:
No specific codes are required for this rule; however, the AWS CLI commands mentioned below can assist in troubleshooting and remediation steps.
Remediation Steps:
Follow these step-by-step instructions to remediate the EC2 instances not deployed within a VPC:
aws ec2 create-vpc --cidr-block <CIDR_BLOCK>
Replace
<CIDR_BLOCK>
with the desired IP address range for your VPC.Review the existing EC2 instances and note down their instance IDs.
Associate each EC2 instance with the newly created VPC using the AWS CLI command:
aws ec2 modify-instance-attribute --instance-id <INSTANCE_ID> --vpc-id <VPC_ID>
Replace
<INSTANCE_ID>
with the EC2 instance ID to be associated with the VPC, and <VPC_ID>
with the ID of the VPC created in the previous step.aws ec2 describe-instances --instance-ids <INSTANCE_ID>
Replace
<INSTANCE_ID>
with the instance ID you want to verify.Review the security groups associated with each EC2 instance and ensure they are properly configured within the VPC.
Verify that each EC2 instance is associated with a subnet using the AWS Management Console or the AWS CLI command:
aws ec2 describe-instances --instance-ids <INSTANCE_ID> --query 'Reservations[].Instances[].SubnetId'
Replace
<INSTANCE_ID>
with the instance ID you want to verify.aws ec2 describe-network-acls --filters "Name=vpc-id,Values=<VPC_ID>"
Replace
<VPC_ID>
with the ID of the VPC.aws ec2 describe-route-tables --filters "Name=vpc-id,Values=<VPC_ID>"
Replace
<VPC_ID>
with the ID of the VPC.aws ec2 describe-internet-gateways --filters "Name=attachment.vpc-id,Values=<VPC_ID>"
Replace
<VPC_ID>
with the ID of the VPC.By following these steps, you can ensure that all EC2 instances within the AWS environment are deployed within a VPC, complying with the NIST 800-53 Revision 5 guideline.