A collection of AWS Security controls for AWS EC2. Controls and templates include Directory Services (Microsoft AD and SimpleAD), SSM Configuration, Auto Scaling Groups, IAM policies, security groups, Flow logs, CloudWatch events and alarms for monitoring as well as Config rules. Configuration templates are available in AWS CloudFormation, AWS CLI and Terraform.
Configuration template to deploy an Amazon EC2 instance with customizable settings that include Instance Metadata Service (IMDS) settings, volume and interface settings, name tag, key pairs, and more.
Configuration to create an Amazon EC2 Launch Template to be used to provision EC2 Instances. The template includes customizable settings such as configuring instance type, image id, IMDS enforcement, volume and interface settings, and more.
Configuration to enable EBS default encryption for all EC2 instances in that region. Includes a CloudFormation custom resource to enable this setting.
This template creates a 100 GiB io1 volume with 100 provisioned IOPS. The volume is created in the same Availability Zone as the EC2 instance.
This template creates a placement group with a cluster placement strategy. The placement group is used to organize instances within the group.
This template creates and configures a launch template to assign public IP addresses to instances launched in a nondefault VPC. Note that when you specify a network interface for Amazon EC2 Auto Scaling, specify the VPC subnets as properties of the Auto Scaling group, and not in the launch template (because they will be ignored). This example launch template also sets the instance placement tenancy to `dedicated`.
This template creates a launch template and an instance profile. The instance profile references the IAM role being created (with ReadOnlyAccess managed policy) and can provide the role's temporary credentials to an application that runs on the instances created by this launch template. The launch template also prevents accidental instance termination when using the Amazon EC2 console, CLI, or API, by specifying `true` for the `DisableApiTermination` property. If the instances created by this launch template are launched in a default VPC, they receive a public IP address by default. If the instances are launched in a nondefault VPC, they do not receive a public IP address by default.
This template imports an existing key pair and specifies it when launching an EC2 instance. The `AWS::EC2::KeyPair` resource is used to import the key pair with the `KeyName` property set to 'NameForMyImportedKeyPair' and the `PublicKeyMaterial` property set to the public key material. The `AWS::EC2::Instance` resource is used to launch the EC2 instance with the `ImageId` property set to 'ami-123456789012' and the `KeyName` property set to the `ImportedKeyPair` resource.
This template creates a new key pair and specifies it when launching an EC2 instance. The `AWS::EC2::KeyPair` resource is used to create the key pair with the `KeyName` property set to 'MyKeyPair'. The `AWS::EC2::Instance` resource is used to launch the EC2 instance with the `ImageId` property set to 'ami-123456789012' and the `KeyName` property set to the `NewKeyPair` resource.
This template creates an EC2 instance and associates a public IP address with the primary network interface. The instance is created in a specified subnet (subnet-123456) and references a new security group created to allow HTTPS traffic from the internet.
This template creates an EC2 instance with a block device mapping. It specifies an io1 volume with a size of 20 GB and overrides a device specified in the AMI block device mapping using NoDevice.
This template attaches an EC2 EBS volume to the EC2 instance with the logical name 'Ec2Instance'. It creates a new volume with a size of 100 and in the same availability zone as the instance. The volume is tagged with a key-value pair. Then, it attaches the volume to the instance with the specified device name '/dev/sdh'.
This template allocates a dedicated host for launching EC2 instances. The host is fully dedicated for your use, helping you address compliance requirements and reduce costs by allowing you to use your existing server-bound software licenses.
This template creates a Capacity Reservation Fleet with the specified attributes. The Capacity Reservation Fleet will create Capacity Reservations for 2 c4.large or c5.large instances. The Fleet prioritizes c4.large over c5.large and both instance types have the same weight.
Configuration for an Auto Scaling Group which creates a logical grouping of EC2 instances, and enables you to use features such as health check replacements and scaling policies. Auto scaling groups also maintain the number of EC2 instances within the defined limits.
This template retrieves AWS Autoscaling Groups filtered by specific tags and sets up notifications for instance changes to a Slack channel via an SNS topic.
Defines an AWS Auto Scaling Group with a specified placement group, lifecycle hooks, and instance maintenance policies.
Configures an Auto Scaling Group to use the latest version of a specified AWS Launch Template.
Demonstrates how to dynamically apply tags to instances in an Auto Scaling Group based on a variable list of tags.
Creates an Auto Scaling Group with a warm pool to maintain a set of pre-initialized instances that can quickly scale out.
Illustrates how to configure an Auto Scaling Group with dynamic traffic sources, specifically targeting VPC Lattice.
This template manages tags for Autoscaling Groups created by an EKS Node Group, specifically setting a label for the cluster autoscaler.
This template sets up an AWS Autoscaling Group and attaches a Lifecycle Hook to it. The hook triggers when an EC2 instance is launching.
Creates a target tracking scaling policy using AWS metric math to dynamically adjust the AutoScaling group size based on queue and instance metrics.
Creates an AWS AutoScaling Group and schedules scaling actions for it.
This template sets up a predictive scaling plan for an AWS Auto Scaling group, using forecast data to scale and optimize for CPU utilization while disabling dynamic scaling.
Configuration to create an Application Load Balancer (ALB), target groups and listeners in an AWS VPC to load balance incoming traffic to targets such as EC2 instances or Lambda functions. The ALB also includes health checks to ensure the state of the targets before forwarding traffic.
Configuration to create a Network Load Balancer (NLB), target groups and listeners in an AWS VPC to load balance incoming traffic to targets such as EC2 instances or ALBs. The NLB also includes health checks to ensure the state of the targets before forwarding traffic.
A configuration guide for setting up the necessary configuration for AWS Systems Manager Patch Manager to automatically scan and/or apply patches to EC2 instances in an AWS environment.
Set up Amazon Inspector by creating an Amazon Inspector Assessment Template and specify EC2 Assessment Targets. Select from predefined rule packages: Common Vulnerabilities and Exposures, Center for Internet Security (CIS) Benchmarks, Security Best Practices for Amazon Inspector, Runtime Behavior Analysis, and Network Reachability.
Set up Amazon Inspector Assessment Template to scan EC2 instances against the CIS Benchmarks Security Rule Package.
Set up Amazon Inspector Assessment Template to scan EC2 instances against the Common Vulnerabilities and Exposures (CVE) Rule Package.
Configuration template for AWS Managed Microsoft Active Directory (AD) service. This service is created as a highly available pair of domain controllers connected to your virtual private cloud (VPC). The domain controllers run in different Availability Zones in a Region of your choice. Host monitoring and recovery, data replication, snapshots, and software updates are automatically configured and managed for you.
This template creates a Simple AD directory with the specified properties. The directory DNS name is 'corp.example.com'. It uses a 'Small' size and is associated with the specified VPC and subnets.
Creates a SimpleAD directory along with a VPC and two subnets in AWS.
Sets up a MicrosoftAD directory with a VPC and two subnets in AWS.
Configures an ADConnector directory with custom DNS and username settings, along with a VPC and two subnets.
Configures multi-factor authentication using a RADIUS server for an AWS Directory Service directory.
This template sets up a multi-region AWS Managed Microsoft AD with primary and secondary configurations including VPCs and subnets.
Creates a Microsoft Active Directory in AWS and shares it with another AWS account.
Accepts a shared directory in a consumer account and configures it with an alternate AWS provider.
This template configures a two-way trust relationship between two AWS Managed Microsoft AD domains, including conditional forwarders.
This template sets up a one-way trust relationship between two AWS Managed Microsoft AD domains, specifying incoming and outgoing trust directions.
A configuration package to monitor EC2 related API activity as well as configuration compliance rules to ensure the security of AWS EC2 configuration. The package includes Config Rules, CloudWatch Alarms, and CloudWatch Event Rules, and uses SNS to deliver email notifications. The package also includes configuration to enable the required AWS logging services: AWS CloudTrail, Config, and CloudWatch log groups
A configuration package to monitor Amazon Machine Images (AMIs) creation and modifications as well as ensure the compliance and security of AMIs available in the account
Retrieves pricing information for an Amazon EC2 instance with specific attributes in the US East (N. Virginia) region.
This CloudFormation template creates an Amazon Image Builder Image Recipe with specified components and block device mappings.
This template creates an infrastructure configuration for Amazon EC2 Image Builder. It provisions resources such as instance profiles, security groups, and S3 logging buckets, and allows customization through tags.
This template creates an Amazon Image Builder component with data, allowing users to build, validate, and test their images using custom scripts.
This template creates an Amazon Image Builder component using a Uri. It allows you to specify the KMS key ID for encryption, the platform, version, and supported OS versions for the component.
This CloudFormation template creates an Amazon Image Builder Container Recipe with specified parameters, including the parent image, components, target repository, Dockerfile template, working directory, and tags. The output is the ARN of the created Container Recipe.
This template creates a distribution configuration for distributing Amazon Machine Images (AMIs) to different regions and target accounts. It allows you to set launch permissions, specify license configurations, and distribute to organizations and organizational units.
This template creates a distribution configuration resource for a container image. It sets the target repository and container tags for container distribution to multiple regions. The container image can be distributed to multiple regions.
This template creates an Image Builder configuration that uses an image recipe, infrastructure configuration, and distribution configuration to build and distribute custom images. It also allows for the configuration of image tests and customer image tags.
This template creates an Amazon Image Builder Image Pipeline with specified parameters, including the image recipe, infrastructure configuration, distribution configuration, and schedule. It also allows for the configuration of tags and image tests.
Creates an AWS Image Builder distribution configuration with AMI distribution settings, including tags and launch permissions, and a launch template configuration.
Creates an AWS Image Builder Image using specified ARNs for distribution, image recipe, and infrastructure configurations.
Creates an AWS Image Builder infrastructure configuration with specified properties such as instance types, key pair, security groups, and logging settings.
Configuration to create AWS Backup plans and vaults. AWS Backup automates the process of backing up of data across AWS services including EFS, DynamoDB, EC2, EBS, Aurora, RDS, and Storage Gateway, as well as setting custom retention policies, access policies, and encryption
Configure a Data Lifecycle Manager (DLM) policy to automate the creation, retention, and deletion of snapshots taken to back up your Amazon EBS volumes.
This template creates a basic snapshot lifecycle policy with a cross-Region copy rule. The policy is enabled and uses an execution role. It applies to volumes with a specific cost center tag. The policy includes a schedule for daily snapshots at 13:00, with a retention count of 1. The snapshots are not encrypted and are copied to the us-east-1 region. The template is available in both JSON and YAML formats.
Build a custom security group.
A security group that allows inbound web traffic (TCP ports 80 and 443).
A security group that allows inbound RDP traffic (TCP port 3389).
A security group that allows inbound SSH traffic (TCP port 22).
A security group that allows domain controller services on Microsoft Active Directory servers.
A security group that allows inbound DNS traffic (TCP and UDP port 53).
A security group that allows inbound ICMP traffic.
A security group that allows inbound access to a Maria DB instance.
A security group that allows inbound access to a Microsoft SQL server instance.
A security group that allows inbound access to a MySQL server instance.
A security group that allows inbound access to an Oracle server instance.
A security group that allows inbound access to an PostgreSQL server instance.
A security group for Amazon EFS that allows inbound NFS access from resources (including the mount target) associated with this security group (TCP 2049).
A security group that allows inbound access to an Amazon Redshift cluster (TCP 5439)
A security group that allows inbound access to an Amazon OpenSearch (TCP 443 and 80)
A CloudWatch Alarm that triggers when changes are made to Security Groups.
A CloudWatch Alarm that triggers when changes are made to large size EC2 Instances.
A CloudWatch Alarm that triggers when changes are made to EC2 Instances.
A CloudWatch Alarm that triggers when new AMIs (Amazon Machine Images) are created or registered in the account.
A CloudWatch Alarm that triggers when existing AMIs (Amazon Machine Images) are modified, deleted, copied or shared with other AWS accounts.
Detect changes to security groups and publishes change events to an SNS topic for notification.
Detect changes to EC2 Instances and publishes change events to an SNS topic for notification.
Auto remediation configuration to release unattached Elastic IPs. Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Auto remediation configuration to stop or terminate EC2 instances running unapproved AMIs (by AMI ID). Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Auto remediation configuration to stop or terminate EC2 instances running unapproved AMIs (by AMI Tag). Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Auto remediation configuration to stop or terminate EC2 instances running unapproved Tenancy Modes (Shared or Dedicated). Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Auto remediation configuration to stop or terminate EC2 instances using unapproved instance types. Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Auto remediation configuration to stop or terminate EC2 instances with public IP addresses. Detection uses a managed AWS Config Rule and remediation is with SSM Automation.
Checks whether the EBS volumes that are in an attached state are encrypted. If you specify the ID of a KMS key for encryption using the kmsId parameter, the rule checks if the EBS volumes in an attached state are encrypted with that KMS key.
Checks whether security groups in use do not allow restricted incoming SSH traffic. This rule applies only to IPv4.
Checks whether running instances are using specified AMIs. Specify a list of approved AMI IDs. Running instances with AMIs that are not on this list are noncompliant.
Checks whether running instances are using specified AMIs. Specify the tags that identify the AMIs. Running instances with AMIs that don't have at least one of the specified tags are noncompliant.
Checks whether security groups in use do not allow unrestricted incoming TCP traffic to the specified ports. This rule applies only to IPv4.
A config rule that checks instances for specified tenancy. Specify AMI IDs to check instances that are launched from those AMIs or specify host IDs to check whether instances are launched on those Dedicated Hosts. Separate multiple ID values with commas.
Check that no EC2 Instances are in Public Subnet.
Check that security groups do not have an inbound rule with protocol of 'All'.
Check that security groups do not have an inbound rule with port range of 'All'.
Check that security groups prefixed with "launch-wizard" are not associated with network interfaces.
A config rule that checks whether your EC2 instances are of the specified instance types.
A Config rule that checks whether the Amazon EC2 instances in your account are managed by AWS Systems Manager.
A Config rule that checks whether the compliance status of the Amazon EC2 Systems Manager (SSM) association compliance is COMPLIANT or NON_COMPLIANT after the association execution on the instance. The rule is compliant if the field status is COMPLIANT.
A Config rule that checks whether the compliance status of the Amazon EC2 Systems Manager patch compliance is COMPLIANT or NON_COMPLIANT after the patch installation on the instance. The rule is compliant if the field status is COMPLIANT.
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.
A Config rule that checks whether detailed monitoring is enabled for EC2 instances.
A Config rule that checks whether EBS volumes are attached to EC2 instances. Optionally checks if EBS volumes are marked for deletion when an instance is terminated.
A Config rule that checks whether all Elastic IP addresses that are allocated to a VPC are attached to EC2 instances or in-use elastic network interfaces (ENIs).
A Config rule that checks whether EC2 managed instances have the desired configurations.
A Config rule that checks whether all of the specified applications are installed on the instance. Optionally, specify the minimum acceptable version. You can also specify the platform to apply the rule only to instances running that platform.
A Config rule that checks that none of the specified applications are installed on the instance. Optionally, specify the application version. Newer versions of the application will not be blacklisted. You can also specify the platform to apply the rule only to instances running that platform.
A Config rule that checks whether instances managed by AWS Systems Manager are configured to collect blacklisted inventory types.
A Config rule that checks that Amazon Elastic Block Store (EBS) encryption is enabled by default. The rule is NON_COMPLIANT if the encryption is not enabled.
A config rule that checks whether all private AMIs are not older than X days.
A config rule that checks whether the Amazon Machine Images are not publicly accessible.
A Config rule that checks whether Amazon Elastic Compute Cloud (Amazon EC2) instances have a public IP association. The rule is NON_COMPLIANT if the publicIp field is present in the Amazon EC2 instance configuration item. This rule applies only to IPv4
A Config rule that checks that security groups are attached to Amazon Elastic Compute Cloud (Amazon EC2) instances or an elastic network interfaces (ENIs). The rule returns NON_COMPLIANT if the security group is not associated with an Amazon EC2 instance or an ENI
A Config rule that checks whether the security group with 0.0.0.0/0 of any Amazon Virtual Private Cloud (Amazon VPCs) allows only specific inbound TCP or UDP traffic. The rule and any security group with inbound 0.0.0.0/0. is NON_COMPLIANT, if you do not provide any ports in the parameters.
A Config rule that checks whether Amazon Elastic Block Store snapshots are not publicly restorable. The rule is NON_COMPLIANT if one or more snapshots with the RestorableByUserIds field is set to all. If this field is set to all, then Amazon EBS snapshots are public.
A Config rule that checks whether there are instances stopped for more than the allowed number of days. The instance is NON_COMPLIANT if the state of the ec2 instance has been stopped for longer than the allowed number of days.
A Config rule that checks whether your Amazon Elastic Compute Cloud (Amazon EC2) instance metadata version is configured with Instance Metadata Service Version 2 (IMDSv2). The rule is COMPLIANT if the HttpTokens is set to required and is NON_COMPLIANT if the HttpTokens is set to optional.
A Config rule that checks if Amazon Elastic Block Store (Amazon EBS) volumes are added in backup plans of AWS Backup. The rule is NON_COMPLIANT if Amazon EBS volumes are not included in backup plans.
A Config rule that checks if capacity rebalancing is enabled for Amazon EC2 Auto Scaling groups that use multiple instance types.
A Config rule that checks if Amazon EC2 Auto Scaling groups have public IP addresses enabled through Launch Configurations. This rule is NON_COMPLIANT if the Launch Configuration for an Auto Scaling group has AssociatePublicIpAddress set to true.
A Config rule that checks whether only IMDSv2 is enabled. This rule is NON_COMPLIANT if the Metadata version is not included in the launch configuration or if both Metadata V1 and V2 are enabled.
A Config rule that checks the number of network hops that the metadata token can travel. This rule is NON_COMPLIANT if the Metadata response hop limit is greater than 1.
A Config rule that checks if the Auto Scaling group spans multiple Availability Zones. The rule is NON_COMPLIANT if the Auto Scaling group does not span multiple Availability Zones.
A Config rule that checks if an Amazon Elastic Compute Cloud (Amazon EC2) Auto Scaling group uses multiple instance types. This rule is NON_COMPLIANT if the Amazon EC2 Auto Scaling group has only one instance type defined.
A Config rule that checks if Amazon Elastic Compute Cloud (Amazon EC2) uses multiple ENIs (Elastic Network Interfaces) or Elastic Fabric Adapters (EFAs). This rule is NON_COMPLIANT an Amazon EC2 instance use multiple network interfaces.
A Config rule that checks if an Amazon Elastic Compute Cloud (Amazon EC2) instance has an Identity and Access Management (IAM) profile attached to it. This rule is NON_COMPLIANT if no IAM profile is attached to the Amazon EC2 instance.
A Config rule that checks if running Amazon Elastic Compute Cloud (EC2) instances are launched using amazon key pairs. The rule is NON_COMPLIANT if a running EC2 instance is launched with a key pair.
A Config rule that checks if the virtualization type of an EC2 instance is paravirtual. This rule is NON_COMPLIANT for an EC2 instance if virtualizationType is set to paravirtual.
A Config rule that checks if an Amazon Elastic Compute Cloud (EC2) instance metadata has a specified token hop limit that is below the desired limit. The rule is NON_COMPLIANT for an instance if it has a hop limit value above the intended limit.
A Config rule that checks if Amazon Elastic Compute Cloud (Amazon EC2) Transit Gateways have AutoAcceptSharedAttachments enabled. The rule is NON_COMPLIANT for a Transit Gateway if AutoAcceptSharedAttachments is set to enable.
A Config rule that checks whether EBS optimization is enabled for your EC2 instances that can be EBS-optimized. The rule is NON_COMPLIANT if EBS optimization is not enabled for an EC2 instance that can be EBS-optimized.
Checks if an Amazon Elastic Compute Cloud (EC2) Auto Scaling group is created from an EC2 launch template. The rule is NON_COMPLIANT if the scaling group is not created from an EC2 launch template.
Checks if a recovery point was created for Amazon Elastic Compute Cloud (Amazon EC2) instances. The rule is NON_COMPLIANT if the Amazon EC2 instance does not have a corresponding recovery point created within the specified time period.
Checks if Amazon EC2 Launch Templates are set to assign public IP addresses to Network Interfaces. The rule is NON_COMPLIANT if the default version of an EC2 Launch Template has at least 1 Network Interface with 'AssociatePublicIpAddress' set to 'true'.
Checks whether instances managed by Amazon EC2 Systems Manager are configured to collect blacklisted inventory types.
Checks if non-default security groups are attached to Elastic network interfaces (ENIs). The rule is NON_COMPLIANT if the security group is not associated with an ENI. Security groups not owned by the calling account evaluate as NOT_APPLICABLE.
Checks if your EC2 instances belong to a virtual private cloud (VPC). Optionally, you can specify the VPC ID to associate with your instances.
A policy that allows starting or stopping a specific EC2 instance and modifying a specific security group (Programmatically and in the Console).
A policy that allows listing information for all EC2 objects and launching EC2 instances in a specific subnet. This policy also provides the permissions necessary to complete this action on the console.
A policy that allows managing Amazon EC2 security groups associated with a specific virtual private cloud (VPC). This policy also provides the permissions necessary to complete this action on the console.
A policy hat allows full EC2 access within a specific region. This policy also provides the permissions necessary to complete this action on the console.
An IAM policy that prevents users from creating their own security groups, and allows users to only launch approved AMIs (Amazon Machine Images). Approved images are identified with Tags (Example, Tag Key: Approved, Tag Value: True). This policy provides the permissions necessary to complete this action programmatically or from the console.
An IAM policy that allows an IAM user to start or stop EC2 instances, but only if the instance tag Owner has the value of that user's user name. This policy also provides the permissions necessary to complete this action on the console.
An IAM policy that prevents users from terminating EC2 instances when the request does not come from a specified IP range. This policy provides the permissions necessary to complete this action using the AWS API or AWS CLI only
An IAM policy that prevents users from launching new EC2 Instances if they are not configured to use the new Instance Metadata Service (IMDSv2)
This SCP prevents the launch of any EC2 instance type that is not whitelisted by the policy (default: t3.micro).
This SCP requires that multi-factor authentication (MFA) is enabled before a principal or root user can stop an Amazon EC2 instance.
This SCP prevents users or roles in any affected account from disabling ebs default encryption