A collection of AWS Security controls for Amazon VPC and related resources (such as Transit Gateway, Network Firewall, Network Manager, Traffic Mirroring, etc.). Controls include IAM policies, security groups, network access lists, CloudWatch events and alarms for monitoring as well as Config rules. Configuration templates are available in AWS CloudFormation, AWS CLI and Terraform

VPC
VPC with Public and Private Subnets

This CloudFormation template creates a VPC with public and private subnets across multiple availability zones. It also provisions NAT gateways for private subnets to enable outbound internet access.

CloudFormationTerraform
VPC Egress Only Internet Gateway

This template creates an egress-only internet gateway for your VPC. An egress-only internet gateway is used to enable outbound communication over IPv6 from instances in your VPC to the internet, and prevents hosts outside of your VPC from initiating an IPv6 connection with your instance.

CloudFormationTerraform
VPC DHCP Options

This template creates a set of DHCP options for your VPC. It specifies the domain name, domain name servers, NTP servers, NetBIOS name servers, NetBIOS node type, and tags for the DHCP options.

CloudFormationTerraform
Interfface VPC Endpoint for SSM

This CloudFormation template creates a security group and VPC endpoint to allow access to SSM VPC Endpoint. The security group allows inbound traffic on port 443 from any IP address, and the VPC endpoint is created in the specified VPC and subnets.

CloudFormationTerraform
Gateway VPC Endpoint for Amazon S3

This CloudFormation template creates a VPC Endpoint for Amazon S3 in the specified VPC, allowing secure and private access to S3 resources within the VPC.

CloudFormationTerraform
VPN Customer Gateway

This template creates a customer gateway with the specified properties. The customer gateway is used to establish a VPN connection between your network and an Amazon VPC.

CloudFormationTerraform
VPC Traffic Mirroring

Configuration to enable Traffic Mirroring from a network interface (ENI) of an Amazon EC2 instance, which can then be used for monitoring and security analysis. Traffic Mirroring supports filters and packet truncation so that only traffic of interest is monitored.

CloudFormationTerraformAWS CLI
Flow Logs

Flow Logs enables you to capture information about the IP traffic going to and from network interfaces in your VPC. Flow Logs can be enabled on a VPC, subnet, or network interface level.

CloudFormationTerraformAWS CLI
Managed Prefix Lists

Configuration template to create a customer managed Prefix List with a set of IPv4 or IPv6 CIDR blocks. A prefix list supports up to 1000 entries, and can be referenced in security groups and in subnet route table entries.

CloudFormationAWS CLI
Amazon VPC Endpoints

Configuration to create a VPC endpoint in an existing VPC. VPC endpoints allow private connectivity from an VPC to supported AWS services. Both Interface and Gateway endpoints are supported.

CloudFormationTerraformAWS CLI
VPC DNS Query Logging

Configuration to enable logging the DNS queries that originate in an Amazon VPC using the Route53 Resolver Query Logging feature. Query logs can be sent to CloudWatch logs, S3 Buckets, or Kinesis Data Firehose.

CloudFormationTerraformAWS CLI
EC2
Create a Gateway Load Balancer endpoint

This template creates a Gateway Load Balancer endpoint that connects `myVPC` with the specified endpoint service in the current Region. The template also creates a VPC and a subnet for the endpoint.

CloudFormationTerraform
Example VPC Gateway Endpoint Configuration

This template creates a gateway endpoint that connects the VPC defined by `myVPC` with Amazon S3 in the current Region. The endpoint policy allows only the `s3:GetObject` action on the specified bucket. Traffic to Amazon S3 from the subnets that are associated with the route table specified in `RouteTableIds` is automatically routed through the gateway endpoint. The template also creates a VPC, subnet, route table, and subnet route table association for the endpoint.

CloudFormationTerraform
Example VPC Interface Endpoint Configuration

This template creates an interface endpoint for Amazon CloudWatch Logs in the current Region. Traffic to CloudWatch Logs from any subnet in the Availability Zones that contain `subnetA` and `subnetB` automatically traverses the interface endpoint. The template also creates a VPC, subnets, and a security group for the endpoint.

CloudFormationTerraform
Example VPN Connection

This template creates a VPN connection between a newly created virtual private gateway and a VPN customer gateway (with IP address 1.2.3.4). It specifies the type of connection as ipsec.1 and sets the StaticRoutesOnly property to true. It also includes a VPN route for the subnet 10.0.0.0/16

CloudFormationTerraform
VPC Peering (Same Account)

This template shows how to peer two VPCs in the same account. It uses an existing VPC as the requester VPC and creates the accepter VPC.

CloudFormationTerraform
VPN Gateway Attachment

This template creates a VPN gateway and an attachment to a VPC (vpc-12345). It also created and attaches an Internet Gateway to the same VPC.

CloudFormationTerraform
Associate an IPv4 CIDR block and an Amazon-provided IPv6 CIDR block

This template associates an IPv4 CIDR block and an Amazon-provided IPv6 CIDR block with a VPC. It also outputs the list of IPv4 CIDR block association IDs and IPv6 CIDR blocks that are associated with the VPC.

CloudFormationTerraform
Transit Gateway

This template creates a transit gateway with the specified properties. The transit gateway can be used to interconnect virtual private clouds (VPC) and on-premises networks. The example includes properties such as AmazonSideAsn, Description, AutoAcceptSharedAttachments, DefaultRouteTableAssociation, DnsSupport, VpnEcmpSupport, and Tags.

CloudFormationTerraform
Example Traffic Mirror Session

This template creates a traffic mirror session that mirrors the first 100 bytes in each packet. It specifies the description, network interface ID, traffic mirror target ID, traffic mirror filter ID, session number, packet length, virtual network ID, and tags for the session.

CloudFormationTerraform
Create a traffic mirror filter rule for inbound UDP traffic

This template creates a Traffic Mirror Filter and a Traffic Mirror filter rule for inbound UDP traffic. The rule has a description and specifies the traffic direction as ingress. The rule number is set to 10, and it filters traffic with a destination CIDR block and source CIDR block both set to 10.0.0.0/16. The rule action is set to accept, and the protocol is set to 17 (UDP). The source port range is set from 10 to 50, and the destination port range is set from 50 to 100.

CloudFormationTerraform
Traffic Mirror Filter

This template creates a traffic mirror filter with the description 'Example traffic mirror filter'. It configures mirroring of Amazon DNS network services.

CloudFormationTerraform
Example VPC Route Table

This template creates a route table for the specified VPC (vpc-123456). The route table is tagged with a key-value pair of 'stack: production'.

CloudFormationTerraform
Route to IGW

This template creates a route in a route table (rtb-123456789) that points to an internet gateway that is created in the template as well. The destination CIDR block is set to `0.0.0.0/0`, which represents all IP addresses.

CloudFormationTerraform
Managed Prefix List

This template creates an IPv4 prefix list with a maximum of 10 entries. It creates 2 entries in the prefix list with CIDR blocks and descriptions.

CloudFormationTerraform
Grant INSTANCE-ATTACH Permission to an ENI

This template creates a permission for a specified network interface and AWS account. It grants the permission to attach the network interface to an instance in the specified AWS account.

CloudFormationTerraform
Network Interface Attachment

This template creates a network interface attachment that attaches an elastic network interface (ENI) to an Amazon EC2 instance. The `InstanceId` property specifies the instance to attach the network interface to, the `NetworkInterfaceId` property specifies the network interface to attach, and the `DeviceIndex` property specifies the device index for the attachment.

CloudFormationTerraform
Example Network Interface Configuration

This template creates a standalone elastic network interface (ENI) with the specified properties. The ENI has a description, has source/destination checking disabled, is associated with a security group, is associated with a subnet, and has a private IP address of 10.0.0.16.

CloudFormationTerraform
NAT Gateway with Route Entry

This template creates a public NAT gateway and a route that sends all internet-bound traffic from the private subnet (subnet-123456789) with EC2 instances to the NAT gateway. A public NAT gateway uses an elastic IP address to provide it with a public IP address that doesn't change. The template includes the creation of a NAT gateway, an elastic IP address, and a route table entry.

CloudFormationTerraform
Internet Gateway with VPC Attachment

This template creates an internet gateway and assigns it a tag. The internet gateway is allocated for use with a VPC. The template also includes an attachment to a VPC (vpc-123456)

CloudFormationTerraform
Custom Format Flow Log Configuration

This template creates a flow log for the specified subnet and captures ACCEPT traffic. The flow log uses a custom log format and is published to a newly created Amazon S3 bucket. The logs are aggregated over 60 second intervals and published in parquet format in Hive-compatible prefixes partitioned on an hourly basis. The flow log is created with two tags.

CloudFormationTerraform
Configure VPC Flow Logs to CloudWatch (Includes IAM Role)

This template creates a flow log for the specified VPC, and captures all traffic types. The flow log is published to the newly created `FlowLogsGroup` log group in CloudWatch Logs and includes the IAM role with the necessary permissions

CloudFormationTerraform
Allocate an Elastic IP Address and Associate with a Network Interface

This template creates an Elastic IP address and a network interface, and associates the Elastic IP address with the network interface. The template uses the ID of an existing subnet and an example IP address from the subnet CIDR range.

CloudFormationTerraform
VPC Security Group with Egress and Ingress Rules

This template creates two VPC security groups with egress and ingress rules. The `SourceSG` security group allows outbound traffic to the `TargetSG` security group. The `TargetSG` security group allows inbound traffic from the `SourceSG` security group. The outbound rule allows TCP traffic from port 0 to port 65535, and the inbound rule allows TCP traffic from port 0 to port 65535.

CloudFormationTerraform
Network Manager
AWS Network Manager Device

This template creates a device in a global network. The device is described as the Chicago office device and is associated with a specific site.

CloudFormationTerraform
AWS Network Manager Link

This template creates a broadband link in Amazon Network Manager with a download and upload speed of 20 Mbps. The link is provided by AnyCompany and is associated with a specific global network and site.

CloudFormationTerraform
AWS Network Manager Site

This template creates a site in Amazon Network Manager for the Chicago office with the specified address and coordinates. It is associated with the global network 'global-network-0d47f6t230mz46dy4' and tagged as 'north-america'.

CloudFormationTerraform
AWS Network Manager Transit Gateway Registration

This template registers a transit gateway in a global network.

CloudFormationTerraform
AWS Network Manager Core Network with VPC Attachment (Single Region)

Configures a core network with a VPC attachment in a single region, including a custom base policy document.

Terraform
AWS Network Manager Core Network with VPC Attachment (Multi-Region)

Configures a core network with VPC attachments across multiple regions, using a base policy document for detailed customization.

Terraform
Core Network with VPC Attachment Using Base Policy Document

Illustrates attaching VPCs to a core network with a custom base policy document specifying ASN and edge locations, followed by applying a policy document.

Terraform
Core Network with VPC Attachment Using Base Policy Regions

Configures a core network with VPC attachments across multiple regions using a base policy that specifies regions, and applies a policy document.

Terraform
Direct Connect
Associate Direct Connect Connection with LAG

This template associates an AWS Direct Connect connection with a Link Aggregation Group (LAG) using specified bandwidth and location.

Terraform
VPN Gateway Association with Direct Connect Gateway

Associates a VPN Gateway with a Direct Connect Gateway using their respective IDs.

Terraform
Transit Gateway Association with Direct Connect Gateway

Associates a Transit Gateway with a Direct Connect Gateway and specifies allowed prefixes for routing.

Terraform
VPN Gateway Association with Allowed Prefixes

Associates a VPN Gateway with a Direct Connect Gateway and configures allowed prefixes for network traffic.

Terraform
AWS Direct Connect Hosted Private Virtual Interface Accepter

Manages the accepter's side of a Direct Connect hosted private virtual interface, accepting ownership from another AWS account.

Terraform
AWS Direct Connect Hosted Public Virtual Interface

Creates a hosted public virtual interface for AWS Direct Connect, allowing the allocation of a virtual interface owned by another AWS account.

Terraform
AWS Direct Connect Hosted Public Virtual Interface Acceptance

Manages the accepter's side of a Direct Connect hosted public virtual interface, accepting ownership from another AWS account.

Terraform
Create MACSec key with CKN and CAK

This template creates a MACSec key association using a Direct Connect connection with specified CKN and CAK values.

Terraform
Create MACSec key with existing Secrets Manager secret

This template creates a MACSec key association using a Direct Connect connection and references an existing Secrets Manager secret.

Terraform
AWS Direct Connect Transit Virtual Interface Setup

Creates a Direct Connect gateway and a transit virtual interface to connect a Direct Connect gateway to one or more transit gateways.

Terraform
Security Group
Custom Security Group

Build a custom security group.

CloudFormationTerraformAWS CLI
Web Server Security Group

A security group that allows inbound web traffic (TCP ports 80 and 443).

CloudFormationTerraformAWS CLI
Remote Desktop Protocol (RDP) Security Group

A security group that allows inbound RDP traffic (TCP port 3389).

CloudFormationTerraformAWS CLI
SSH Security Group

A security group that allows inbound SSH traffic (TCP port 22).

CloudFormationTerraformAWS CLI
Microsoft Active Directory Security Group

A security group that allows domain controller services on Microsoft Active Directory servers.

CloudFormationTerraformAWS CLI
DNS Server Security Group

A security group that allows inbound DNS traffic (TCP and UDP port 53).

CloudFormationTerraformAWS CLI
ICMP Security Group

A security group that allows inbound ICMP traffic.

CloudFormationTerraformAWS CLI
Maria DB Security Group

A security group that allows inbound access to a Maria DB instance.

CloudFormationTerraformAWS CLI
Microsoft SQL Server Security Group

A security group that allows inbound access to a Microsoft SQL server instance.

CloudFormationTerraformAWS CLI
MySql DB Security Group.

A security group that allows inbound access to a MySQL server instance.

CloudFormationTerraformAWS CLI
Oracle DB Security Group.

A security group that allows inbound access to an Oracle server instance.

CloudFormationTerraformAWS CLI
PostgreSQL DB Security Group.

A security group that allows inbound access to an PostgreSQL server instance.

CloudFormationTerraformAWS CLI
Amazon EFS Security Group

A security group for Amazon EFS that allows inbound NFS access from resources (including the mount target) associated with this security group (TCP 2049).

CloudFormationTerraformAWS CLI
Redshift Cluster Security Group

A security group that allows inbound access to an Amazon Redshift cluster (TCP 5439)

CloudFormationTerraformAWS CLI
Amazon OpenSearch Security Group

A security group that allows inbound access to an Amazon OpenSearch (TCP 443 and 80)

CloudFormationTerraformAWS CLI
Config Rule
Security Groups SSH Restricted Check

Checks whether security groups in use do not allow restricted incoming SSH traffic. This rule applies only to IPv4.

CloudFormationTerraformAWS CLI
Security Groups Unrestricted Common Ports Check

Checks whether security groups in use do not allow unrestricted incoming TCP traffic to the specified ports. This rule applies only to IPv4.

CloudFormationTerraformAWS CLI
No EC2 Instances in Public Subnets Check

Check that no EC2 Instances are in Public Subnet.

CloudFormationTerraformAWS CLI
Security Groups Do Not Allow All Protocols Check

Check that security groups do not have an inbound rule with protocol of 'All'.

CloudFormationTerraformAWS CLI
Security Groups Do Not Allow All Ports Check

Check that security groups do not have an inbound rule with port range of 'All'.

CloudFormationTerraformAWS CLI
Launch Wizard Security Groups are Not Used Check

Check that security groups prefixed with "launch-wizard" are not associated with network interfaces.

CloudFormationTerraformAWS CLI
Default Security Group Closed Check

A config rule that checks that the default security group of any Amazon Virtual Private Cloud (VPC) does not allow inbound or outbound traffic. The rule returns NOT_APPLICABLE if the security group is not default. The rule is NON_COMPLIANT if the default security group has one or more inbound or outbound traffic.

CloudFormationTerraformAWS CLI
VPC Flow Logs Enabled Check

A config rule that checks whether Amazon Virtual Private Cloud flow logs are found and enabled for Amazon VPC.

CloudFormationTerraformAWS CLI
VPC VPN Tunnels Status Check

A Config rule that checks that both AWS Virtual Private Network tunnels provided by AWS Site-to-Site VPN are in UP status. The rule returns NON_COMPLIANT if one or both tunnels are in DOWN status.

CloudFormationTerraformAWS CLI
Internet Gateways Attached to Authorized VPCs Only Check

A config rule that checks that Internet gateways (IGWs) are only attached to an authorized Amazon Virtual Private Cloud (VPCs). The rule is NON_COMPLIANT if IGWs are not attached to an authorized VPC.

CloudFormationTerraformAWS CLI
VPC Endpoints Enabled

A Config rule that checks whether Service Endpoint for the service provided in rule parameter is created for each Amazon VPC. The rule returns NON_COMPLIANT if an Amazon VPC doesn't have a VPC endpoint created for the service.

CloudFormationTerraformAWS CLI
Subnet Auto-Assign Public IP Disabled Check

A config rule that checks if Amazon Virtual Private Cloud (Amazon VPC) subnets are assigned a public IP address. The rule is COMPLIANT if Amazon VPC does not have subnets that are assigned a public IP address. The rule is NON_COMPLIANT if Amazon VPC has subnets that are assigned a public IP address.

CloudFormationTerraformAWS CLI
NACL Does Not Allow Unrestricted SSH or RDP Check

A Config rule that checks if default ports for SSH/RDP ingress traffic for network access control lists (NACLs) is unrestricted. The rule is NON_COMPLIANT if a NACL inbound entry allows a source TCP or UDP CIDR block for ports 22 or 3389.

CloudFormationTerraformAWS CLI
No Unrestricted Route To IGW Check

A Config rule that checks if there are public routes in the route table to an Internet Gateway (IGW). The rule is NON_COMPLIANT if a route to an IGW has a destination CIDR block of '0.0.0.0/0' or '::/0' or if a destination CIDR block does not match the rule parameter.

CloudFormationTerraformAWS CLI
Check if AWS Client VPN authorization rules authorizes connection access for all clients

Checks if the AWS Client VPN authorization rules authorizes connection access for all clients. The rule is NON_COMPLIANT if 'AccessAll' is present and set to true.

CloudFormationTerraform
Check for unused network ACLs

Checks if there are unused network access control lists (network ACLs). The rule is COMPLIANT if each network ACL is associated with a subnet. The rule is NON_COMPLIANT if a network ACL is not associated with a subnet.

CloudFormationTerraform
Service Control Policy
Prevent Any VPC That Doesn't Already Have Internet Access from Getting It

This SCP prevents users or roles in any affected account from changing the configuration of your Amazon EC2 virtual private clouds (VPCs) to grant them direct access to the internet. It doesn't block existing direct access or any access that routes through your on-premises network environment.

CloudFormationTerraformAWS CLI
Protect VPC Connectivity Settings from Modification

This SCP restricts IAM principals in an AWS account from changing creating, updating or deleting settings for Internet Gateways, NAT Gateways, VPC Peering, VPN Gateways, Client VPNs, Direct Connect and Global Accelerator.

CloudFormationTerraformAWS CLI
Protect VPC Internet and NAT Gateway Settings from any Modifications

This SCP restricts IAM principals in an AWS account from changing creating, updating or deleting Internet Gateways and NAT Gateways.

CloudFormationTerraformAWS CLI
Prevent Users from Deleting Amazon VPC Flow Logs

This SCP prevents users or roles in any affected account from deleting Amazon EC2 flow logs or CloudWatch log groups or log streams.

CloudFormationTerraformAWS CLI
Restrict VPC CIDR to Specific IP Pools from Amazon VPC IPAM (IP Address Manager)

This SCP restrict users in your AWS Organizations account to creating VPCs with CIDRs from a specific IPv4 pool and associating CIDRs to the VPCs from the pool. Users in the account will not be able to create VPCs with CIDRs or associate CIDRs to VPCs from any other pools from the one you choose.

CloudFormationTerraformAWS CLI
Prevent Users from Creating Default VPC and Subnet

This SCP prevents users or roles in any affected account from creating a default VPC or Subnets

CloudFormationTerraformAWS CLI