Package software.amazon.awscdk.services.ec2
Amazon EC2 Construct Library
The aws-cdk-lib/aws-ec2 package contains primitives for setting up networking and
instances.
import software.amazon.awscdk.services.ec2.*;
VPC
Most projects need a Virtual Private Cloud to provide security by means of
network partitioning. This is achieved by creating an instance of
Vpc:
Vpc vpc = new Vpc(this, "VPC");
All default constructs require EC2 instances to be launched inside a VPC, so you should generally start by defining a VPC whenever you need to launch instances for your project.
Subnet Types
A VPC consists of one or more subnets that instances can be placed into. CDK distinguishes three different subnet types:
- Public (
SubnetType.PUBLIC) - public subnets connect directly to the Internet using an Internet Gateway. If you want your instances to have a public IP address and be directly reachable from the Internet, you must place them in a public subnet. - Private with Internet Access (
SubnetType.PRIVATE_WITH_EGRESS) - instances in private subnets are not directly routable from the Internet, and you must provide a way to connect out to the Internet. By default, a NAT gateway is created in every public subnet for maximum availability. Be aware that you will be charged for NAT gateways. Alternatively you can setnatGateways:0and provide your own egress configuration (i.e through Transit Gateway) - Isolated (
SubnetType.PRIVATE_ISOLATED) - isolated subnets do not route from or to the Internet, and as such do not require NAT gateways. They can only connect to or be connected to from other instances in the same VPC. A default VPC configuration will not include isolated subnets,
A default VPC configuration will create public and private subnets. However, if
natGateways:0 and subnetConfiguration is undefined, default VPC configuration
will create public and isolated subnets. See Advanced Subnet Configuration
below for information on how to change the default subnet configuration.
Constructs using the VPC will "launch instances" (or more accurately, create
Elastic Network Interfaces) into one or more of the subnets. They all accept
a property called subnetSelection (sometimes called vpcSubnets) to allow
you to select in what subnet to place the ENIs, usually defaulting to
private subnets if the property is omitted.
If you would like to save on the cost of NAT gateways, you can use
isolated subnets instead of private subnets (as described in Advanced
Subnet Configuration). If you need private instances to have
internet connectivity, another option is to reduce the number of NAT gateways
created by setting the natGateways property to a lower value (the default
is one NAT gateway per availability zone). Be aware that this may have
availability implications for your application.
Control over availability zones
By default, a VPC will spread over at most 3 Availability Zones available to
it. To change the number of Availability Zones that the VPC will spread over,
specify the maxAzs property when defining it.
The number of Availability Zones that are available depends on the region
and account of the Stack containing the VPC. If the region and account are
specified on
the Stack, the CLI will look up the existing Availability
Zones
and get an accurate count. The result of this operation will be written to a file
called cdk.context.json. You must commit this file to source control so
that the lookup values are available in non-privileged environments such
as CI build steps, and to ensure your template builds are repeatable.
If region and account are not specified, the stack could be deployed anywhere and it will have to make a safe choice, limiting itself to 2 Availability Zones.
Therefore, to get the VPC to spread over 3 or more availability zones, you must specify the environment where the stack will be deployed.
You can gain full control over the availability zones selection strategy by overriding the Stack's get availabilityZones() method:
// This example is only available in TypeScript
class MyStack extends Stack {
constructor(scope: Construct, id: string, props?: StackProps) {
super(scope, id, props);
// ...
}
get availabilityZones(): string[] {
return ['us-west-2a', 'us-west-2b'];
}
}
Note that overriding the get availabilityZones() method will override the default behavior for all constructs defined within the Stack.
Choosing subnets for resources
When creating resources that create Elastic Network Interfaces (such as
databases or instances), there is an option to choose which subnets to place
them in. For example, a VPC endpoint by default is placed into a subnet in
every availability zone, but you can override which subnets to use. The property
is typically called one of subnets, vpcSubnets or subnetSelection.
The example below will place the endpoint into two AZs (us-east-1a and us-east-1c),
in Isolated subnets:
Vpc vpc;
InterfaceVpcEndpoint.Builder.create(this, "VPC Endpoint")
.vpc(vpc)
.service(new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc", 443))
.subnets(SubnetSelection.builder()
.subnetType(SubnetType.PRIVATE_ISOLATED)
.availabilityZones(List.of("us-east-1a", "us-east-1c"))
.build())
.build();
You can also specify specific subnet objects for granular control:
Vpc vpc;
Subnet subnet1;
Subnet subnet2;
InterfaceVpcEndpoint.Builder.create(this, "VPC Endpoint")
.vpc(vpc)
.service(new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc", 443))
.subnets(SubnetSelection.builder()
.subnets(List.of(subnet1, subnet2))
.build())
.build();
Which subnets are selected is evaluated as follows:
subnets: if specific subnet objects are supplied, these are selected, and no other logic is used.subnetType/subnetGroupName: otherwise, a set of subnets is selected by supplying either type or name:subnetTypewill select all subnets of the given type.subnetGroupNameshould be used to distinguish between multiple groups of subnets of the same type (for example, you may want to separate your application instances and your RDS instances into two distinct groups of Isolated subnets).- If neither are given, the first available subnet group of a given type that exists in the VPC will be used, in this order: Private, then Isolated, then Public. In short: by default ENIs will preferentially be placed in subnets not connected to the Internet.
availabilityZones/onePerAz: finally, some availability-zone based filtering may be done. This filtering by availability zones will only be possible if the VPC has been created or looked up in a non-environment agnostic stack (so account and region have been set and availability zones have been looked up).availabilityZones: only the specific subnets from the selected subnet groups that are in the given availability zones will be returned.onePerAz: per availability zone, a maximum of one subnet will be returned (Useful for resource types that do not allow creating two ENIs in the same availability zone).
subnetFilters: additional filtering on subnets using any number of user-provided filters which extendSubnetFilter. The following methods on theSubnetFilterclass can be used to create a filter:byIds: chooses subnets from a list of idsavailabilityZones: chooses subnets in the provided list of availability zonesonePerAz: chooses at most one subnet per availability zonecontainsIpAddresses: chooses a subnet which contains any of the listed ip addressesbyCidrMask: chooses subnets that have the provided CIDR netmaskbyCidrRanges: chooses subnets which are inside any of the specified CIDR ranges
Using NAT instances
By default, the Vpc construct will create NAT gateways for you, which
are managed by AWS. If you would prefer to use your own managed NAT
instances instead, specify a different value for the natGatewayProvider
property, as follows:
The construct will automatically selects the latest version of Amazon Linux 2023.
If you prefer to use a custom AMI, use machineImage: MachineImage.genericLinux({ ... }) and configure the right AMI ID for the
regions you want to deploy to.
Warning The NAT instances created using this method will be unmonitored. They are not part of an Auto Scaling Group, and if they become unavailable or are terminated for any reason, will not be restarted or replaced.
By default, the NAT instances will route all traffic. To control what traffic
gets routed, pass a custom value for defaultAllowedTraffic and access the
NatInstanceProvider.connections member after having passed the NAT provider to
the VPC:
InstanceType instanceType;
NatInstanceProviderV2 provider = NatProvider.instanceV2(NatInstanceProps.builder()
.instanceType(instanceType)
.defaultAllowedTraffic(NatTrafficDirection.OUTBOUND_ONLY)
.build());
Vpc.Builder.create(this, "TheVPC")
.natGatewayProvider(provider)
.build();
provider.connections.allowFrom(Peer.ipv4("1.2.3.4/8"), Port.HTTP);
You can also customize the characteristics of your NAT instances, including their security group, as well as their initialization scripts:
Bucket bucket;
UserData userData = UserData.forLinux();
userData.addCommands(
(SpreadElement ...ec2.NatInstanceProviderV2.DEFAULT_USER_DATA_COMMANDS
NatInstanceProviderV2.DEFAULT_USER_DATA_COMMANDS), "echo \"hello world!\" > hello.txt", String.format("aws s3 cp hello.txt s3://%s", bucket.getBucketName()));
NatInstanceProviderV2 provider = NatProvider.instanceV2(NatInstanceProps.builder()
.instanceType(new InstanceType("t3.small"))
.creditSpecification(CpuCredits.UNLIMITED)
.defaultAllowedTraffic(NatTrafficDirection.NONE)
.build());
Vpc vpc = Vpc.Builder.create(this, "TheVPC")
.natGatewayProvider(provider)
.natGateways(2)
.build();
SecurityGroup securityGroup = SecurityGroup.Builder.create(this, "SecurityGroup").vpc(vpc).build();
securityGroup.addEgressRule(Peer.anyIpv4(), Port.tcp(443));
for (Object gateway : provider.getGatewayInstances()) {
bucket.grantWrite(gateway);
gateway.addSecurityGroup(securityGroup);
}
// Configure the `natGatewayProvider` when defining a Vpc
NatInstanceProvider natGatewayProvider = NatProvider.instance(NatInstanceProps.builder()
.instanceType(new InstanceType("t3.small"))
.build());
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
.natGatewayProvider(natGatewayProvider)
// The 'natGateways' parameter now controls the number of NAT instances
.natGateways(2)
.build();
The V1 NatProvider.instance construct will use the AWS official NAT instance AMI, which has already
reached EOL on Dec 31, 2023. For more information, see the following blog post:
Amazon Linux AMI end of life.
InstanceType instanceType;
NatInstanceProvider provider = NatProvider.instance(NatInstanceProps.builder()
.instanceType(instanceType)
.defaultAllowedTraffic(NatTrafficDirection.OUTBOUND_ONLY)
.build());
Vpc.Builder.create(this, "TheVPC")
.natGatewayProvider(provider)
.build();
provider.connections.allowFrom(Peer.ipv4("1.2.3.4/8"), Port.HTTP);
Associate Public IP Address to NAT Instance
You can choose to associate public IP address to a NAT instance V2 by specifying associatePublicIpAddress
like the following:
NatInstanceProviderV2 natGatewayProvider = NatProvider.instanceV2(NatInstanceProps.builder()
.instanceType(new InstanceType("t3.small"))
.associatePublicIpAddress(true)
.build());
In certain scenarios where the public subnet has set mapPublicIpOnLaunch to false, NAT instances does not
get public IP addresses assigned which would result in non-working NAT instance as NAT instance requires a public
IP address to enable outbound internet connectivity. Users can specify associatePublicIpAddress to true to
solve this problem.
Ip Address Management
The VPC spans a supernet IP range, which contains the non-overlapping IPs of its contained subnets. Possible sources for this IP range are:
- You specify an IP range directly by specifying a CIDR
- You allocate an IP range of a given size automatically from AWS IPAM
By default the Vpc will allocate the 10.0.0.0/16 address range which will be exhaustively spread across all subnets in the subnet configuration. This behavior can be changed by passing an object that implements IIpAddresses to the ipAddress property of a Vpc. See the subsequent sections for the options.
Be aware that if you don't explicitly reserve subnet groups in subnetConfiguration, the address space will be fully allocated! If you predict you may need to add more subnet groups later, add them early on and set reserved: true (see the "Advanced Subnet Configuration" section for more information).
Specifying a CIDR directly
Use IpAddresses.cidr to define a Cidr range for your Vpc directly in code:
import software.amazon.awscdk.services.ec2.IpAddresses;
Vpc.Builder.create(this, "TheVPC")
.ipAddresses(IpAddresses.cidr("10.0.1.0/20"))
.build();
Space will be allocated to subnets in the following order:
- First, spaces is allocated for all subnets groups that explicitly have a
cidrMaskset as part of their configuration (including reserved subnets). - Afterwards, any remaining space is divided evenly between the rest of the subnets (if any).
The argument to IpAddresses.cidr may not be a token, and concrete Cidr values are generated in the synthesized CloudFormation template.
Allocating an IP range from AWS IPAM
Amazon VPC IP Address Manager (IPAM) manages a large IP space, from which chunks can be allocated for use in the Vpc. For information on Amazon VPC IP Address Manager please see the official documentation. An example of allocating from AWS IPAM looks like this:
import software.amazon.awscdk.services.ec2.IpAddresses;
CfnIPAMPool pool;
Vpc.Builder.create(this, "TheVPC")
.ipAddresses(IpAddresses.awsIpamAllocation(AwsIpamProps.builder()
.ipv4IpamPoolId(pool.getRef())
.ipv4NetmaskLength(18)
.defaultSubnetIpv4NetmaskLength(24)
.build()))
.build();
IpAddresses.awsIpamAllocation requires the following:
ipv4IpamPoolId, the id of an IPAM Pool from which the VPC range should be allocated.ipv4NetmaskLength, the size of the IP range that will be requested from the Pool at deploy time.defaultSubnetIpv4NetmaskLength, the size of subnets in groups that don't havecidrMaskset.
With this method of IP address management, no attempt is made to guess at subnet group sizes or to exhaustively allocate the IP range. All subnet groups must have an explicit cidrMask set as part of their subnet configuration, or defaultSubnetIpv4NetmaskLength must be set for a default size. If not, synthesis will fail and you must provide one or the other.
Dual Stack configuration
To allocate both IPv4 and IPv6 addresses in your VPC, you can configure your VPC to have a dual stack protocol.
Vpc.Builder.create(this, "DualStackVpc")
.ipProtocol(IpProtocol.DUAL_STACK)
.build();
By default, a dual stack VPC will create an Amazon provided IPv6 /56 CIDR block associated to the VPC. It will then assign /64 portions of the block to each subnet. For each subnet, auto-assigning an IPv6 address will be enabled, and auto-asigning a public IPv4 address will be disabled. An egress only internet gateway will be created for PRIVATE_WITH_EGRESS subnets, and IPv6 routes will be added for IGWs and EIGWs.
Disabling the auto-assigning of a public IPv4 address by default can avoid the cost of public IPv4 addresses starting 2/1/2024. For use cases that need an IPv4 address, the mapPublicIpOnLaunch property in subnetConfiguration can be set to auto-assign the IPv4 address. Note that private IPv4 address allocation will not be changed.
See Advanced Subnet Configuration for all IPv6 specific properties.
Reserving availability zones
There are situations where the IP space for availability zones will
need to be reserved. This is useful in situations where availability
zones would need to be added after the vpc is originally deployed,
without causing IP renumbering for availability zones subnets. The IP
space for reserving n availability zones can be done by setting the
reservedAzs to n in vpc props, as shown below:
Vpc vpc = Vpc.Builder.create(this, "TheVPC")
.cidr("10.0.0.0/21")
.maxAzs(3)
.reservedAzs(1)
.build();
In the example above, the subnets for reserved availability zones is not
actually provisioned but its IP space is still reserved. If, in the future,
new availability zones needs to be provisioned, then we would decrement
the value of reservedAzs and increment the maxAzs or availabilityZones
accordingly. This action would not cause the IP address of subnets to get
renumbered, but rather the IP space that was previously reserved will be
used for the new availability zones subnets.
Advanced Subnet Configuration
If the default VPC configuration (public and private subnets spanning the
size of the VPC) don't suffice for you, you can configure what subnets to
create by specifying the subnetConfiguration property. It allows you
to configure the number and size of all subnets. Specifying an advanced
subnet configuration could look like this:
Vpc vpc = Vpc.Builder.create(this, "TheVPC")
// 'IpAddresses' configures the IP range and size of the entire VPC.
// The IP space will be divided based on configuration for the subnets.
.ipAddresses(IpAddresses.cidr("10.0.0.0/21"))
// 'maxAzs' configures the maximum number of availability zones to use.
// If you want to specify the exact availability zones you want the VPC
// to use, use `availabilityZones` instead.
.maxAzs(3)
// 'subnetConfiguration' specifies the "subnet groups" to create.
// Every subnet group will have a subnet for each AZ, so this
// configuration will create `3 groups × 3 AZs = 9` subnets.
.subnetConfiguration(List.of(SubnetConfiguration.builder()
// 'subnetType' controls Internet access, as described above.
.subnetType(SubnetType.PUBLIC)
// 'name' is used to name this particular subnet group. You will have to
// use the name for subnet selection if you have more than one subnet
// group of the same type.
.name("Ingress")
// 'cidrMask' specifies the IP addresses in the range of of individual
// subnets in the group. Each of the subnets in this group will contain
// `2^(32 address bits - 24 subnet bits) - 2 reserved addresses = 254`
// usable IP addresses.
//
// If 'cidrMask' is left out the available address space is evenly
// divided across the remaining subnet groups.
.cidrMask(24)
.build(), SubnetConfiguration.builder()
.cidrMask(24)
.name("Application")
.subnetType(SubnetType.PRIVATE_WITH_EGRESS)
.build(), SubnetConfiguration.builder()
.cidrMask(28)
.name("Database")
.subnetType(SubnetType.PRIVATE_ISOLATED)
// 'reserved' can be used to reserve IP address space. No resources will
// be created for this subnet, but the IP range will be kept available for
// future creation of this subnet, or even for future subdivision.
.reserved(true)
.build()))
.build();
The example above is one possible configuration, but the user can use the constructs above to implement many other network configurations.
The Vpc from the above configuration in a Region with three
availability zones will be the following:
Subnet Name |Type |IP Block |AZ|Features
------------------|----------|--------------|--|--------
IngressSubnet1 |PUBLIC |10.0.0.0/24 |#1|NAT Gateway
IngressSubnet2 |PUBLIC |10.0.1.0/24 |#2|NAT Gateway
IngressSubnet3 |PUBLIC |10.0.2.0/24 |#3|NAT Gateway
ApplicationSubnet1|PRIVATE |10.0.3.0/24 |#1|Route to NAT in IngressSubnet1
ApplicationSubnet2|PRIVATE |10.0.4.0/24 |#2|Route to NAT in IngressSubnet2
ApplicationSubnet3|PRIVATE |10.0.5.0/24 |#3|Route to NAT in IngressSubnet3
DatabaseSubnet1 |ISOLATED|10.0.6.0/28 |#1|Only routes within the VPC
DatabaseSubnet2 |ISOLATED|10.0.6.16/28|#2|Only routes within the VPC
DatabaseSubnet3 |ISOLATED|10.0.6.32/28|#3|Only routes within the VPC
Dual Stack Configurations
Here is a break down of IPv4 and IPv6 specific subnetConfiguration properties in a dual stack VPC:
Vpc vpc = Vpc.Builder.create(this, "TheVPC")
.ipProtocol(IpProtocol.DUAL_STACK)
.subnetConfiguration(List.of(SubnetConfiguration.builder()
// general properties
.name("Public")
.subnetType(SubnetType.PUBLIC)
.reserved(false)
// IPv4 specific properties
.mapPublicIpOnLaunch(true)
.cidrMask(24)
// new IPv6 specific property
.ipv6AssignAddressOnCreation(true)
.build()))
.build();
The property mapPublicIpOnLaunch controls if a public IPv4 address will be assigned. This defaults to false for dual stack VPCs to avoid inadvertant costs of having the public address. However, a public IP must be enabled (or otherwise configured with BYOIP or IPAM) in order for services that rely on the address to function.
The ipv6AssignAddressOnCreation property controls the same behavior for the IPv6 address. It defaults to true.
Using IPv6 specific properties in an IPv4 only VPC will result in errors.
Accessing the Internet Gateway
If you need access to the internet gateway, you can get its ID like so:
Vpc vpc; String igwId = vpc.getInternetGatewayId();
For a VPC with only ISOLATED subnets, this value will be undefined.
This is only supported for VPCs created in the stack - currently you're unable to get the ID for imported VPCs. To do that you'd have to specifically look up the Internet Gateway by name, which would require knowing the name beforehand.
This can be useful for configuring routing using a combination of gateways: for more information see Routing below.
Disabling the creation of the default internet gateway
If you need to control the creation of the internet gateway explicitly,
you can disable the creation of the default one using the createInternetGateway
property:
Vpc vpc = Vpc.Builder.create(this, "VPC")
.createInternetGateway(false)
.subnetConfiguration(List.of(SubnetConfiguration.builder()
.subnetType(SubnetType.PUBLIC)
.name("Public")
.build()))
.build();
Routing
It's possible to add routes to any subnets using the addRoute() method. If for
example you want an isolated subnet to have a static route via the default
Internet Gateway created for the public subnet - perhaps for routing a VPN
connection - you can do so like this:
Vpc vpc = Vpc.Builder.create(this, "VPC")
.subnetConfiguration(List.of(SubnetConfiguration.builder()
.subnetType(SubnetType.PUBLIC)
.name("Public")
.build(), SubnetConfiguration.builder()
.subnetType(SubnetType.PRIVATE_ISOLATED)
.name("Isolated")
.build()))
.build();
((Subnet)vpc.isolatedSubnets[0]).addRoute("StaticRoute", AddRouteOptions.builder()
.routerId(vpc.getInternetGatewayId())
.routerType(RouterType.GATEWAY)
.destinationCidrBlock("8.8.8.8/32")
.build());
Note that we cast to Subnet here because the list of subnets only returns an
ISubnet.
Reserving subnet IP space
There are situations where the IP space for a subnet or number of subnets
will need to be reserved. This is useful in situations where subnets would
need to be added after the vpc is originally deployed, without causing IP
renumbering for existing subnets. The IP space for a subnet may be reserved
by setting the reserved subnetConfiguration property to true, as shown
below:
Vpc vpc = Vpc.Builder.create(this, "TheVPC")
.natGateways(1)
.subnetConfiguration(List.of(SubnetConfiguration.builder()
.cidrMask(26)
.name("Public")
.subnetType(SubnetType.PUBLIC)
.build(), SubnetConfiguration.builder()
.cidrMask(26)
.name("Application1")
.subnetType(SubnetType.PRIVATE_WITH_EGRESS)
.build(), SubnetConfiguration.builder()
.cidrMask(26)
.name("Application2")
.subnetType(SubnetType.PRIVATE_WITH_EGRESS)
.reserved(true)
.build(), SubnetConfiguration.builder()
.cidrMask(27)
.name("Database")
.subnetType(SubnetType.PRIVATE_ISOLATED)
.build()))
.build();
In the example above, the subnet for Application2 is not actually provisioned
but its IP space is still reserved. If in the future this subnet needs to be
provisioned, then the reserved: true property should be removed. Reserving
parts of the IP space prevents the other subnets from getting renumbered.
Sharing VPCs between stacks
If you are creating multiple Stacks inside the same CDK application, you
can reuse a VPC defined in one Stack in another by simply passing the VPC
instance around:
/**
* Stack1 creates the VPC
*/
public class Stack1 extends Stack {
public final Vpc vpc;
public Stack1(App scope, String id) {
this(scope, id, null);
}
public Stack1(App scope, String id, StackProps props) {
super(scope, id, props);
this.vpc = new Vpc(this, "VPC");
}
}
public class Stack2Props extends StackProps {
private IVpc vpc;
public IVpc getVpc() {
return this.vpc;
}
public Stack2Props vpc(IVpc vpc) {
this.vpc = vpc;
return this;
}
}
/**
* Stack2 consumes the VPC
*/
public class Stack2 extends Stack {
public Stack2(App scope, String id, Stack2Props props) {
super(scope, id, props);
// Pass the VPC to a construct that needs it
// Pass the VPC to a construct that needs it
new ConstructThatTakesAVpc(this, "Construct", new ConstructThatTakesAVpcProps()
.vpc(props.getVpc())
);
}
}
Stack1 stack1 = new Stack1(app, "Stack1");
Stack2 stack2 = new Stack2(app, "Stack2", new Stack2Props()
.vpc(stack1.getVpc())
);
Note: If you encounter an error like "Delete canceled. Cannot delete export ..." when using a cross-stack reference to a VPC, it's likely due to CloudFormation export/import constraints. In such cases, it's safer to use Vpc.fromLookup() in the consuming stack instead of directly referencing the VPC object, more details is provided in Importing an existing VPC. This avoids creating CloudFormation exports and gives more flexibility, especially when stacks need to be deleted or updated independently.
Importing an existing VPC
If your VPC is created outside your CDK app, you can use Vpc.fromLookup().
The CDK CLI will search for the specified VPC in the the stack's region and
account, and import the subnet configuration. Looking up can be done by VPC
ID, but more flexibly by searching for a specific tag on the VPC.
Subnet types will be determined from the aws-cdk:subnet-type tag on the
subnet if it exists, or the presence of a route to an Internet Gateway
otherwise. Subnet names will be determined from the aws-cdk:subnet-name tag
on the subnet if it exists, or will mirror the subnet type otherwise (i.e.
a public subnet will have the name "Public").
The result of the Vpc.fromLookup() operation will be written to a file
called cdk.context.json. You must commit this file to source control so
that the lookup values are available in non-privileged environments such
as CI build steps, and to ensure your template builds are repeatable.
Here's how Vpc.fromLookup() can be used:
IVpc vpc = Vpc.fromLookup(stack, "VPC", VpcLookupOptions.builder()
// This imports the default VPC but you can also
// specify a 'vpcName' or 'tags'.
.isDefault(true)
.build());
Vpc.fromLookup is the recommended way to import VPCs. If for whatever
reason you do not want to use the context mechanism to look up a VPC at
synthesis time, you can also use Vpc.fromVpcAttributes. This has the
following limitations:
- Every subnet group in the VPC must have a subnet in each availability zone (for example, each AZ must have both a public and private subnet). Asymmetric VPCs are not supported.
- All VpcId, SubnetId, RouteTableId, ... parameters must either be known at synthesis time, or they must come from deploy-time list parameters whose deploy-time lengths are known at synthesis time.
Using Vpc.fromVpcAttributes() looks like this:
IVpc vpc = Vpc.fromVpcAttributes(this, "VPC", VpcAttributes.builder()
.vpcId("vpc-1234")
.availabilityZones(List.of("us-east-1a", "us-east-1b"))
// Either pass literals for all IDs
.publicSubnetIds(List.of("s-12345", "s-67890"))
// OR: import a list of known length
.privateSubnetIds(Fn.importListValue("PrivateSubnetIds", 2))
// OR: split an imported string to a list of known length
.isolatedSubnetIds(Fn.split(",", StringParameter.valueForStringParameter(this, "MyParameter"), 2))
.build());
For each subnet group the import function accepts optional parameters for subnet
names, route table ids and IPv4 CIDR blocks. When supplied, the length of these
lists are required to match the length of the list of subnet ids, allowing the
lists to be zipped together to form ISubnet instances.
Public subnet group example (for private or isolated subnet groups, use the properties with the respective prefix):
IVpc vpc = Vpc.fromVpcAttributes(this, "VPC", VpcAttributes.builder()
.vpcId("vpc-1234")
.availabilityZones(List.of("us-east-1a", "us-east-1b", "us-east-1c"))
.publicSubnetIds(List.of("s-12345", "s-34567", "s-56789"))
.publicSubnetNames(List.of("Subnet A", "Subnet B", "Subnet C"))
.publicSubnetRouteTableIds(List.of("rt-12345", "rt-34567", "rt-56789"))
.publicSubnetIpv4CidrBlocks(List.of("10.0.0.0/24", "10.0.1.0/24", "10.0.2.0/24"))
.build());
The above example will create an IVpc instance with three public subnets:
| Subnet id | Availability zone | Subnet name | Route table id | IPv4 CIDR | | --------- | ----------------- | ----------- | -------------- | ----------- | | s-12345 | us-east-1a | Subnet A | rt-12345 | 10.0.0.0/24 | | s-34567 | us-east-1b | Subnet B | rt-34567 | 10.0.1.0/24 | | s-56789 | us-east-1c | Subnet B | rt-56789 | 10.0.2.0/24 |
Restricting access to the VPC default security group
AWS Security best practices recommend that the VPC default security group should
not allow inbound and outbound
traffic.
When the @aws-cdk/aws-ec2:restrictDefaultSecurityGroup feature flag is set to
true (default for new projects) this will be enabled by default. If you do not
have this feature flag set you can either set the feature flag or you can set
the restrictDefaultSecurityGroup property to true.
Vpc.Builder.create(this, "VPC")
.restrictDefaultSecurityGroup(true)
.build();
If you set this property to true and then later remove it or set it to false
the default ingress/egress will be restored on the default security group.
Allowing Connections
In AWS, all network traffic in and out of Elastic Network Interfaces (ENIs)
is controlled by Security Groups. You can think of Security Groups as a
firewall with a set of rules. By default, Security Groups allow no incoming
(ingress) traffic and all outgoing (egress) traffic. You can add ingress rules
to them to allow incoming traffic streams. To exert fine-grained control over
egress traffic, set allowAllOutbound: false on the SecurityGroup, after
which you can add egress traffic rules.
You can manipulate Security Groups directly:
SecurityGroup mySecurityGroup = SecurityGroup.Builder.create(this, "SecurityGroup")
.vpc(vpc)
.description("Allow ssh access to ec2 instances")
.allowAllOutbound(true)
.build();
mySecurityGroup.addIngressRule(Peer.anyIpv4(), Port.tcp(22), "allow ssh access from the world");
All constructs that create ENIs on your behalf (typically constructs that create EC2 instances or other VPC-connected resources) will all have security groups automatically assigned. Those constructs have an attribute called connections, which is an object that makes it convenient to update the security groups. If you want to allow connections between two constructs that have security groups, you have to add an Egress rule to one Security Group, and an Ingress rule to the other. The connections object will automatically take care of this for you:
ApplicationLoadBalancer loadBalancer;
AutoScalingGroup appFleet;
AutoScalingGroup dbFleet;
// Allow connections from anywhere
loadBalancer.connections.allowFromAnyIpv4(Port.HTTPS, "Allow inbound HTTPS");
// The same, but an explicit IP address
loadBalancer.connections.allowFrom(Peer.ipv4("1.2.3.4/32"), Port.HTTPS, "Allow inbound HTTPS");
// Allow connection between AutoScalingGroups
appFleet.connections.allowTo(dbFleet, Port.HTTPS, "App can call database");
Connection Peers
There are various classes that implement the connection peer part:
AutoScalingGroup appFleet;
AutoScalingGroup dbFleet;
// Simple connection peers
IPeer peer = Peer.ipv4("10.0.0.0/16");
peer = Peer.anyIpv4();
peer = Peer.ipv6("::0/0");
peer = Peer.anyIpv6();
appFleet.connections.allowTo(peer, Port.HTTPS, "Allow outbound HTTPS");
Any object that has a security group can itself be used as a connection peer:
AutoScalingGroup fleet1; AutoScalingGroup fleet2; AutoScalingGroup appFleet; // These automatically create appropriate ingress and egress rules in both security groups fleet1.connections.allowTo(fleet2, Port.HTTP, "Allow between fleets"); appFleet.connections.allowFromAnyIpv4(Port.HTTP, "Allow from load balancer");
A managed prefix list is also a connection peer:
AutoScalingGroup appFleet; PrefixList prefixList = PrefixList.Builder.create(this, "PrefixList").maxEntries(10).build(); appFleet.connections.allowFrom(prefixList, Port.HTTPS);
Port Ranges
The connections that are allowed are specified by port ranges. A number of classes provide the connection specifier:
Port.tcp(80); Port.HTTPS; Port.tcpRange(60000, 65535); Port.allTcp(); Port.allIcmp(); Port.allIcmpV6(); Port.allTraffic();
NOTE: Not all protocols have corresponding helper methods. In the absence of a helper method, you can instantiate
Portyourself with your own settings. You are also welcome to contribute new helper methods.
Default Ports
Some Constructs have default ports associated with them. For example, the listener of a load balancer does (it's the public port), or instances of an RDS database (it's the port the database is accepting connections on).
If the object you're calling the peering method on has a default port associated with it, you can call
allowDefaultPortFrom() and omit the port specifier. If the argument has an associated default port, call
allowDefaultPortTo().
For example:
ApplicationListener listener;
AutoScalingGroup appFleet;
DatabaseCluster rdsDatabase;
// Port implicit in listener
listener.connections.allowDefaultPortFromAnyIpv4("Allow public");
// Port implicit in peer
appFleet.connections.allowDefaultPortTo(rdsDatabase, "Fleet can access database");
Security group rules
By default, security group wills be added inline to the security group in the output cloud formation template, if applicable. This includes any static rules by ip address and port range. This optimization helps to minimize the size of the template.
In some environments this is not desirable, for example if your security group access is controlled
via tags. You can disable inline rules per security group or globally via the context key
@aws-cdk/aws-ec2.securityGroupDisableInlineRules.
SecurityGroup mySecurityGroupWithoutInlineRules = SecurityGroup.Builder.create(this, "SecurityGroup")
.vpc(vpc)
.description("Allow ssh access to ec2 instances")
.allowAllOutbound(true)
.disableInlineRules(true)
.build();
//This will add the rule as an external cloud formation construct
mySecurityGroupWithoutInlineRules.addIngressRule(Peer.anyIpv4(), Port.SSH, "allow ssh access from the world");
Importing an existing security group
If you know the ID and the configuration of the security group to import, you can use SecurityGroup.fromSecurityGroupId:
ISecurityGroup sg = SecurityGroup.fromSecurityGroupId(this, "SecurityGroupImport", "sg-1234", SecurityGroupImportOptions.builder()
.allowAllOutbound(true)
.build());
Alternatively, use lookup methods to import security groups if you do not know the ID or the configuration details. Method SecurityGroup.fromLookupByName looks up a security group if the security group ID is unknown.
ISecurityGroup sg = SecurityGroup.fromLookupByName(this, "SecurityGroupLookup", "security-group-name", vpc);
If the security group ID is known and configuration details are unknown, use method SecurityGroup.fromLookupById instead. This method will lookup property allowAllOutbound from the current configuration of the security group.
ISecurityGroup sg = SecurityGroup.fromLookupById(this, "SecurityGroupLookup", "sg-1234");
The result of SecurityGroup.fromLookupByName and SecurityGroup.fromLookupById operations will be
written to a file called cdk.context.json.
You must commit this file to source control so that the lookup values are available in non-privileged
environments such as CI build steps, and to ensure your template builds are repeatable.
Cross Stack Connections
If you are attempting to add a connection from a peer in one stack to a peer in a different stack, sometimes it is necessary to ensure that you are making the connection in a specific stack in order to avoid a cyclic reference. If there are no other dependencies between stacks then it will not matter in which stack you make the connection, but if there are existing dependencies (i.e. stack1 already depends on stack2), then it is important to make the connection in the dependent stack (i.e. stack1).
Whenever you make a connections function call, the ingress and egress security group rules will be added to the stack that the calling object exists in.
So if you are doing something like peer1.connections.allowFrom(peer2), then the security group rules (both ingress and egress) will be created in peer1's Stack.
As an example, if we wanted to allow a connection from a security group in one stack (egress) to a security group in a different stack (ingress), we would make the connection like:
If Stack1 depends on Stack2
// Stack 1
Stack stack1;
Stack stack2;
SecurityGroup sg1 = SecurityGroup.Builder.create(stack1, "SG1")
.allowAllOutbound(false) // if this is `true` then no egress rule will be created
.vpc(vpc)
.build();
// Stack 2
SecurityGroup sg2 = SecurityGroup.Builder.create(stack2, "SG2")
.allowAllOutbound(false) // if this is `true` then no egress rule will be created
.vpc(vpc)
.build();
// `connections.allowTo` on `sg1` since we want the
// rules to be created in Stack1
sg1.connections.allowTo(sg2, Port.tcp(3333));
In this case both the Ingress Rule for sg2 and the Egress Rule for sg1 will both be created
in Stack 1 which avoids the cyclic reference.
If Stack2 depends on Stack1
// Stack 1
Stack stack1;
Stack stack2;
SecurityGroup sg1 = SecurityGroup.Builder.create(stack1, "SG1")
.allowAllOutbound(false) // if this is `true` then no egress rule will be created
.vpc(vpc)
.build();
// Stack 2
SecurityGroup sg2 = SecurityGroup.Builder.create(stack2, "SG2")
.allowAllOutbound(false) // if this is `true` then no egress rule will be created
.vpc(vpc)
.build();
// `connections.allowFrom` on `sg2` since we want the
// rules to be created in Stack2
sg2.connections.allowFrom(sg1, Port.tcp(3333));
In this case both the Ingress Rule for sg2 and the Egress Rule for sg1 will both be created
in Stack 2 which avoids the cyclic reference.
Machine Images (AMIs)
AMIs control the OS that gets launched when you start your EC2 instance. The EC2 library contains constructs to select the AMI you want to use.
Depending on the type of AMI, you select it a different way. Here are some examples of images you might want to use:
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
IMachineImage amznLinux = MachineImage.latestAmazonLinux(AmazonLinuxImageProps.builder()
.generation(AmazonLinuxGeneration.AMAZON_LINUX)
.edition(AmazonLinuxEdition.STANDARD)
.virtualization(AmazonLinuxVirt.HVM)
.storage(AmazonLinuxStorage.GENERAL_PURPOSE)
.cpuType(AmazonLinuxCpuType.X86_64)
.build());
// Pick a Windows edition to use
IMachineImage windows = MachineImage.latestWindows(WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);
// Read AMI id from SSM parameter store
IMachineImage ssm = MachineImage.fromSsmParameter("/my/ami", SsmParameterImageOptions.builder().os(OperatingSystemType.LINUX).build());
// Look up the most recent image matching a set of AMI filters.
// In this case, look up the NAT instance AMI, by using a wildcard
// in the 'name' field:
IMachineImage natAmi = MachineImage.lookup(LookupMachineImageProps.builder()
.name("amzn-ami-vpc-nat-*")
.owners(List.of("amazon"))
.build());
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
IMachineImage linux = MachineImage.genericLinux(Map.of(
"us-east-1", "ami-97785bed",
"eu-west-1", "ami-12345678"));
// For other custom (Windows) images, instantiate a `GenericWindowsImage` with
// a map giving the AMI to in for each region:
IMachineImage genericWindows = MachineImage.genericWindows(Map.of(
"us-east-1", "ami-97785bed",
"eu-west-1", "ami-12345678"));
NOTE: The AMIs selected by
MachineImage.lookup()will be cached incdk.context.json, so that your AutoScalingGroup instances aren't replaced while you are making unrelated changes to your CDK app.To query for the latest AMI again, remove the relevant cache entry from
cdk.context.json, or use thecdk contextcommand. For more information, see Runtime Context in the CDK developer guide.To customize the cache key, use the
additionalCacheKeyparameter. This allows you to have multiple lookups with the same parameters cache their values separately. This can be useful if you want to scope the context variable to a construct (ie, usingadditionalCacheKey: this.node.path), so that if the value in the cache needs to be updated, it does not need to be updated for all constructs at the same time.
MachineImage.genericLinux(),MachineImage.genericWindows()will useCfnMappingin an agnostic stack.
Special VPC configurations
VPN connections to a VPC
Create your VPC with VPN connections by specifying the vpnConnections props (keys are construct ids):
import software.amazon.awscdk.SecretValue;
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
.vpnConnections(Map.of(
"dynamic", VpnConnectionOptions.builder() // Dynamic routing (BGP)
.ip("1.2.3.4")
.tunnelOptions(List.of(VpnTunnelOption.builder()
.preSharedKeySecret(SecretValue.unsafePlainText("secretkey1234"))
.build(), VpnTunnelOption.builder()
.preSharedKeySecret(SecretValue.unsafePlainText("secretkey5678"))
.build())).build(),
"static", VpnConnectionOptions.builder() // Static routing
.ip("4.5.6.7")
.staticRoutes(List.of("192.168.10.0/24", "192.168.20.0/24")).build()))
.build();
To create a VPC that can accept VPN connections, set vpnGateway to true:
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
.vpnGateway(true)
.build();
VPN connections can then be added:
vpc.addVpnConnection("Dynamic", VpnConnectionOptions.builder()
.ip("1.2.3.4")
.build());
By default, routes will be propagated on the route tables associated with the private subnets. If no
private subnets exist, isolated subnets are used. If no isolated subnets exist, public subnets are
used. Use the Vpc property vpnRoutePropagation to customize this behavior.
VPN connections expose metrics (cloudwatch.Metric) across all tunnels in the account/region and per connection:
// Across all tunnels in the account/region
Metric allDataOut = VpnConnection.metricAllTunnelDataOut();
// For a specific vpn connection
VpnConnection vpnConnection = vpc.addVpnConnection("Dynamic", VpnConnectionOptions.builder()
.ip("1.2.3.4")
.build());
Metric state = vpnConnection.metricTunnelState();
VPC endpoints
A VPC endpoint enables you to privately connect your VPC to supported AWS services and VPC endpoint services powered by PrivateLink without requiring an internet gateway, NAT device, VPN connection, or AWS Direct Connect connection. Instances in your VPC do not require public IP addresses to communicate with resources in the service. Traffic between your VPC and the other service does not leave the Amazon network.
Endpoints are virtual devices. They are horizontally scaled, redundant, and highly available VPC components that allow communication between instances in your VPC and services without imposing availability risks or bandwidth constraints on your network traffic.
// Add gateway endpoints when creating the VPC
Vpc vpc = Vpc.Builder.create(this, "MyVpc")
.gatewayEndpoints(Map.of(
"S3", GatewayVpcEndpointOptions.builder()
.service(GatewayVpcEndpointAwsService.S3)
.build()))
.build();
// Alternatively gateway endpoints can be added on the VPC
GatewayVpcEndpoint dynamoDbEndpoint = vpc.addGatewayEndpoint("DynamoDbEndpoint", GatewayVpcEndpointOptions.builder()
.service(GatewayVpcEndpointAwsService.DYNAMODB)
.build());
// This allows to customize the endpoint policy
dynamoDbEndpoint.addToPolicy(
PolicyStatement.Builder.create() // Restrict to listing and describing tables
.principals(List.of(new AnyPrincipal()))
.actions(List.of("dynamodb:DescribeTable", "dynamodb:ListTables"))
.resources(List.of("*")).build());
// Add an interface endpoint
vpc.addInterfaceEndpoint("EcrDockerEndpoint", InterfaceVpcEndpointOptions.builder()
.service(InterfaceVpcEndpointAwsService.ECR_DOCKER)
.build());
By default, CDK will place a VPC endpoint in one subnet per AZ. If you wish to override the AZs CDK places the VPC endpoint in,
use the subnets parameter as follows:
Vpc vpc;
InterfaceVpcEndpoint.Builder.create(this, "VPC Endpoint")
.vpc(vpc)
.service(new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc", 443))
// Choose which availability zones to place the VPC endpoint in, based on
// available AZs
.subnets(SubnetSelection.builder()
.availabilityZones(List.of("us-east-1a", "us-east-1c"))
.build())
.build();
Per the AWS documentation, not all
VPC endpoint services are available in all AZs. If you specify the parameter lookupSupportedAzs, CDK attempts to discover which
AZs an endpoint service is available in, and will ensure the VPC endpoint is not placed in a subnet that doesn't match those AZs.
These AZs will be stored in cdk.context.json.
Vpc vpc;
InterfaceVpcEndpoint.Builder.create(this, "VPC Endpoint")
.vpc(vpc)
.service(new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-uuddlrlrbastrtsvc", 443))
// Choose which availability zones to place the VPC endpoint in, based on
// available AZs
.lookupSupportedAzs(true)
.build();
Pre-defined AWS services are defined in the InterfaceVpcEndpointAwsService class, and can be used to create VPC endpoints without having to configure name, ports, etc. For example, a Keyspaces endpoint can be created for use in your VPC:
Vpc vpc;
InterfaceVpcEndpoint.Builder.create(this, "VPC Endpoint")
.vpc(vpc)
.service(InterfaceVpcEndpointAwsService.KEYSPACES)
.build();
For cross-region VPC endpoints, specify the serviceRegion parameter:
Vpc vpc;
InterfaceVpcEndpoint.Builder.create(this, "CrossRegionEndpoint")
.vpc(vpc)
.service(new InterfaceVpcEndpointService("com.amazonaws.vpce.us-east-1.vpce-svc-123456", 443))
.serviceRegion("us-east-1")
.build();
Security groups for interface VPC endpoints
By default, interface VPC endpoints create a new security group and all traffic to the endpoint from within the VPC will be automatically allowed.
Use the connections object to allow other traffic to flow to the endpoint:
InterfaceVpcEndpoint myEndpoint; myEndpoint.connections.allowDefaultPortFromAnyIpv4();
Alternatively, existing security groups can be used by specifying the securityGroups prop.
IPv6 and Dualstack support
As IPv4 addresses are running out, many AWS services are adding support for IPv6 or Dualstack (IPv4 and IPv6 support) for their VPC Endpoints.
IPv6 and Dualstack address types can be configured by using:
vpc.addInterfaceEndpoint("ExampleEndpoint", InterfaceVpcEndpointOptions.builder()
.service(InterfaceVpcEndpointAwsService.ECR)
.ipAddressType(VpcEndpointIpAddressType.IPV6)
.dnsRecordIpType(VpcEndpointDnsRecordIpType.IPV6)
.build());
The possible values for ipAddressType are:
IPV4This option is supported only if all selected subnets have IPv4 address ranges and the endpoint service accepts IPv4 requests.IPV6This option is supported only if all selected subnets are IPv6 only subnets and the endpoint service accepts IPv6 requests.DUALSTACKAssign both IPv4 and IPv6 addresses to the endpoint network interfaces. This option is supported only if all selected subnets have both IPv4 and IPv6 address ranges and the endpoint service accepts both IPv4 and IPv6 requests. The possible values fordnsRecordIpTypeare:IPV4Create A records for the private, Regional, and zonal DNS names.ipAddressTypeMUST beIPV4orDUALSTACKIPV6Create AAAA records for the private, Regional, and zonal DNS names.ipAddressTypeMUST beIPV6orDUALSTACKDUALSTACKCreate A and AAAA records for the private, Regional, and zonal DNS names.ipAddressTypeMUST beDUALSTACKSERVICE_DEFINEDCreate A records for the private, Regional, and zonal DNS names and AAAA records for the Regional and zonal DNS names.ipAddressTypeMUST beDUALSTACKWe can only configure dnsRecordIpType when ipAddressType is specified and private DNS must be enabled to use any DNS related features. To avoid complications, it is recommended to always setprivateDnsEnabledto true (defaults to true) and set theipAddressTypeanddnsRecordIpTypeexplicitly when needing specific IP type behavior. Furthermore, check that the VPC being used supports the IP address type that is being configued. More documentation on compatibility and specifications can be found here
VPC endpoint services
A VPC endpoint service enables you to expose a Network Load Balancer(s) as a provider service to consumers, who connect to your service over a VPC endpoint. You can restrict access to your service via allowed principals (anything that extends ArnPrincipal), and require that new connections be manually accepted. You can also enable Contributor Insight rules.
NetworkLoadBalancer networkLoadBalancer1;
NetworkLoadBalancer networkLoadBalancer2;
VpcEndpointService.Builder.create(this, "EndpointService")
.vpcEndpointServiceLoadBalancers(List.of(networkLoadBalancer1, networkLoadBalancer2))
.acceptanceRequired(true)
.allowedPrincipals(List.of(new ArnPrincipal("arn:aws:iam::123456789012:root")))
.contributorInsights(true)
.build();
You can also include a service principal in the allowedPrincipals property by specifying it as a parameter to the ArnPrincipal constructor.
The resulting VPC endpoint will have an allowlisted principal of type Service, instead of Arn for that item in the list.
NetworkLoadBalancer networkLoadBalancer;
VpcEndpointService.Builder.create(this, "EndpointService")
.vpcEndpointServiceLoadBalancers(List.of(networkLoadBalancer))
.allowedPrincipals(List.of(new ArnPrincipal("ec2.amazonaws.com")))
.build();
You can specify which IP address types (IPv4, IPv6, or both) are supported for your VPC endpoint service:
NetworkLoadBalancer networkLoadBalancer;
VpcEndpointService.Builder.create(this, "EndpointService")
.vpcEndpointServiceLoadBalancers(List.of(networkLoadBalancer))
// Support both IPv4 and IPv6 connections to the endpoint service
.supportedIpAddressTypes(List.of(IpAddressType.IPV4, IpAddressType.IPV6))
.build();
You can restrict access to your endpoint service to specific AWS regions:
NetworkLoadBalancer networkLoadBalancer;
VpcEndpointService.Builder.create(this, "EndpointService")
.vpcEndpointServiceLoadBalancers(List.of(networkLoadBalancer))
// Allow service consumers from these regions only
.allowedRegions(List.of("us-east-1", "eu-west-1"))
.build();
Endpoint services support private DNS, which makes it easier for clients to connect to your service by automatically setting up DNS in their VPC. You can enable private DNS on an endpoint service like so:
import software.amazon.awscdk.services.route53.PublicHostedZone;
import software.amazon.awscdk.services.route53.VpcEndpointServiceDomainName;
PublicHostedZone zone;
VpcEndpointService vpces;
VpcEndpointServiceDomainName.Builder.create(this, "EndpointDomain")
.endpointService(vpces)
.domainName("my-stuff.aws-cdk.dev")
.publicHostedZone(zone)
.build();
Note: The domain name must be owned (registered through Route53) by the account the endpoint service is in, or delegated to the account. The VpcEndpointServiceDomainName will handle the AWS side of domain verification, the process for which can be found here
Client VPN endpoint
AWS Client VPN is a managed client-based VPN service that enables you to securely access your AWS resources and resources in your on-premises network. With Client VPN, you can access your resources from any location using an OpenVPN-based VPN client.
Use the addClientVpnEndpoint() method to add a client VPN endpoint to a VPC:
vpc.addClientVpnEndpoint("Endpoint", ClientVpnEndpointOptions.builder()
.cidr("10.100.0.0/16")
.serverCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id")
// Mutual authentication
.clientCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/client-certificate-id")
// User-based authentication
.userBasedAuthentication(ClientVpnUserBasedAuthentication.federated(samlProvider))
.build());
The endpoint must use at least one authentication method:
- Mutual authentication with a client certificate
- User-based authentication (directory or federated)
If user-based authentication is used, the self-service portal URL is made available via a CloudFormation output.
By default, a new security group is created, and logging is enabled. Moreover, a rule to authorize all users to the VPC CIDR is created.
To customize authorization rules, set the authorizeAllUsersToVpcCidr prop to false
and use addAuthorizationRule():
ClientVpnEndpoint endpoint = vpc.addClientVpnEndpoint("Endpoint", ClientVpnEndpointOptions.builder()
.cidr("10.100.0.0/16")
.serverCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id")
.userBasedAuthentication(ClientVpnUserBasedAuthentication.federated(samlProvider))
.authorizeAllUsersToVpcCidr(false)
.build());
endpoint.addAuthorizationRule("Rule", ClientVpnAuthorizationRuleOptions.builder()
.cidr("10.0.10.0/32")
.groupId("group-id")
.build());
Use addRoute() to configure network routes:
ClientVpnEndpoint endpoint = vpc.addClientVpnEndpoint("Endpoint", ClientVpnEndpointOptions.builder()
.cidr("10.100.0.0/16")
.serverCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id")
.userBasedAuthentication(ClientVpnUserBasedAuthentication.federated(samlProvider))
.build());
// Client-to-client access
endpoint.addRoute("Route", ClientVpnRouteOptions.builder()
.cidr("10.100.0.0/16")
.target(ClientVpnRouteTarget.local())
.build());
Use the connections object of the endpoint to allow traffic to other security groups.
To enable client route enforcement, configure the clientRouteEnforcementOptions.enforced prop to true:
ClientVpnEndpoint endpoint = vpc.addClientVpnEndpoint("Endpoint", ClientVpnEndpointOptions.builder()
.cidr("10.100.0.0/16")
.serverCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id")
.clientCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/client-certificate-id")
.clientRouteEnforcementOptions(ClientRouteEnforcementOptions.builder()
.enforced(true)
.build())
.build());
To control whether clients are automatically disconnected when the maximum session duration is reached, use the disconnectOnSessionTimeout prop.
By default (true), clients are disconnected and must manually reconnect.
Set to false to allow automatic reconnection attempts:
ClientVpnEndpoint endpoint = vpc.addClientVpnEndpoint("Endpoint", ClientVpnEndpointOptions.builder()
.cidr("10.100.0.0/16")
.serverCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/server-certificate-id")
.clientCertificateArn("arn:aws:acm:us-east-1:123456789012:certificate/client-certificate-id")
.disconnectOnSessionTimeout(false)
.build());
Detail information about maximum VPN session duration timeout can be found in the AWS documentation.
Instances
You can use the Instance class to start up a single EC2 instance. For production setups, we recommend
you use an AutoScalingGroup from the aws-autoscaling module instead, as AutoScalingGroups will take
care of restarting your instance if it ever fails.
Vpc vpc;
InstanceType instanceType;
// Amazon Linux 2
// Amazon Linux 2
Instance.Builder.create(this, "Instance2")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2())
.build();
// Amazon Linux 2 with kernel 5.x
// Amazon Linux 2 with kernel 5.x
Instance.Builder.create(this, "Instance3")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2(AmazonLinux2ImageSsmParameterProps.builder()
.kernel(AmazonLinux2Kernel.KERNEL_5_10)
.build()))
.build();
// Amazon Linux 2023
// Amazon Linux 2023
Instance.Builder.create(this, "Instance4")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.build();
// Graviton 3 Processor
// Graviton 3 Processor
Instance.Builder.create(this, "Instance5")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2023(AmazonLinux2023ImageSsmParameterProps.builder()
.cpuType(AmazonLinuxCpuType.ARM_64)
.build()))
.build();
Latest Amazon Linux Images
Rather than specifying a specific AMI ID to use, it is possible to specify a SSM
Parameter that contains the AMI ID. AWS publishes a set of public parameters
that contain the latest Amazon Linux AMIs. To make it easier to query a
particular image parameter, the CDK provides a couple of constructs AmazonLinux2ImageSsmParameter,
AmazonLinux2022ImageSsmParameter, & AmazonLinux2023SsmParameter. For example
to use the latest al2023 image:
Vpc vpc;
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2023())
.build();
Warning Since this retrieves the value from an SSM parameter at deployment time, the value will be resolved each time the stack is deployed. This means that if the parameter contains a different value on your next deployment, the instance will be replaced.
It is also possible to perform the lookup once at synthesis time and then cache the value in CDK context. This way the value will not change on future deployments unless you manually refresh the context.
Vpc vpc;
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2023(AmazonLinux2023ImageSsmParameterProps.builder()
.cachedInContext(true)
.build()))
.build();
// or
// or
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
// context cache is turned on by default
.machineImage(new AmazonLinux2023ImageSsmParameter())
.build();
// or
// or
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2023(AmazonLinux2023ImageSsmParameterProps.builder()
.cachedInContext(true)
// creates a distinct context variable for this image, instead of resolving to the same
// value anywhere this lookup is done in your app
.additionalCacheKey(this.node.getPath())
.build()))
.build();
// or
// or
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
// context cache is turned on by default
.machineImage(AmazonLinux2023ImageSsmParameter.Builder.create()
// creates a distinct context variable for this image, instead of resolving to the same
// value anywhere this lookup is done in your app
.additionalCacheKey(this.node.getPath())
.build())
.build();
Kernel Versions
Each Amazon Linux AMI uses a specific kernel version. Most Amazon Linux generations come with an AMI using the "default" kernel and then 1 or more AMIs using a specific kernel version, which may or may not be different from the default kernel version.
For example, Amazon Linux 2 has two different AMIs available from the SSM parameters.
/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-ebs- This is the "default" kernel which uses
kernel-4.14
- This is the "default" kernel which uses
/aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.10-hvm-x86_64-ebs
If a new Amazon Linux generation AMI is published with a new kernel version,
then a new SSM parameter will be created with the new version
(e.g. /aws/service/ami-amazon-linux-latest/amzn2-ami-kernel-5.15-hvm-x86_64-ebs),
but the "default" AMI may or may not be updated.
If you would like to make sure you always have the latest kernel version, then either specify the specific latest kernel version or opt-in to using the CDK latest kernel version.
Vpc vpc;
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
// context cache is turned on by default
.machineImage(AmazonLinux2023ImageSsmParameter.Builder.create()
.kernel(AmazonLinux2023Kernel.KERNEL_6_1)
.build())
.build();
CDK managed latest
Vpc vpc;
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
// context cache is turned on by default
.machineImage(AmazonLinux2023ImageSsmParameter.Builder.create()
.kernel(AmazonLinux2023Kernel.CDK_LATEST)
.build())
.build();
// or
// or
Instance.Builder.create(this, "LatestAl2023")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.C7G, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2023())
.build();
When using the CDK managed latest version, when a new kernel version is made
available the LATEST will be updated to point to the new kernel version. You
then would be required to update the newest CDK version for it to take effect.
Configuring Instances using CloudFormation Init (cfn-init)
CloudFormation Init allows you to configure your instances by writing files to them, installing software
packages, starting services and running arbitrary commands. By default, if any of the instance setup
commands throw an error; the deployment will fail and roll back to the previously known good state.
The following documentation also applies to AutoScalingGroups.
For the full set of capabilities of this system, see the documentation for
AWS::CloudFormation::Init.
Here is an example of applying some configuration to an instance:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// Showing the most complex setup, if you have simpler requirements
// you can use `CloudFormationInit.fromElements()`.
.init(CloudFormationInit.fromConfigSets(ConfigSetProps.builder()
.configSets(Map.of(
// Applies the configs below in this order
"default", List.of("yumPreinstall", "config")))
.configs(Map.of(
"yumPreinstall", new InitConfig(List.of(InitPackage.yum("git"))),
"config", new InitConfig(List.of(InitFile.fromObject("/etc/stack.json", Map.of(
"stackId", Stack.of(this).getStackId(),
"stackName", Stack.of(this).getStackName(),
"region", Stack.of(this).getRegion())), InitGroup.fromName("my-group"), InitUser.fromName("my-user"), InitPackage.rpm("http://mirrors.ukfast.co.uk/sites/dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/r/rubygem-git-1.5.0-2.el8.noarch.rpm")))))
.build()))
.initOptions(ApplyCloudFormationInitOptions.builder()
// Optional, which configsets to activate (['default'] by default)
.configSets(List.of("default"))
// Optional, how long the installation is expected to take (5 minutes by default)
.timeout(Duration.minutes(30))
// Optional, whether to include the --url argument when running cfn-init and cfn-signal commands (false by default)
.includeUrl(true)
// Optional, whether to include the --role argument when running cfn-init and cfn-signal commands (false by default)
.includeRole(true)
.build())
.build();
InitCommand can not be used to start long-running processes. At deploy time,
cfn-init will always wait for the process to exit before continuing, causing
the CloudFormation deployment to fail because the signal hasn't been received
within the expected timeout.
Instead, you should install a service configuration file onto your machine InitFile,
and then use InitService to start it.
If your Linux OS is using SystemD (like Amazon Linux 2 or higher), the CDK has
helpers to create a long-running service using CFN Init. You can create a
SystemD-compatible config file using InitService.systemdConfigFile(), and
start it immediately. The following examples shows how to start a trivial Python
3 web server:
Vpc vpc;
InstanceType instanceType;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.init(CloudFormationInit.fromElements(InitService.systemdConfigFile("simpleserver", SystemdConfigFileOptions.builder()
.command("/usr/bin/python3 -m http.server 8080")
.cwd("/var/www/html")
.build()), InitService.enable("simpleserver", InitServiceOptions.builder()
.serviceManager(ServiceManager.SYSTEMD)
.build()), InitFile.fromString("/var/www/html/index.html", "Hello! It's working!")))
.build();
You can have services restarted after the init process has made changes to the system.
To do that, instantiate an InitServiceRestartHandle and pass it to the config elements
that need to trigger the restart and the service itself. For example, the following
config writes a config file for nginx, extracts an archive to the root directory, and then
restarts nginx so that it picks up the new config and files:
Bucket myBucket;
InitServiceRestartHandle handle = new InitServiceRestartHandle();
CloudFormationInit.fromElements(InitFile.fromString("/etc/nginx/nginx.conf", "...", InitFileOptions.builder().serviceRestartHandles(List.of(handle)).build()), InitSource.fromS3Object("/var/www/html", myBucket, "html.zip", InitSourceOptions.builder().serviceRestartHandles(List.of(handle)).build()), InitService.enable("nginx", InitServiceOptions.builder()
.serviceRestartHandle(handle)
.build()));
You can use the environmentVariables or environmentFiles parameters to specify environment variables
for your services:
new InitConfig(List.of(InitFile.fromString("/myvars.env", "VAR_FROM_FILE=\"VAR_FROM_FILE\""), InitService.systemdConfigFile("myapp", SystemdConfigFileOptions.builder()
.command("/usr/bin/python3 -m http.server 8080")
.cwd("/var/www/html")
.environmentVariables(Map.of(
"MY_VAR", "MY_VAR"))
.environmentFiles(List.of("/myvars.env"))
.build())));
Bastion Hosts
A bastion host functions as an instance used to access servers and resources in a VPC without open up the complete VPC on a network level. You can use bastion hosts using a standard SSH connection targeting port 22 on the host. As an alternative, you can connect the SSH connection feature of AWS Systems Manager Session Manager, which does not need an opened security group. (https://aws.amazon.com/about-aws/whats-new/2019/07/session-manager-launches-tunneling-support-for-ssh-and-scp/)
A default bastion host for use via SSM can be configured like:
BastionHostLinux host = BastionHostLinux.Builder.create(this, "BastionHost").vpc(vpc).build();
If you want to connect from the internet using SSH, you need to place the host into a public subnet. You can then configure allowed source hosts.
BastionHostLinux host = BastionHostLinux.Builder.create(this, "BastionHost")
.vpc(vpc)
.subnetSelection(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build())
.build();
host.allowSshAccessFrom(Peer.ipv4("1.2.3.4/32"));
As there are no SSH public keys deployed on this machine, you need to use EC2 Instance Connect
with the command aws ec2-instance-connect send-ssh-public-key to provide your SSH public key.
EBS volume for the bastion host can be encrypted like:
BastionHostLinux host = BastionHostLinux.Builder.create(this, "BastionHost")
.vpc(vpc)
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/sdh")
.volume(BlockDeviceVolume.ebs(10, EbsDeviceOptions.builder()
.encrypted(true)
.build()))
.build()))
.build();
It's recommended to set the @aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault
feature flag to true to use Amazon Linux 2023 as the
bastion host AMI. Without this flag set, the bastion host will default to Amazon Linux 2, which will be unsupported in
June 2025.
{
"context": {
"@aws-cdk/aws-ec2:bastionHostUseAmazonLinux2023ByDefault": true
}
}
Placement Group
Specify placementGroup to enable the placement group support:
InstanceType instanceType;
PlacementGroup pg = PlacementGroup.Builder.create(this, "test-pg")
.strategy(PlacementGroupStrategy.SPREAD)
.build();
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.placementGroup(pg)
.build();
Block Devices
To add EBS block device mappings, specify the blockDevices property. The following example sets the EBS-backed
root device (/dev/sda1) size to 50 GiB, and adds another EBS-backed device mapped to /dev/sdm that is 100 GiB in
size:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// ...
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/sda1")
.volume(BlockDeviceVolume.ebs(50))
.build(), BlockDevice.builder()
.deviceName("/dev/sdm")
.volume(BlockDeviceVolume.ebs(100))
.build()))
.build();
It is also possible to encrypt the block devices. In this example we will create an customer managed key encrypted EBS-backed root device:
import software.amazon.awscdk.services.kms.Key;
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Key kmsKey = new Key(this, "KmsKey");
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// ...
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/sda1")
.volume(BlockDeviceVolume.ebs(50, EbsDeviceOptions.builder()
.encrypted(true)
.kmsKey(kmsKey)
.build()))
.build()))
.build();
To specify the throughput value for gp3 volumes, use the throughput property:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// ...
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/sda1")
.volume(BlockDeviceVolume.ebs(100, EbsDeviceOptions.builder()
.volumeType(EbsDeviceVolumeType.GP3)
.throughput(250)
.build()))
.build()))
.build();
EBS Optimized Instances
An Amazon EBS–optimized instance uses an optimized configuration stack and provides additional, dedicated capacity for Amazon EBS I/O. This optimization provides the best performance for your EBS volumes by minimizing contention between Amazon EBS I/O and other traffic from your instance.
Depending on the instance type, this features is enabled by default while others require explicit activation. Please refer to the documentation for details.
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
.ebsOptimized(true)
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/xvda")
.volume(BlockDeviceVolume.ebs(8))
.build()))
.build();
Volumes
Whereas a BlockDeviceVolume is an EBS volume that is created and destroyed as part of the creation and destruction of a specific instance. A Volume is for when you want an EBS volume separate from any particular instance. A Volume is an EBS block device that can be attached to, or detached from, any instance at any time. Some types of Volumes can also be attached to multiple instances at the same time to allow you to have shared storage between those instances.
A notable restriction is that a Volume can only be attached to instances in the same availability zone as the Volume itself.
The following demonstrates how to create a 500 GiB encrypted Volume in the us-west-2a availability zone, and give a role the ability to attach that Volume to a specific instance:
Instance instance;
Role role;
Volume volume = Volume.Builder.create(this, "Volume")
.availabilityZone("us-west-2a")
.size(Size.gibibytes(500))
.encrypted(true)
.build();
volume.grantAttachVolume(role, List.of(instance));
Instances Attaching Volumes to Themselves
If you need to grant an instance the ability to attach/detach an EBS volume to/from itself, then using grantAttachVolume and grantDetachVolume as outlined above
will lead to an unresolvable circular reference between the instance role and the instance. In this case, use grantAttachVolumeByResourceTag and grantDetachVolumeByResourceTag as follows:
Instance instance; Volume volume; Grant attachGrant = volume.grantAttachVolumeByResourceTag(instance.getGrantPrincipal(), List.of(instance)); Grant detachGrant = volume.grantDetachVolumeByResourceTag(instance.getGrantPrincipal(), List.of(instance));
Attaching Volumes
The Amazon EC2 documentation for Linux Instances and Windows Instances contains information on how to attach and detach your Volumes to/from instances, and how to format them for use.
The following is a sample skeleton of EC2 UserData that can be used to attach a Volume to the Linux instance that it is running on:
Instance instance;
Volume volume;
volume.grantAttachVolumeByResourceTag(instance.getGrantPrincipal(), List.of(instance));
String targetDevice = "/dev/xvdz";
instance.userData.addCommands("TOKEN=$(curl -SsfX PUT \"http://169.254.169.254/latest/api/token\" -H \"X-aws-ec2-metadata-token-ttl-seconds: 21600\")", "INSTANCE_ID=$(curl -SsfH \"X-aws-ec2-metadata-token: $TOKEN\" http://169.254.169.254/latest/meta-data/instance-id)", String.format("aws --region %s ec2 attach-volume --volume-id %s --instance-id $INSTANCE_ID --device %s", Stack.of(this).getRegion(), volume.getVolumeId(), targetDevice), String.format("while ! test -e %s; do sleep 1; done", targetDevice));
Tagging Volumes
You can configure tag propagation on volume creation.
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.machineImage(machineImage)
.instanceType(instanceType)
.propagateTagsToVolumeOnCreation(true)
.build();
Throughput on GP3 Volumes
You can specify the throughput of a GP3 volume from 125 (default) to 2000.
Volume.Builder.create(this, "Volume")
.availabilityZone("us-east-1a")
.size(Size.gibibytes(125))
.volumeType(EbsDeviceVolumeType.GP3)
.throughput(125)
.build();
Volume initialization rate
When creating an EBS volume from a snapshot, you can specify the volume initialization rate at which the snapshot blocks are downloaded from Amazon S3 to the volume. Specifying a volume initialization rate ensures that the volume is initialized at a predictable and consistent rate after creation.
Volume.Builder.create(this, "Volume")
.availabilityZone("us-east-1a")
.size(Size.gibibytes(500))
.snapshotId("snap-1234567890abcdef0")
.volumeInitializationRate(Size.mebibytes(250))
.build();
The volumeInitializationRate must be:
- Between 100 and 300 MiB/s
- Only specified when creating a volume from a snapshot
Configuring Instance Metadata Service (IMDS)
Comprehensive Metadata Options
You can configure EC2 Instance Metadata Service options using individual properties. This provides comprehensive control over all metadata service settings:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
// Example 1: Enforce IMDSv2 with comprehensive options
// Example 1: Enforce IMDSv2 with comprehensive options
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
.httpEndpoint(true)
.httpProtocolIpv6(false)
.httpPutResponseHopLimit(2)
.httpTokens(HttpTokens.REQUIRED)
.instanceMetadataTags(true)
.build();
// Example 2: Enforce IMDSv2 with minimal configuration
// Example 2: Enforce IMDSv2 with minimal configuration
Instance.Builder.create(this, "SecureInstance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
.httpTokens(HttpTokens.REQUIRED)
.build();
Simple IMDSv2 Enforcement
For simple IMDSv2 enforcement without additional configuration, you can use the requireImdsv2 property:
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(machineImage)
// Simple IMDSv2 enforcement
.requireImdsv2(true)
.build();
Applying to Multiple Instances
You can also use the either the InstanceRequireImdsv2Aspect for EC2 instances or the LaunchTemplateRequireImdsv2Aspect for EC2 launch templates
to apply the operation to multiple instances or launch templates, respectively.
The following example demonstrates how to use the InstanceRequireImdsv2Aspect to require IMDSv2 for all EC2 instances in a stack:
InstanceRequireImdsv2Aspect aspect = new InstanceRequireImdsv2Aspect(); Aspects.of(this).add(aspect);
Associating a Public IP Address with an Instance
All subnets have an attribute that determines whether instances launched into that subnet are assigned a public IPv4 address. This attribute is set to true by default for default public subnets. Thus, an EC2 instance launched into a default public subnet will be assigned a public IPv4 address. Nondefault public subnets have this attribute set to false by default and any EC2 instance launched into a nondefault public subnet will not be assigned a public IPv4 address automatically. To automatically assign a public IPv4 address to an instance launched into a nondefault public subnet, you can set the associatePublicIpAddress property on the Instance construct to true. Alternatively, to not automatically assign a public IPv4 address to an instance launched into a default public subnet, you can set associatePublicIpAddress to false. Including this property, removing this property, or updating the value of this property on an existing instance will result in replacement of the instance.
Vpc vpc = Vpc.Builder.create(this, "VPC")
.cidr("10.0.0.0/16")
.natGateways(0)
.maxAzs(3)
.subnetConfiguration(List.of(SubnetConfiguration.builder()
.name("public-subnet-1")
.subnetType(SubnetType.PUBLIC)
.cidrMask(24)
.build()))
.build();
Instance instance = Instance.Builder.create(this, "Instance")
.vpc(vpc)
.vpcSubnets(SubnetSelection.builder().subnetGroupName("public-subnet-1").build())
.instanceType(InstanceType.of(InstanceClass.T3, InstanceSize.NANO))
.machineImage(AmazonLinuxImage.Builder.create().generation(AmazonLinuxGeneration.AMAZON_LINUX_2).build())
.detailedMonitoring(true)
.associatePublicIpAddress(true)
.build();
Specifying a key pair
To allow SSH access to an EC2 instance by default, a Key Pair must be specified. Key pairs can
be provided with the keyPair property to instances and launch templates. You can create a
key pair for an instance like this:
Vpc vpc;
InstanceType instanceType;
KeyPair keyPair = KeyPair.Builder.create(this, "KeyPair")
.type(KeyPairType.ED25519)
.format(KeyPairFormat.PEM)
.build();
Instance instance = Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
// Use the custom key pair
.keyPair(keyPair)
.build();
When a new EC2 Key Pair is created (without imported material), the private key material is automatically stored in Systems Manager Parameter Store. This can be retrieved from the key pair construct:
KeyPair keyPair = new KeyPair(this, "KeyPair"); IStringParameter privateKey = keyPair.getPrivateKey();
If you already have an SSH key that you wish to use in EC2, that can be provided when constructing the
KeyPair. If public key material is provided, the key pair is considered "imported" and there
will not be any data automatically stored in Systems Manager Parameter Store and the type property
cannot be specified for the key pair.
KeyPair keyPair = KeyPair.Builder.create(this, "KeyPair")
.publicKeyMaterial("ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB7jpNzG+YG0s+xIGWbxrxIZiiozHOEuzIJacvASP0mq")
.build();
Using an existing EC2 Key Pair
If you already have an EC2 Key Pair created outside of the CDK, you can import that key to your CDK stack.
You can import it purely by name:
IKeyPair keyPair = KeyPair.fromKeyPairName(this, "KeyPair", "the-keypair-name");
Or by specifying additional attributes:
IKeyPair keyPair = KeyPair.fromKeyPairAttributes(this, "KeyPair", KeyPairAttributes.builder()
.keyPairName("the-keypair-name")
.type(KeyPairType.RSA)
.build());
Using IPv6 IPs
Instances can be given IPv6 IPs by launching them into a subnet of a dual stack VPC.
Vpc vpc = Vpc.Builder.create(this, "Ip6VpcDualStack")
.ipProtocol(IpProtocol.DUAL_STACK)
.subnetConfiguration(List.of(SubnetConfiguration.builder()
.name("Public")
.subnetType(SubnetType.PUBLIC)
.mapPublicIpOnLaunch(true)
.build(), SubnetConfiguration.builder()
.name("Private")
.subnetType(SubnetType.PRIVATE_ISOLATED)
.build()))
.build();
Instance instance = Instance.Builder.create(this, "MyInstance")
.instanceType(InstanceType.of(InstanceClass.T2, InstanceSize.MICRO))
.machineImage(MachineImage.latestAmazonLinux2())
.vpc(vpc)
.vpcSubnets(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build())
.allowAllIpv6Outbound(true)
.build();
instance.connections.allowFrom(Peer.anyIpv6(), Port.allIcmpV6(), "allow ICMPv6");
Note to set mapPublicIpOnLaunch to true in the subnetConfiguration.
Additionally, IPv6 support varies by instance type. Most instance types have IPv6 support with exception of m1-m3, c1, g2, and t1.micro. A full list can be found here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-eni.html#AvailableIpPerENI.
Specifying the IPv6 Address
If you want to specify the number of IPv6 addresses to assign to the instance, you can use the ipv6AddresseCount property:
// dual stack VPC
Vpc vpc;
Instance instance = Instance.Builder.create(this, "MyInstance")
.instanceType(InstanceType.of(InstanceClass.M5, InstanceSize.LARGE))
.machineImage(MachineImage.latestAmazonLinux2())
.vpc(vpc)
.vpcSubnets(SubnetSelection.builder().subnetType(SubnetType.PUBLIC).build())
// Assign 2 IPv6 addresses to the instance
.ipv6AddressCount(2)
.build();
Credit configuration modes for burstable instances
You can set the credit configuration mode for burstable instances (T2, T3, T3a and T4g instance types):
Vpc vpc;
Instance instance = Instance.Builder.create(this, "Instance")
.instanceType(InstanceType.of(InstanceClass.T3, InstanceSize.MICRO))
.machineImage(MachineImage.latestAmazonLinux2())
.vpc(vpc)
.creditSpecification(CpuCredits.STANDARD)
.build();
It is also possible to set the credit configuration mode for NAT instances.
NatInstanceProvider natInstanceProvider = NatProvider.instance(NatInstanceProps.builder()
.instanceType(InstanceType.of(InstanceClass.T4G, InstanceSize.LARGE))
.machineImage(new AmazonLinuxImage())
.creditSpecification(CpuCredits.UNLIMITED)
.build());
Vpc.Builder.create(this, "VPC")
.natGatewayProvider(natInstanceProvider)
.build();
Note: CpuCredits.UNLIMITED mode is not supported for T3 instances that are launched on a Dedicated Host.
Shutdown behavior
You can specify the behavior of the instance when you initiate shutdown from the instance (using the operating system command for system shutdown).
Vpc vpc;
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(InstanceType.of(InstanceClass.T3, InstanceSize.NANO))
.machineImage(AmazonLinuxImage.Builder.create().generation(AmazonLinuxGeneration.AMAZON_LINUX_2).build())
.instanceInitiatedShutdownBehavior(InstanceInitiatedShutdownBehavior.TERMINATE)
.build();
Enabling Nitro Enclaves
You can enable AWS Nitro Enclaves for
your EC2 instances by setting the enclaveEnabled property to true. Nitro Enclaves is a feature of
AWS Nitro System that enables creating isolated and highly constrained CPU environments known as enclaves.
Vpc vpc;
Instance instance = Instance.Builder.create(this, "Instance")
.instanceType(InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE))
.machineImage(new AmazonLinuxImage())
.vpc(vpc)
.enclaveEnabled(true)
.build();
NOTE: You must use an instance type and operating system that support Nitro Enclaves. For more information, see Requirements.
Enabling Termination Protection
You can enable Termination Protection for
your EC2 instances by setting the disableApiTermination property to true. Termination Protection controls whether the instance can be terminated using the AWS Management Console, AWS Command Line Interface (AWS CLI), or API.
Vpc vpc;
Instance instance = Instance.Builder.create(this, "Instance")
.instanceType(InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE))
.machineImage(new AmazonLinuxImage())
.vpc(vpc)
.disableApiTermination(true)
.build();
Enabling Instance Hibernation
You can enable Instance Hibernation for
your EC2 instances by setting the hibernationEnabled property to true. Instance Hibernation saves the
instance's in-memory (RAM) state when an instance is stopped, and restores that state when the instance is started.
Vpc vpc;
Instance instance = Instance.Builder.create(this, "Instance")
.instanceType(InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE))
.machineImage(new AmazonLinuxImage())
.vpc(vpc)
.hibernationEnabled(true)
.blockDevices(List.of(BlockDevice.builder()
.deviceName("/dev/xvda")
.volume(BlockDeviceVolume.ebs(30, EbsDeviceOptions.builder()
.volumeType(EbsDeviceVolumeType.GP3)
.encrypted(true)
.deleteOnTermination(true)
.build()))
.build()))
.build();
NOTE: You must use an instance and a volume that meet the requirements for hibernation. For more information, see Prerequisites for Amazon EC2 instance hibernation.
VPC Flow Logs
VPC Flow Logs is a feature that enables you to capture information about the IP traffic going to and from network interfaces in your VPC. Flow log data can be published to Amazon CloudWatch Logs and Amazon S3. After you've created a flow log, you can retrieve and view its data in the chosen destination. (https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html).
By default, a flow log will be created with CloudWatch Logs as the destination.
You can create a flow log like this:
Vpc vpc;
FlowLog.Builder.create(this, "FlowLog")
.resourceType(FlowLogResourceType.fromVpc(vpc))
.build();
Or you can add a Flow Log to a VPC by using the addFlowLog method like this:
Vpc vpc = new Vpc(this, "Vpc");
vpc.addFlowLog("FlowLog");
You can also add multiple flow logs with different destinations.
Vpc vpc = new Vpc(this, "Vpc");
vpc.addFlowLog("FlowLogS3", FlowLogOptions.builder()
.destination(FlowLogDestination.toS3())
.build());
// Only reject traffic and interval every minute.
vpc.addFlowLog("FlowLogCloudWatch", FlowLogOptions.builder()
.trafficType(FlowLogTrafficType.REJECT)
.maxAggregationInterval(FlowLogMaxAggregationInterval.ONE_MINUTE)
.build());
To create a Transit Gateway flow log, you can use the fromTransitGatewayId method:
CfnTransitGateway tgw;
FlowLog.Builder.create(this, "TransitGatewayFlowLog")
.resourceType(FlowLogResourceType.fromTransitGatewayId(tgw.getRef()))
.build();
To create a Transit Gateway Attachment flow log, you can use the fromTransitGatewayAttachmentId method:
CfnTransitGatewayAttachment tgwAttachment;
FlowLog.Builder.create(this, "TransitGatewayAttachmentFlowLog")
.resourceType(FlowLogResourceType.fromTransitGatewayAttachmentId(tgwAttachment.getRef()))
.build();
For flow logs targeting TransitGateway and TransitGatewayAttachment, specifying the trafficType is not possible.
Custom Formatting
You can also custom format flow logs.
Vpc vpc = new Vpc(this, "Vpc");
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.DST_PORT, LogFormat.SRC_PORT))
.build());
// If you just want to add a field to the default field
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.VERSION, LogFormat.ALL_DEFAULT_FIELDS))
.build());
// If AWS CDK does not support the new fields
vpc.addFlowLog("FlowLog", FlowLogOptions.builder()
.logFormat(List.of(LogFormat.SRC_PORT, LogFormat.custom("${new-field}")))
.build());
By default, the CDK will create the necessary resources for the destination. For the CloudWatch Logs destination it will create a CloudWatch Logs Log Group as well as the IAM role with the necessary permissions to publish to the log group. In the case of an S3 destination, it will create the S3 bucket.
If you want to customize any of the destination resources you can provide your own as part of the destination.
CloudWatch Logs
Vpc vpc;
LogGroup logGroup = new LogGroup(this, "MyCustomLogGroup");
Role role = Role.Builder.create(this, "MyCustomRole")
.assumedBy(new ServicePrincipal("vpc-flow-logs.amazonaws.com"))
.build();
FlowLog.Builder.create(this, "FlowLog")
.resourceType(FlowLogResourceType.fromVpc(vpc))
.destination(FlowLogDestination.toCloudWatchLogs(logGroup, role))
.build();
S3
Vpc vpc;
Bucket bucket = new Bucket(this, "MyCustomBucket");
FlowLog.Builder.create(this, "FlowLog")
.resourceType(FlowLogResourceType.fromVpc(vpc))
.destination(FlowLogDestination.toS3(bucket))
.build();
FlowLog.Builder.create(this, "FlowLogWithKeyPrefix")
.resourceType(FlowLogResourceType.fromVpc(vpc))
.destination(FlowLogDestination.toS3(bucket, "prefix/"))
.build();
Amazon Data Firehose
import software.amazon.awscdk.services.kinesisfirehose.*;
Vpc vpc;
CfnDeliveryStream deliveryStream;
vpc.addFlowLog("FlowLogsKinesisDataFirehose", FlowLogOptions.builder()
.destination(FlowLogDestination.toKinesisDataFirehoseDestination(deliveryStream.getAttrArn()))
.build());
When the S3 destination is configured, AWS will automatically create an S3 bucket policy
that allows the service to write logs to the bucket. This makes it impossible to later update
that bucket policy. To have CDK create the bucket policy so that future updates can be made,
the @aws-cdk/aws-s3:createDefaultLoggingPolicy feature flag can be used. This can be set
in the cdk.json file.
{
"context": {
"@aws-cdk/aws-s3:createDefaultLoggingPolicy": true
}
}
User Data
User data enables you to run a script when your instances start up. In order to configure these scripts you can add commands directly to the script or you can use the UserData's convenience functions to aid in the creation of your script.
A user data could be configured to run a script found in an asset through the following:
import software.amazon.awscdk.services.s3.assets.Asset;
Instance instance;
Asset asset = Asset.Builder.create(this, "Asset")
.path("./configure.sh")
.build();
String localPath = instance.userData.addS3DownloadCommand(S3DownloadOptions.builder()
.bucket(asset.getBucket())
.bucketKey(asset.getS3ObjectKey())
.region("us-east-1")
.build());
instance.userData.addExecuteFileCommand(ExecuteFileOptions.builder()
.filePath(localPath)
.arguments("--verbose -y")
.build());
asset.grantRead(instance.getRole());
Persisting user data
By default, EC2 UserData is run once on only the first time that an instance is started. It is possible to make the user data script run on every start of the instance.
When creating a Windows UserData you can use the persist option to set whether or not to add
<persist>true</persist> to the user data script. it can be used as follows:
UserData windowsUserData = UserData.forWindows(WindowsUserDataOptions.builder().persist(true).build());
For a Linux instance, this can be accomplished by using a Multipart user data to configure cloud-config as detailed in: https://aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/
Multipart user data
In addition, to above the MultipartUserData can be used to change instance startup behavior. Multipart user data are composed
from separate parts forming archive. The most common parts are scripts executed during instance set-up. However, there are other
kinds, too.
The advantage of multipart archive is in flexibility when it's needed to add additional parts or to use specialized parts to
fine tune instance startup. Some services (like AWS Batch) support only MultipartUserData.
The parts can be executed at different moment of instance start-up and can serve a different purpose. This is controlled by contentType property.
For common scripts, text/x-shellscript; charset="utf-8" can be used as content type.
In order to create archive the MultipartUserData has to be instantiated. Than, user can add parts to multipart archive using addPart. The MultipartBody contains methods supporting creation of body parts.
If the very custom part is required, it can be created using MultipartUserData.fromRawBody, in this case full control over content type,
transfer encoding, and body properties is given to the user.
Below is an example for creating multipart user data with single body part responsible for installing awscli and configuring maximum size
of storage used by Docker containers:
UserData bootHookConf = UserData.forLinux();
bootHookConf.addCommands("cloud-init-per once docker_options echo 'OPTIONS=\"${OPTIONS} --storage-opt dm.basesize=40G\"' >> /etc/sysconfig/docker");
UserData setupCommands = UserData.forLinux();
setupCommands.addCommands("sudo yum install awscli && echo Packages installed らと > /var/tmp/setup");
MultipartUserData multipartUserData = new MultipartUserData();
// The docker has to be configured at early stage, so content type is overridden to boothook
multipartUserData.addPart(MultipartBody.fromUserData(bootHookConf, "text/cloud-boothook; charset=\"us-ascii\""));
// Execute the rest of setup
multipartUserData.addPart(MultipartBody.fromUserData(setupCommands));
LaunchTemplate.Builder.create(this, "")
.userData(multipartUserData)
.blockDevices(List.of())
.build();
For more information see Specifying Multiple User Data Blocks Using a MIME Multi Part Archive
Using add*Command on MultipartUserData
To use the add*Command methods, that are inherited from the UserData interface, on MultipartUserData you must add a part
to the MultipartUserData and designate it as the receiver for these methods. This is accomplished by using the addUserDataPart()
method on MultipartUserData with the makeDefault argument set to true:
MultipartUserData multipartUserData = new MultipartUserData();
UserData commandsUserData = UserData.forLinux();
multipartUserData.addUserDataPart(commandsUserData, MultipartBody.SHELL_SCRIPT, true);
// Adding commands to the multipartUserData adds them to commandsUserData, and vice-versa.
multipartUserData.addCommands("touch /root/multi.txt");
commandsUserData.addCommands("touch /root/userdata.txt");
When used on an EC2 instance, the above multipartUserData will create both multi.txt and userdata.txt in /root.
Importing existing subnet
To import an existing Subnet, call Subnet.fromSubnetAttributes() or
Subnet.fromSubnetId(). Only if you supply the subnet's Availability Zone
and Route Table Ids when calling Subnet.fromSubnetAttributes() will you be
able to use the CDK features that use these values (such as selecting one
subnet per AZ).
Importing an existing subnet looks like this:
// Supply all properties
ISubnet subnet1 = Subnet.fromSubnetAttributes(this, "SubnetFromAttributes", SubnetAttributes.builder()
.subnetId("s-1234")
.availabilityZone("pub-az-4465")
.routeTableId("rt-145")
.build());
// Supply only subnet id
ISubnet subnet2 = Subnet.fromSubnetId(this, "SubnetFromId", "s-1234");
Launch Templates
A Launch Template is a standardized template that contains the configuration information to launch an instance. They can be used when launching instances on their own, through Amazon EC2 Auto Scaling, EC2 Fleet, and Spot Fleet. Launch templates enable you to store launch parameters so that you do not have to specify them every time you launch an instance. For information on Launch Templates please see the official documentation.
The following demonstrates how to create a launch template with an Amazon Machine Image, security group, and an instance profile.
Vpc vpc;
Role role = Role.Builder.create(this, "Role")
.assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
.build();
InstanceProfile instanceProfile = InstanceProfile.Builder.create(this, "InstanceProfile")
.role(role)
.build();
LaunchTemplate template = LaunchTemplate.Builder.create(this, "LaunchTemplate")
.launchTemplateName("MyTemplateV1")
.versionDescription("This is my v1 template")
.machineImage(MachineImage.latestAmazonLinux2023())
.securityGroup(SecurityGroup.Builder.create(this, "LaunchTemplateSG")
.vpc(vpc)
.build())
.instanceProfile(instanceProfile)
.build();
And the following demonstrates how to enable metadata options support.
LaunchTemplate.Builder.create(this, "LaunchTemplate")
.httpEndpoint(true)
.httpProtocolIpv6(true)
.httpPutResponseHopLimit(1)
.httpTokens(LaunchTemplateHttpTokens.REQUIRED)
.instanceMetadataTags(true)
.build();
And the following demonstrates how to add one or more security groups to launch template.
Vpc vpc;
SecurityGroup sg1 = SecurityGroup.Builder.create(this, "sg1")
.vpc(vpc)
.build();
SecurityGroup sg2 = SecurityGroup.Builder.create(this, "sg2")
.vpc(vpc)
.build();
LaunchTemplate launchTemplate = LaunchTemplate.Builder.create(this, "LaunchTemplate")
.machineImage(MachineImage.latestAmazonLinux2023())
.securityGroup(sg1)
.build();
launchTemplate.addSecurityGroup(sg2);
To use AWS Systems Manager parameters instead of AMI IDs in launch templates and resolve the AMI IDs at instance launch time:
LaunchTemplate launchTemplate = LaunchTemplate.Builder.create(this, "LaunchTemplate")
.machineImage(MachineImage.resolveSsmParameterAtLaunch("parameterName"))
.build();
Placement Group
Specify placementGroup to enable the placement group support:
InstanceType instanceType;
PlacementGroup pg = PlacementGroup.Builder.create(this, "test-pg")
.strategy(PlacementGroupStrategy.SPREAD)
.build();
LaunchTemplate.Builder.create(this, "LaunchTemplate")
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.placementGroup(pg)
.build();
Please note this feature does not support Launch Configurations.
Detailed Monitoring
The following demonstrates how to enable Detailed Monitoring for an EC2 instance. Keep in mind that Detailed Monitoring results in additional charges.
Vpc vpc;
InstanceType instanceType;
Instance.Builder.create(this, "Instance1")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.detailedMonitoring(true)
.build();
Connecting to your instances using SSM Session Manager
SSM Session Manager makes it possible to connect to your instances from the AWS Console, without preparing SSH keys.
To do so, you need to:
- Use an image with SSM agent installed and configured. Many images come with SSM Agent preinstalled, otherwise you may need to manually put instructions to install SSM Agent into your instance's UserData or use EC2 Init).
- Create the instance with
ssmSessionPermissions: true.
If these conditions are met, you can connect to the instance from the EC2 Console. Example:
Vpc vpc;
InstanceType instanceType;
Instance.Builder.create(this, "Instance1")
.vpc(vpc)
.instanceType(instanceType)
// Amazon Linux 2023 comes with SSM Agent by default
.machineImage(MachineImage.latestAmazonLinux2023())
// Turn on SSM
.ssmSessionPermissions(true)
.build();
Managed Prefix Lists
Create and manage customer-managed prefix lists. If you don't specify anything in this construct, it will manage IPv4 addresses.
You can also create an empty Prefix List with only the maximum number of entries specified, as shown in the following code. If nothing is specified, maxEntries=1.
PrefixList.Builder.create(this, "EmptyPrefixList")
.maxEntries(100)
.build();
maxEntries can also be omitted as follows. In this case maxEntries: 2, will be set.
PrefixList.Builder.create(this, "PrefixList")
.entries(List.of(EntryProperty.builder().cidr("10.0.0.1/32").build(), EntryProperty.builder().cidr("10.0.0.2/32").description("sample1").build()))
.build();
To import AWS-managed prefix list, you can use PrefixList.fromLookup().
PrefixList.fromLookup(this, "PrefixListFromName", PrefixListLookupOptions.builder()
.prefixListName("com.amazonaws.global.cloudfront.origin-facing")
.build());
For more information see Work with customer-managed prefix lists.
IAM instance profile
Use instanceProfile to apply specific IAM Instance Profile. Cannot be used with role
InstanceType instanceType;
Vpc vpc;
Role role = Role.Builder.create(this, "Role")
.assumedBy(new ServicePrincipal("ec2.amazonaws.com"))
.build();
InstanceProfile instanceProfile = InstanceProfile.Builder.create(this, "InstanceProfile")
.role(role)
.build();
Instance.Builder.create(this, "Instance")
.vpc(vpc)
.instanceType(instanceType)
.machineImage(MachineImage.latestAmazonLinux2023())
.instanceProfile(instanceProfile)
.build();
-
ClassDescriptionSupported hardware accelerator manufacturers.Specific hardware accelerator models supported by EC2.Hardware accelerator categories available for EC2 instances.Either an IPv4 or an IPv6 CIDR.Acl Configuration for CIDR.A builder for
AclCidrConfigAn implementation forAclCidrConfigProperties to create Icmp.A builder forAclIcmpAn implementation forAclIcmpProperties to create PortRange.A builder forAclPortRangeAn implementation forAclPortRangeThe traffic that is configured using a Network ACL entry.Acl Configuration for traffic.A builder forAclTrafficConfigAn implementation forAclTrafficConfigWhat action to apply to traffic matching the ACL.The IP address type.Options for adding a new route to a subnet.A builder forAddRouteOptionsAn implementation forAddRouteOptionsRequest for subnets CIDR to be allocated for a Vpc.A builder forAllocateCidrRequestAn implementation forAllocateCidrRequestCIDR Allocated Subnet.A builder forAllocatedSubnetAn implementation forAllocatedSubnetRequest for subnet IPv6 CIDRs to be allocated for a VPC.A builder forAllocateIpv6CidrRequestAn implementation forAllocateIpv6CidrRequestRequest for allocation of the VPC IPv6 CIDR.A builder forAllocateVpcIpv6CidrRequestAn implementation forAllocateVpcIpv6CidrRequestA SSM Parameter that contains the AMI ID for Amazon Linux 2023.A fluent builder forAmazonLinux2022ImageSsmParameter.Properties specific to al2022 images.A builder forAmazonLinux2022ImageSsmParameterPropsAn implementation forAmazonLinux2022ImageSsmParameterPropsAmazon Linux 2022 kernel versions.A SSM Parameter that contains the AMI ID for Amazon Linux 2023.A fluent builder forAmazonLinux2023ImageSsmParameter.Properties specific to al2023 images.A builder forAmazonLinux2023ImageSsmParameterPropsAn implementation forAmazonLinux2023ImageSsmParameterPropsAmazon Linux 2023 kernel versions.A SSM Parameter that contains the AMI ID for Amazon Linux 2.A fluent builder forAmazonLinux2ImageSsmParameter.Properties specific to amzn2 images.A builder forAmazonLinux2ImageSsmParameterPropsAn implementation forAmazonLinux2ImageSsmParameterPropsAmazon Linux 2 kernel versions.CPU type.Amazon Linux edition.What generation of Amazon Linux to use.Selects the latest version of Amazon Linux.A fluent builder forAmazonLinuxImage.Amazon Linux image properties.A builder forAmazonLinuxImagePropsAn implementation forAmazonLinuxImagePropsBase options for amazon linux ssm parameters.A builder forAmazonLinuxImageSsmParameterBaseOptionsAn implementation forAmazonLinuxImageSsmParameterBaseOptionsBase properties for an Amazon Linux SSM Parameter.A builder forAmazonLinuxImageSsmParameterBasePropsAn implementation forAmazonLinuxImageSsmParameterBasePropsCommon options across all generations.A builder forAmazonLinuxImageSsmParameterCommonOptionsAn implementation forAmazonLinuxImageSsmParameterCommonOptionsAmazon Linux Kernel.Available storage options for Amazon Linux images Only applies to Amazon Linux & Amazon Linux 2.Virtualization type for Amazon Linux.Options for applying CloudFormation init to an instance or instance group.A builder forApplyCloudFormationInitOptionsAn implementation forApplyCloudFormationInitOptionsOptions for attaching a CloudFormationInit to a resource.A builder forAttachInitOptionsAn implementation forAttachInitOptionsConfiguration for AwsIpam.A builder forAwsIpamPropsAn implementation forAwsIpamPropsBare metal support requirements for EC2 instances.This creates a linux bastion host you can use to connect to other instances or services in your VPC.A fluent builder forBastionHostLinux.Properties of the bastion host.A builder forBastionHostLinuxPropsAn implementation forBastionHostLinuxPropsBlock device.A builder forBlockDeviceAn implementation forBlockDeviceDescribes a block device mapping for an EC2 instance or Auto Scaling group.Burstable CPU performance requirements for EC2 instances.Creates a new data export configuration for EC2 Capacity Manager.A fluent builder forCfnCapacityManagerDataExport.Properties for defining aCfnCapacityManagerDataExport.A builder forCfnCapacityManagerDataExportPropsAn implementation forCfnCapacityManagerDataExportPropsCreates a new Capacity Reservation with the specified attributes.A fluent builder forCfnCapacityReservation.Information about instance capacity usage for a Capacity Reservation.A builder forCfnCapacityReservation.CapacityAllocationPropertyAn implementation forCfnCapacityReservation.CapacityAllocationPropertyInformation about your commitment for a future-dated Capacity Reservation.A builder forCfnCapacityReservation.CommitmentInfoPropertyAn implementation forCfnCapacityReservation.CommitmentInfoPropertyAn array of key-value pairs to apply to this resource.A builder forCfnCapacityReservation.TagSpecificationPropertyAn implementation forCfnCapacityReservation.TagSpecificationPropertyCreates a new Capacity Reservation Fleet with the specified attributes.A fluent builder forCfnCapacityReservationFleet.Specifies information about an instance type to use in a Capacity Reservation Fleet.An implementation forCfnCapacityReservationFleet.InstanceTypeSpecificationPropertyThe tags to apply to a resource when the resource is being created.A builder forCfnCapacityReservationFleet.TagSpecificationPropertyAn implementation forCfnCapacityReservationFleet.TagSpecificationPropertyProperties for defining aCfnCapacityReservationFleet.A builder forCfnCapacityReservationFleetPropsAn implementation forCfnCapacityReservationFleetPropsProperties for defining aCfnCapacityReservation.A builder forCfnCapacityReservationPropsAn implementation forCfnCapacityReservationPropsCreates a carrier gateway.A fluent builder forCfnCarrierGateway.Properties for defining aCfnCarrierGateway.A builder forCfnCarrierGatewayPropsAn implementation forCfnCarrierGatewayPropsSpecifies an ingress authorization rule to add to a Client VPN endpoint.A fluent builder forCfnClientVpnAuthorizationRule.Properties for defining aCfnClientVpnAuthorizationRule.A builder forCfnClientVpnAuthorizationRulePropsAn implementation forCfnClientVpnAuthorizationRulePropsSpecifies a Client VPN endpoint.A fluent builder forCfnClientVpnEndpoint.Information about the client certificate to be used for authentication.An implementation forCfnClientVpnEndpoint.CertificateAuthenticationRequestPropertyDescribes the authentication method to be used by a Client VPN endpoint.A builder forCfnClientVpnEndpoint.ClientAuthenticationRequestPropertyAn implementation forCfnClientVpnEndpoint.ClientAuthenticationRequestPropertyIndicates whether client connect options are enabled.A builder forCfnClientVpnEndpoint.ClientConnectOptionsPropertyAn implementation forCfnClientVpnEndpoint.ClientConnectOptionsPropertyOptions for enabling a customizable text banner that will be displayed on AWS provided clients when a VPN session is established.A builder forCfnClientVpnEndpoint.ClientLoginBannerOptionsPropertyAn implementation forCfnClientVpnEndpoint.ClientLoginBannerOptionsPropertyClient Route Enforcement is a feature of Client VPN that helps enforce administrator defined routes on devices connected through the VPN.An implementation forCfnClientVpnEndpoint.ClientRouteEnforcementOptionsPropertyDescribes the client connection logging options for the Client VPN endpoint.A builder forCfnClientVpnEndpoint.ConnectionLogOptionsPropertyAn implementation forCfnClientVpnEndpoint.ConnectionLogOptionsPropertyDescribes the Active Directory to be used for client authentication.An implementation forCfnClientVpnEndpoint.DirectoryServiceAuthenticationRequestPropertyThe IAM SAML identity provider used for federated authentication.An implementation forCfnClientVpnEndpoint.FederatedAuthenticationRequestPropertySpecifies the tags to apply to the Client VPN endpoint.A builder forCfnClientVpnEndpoint.TagSpecificationPropertyAn implementation forCfnClientVpnEndpoint.TagSpecificationPropertyProperties for defining aCfnClientVpnEndpoint.A builder forCfnClientVpnEndpointPropsAn implementation forCfnClientVpnEndpointPropsSpecifies a network route to add to a Client VPN endpoint.A fluent builder forCfnClientVpnRoute.Properties for defining aCfnClientVpnRoute.A builder forCfnClientVpnRoutePropsAn implementation forCfnClientVpnRoutePropsSpecifies a target network to associate with a Client VPN endpoint.A fluent builder forCfnClientVpnTargetNetworkAssociation.Properties for defining aCfnClientVpnTargetNetworkAssociation.A builder forCfnClientVpnTargetNetworkAssociationPropsAn implementation forCfnClientVpnTargetNetworkAssociationPropsSpecifies a customer gateway.A fluent builder forCfnCustomerGateway.Properties for defining aCfnCustomerGateway.A builder forCfnCustomerGatewayPropsAn implementation forCfnCustomerGatewayPropsSpecifies a set of DHCP options for your VPC.A fluent builder forCfnDHCPOptions.Properties for defining aCfnDHCPOptions.A builder forCfnDHCPOptionsPropsAn implementation forCfnDHCPOptionsPropsSpecifies the configuration information to launch a fleet--or group--of instances.The minimum and maximum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) on an instance.A builder forCfnEC2Fleet.AcceleratorCountRequestPropertyAn implementation forCfnEC2Fleet.AcceleratorCountRequestPropertyThe minimum and maximum amount of total accelerator memory, in MiB.A builder forCfnEC2Fleet.AcceleratorTotalMemoryMiBRequestPropertyAn implementation forCfnEC2Fleet.AcceleratorTotalMemoryMiBRequestPropertyThe minimum and maximum baseline bandwidth to Amazon EBS, in Mbps.A builder forCfnEC2Fleet.BaselineEbsBandwidthMbpsRequestPropertyAn implementation forCfnEC2Fleet.BaselineEbsBandwidthMbpsRequestPropertyThe baseline performance to consider, using an instance family as a baseline reference.A builder forCfnEC2Fleet.BaselinePerformanceFactorsRequestPropertyAn implementation forCfnEC2Fleet.BaselinePerformanceFactorsRequestPropertyDescribes a block device mapping, which defines the EBS volumes and instance store volumes to attach to an instance at launch.A builder forCfnEC2Fleet.BlockDeviceMappingPropertyAn implementation forCfnEC2Fleet.BlockDeviceMappingPropertyA fluent builder forCfnEC2Fleet.The Spot Instance replacement strategy to use when Amazon EC2 emits a rebalance notification signal that your Spot Instance is at an elevated risk of being interrupted.A builder forCfnEC2Fleet.CapacityRebalancePropertyAn implementation forCfnEC2Fleet.CapacityRebalancePropertyDescribes the strategy for using unused Capacity Reservations for fulfilling On-Demand capacity.A builder forCfnEC2Fleet.CapacityReservationOptionsRequestPropertyAn implementation forCfnEC2Fleet.CapacityReservationOptionsRequestPropertyThe CPU performance to consider, using an instance family as the baseline reference.A builder forCfnEC2Fleet.CpuPerformanceFactorRequestPropertyAn implementation forCfnEC2Fleet.CpuPerformanceFactorRequestPropertyDescribes a block device for an EBS volume.A builder forCfnEC2Fleet.EbsBlockDevicePropertyAn implementation forCfnEC2Fleet.EbsBlockDevicePropertySpecifies a launch template and overrides for an EC2 Fleet.A builder forCfnEC2Fleet.FleetLaunchTemplateConfigRequestPropertyAn implementation forCfnEC2Fleet.FleetLaunchTemplateConfigRequestPropertySpecifies overrides for a launch template for an EC2 Fleet.A builder forCfnEC2Fleet.FleetLaunchTemplateOverridesRequestPropertyAn implementation forCfnEC2Fleet.FleetLaunchTemplateOverridesRequestPropertySpecifies the launch template to be used by the EC2 Fleet for configuring Amazon EC2 instances.An implementation forCfnEC2Fleet.FleetLaunchTemplateSpecificationRequestPropertyThe attributes for the instance types.A builder forCfnEC2Fleet.InstanceRequirementsRequestPropertyAn implementation forCfnEC2Fleet.InstanceRequirementsRequestPropertyThe strategies for managing your Spot Instances that are at an elevated risk of being interrupted.A builder forCfnEC2Fleet.MaintenanceStrategiesPropertyAn implementation forCfnEC2Fleet.MaintenanceStrategiesPropertyThe minimum and maximum amount of memory per vCPU, in GiB.A builder forCfnEC2Fleet.MemoryGiBPerVCpuRequestPropertyAn implementation forCfnEC2Fleet.MemoryGiBPerVCpuRequestPropertyThe minimum and maximum amount of memory, in MiB.A builder forCfnEC2Fleet.MemoryMiBRequestPropertyAn implementation forCfnEC2Fleet.MemoryMiBRequestPropertyThe minimum and maximum amount of network bandwidth, in gigabits per second (Gbps).A builder forCfnEC2Fleet.NetworkBandwidthGbpsRequestPropertyAn implementation forCfnEC2Fleet.NetworkBandwidthGbpsRequestPropertyThe minimum and maximum number of network interfaces.A builder forCfnEC2Fleet.NetworkInterfaceCountRequestPropertyAn implementation forCfnEC2Fleet.NetworkInterfaceCountRequestPropertySpecifies the allocation strategy of On-Demand Instances in an EC2 Fleet.A builder forCfnEC2Fleet.OnDemandOptionsRequestPropertyAn implementation forCfnEC2Fleet.OnDemandOptionsRequestPropertySpecify an instance family to use as the baseline reference for CPU performance.A builder forCfnEC2Fleet.PerformanceFactorReferenceRequestPropertyAn implementation forCfnEC2Fleet.PerformanceFactorReferenceRequestPropertyDescribes the placement of an instance.A builder forCfnEC2Fleet.PlacementPropertyAn implementation forCfnEC2Fleet.PlacementPropertySpecifies the configuration of Spot Instances for an EC2 Fleet.A builder forCfnEC2Fleet.SpotOptionsRequestPropertyAn implementation forCfnEC2Fleet.SpotOptionsRequestPropertySpecifies the tags to apply to a resource when the resource is being created for an EC2 Fleet.A builder forCfnEC2Fleet.TagSpecificationPropertyAn implementation forCfnEC2Fleet.TagSpecificationPropertySpecifies the number of units to request for an EC2 Fleet.A builder forCfnEC2Fleet.TargetCapacitySpecificationRequestPropertyAn implementation forCfnEC2Fleet.TargetCapacitySpecificationRequestPropertyThe minimum and maximum amount of total local storage, in GB.A builder forCfnEC2Fleet.TotalLocalStorageGBRequestPropertyAn implementation forCfnEC2Fleet.TotalLocalStorageGBRequestPropertyThe minimum and maximum number of vCPUs.A builder forCfnEC2Fleet.VCpuCountRangeRequestPropertyAn implementation forCfnEC2Fleet.VCpuCountRangeRequestPropertyProperties for defining aCfnEC2Fleet.A builder forCfnEC2FleetPropsAn implementation forCfnEC2FleetProps[IPv6 only] Specifies an egress-only internet gateway for your VPC.A fluent builder forCfnEgressOnlyInternetGateway.Properties for defining aCfnEgressOnlyInternetGateway.A builder forCfnEgressOnlyInternetGatewayPropsAn implementation forCfnEgressOnlyInternetGatewayPropsSpecifies an Elastic IP (EIP) address and can, optionally, associate it with an Amazon EC2 instance.A fluent builder forCfnEIP.Associates an Elastic IP address with an instance or a network interface.A fluent builder forCfnEIPAssociation.Properties for defining aCfnEIPAssociation.A builder forCfnEIPAssociationPropsAn implementation forCfnEIPAssociationPropsProperties for defining aCfnEIP.A builder forCfnEIPPropsAn implementation forCfnEIPPropsAssociates an AWS Identity and Access Management (IAM) role with an Certificate Manager (ACM) certificate.A fluent builder forCfnEnclaveCertificateIamRoleAssociation.Properties for defining aCfnEnclaveCertificateIamRoleAssociation.A builder forCfnEnclaveCertificateIamRoleAssociationPropsAn implementation forCfnEnclaveCertificateIamRoleAssociationPropsSpecifies a VPC flow log that captures IP traffic for a specified network interface, subnet, or VPC.A fluent builder forCfnFlowLog.Describes the destination options for a flow log.A builder forCfnFlowLog.DestinationOptionsPropertyAn implementation forCfnFlowLog.DestinationOptionsPropertyProperties for defining aCfnFlowLog.A builder forCfnFlowLogPropsAn implementation forCfnFlowLogPropsAssociates a virtual private gateway or internet gateway with a route table.A fluent builder forCfnGatewayRouteTableAssociation.Properties for defining aCfnGatewayRouteTableAssociation.A builder forCfnGatewayRouteTableAssociationPropsAn implementation forCfnGatewayRouteTableAssociationPropsAllocates a fully dedicated physical server for launching EC2 instances.A fluent builder forCfnHost.Properties for defining aCfnHost.A builder forCfnHostPropsAn implementation forCfnHostPropsSpecifies an EC2 instance.Specifies input parameter values for an SSM document in AWS Systems Manager .A builder forCfnInstance.AssociationParameterPropertyAn implementation forCfnInstance.AssociationParameterPropertySpecifies a block device mapping for an instance.A builder forCfnInstance.BlockDeviceMappingPropertyAn implementation forCfnInstance.BlockDeviceMappingPropertyA fluent builder forCfnInstance.Specifies the CPU options for the instance.A builder forCfnInstance.CpuOptionsPropertyAn implementation forCfnInstance.CpuOptionsPropertySpecifies the credit option for CPU usage of a T instance.A builder forCfnInstance.CreditSpecificationPropertyAn implementation forCfnInstance.CreditSpecificationPropertySpecifies a block device for an EBS volume.A builder forCfnInstance.EbsPropertyAn implementation forCfnInstance.EbsPropertyA builder forCfnInstance.ElasticGpuSpecificationPropertyAn implementation forCfnInstance.ElasticGpuSpecificationPropertyA builder forCfnInstance.ElasticInferenceAcceleratorPropertyAn implementation forCfnInstance.ElasticInferenceAcceleratorPropertyENA Express uses AWS Scalable Reliable Datagram (SRD) technology to increase the maximum bandwidth used per stream and minimize tail latency of network traffic between EC2 instances.A builder forCfnInstance.EnaSrdSpecificationPropertyAn implementation forCfnInstance.EnaSrdSpecificationPropertyENA Express is compatible with both TCP and UDP transport protocols.A builder forCfnInstance.EnaSrdUdpSpecificationPropertyAn implementation forCfnInstance.EnaSrdUdpSpecificationPropertyIndicates whether the instance is enabled for AWS Nitro Enclaves.A builder forCfnInstance.EnclaveOptionsPropertyAn implementation forCfnInstance.EnclaveOptionsPropertySpecifies the hibernation options for the instance.A builder forCfnInstance.HibernationOptionsPropertyAn implementation forCfnInstance.HibernationOptionsPropertySpecifies the IPv6 address for the instance.A builder forCfnInstance.InstanceIpv6AddressPropertyAn implementation forCfnInstance.InstanceIpv6AddressPropertySpecifies a launch template to use when launching an Amazon EC2 instance.A builder forCfnInstance.LaunchTemplateSpecificationPropertyAn implementation forCfnInstance.LaunchTemplateSpecificationPropertySpecifies the license configuration to use.A builder forCfnInstance.LicenseSpecificationPropertyAn implementation forCfnInstance.LicenseSpecificationPropertySpecifies the metadata options for the instance.A builder forCfnInstance.MetadataOptionsPropertyAn implementation forCfnInstance.MetadataOptionsPropertySpecifies a network interface that is to be attached to an instance.A builder forCfnInstance.NetworkInterfacePropertyAn implementation forCfnInstance.NetworkInterfacePropertyExample:A builder forCfnInstance.NoDevicePropertyAn implementation forCfnInstance.NoDevicePropertyThe type of hostnames to assign to instances in the subnet at launch.A builder forCfnInstance.PrivateDnsNameOptionsPropertyAn implementation forCfnInstance.PrivateDnsNameOptionsPropertySpecifies a secondary private IPv4 address for a network interface.A builder forCfnInstance.PrivateIpAddressSpecificationPropertyAn implementation forCfnInstance.PrivateIpAddressSpecificationPropertySpecifies the SSM document and parameter values in AWS Systems Manager to associate with an instance.A builder forCfnInstance.SsmAssociationPropertyAn implementation forCfnInstance.SsmAssociationPropertyDescribes the current state of an instance.A builder forCfnInstance.StatePropertyAn implementation forCfnInstance.StatePropertySpecifies a volume to attach to an instance.A builder forCfnInstance.VolumePropertyAn implementation forCfnInstance.VolumePropertyCreates an EC2 Instance Connect Endpoint.A fluent builder forCfnInstanceConnectEndpoint.Properties for defining aCfnInstanceConnectEndpoint.A builder forCfnInstanceConnectEndpointPropsAn implementation forCfnInstanceConnectEndpointPropsProperties for defining aCfnInstance.A builder forCfnInstancePropsAn implementation forCfnInstancePropsAllocates an internet gateway for use with a VPC.A fluent builder forCfnInternetGateway.Properties for defining aCfnInternetGateway.A builder forCfnInternetGatewayPropsAn implementation forCfnInternetGatewayPropsIPAM is a VPC feature that you can use to automate your IP address management workflows including assigning, tracking, troubleshooting, and auditing IP addresses across AWS Regions and accounts throughout your AWS Organization.A fluent builder forCfnIPAM.The operating Regions for an IPAM.A builder forCfnIPAM.IpamOperatingRegionPropertyAn implementation forCfnIPAM.IpamOperatingRegionPropertyIf your IPAM is integrated with AWS Organizations, you can exclude an organizational unit (OU) from being managed by IPAM.A builder forCfnIPAM.IpamOrganizationalUnitExclusionPropertyAn implementation forCfnIPAM.IpamOrganizationalUnitExclusionPropertyIn IPAM, an allocation is a CIDR assignment from an IPAM pool to another IPAM pool or to a resource.A fluent builder forCfnIPAMAllocation.Properties for defining aCfnIPAMAllocation.A builder forCfnIPAMAllocationPropsAn implementation forCfnIPAMAllocationPropsIn IPAM, a pool is a collection of contiguous IP addresses CIDRs.A fluent builder forCfnIPAMPool.The CIDR provisioned to the IPAM pool.A builder forCfnIPAMPool.ProvisionedCidrPropertyAn implementation forCfnIPAMPool.ProvisionedCidrPropertyThe resource used to provision CIDRs to a resource planning pool.A builder forCfnIPAMPool.SourceResourcePropertyAn implementation forCfnIPAMPool.SourceResourcePropertyA CIDR provisioned to an IPAM pool.A fluent builder forCfnIPAMPoolCidr.Properties for defining aCfnIPAMPoolCidr.A builder forCfnIPAMPoolCidrPropsAn implementation forCfnIPAMPoolCidrPropsProperties for defining aCfnIPAMPool.A builder forCfnIPAMPoolPropsAn implementation forCfnIPAMPoolPropsProperties for defining aCfnIPAM.A builder forCfnIPAMPropsAn implementation forCfnIPAMPropsA resource discovery is an IPAM component that enables IPAM to manage and monitor resources that belong to the owning account.A fluent builder forCfnIPAMResourceDiscovery.The operating Regions for an IPAM.A builder forCfnIPAMResourceDiscovery.IpamOperatingRegionPropertyAn implementation forCfnIPAMResourceDiscovery.IpamOperatingRegionPropertyIf your IPAM is integrated with AWS Organizations, you can exclude an organizational unit (OU) from being managed by IPAM.An implementation forCfnIPAMResourceDiscovery.IpamResourceDiscoveryOrganizationalUnitExclusionPropertyAn IPAM resource discovery association.A fluent builder forCfnIPAMResourceDiscoveryAssociation.Properties for defining aCfnIPAMResourceDiscoveryAssociation.A builder forCfnIPAMResourceDiscoveryAssociationPropsAn implementation forCfnIPAMResourceDiscoveryAssociationPropsProperties for defining aCfnIPAMResourceDiscovery.A builder forCfnIPAMResourceDiscoveryPropsAn implementation forCfnIPAMResourceDiscoveryPropsIn IPAM, a scope is the highest-level container within IPAM.A fluent builder forCfnIPAMScope.The configuration that links an Amazon VPC IPAM scope to an external authority system.An implementation forCfnIPAMScope.IpamScopeExternalAuthorityConfigurationPropertyProperties for defining aCfnIPAMScope.A builder forCfnIPAMScopePropsAn implementation forCfnIPAMScopePropsA route server association is the connection established between a route server and a VPC.A fluent builder forCfnIpPoolRouteTableAssociation.Properties for defining aCfnIpPoolRouteTableAssociation.A builder forCfnIpPoolRouteTableAssociationPropsAn implementation forCfnIpPoolRouteTableAssociationPropsSpecifies a key pair for use with an Amazon Elastic Compute Cloud instance as follows:.A fluent builder forCfnKeyPair.Properties for defining aCfnKeyPair.A builder forCfnKeyPairPropsAn implementation forCfnKeyPairPropsSpecifies the properties for creating a launch template.The minimum and maximum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) on an instance.A builder forCfnLaunchTemplate.AcceleratorCountPropertyAn implementation forCfnLaunchTemplate.AcceleratorCountPropertyThe minimum and maximum amount of total accelerator memory, in MiB.A builder forCfnLaunchTemplate.AcceleratorTotalMemoryMiBPropertyAn implementation forCfnLaunchTemplate.AcceleratorTotalMemoryMiBPropertyThe minimum and maximum baseline bandwidth to Amazon EBS, in Mbps.A builder forCfnLaunchTemplate.BaselineEbsBandwidthMbpsPropertyAn implementation forCfnLaunchTemplate.BaselineEbsBandwidthMbpsPropertyThe baseline performance to consider, using an instance family as a baseline reference.A builder forCfnLaunchTemplate.BaselinePerformanceFactorsPropertyAn implementation forCfnLaunchTemplate.BaselinePerformanceFactorsPropertySpecifies a block device mapping for a launch template.A builder forCfnLaunchTemplate.BlockDeviceMappingPropertyAn implementation forCfnLaunchTemplate.BlockDeviceMappingPropertyA fluent builder forCfnLaunchTemplate.Specifies an instance's Capacity Reservation targeting option.An implementation forCfnLaunchTemplate.CapacityReservationSpecificationPropertySpecifies a target Capacity Reservation.A builder forCfnLaunchTemplate.CapacityReservationTargetPropertyAn implementation forCfnLaunchTemplate.CapacityReservationTargetPropertyA security group connection tracking specification that enables you to set the idle timeout for connection tracking on an Elastic network interface.An implementation forCfnLaunchTemplate.ConnectionTrackingSpecificationPropertySpecifies the CPU options for an instance.A builder forCfnLaunchTemplate.CpuOptionsPropertyAn implementation forCfnLaunchTemplate.CpuOptionsPropertySpecifies the CPU performance to consider when using an instance family as the baseline reference.A builder forCfnLaunchTemplate.CpuPropertyAn implementation forCfnLaunchTemplate.CpuPropertySpecifies the credit option for CPU usage of a T2, T3, or T3a instance.A builder forCfnLaunchTemplate.CreditSpecificationPropertyAn implementation forCfnLaunchTemplate.CreditSpecificationPropertyParameters for a block device for an EBS volume in an Amazon EC2 launch template.A builder forCfnLaunchTemplate.EbsPropertyAn implementation forCfnLaunchTemplate.EbsPropertyExample:A builder forCfnLaunchTemplate.ElasticGpuSpecificationPropertyAn implementation forCfnLaunchTemplate.ElasticGpuSpecificationPropertyENA Express uses AWS Scalable Reliable Datagram (SRD) technology to increase the maximum bandwidth used per stream and minimize tail latency of network traffic between EC2 instances.A builder forCfnLaunchTemplate.EnaSrdSpecificationPropertyAn implementation forCfnLaunchTemplate.EnaSrdSpecificationPropertyENA Express is compatible with both TCP and UDP transport protocols.A builder forCfnLaunchTemplate.EnaSrdUdpSpecificationPropertyAn implementation forCfnLaunchTemplate.EnaSrdUdpSpecificationPropertyIndicates whether the instance is enabled for AWS Nitro Enclaves.A builder forCfnLaunchTemplate.EnclaveOptionsPropertyAn implementation forCfnLaunchTemplate.EnclaveOptionsPropertySpecifies whether your instance is configured for hibernation.A builder forCfnLaunchTemplate.HibernationOptionsPropertyAn implementation forCfnLaunchTemplate.HibernationOptionsPropertySpecifies an IAM instance profile, which is a container for an IAM role for your instance.A builder forCfnLaunchTemplate.IamInstanceProfilePropertyAn implementation forCfnLaunchTemplate.IamInstanceProfilePropertySpecifies the market (purchasing) option for an instance.A builder forCfnLaunchTemplate.InstanceMarketOptionsPropertyAn implementation forCfnLaunchTemplate.InstanceMarketOptionsPropertyThe attributes for the instance types.A builder forCfnLaunchTemplate.InstanceRequirementsPropertyAn implementation forCfnLaunchTemplate.InstanceRequirementsPropertySpecifies an IPv4 prefix for a network interface.A builder forCfnLaunchTemplate.Ipv4PrefixSpecificationPropertyAn implementation forCfnLaunchTemplate.Ipv4PrefixSpecificationPropertySpecifies an IPv6 address in an Amazon EC2 launch template.A builder forCfnLaunchTemplate.Ipv6AddPropertyAn implementation forCfnLaunchTemplate.Ipv6AddPropertySpecifies an IPv6 prefix for a network interface.A builder forCfnLaunchTemplate.Ipv6PrefixSpecificationPropertyAn implementation forCfnLaunchTemplate.Ipv6PrefixSpecificationPropertyThe information to include in the launch template.A builder forCfnLaunchTemplate.LaunchTemplateDataPropertyAn implementation forCfnLaunchTemplate.LaunchTemplateDataPropertyExample:An implementation forCfnLaunchTemplate.LaunchTemplateElasticInferenceAcceleratorPropertySpecifies the tags to apply to the launch template during creation.A builder forCfnLaunchTemplate.LaunchTemplateTagSpecificationPropertyAn implementation forCfnLaunchTemplate.LaunchTemplateTagSpecificationPropertySpecifies a license configuration for an instance.A builder forCfnLaunchTemplate.LicenseSpecificationPropertyAn implementation forCfnLaunchTemplate.LicenseSpecificationPropertyThe maintenance options of your instance.A builder forCfnLaunchTemplate.MaintenanceOptionsPropertyAn implementation forCfnLaunchTemplate.MaintenanceOptionsPropertyThe minimum and maximum amount of memory per vCPU, in GiB.A builder forCfnLaunchTemplate.MemoryGiBPerVCpuPropertyAn implementation forCfnLaunchTemplate.MemoryGiBPerVCpuPropertyThe minimum and maximum amount of memory, in MiB.A builder forCfnLaunchTemplate.MemoryMiBPropertyAn implementation forCfnLaunchTemplate.MemoryMiBPropertyThe metadata options for the instance.A builder forCfnLaunchTemplate.MetadataOptionsPropertyAn implementation forCfnLaunchTemplate.MetadataOptionsPropertySpecifies whether detailed monitoring is enabled for an instance.A builder forCfnLaunchTemplate.MonitoringPropertyAn implementation forCfnLaunchTemplate.MonitoringPropertyThe minimum and maximum amount of network bandwidth, in gigabits per second (Gbps).A builder forCfnLaunchTemplate.NetworkBandwidthGbpsPropertyAn implementation forCfnLaunchTemplate.NetworkBandwidthGbpsPropertyThe minimum and maximum number of network interfaces.A builder forCfnLaunchTemplate.NetworkInterfaceCountPropertyAn implementation forCfnLaunchTemplate.NetworkInterfaceCountPropertySpecifies the parameters for a network interface.A builder forCfnLaunchTemplate.NetworkInterfacePropertyAn implementation forCfnLaunchTemplate.NetworkInterfacePropertyContains settings for the network performance options for the instance.A builder forCfnLaunchTemplate.NetworkPerformanceOptionsPropertyAn implementation forCfnLaunchTemplate.NetworkPerformanceOptionsPropertySpecifies the placement of an instance.A builder forCfnLaunchTemplate.PlacementPropertyAn implementation forCfnLaunchTemplate.PlacementPropertyThe hostname type for EC2 instances launched into this subnet and how DNS A and AAAA record queries should be handled.A builder forCfnLaunchTemplate.PrivateDnsNameOptionsPropertyAn implementation forCfnLaunchTemplate.PrivateDnsNameOptionsPropertySpecifies a secondary private IPv4 address for a network interface.A builder forCfnLaunchTemplate.PrivateIpAddPropertyAn implementation forCfnLaunchTemplate.PrivateIpAddPropertySpecifies an instance family to use as the baseline reference for CPU performance.A builder forCfnLaunchTemplate.ReferencePropertyAn implementation forCfnLaunchTemplate.ReferencePropertySpecifies options for Spot Instances.A builder forCfnLaunchTemplate.SpotOptionsPropertyAn implementation forCfnLaunchTemplate.SpotOptionsPropertySpecifies the tags to apply to resources that are created during instance launch.A builder forCfnLaunchTemplate.TagSpecificationPropertyAn implementation forCfnLaunchTemplate.TagSpecificationPropertyThe minimum and maximum amount of total local storage, in GB.A builder forCfnLaunchTemplate.TotalLocalStorageGBPropertyAn implementation forCfnLaunchTemplate.TotalLocalStorageGBPropertyThe minimum and maximum number of vCPUs.A builder forCfnLaunchTemplate.VCpuCountPropertyAn implementation forCfnLaunchTemplate.VCpuCountPropertyProperties for defining aCfnLaunchTemplate.A builder forCfnLaunchTemplatePropsAn implementation forCfnLaunchTemplatePropsCreates a static route for the specified local gateway route table.A fluent builder forCfnLocalGatewayRoute.Properties for defining aCfnLocalGatewayRoute.A builder forCfnLocalGatewayRoutePropsAn implementation forCfnLocalGatewayRoutePropsDescribes a local gateway route table.A fluent builder forCfnLocalGatewayRouteTable.Properties for defining aCfnLocalGatewayRouteTable.A builder forCfnLocalGatewayRouteTablePropsAn implementation forCfnLocalGatewayRouteTablePropsDescribes an association between a local gateway route table and a virtual interface group.A fluent builder forCfnLocalGatewayRouteTableVirtualInterfaceGroupAssociation.Properties for defining aCfnLocalGatewayRouteTableVirtualInterfaceGroupAssociation.An implementation forCfnLocalGatewayRouteTableVirtualInterfaceGroupAssociationPropsAssociates the specified VPC with the specified local gateway route table.A fluent builder forCfnLocalGatewayRouteTableVPCAssociation.Properties for defining aCfnLocalGatewayRouteTableVPCAssociation.A builder forCfnLocalGatewayRouteTableVPCAssociationPropsAn implementation forCfnLocalGatewayRouteTableVPCAssociationPropsDescribes a local gateway virtual interface.A fluent builder forCfnLocalGatewayVirtualInterface.Describes a local gateway virtual interface group.A fluent builder forCfnLocalGatewayVirtualInterfaceGroup.Properties for defining aCfnLocalGatewayVirtualInterfaceGroup.A builder forCfnLocalGatewayVirtualInterfaceGroupPropsAn implementation forCfnLocalGatewayVirtualInterfaceGroupPropsProperties for defining aCfnLocalGatewayVirtualInterface.A builder forCfnLocalGatewayVirtualInterfacePropsAn implementation forCfnLocalGatewayVirtualInterfacePropsSpecifies a network address translation (NAT) gateway in the specified subnet.For regional NAT gateways only: The configuration specifying which Elastic IP address (EIP) to use for handling outbound NAT traffic from a specific Availability Zone.A builder forCfnNatGateway.AvailabilityZoneAddressPropertyAn implementation forCfnNatGateway.AvailabilityZoneAddressPropertyA fluent builder forCfnNatGateway.Properties for defining aCfnNatGateway.A builder forCfnNatGatewayPropsAn implementation forCfnNatGatewayPropsSpecifies a network ACL for your VPC.A fluent builder forCfnNetworkAcl.Specifies an entry, known as a rule, in a network ACL with a rule number you specify.A fluent builder forCfnNetworkAclEntry.Describes the ICMP type and code.A builder forCfnNetworkAclEntry.IcmpPropertyAn implementation forCfnNetworkAclEntry.IcmpPropertyDescribes a range of ports.A builder forCfnNetworkAclEntry.PortRangePropertyAn implementation forCfnNetworkAclEntry.PortRangePropertyProperties for defining aCfnNetworkAclEntry.A builder forCfnNetworkAclEntryPropsAn implementation forCfnNetworkAclEntryPropsProperties for defining aCfnNetworkAcl.A builder forCfnNetworkAclPropsAn implementation forCfnNetworkAclPropsDescribes a Network Access Scope.Describes a path.An implementation forCfnNetworkInsightsAccessScope.AccessScopePathRequestPropertyA fluent builder forCfnNetworkInsightsAccessScope.Describes a packet header statement.An implementation forCfnNetworkInsightsAccessScope.PacketHeaderStatementRequestPropertyDescribes a path statement.An implementation forCfnNetworkInsightsAccessScope.PathStatementRequestPropertyDescribes a resource statement.An implementation forCfnNetworkInsightsAccessScope.ResourceStatementRequestPropertyDescribes a through resource statement.An implementation forCfnNetworkInsightsAccessScope.ThroughResourcesStatementRequestPropertyDescribes a Network Access Scope analysis.A fluent builder forCfnNetworkInsightsAccessScopeAnalysis.Properties for defining aCfnNetworkInsightsAccessScopeAnalysis.A builder forCfnNetworkInsightsAccessScopeAnalysisPropsAn implementation forCfnNetworkInsightsAccessScopeAnalysisPropsProperties for defining aCfnNetworkInsightsAccessScope.A builder forCfnNetworkInsightsAccessScopePropsAn implementation forCfnNetworkInsightsAccessScopePropsSpecifies a network insights analysis.Describes an additional detail for a path analysis.A builder forCfnNetworkInsightsAnalysis.AdditionalDetailPropertyAn implementation forCfnNetworkInsightsAnalysis.AdditionalDetailPropertyDescribes an potential intermediate component of a feasible path.A builder forCfnNetworkInsightsAnalysis.AlternatePathHintPropertyAn implementation forCfnNetworkInsightsAnalysis.AlternatePathHintPropertyDescribes a network access control (ACL) rule.A builder forCfnNetworkInsightsAnalysis.AnalysisAclRulePropertyAn implementation forCfnNetworkInsightsAnalysis.AnalysisAclRulePropertyDescribes a path component.A builder forCfnNetworkInsightsAnalysis.AnalysisComponentPropertyAn implementation forCfnNetworkInsightsAnalysis.AnalysisComponentPropertyDescribes a load balancer listener.An implementation forCfnNetworkInsightsAnalysis.AnalysisLoadBalancerListenerPropertyDescribes a load balancer target.An implementation forCfnNetworkInsightsAnalysis.AnalysisLoadBalancerTargetPropertyDescribes a header.A builder forCfnNetworkInsightsAnalysis.AnalysisPacketHeaderPropertyAn implementation forCfnNetworkInsightsAnalysis.AnalysisPacketHeaderPropertyDescribes a route table route.An implementation forCfnNetworkInsightsAnalysis.AnalysisRouteTableRoutePropertyDescribes a security group rule.An implementation forCfnNetworkInsightsAnalysis.AnalysisSecurityGroupRulePropertyA fluent builder forCfnNetworkInsightsAnalysis.Describes an explanation code for an unreachable path.A builder forCfnNetworkInsightsAnalysis.ExplanationPropertyAn implementation forCfnNetworkInsightsAnalysis.ExplanationPropertyDescribes a path component.A builder forCfnNetworkInsightsAnalysis.PathComponentPropertyAn implementation forCfnNetworkInsightsAnalysis.PathComponentPropertyDescribes a range of ports.A builder forCfnNetworkInsightsAnalysis.PortRangePropertyAn implementation forCfnNetworkInsightsAnalysis.PortRangePropertyDescribes a route in a transit gateway route table.An implementation forCfnNetworkInsightsAnalysis.TransitGatewayRouteTableRoutePropertyProperties for defining aCfnNetworkInsightsAnalysis.A builder forCfnNetworkInsightsAnalysisPropsAn implementation forCfnNetworkInsightsAnalysisPropsSpecifies a path to analyze for reachability.A fluent builder forCfnNetworkInsightsPath.Describes a port range.A builder forCfnNetworkInsightsPath.FilterPortRangePropertyAn implementation forCfnNetworkInsightsPath.FilterPortRangePropertyDescribes a set of filters for a path analysis.A builder forCfnNetworkInsightsPath.PathFilterPropertyAn implementation forCfnNetworkInsightsPath.PathFilterPropertyProperties for defining aCfnNetworkInsightsPath.A builder forCfnNetworkInsightsPathPropsAn implementation forCfnNetworkInsightsPathPropsDescribes a network interface in an Amazon EC2 instance for AWS CloudFormation .A fluent builder forCfnNetworkInterface.Configurable options for connection tracking on a network interface.An implementation forCfnNetworkInterface.ConnectionTrackingSpecificationPropertyDescribes the IPv6 addresses to associate with the network interface.A builder forCfnNetworkInterface.InstanceIpv6AddressPropertyAn implementation forCfnNetworkInterface.InstanceIpv6AddressPropertyDescribes an IPv4 prefix.A builder forCfnNetworkInterface.Ipv4PrefixSpecificationPropertyAn implementation forCfnNetworkInterface.Ipv4PrefixSpecificationPropertyDescribes the IPv6 prefix.A builder forCfnNetworkInterface.Ipv6PrefixSpecificationPropertyAn implementation forCfnNetworkInterface.Ipv6PrefixSpecificationPropertyDescribes a secondary private IPv4 address for a network interface.An implementation forCfnNetworkInterface.PrivateIpAddressSpecificationPropertyAttaches an elastic network interface (ENI) to an Amazon EC2 instance.A fluent builder forCfnNetworkInterfaceAttachment.ENA Express uses AWS Scalable Reliable Datagram (SRD) technology to increase the maximum bandwidth used per stream and minimize tail latency of network traffic between EC2 instances.An implementation forCfnNetworkInterfaceAttachment.EnaSrdSpecificationPropertyENA Express is compatible with both TCP and UDP transport protocols.An implementation forCfnNetworkInterfaceAttachment.EnaSrdUdpSpecificationPropertyProperties for defining aCfnNetworkInterfaceAttachment.A builder forCfnNetworkInterfaceAttachmentPropsAn implementation forCfnNetworkInterfaceAttachmentPropsSpecifies a permission for the network interface, For example, you can grant an AWS -authorized account permission to attach the network interface to an instance in their account.A fluent builder forCfnNetworkInterfacePermission.Properties for defining aCfnNetworkInterfacePermission.A builder forCfnNetworkInterfacePermissionPropsAn implementation forCfnNetworkInterfacePermissionPropsProperties for defining aCfnNetworkInterface.A builder forCfnNetworkInterfacePropsAn implementation forCfnNetworkInterfacePropsDescribes Infrastructure Performance subscriptions.A fluent builder forCfnNetworkPerformanceMetricSubscription.Properties for defining aCfnNetworkPerformanceMetricSubscription.A builder forCfnNetworkPerformanceMetricSubscriptionPropsAn implementation forCfnNetworkPerformanceMetricSubscriptionPropsSpecifies a placement group in which to launch instances.A fluent builder forCfnPlacementGroup.Properties for defining aCfnPlacementGroup.A builder forCfnPlacementGroupPropsAn implementation forCfnPlacementGroupPropsSpecifies a managed prefix list.A fluent builder forCfnPrefixList.An entry for a prefix list.A builder forCfnPrefixList.EntryPropertyAn implementation forCfnPrefixList.EntryPropertyProperties for defining aCfnPrefixList.A builder forCfnPrefixListPropsAn implementation forCfnPrefixListPropsSpecifies a route in a route table.A fluent builder forCfnRoute.Properties for defining aCfnRoute.A builder forCfnRoutePropsAn implementation forCfnRoutePropsSpecifies a route server to manage dynamic routing in a VPC.A fluent builder forCfnRouteServer.Specifies the association between a route server and a VPC.A fluent builder forCfnRouteServerAssociation.Properties for defining aCfnRouteServerAssociation.A builder forCfnRouteServerAssociationPropsAn implementation forCfnRouteServerAssociationPropsCreates a new endpoint for a route server in a specified subnet.A fluent builder forCfnRouteServerEndpoint.Properties for defining aCfnRouteServerEndpoint.A builder forCfnRouteServerEndpointPropsAn implementation forCfnRouteServerEndpointPropsSpecifies a BGP peer configuration for a route server endpoint.The BGP configuration options for this peer, including ASN (Autonomous System Number) and BFD (Bidrectional Forwarding Detection) settings.A builder forCfnRouteServerPeer.BgpOptionsPropertyAn implementation forCfnRouteServerPeer.BgpOptionsPropertyA fluent builder forCfnRouteServerPeer.Properties for defining aCfnRouteServerPeer.A builder forCfnRouteServerPeerPropsAn implementation forCfnRouteServerPeerPropsSpecifies route propagation from a route server to a route table.A fluent builder forCfnRouteServerPropagation.Properties for defining aCfnRouteServerPropagation.A builder forCfnRouteServerPropagationPropsAn implementation forCfnRouteServerPropagationPropsProperties for defining aCfnRouteServer.A builder forCfnRouteServerPropsAn implementation forCfnRouteServerPropsSpecifies a route table for the specified VPC.A fluent builder forCfnRouteTable.Properties for defining aCfnRouteTable.A builder forCfnRouteTablePropsAn implementation forCfnRouteTablePropsSpecifies a security group.A fluent builder forCfnSecurityGroup.Adds the specified outbound (egress) rule to a security group.A builder forCfnSecurityGroup.EgressPropertyAn implementation forCfnSecurityGroup.EgressPropertyAdds an inbound (ingress) rule to a security group.A builder forCfnSecurityGroup.IngressPropertyAn implementation forCfnSecurityGroup.IngressPropertyAdds the specified outbound (egress) rule to a security group.A fluent builder forCfnSecurityGroupEgress.Properties for defining aCfnSecurityGroupEgress.A builder forCfnSecurityGroupEgressPropsAn implementation forCfnSecurityGroupEgressPropsAdds an inbound (ingress) rule to a security group.A fluent builder forCfnSecurityGroupIngress.Properties for defining aCfnSecurityGroupIngress.A builder forCfnSecurityGroupIngressPropsAn implementation forCfnSecurityGroupIngressPropsProperties for defining aCfnSecurityGroup.A builder forCfnSecurityGroupPropsAn implementation forCfnSecurityGroupPropsA security group association with a VPC.A fluent builder forCfnSecurityGroupVpcAssociation.Properties for defining aCfnSecurityGroupVpcAssociation.A builder forCfnSecurityGroupVpcAssociationPropsAn implementation forCfnSecurityGroupVpcAssociationPropsSpecifies the state of the block public access for snapshots setting for the Region.A fluent builder forCfnSnapshotBlockPublicAccess.Properties for defining aCfnSnapshotBlockPublicAccess.A builder forCfnSnapshotBlockPublicAccessPropsAn implementation forCfnSnapshotBlockPublicAccessPropsSpecifies a Spot Fleet request.The minimum and maximum number of accelerators (GPUs, FPGAs, or AWS Inferentia chips) on an instance.A builder forCfnSpotFleet.AcceleratorCountRequestPropertyAn implementation forCfnSpotFleet.AcceleratorCountRequestPropertyThe minimum and maximum amount of total accelerator memory, in MiB.A builder forCfnSpotFleet.AcceleratorTotalMemoryMiBRequestPropertyAn implementation forCfnSpotFleet.AcceleratorTotalMemoryMiBRequestPropertyThe minimum and maximum baseline bandwidth to Amazon EBS, in Mbps.A builder forCfnSpotFleet.BaselineEbsBandwidthMbpsRequestPropertyAn implementation forCfnSpotFleet.BaselineEbsBandwidthMbpsRequestPropertyThe baseline performance to consider, using an instance family as a baseline reference.A builder forCfnSpotFleet.BaselinePerformanceFactorsRequestPropertyAn implementation forCfnSpotFleet.BaselinePerformanceFactorsRequestPropertySpecifies a block device mapping.A builder forCfnSpotFleet.BlockDeviceMappingPropertyAn implementation forCfnSpotFleet.BlockDeviceMappingPropertyA fluent builder forCfnSpotFleet.Specifies a Classic Load Balancer.A builder forCfnSpotFleet.ClassicLoadBalancerPropertyAn implementation forCfnSpotFleet.ClassicLoadBalancerPropertySpecifies the Classic Load Balancers to attach to a Spot Fleet.A builder forCfnSpotFleet.ClassicLoadBalancersConfigPropertyAn implementation forCfnSpotFleet.ClassicLoadBalancersConfigPropertyThe CPU performance to consider, using an instance family as the baseline reference.A builder forCfnSpotFleet.CpuPerformanceFactorRequestPropertyAn implementation forCfnSpotFleet.CpuPerformanceFactorRequestPropertyDescribes a block device for an EBS volume.A builder forCfnSpotFleet.EbsBlockDevicePropertyAn implementation forCfnSpotFleet.EbsBlockDevicePropertySpecifies the launch template to be used by the Spot Fleet request for configuring Amazon EC2 instances.A builder forCfnSpotFleet.FleetLaunchTemplateSpecificationPropertyAn implementation forCfnSpotFleet.FleetLaunchTemplateSpecificationPropertyDescribes a security group.A builder forCfnSpotFleet.GroupIdentifierPropertyAn implementation forCfnSpotFleet.GroupIdentifierPropertyDescribes an IAM instance profile.A builder forCfnSpotFleet.IamInstanceProfileSpecificationPropertyAn implementation forCfnSpotFleet.IamInstanceProfileSpecificationPropertyDescribes an IPv6 address.A builder forCfnSpotFleet.InstanceIpv6AddressPropertyAn implementation forCfnSpotFleet.InstanceIpv6AddressPropertyDescribes a network interface.An implementation forCfnSpotFleet.InstanceNetworkInterfaceSpecificationPropertyThe attributes for the instance types.A builder forCfnSpotFleet.InstanceRequirementsRequestPropertyAn implementation forCfnSpotFleet.InstanceRequirementsRequestPropertySpecifies a launch template and overrides.A builder forCfnSpotFleet.LaunchTemplateConfigPropertyAn implementation forCfnSpotFleet.LaunchTemplateConfigPropertySpecifies overrides for a launch template.A builder forCfnSpotFleet.LaunchTemplateOverridesPropertyAn implementation forCfnSpotFleet.LaunchTemplateOverridesPropertySpecifies the Classic Load Balancers and target groups to attach to a Spot Fleet request.A builder forCfnSpotFleet.LoadBalancersConfigPropertyAn implementation forCfnSpotFleet.LoadBalancersConfigPropertyThe minimum and maximum amount of memory per vCPU, in GiB.A builder forCfnSpotFleet.MemoryGiBPerVCpuRequestPropertyAn implementation forCfnSpotFleet.MemoryGiBPerVCpuRequestPropertyThe minimum and maximum amount of memory, in MiB.A builder forCfnSpotFleet.MemoryMiBRequestPropertyAn implementation forCfnSpotFleet.MemoryMiBRequestPropertyThe minimum and maximum amount of baseline network bandwidth, in gigabits per second (Gbps).A builder forCfnSpotFleet.NetworkBandwidthGbpsRequestPropertyAn implementation forCfnSpotFleet.NetworkBandwidthGbpsRequestPropertyThe minimum and maximum number of network interfaces.A builder forCfnSpotFleet.NetworkInterfaceCountRequestPropertyAn implementation forCfnSpotFleet.NetworkInterfaceCountRequestPropertySpecify an instance family to use as the baseline reference for CPU performance.A builder forCfnSpotFleet.PerformanceFactorReferenceRequestPropertyAn implementation forCfnSpotFleet.PerformanceFactorReferenceRequestPropertyDescribes a secondary private IPv4 address for a network interface.A builder forCfnSpotFleet.PrivateIpAddressSpecificationPropertyAn implementation forCfnSpotFleet.PrivateIpAddressSpecificationPropertyThe Spot Instance replacement strategy to use when Amazon EC2 emits a signal that your Spot Instance is at an elevated risk of being interrupted.A builder forCfnSpotFleet.SpotCapacityRebalancePropertyAn implementation forCfnSpotFleet.SpotCapacityRebalancePropertySpecifies the launch specification for one or more Spot Instances.A builder forCfnSpotFleet.SpotFleetLaunchSpecificationPropertyAn implementation forCfnSpotFleet.SpotFleetLaunchSpecificationPropertyDescribes whether monitoring is enabled.A builder forCfnSpotFleet.SpotFleetMonitoringPropertyAn implementation forCfnSpotFleet.SpotFleetMonitoringPropertySpecifies the configuration of a Spot Fleet request.A builder forCfnSpotFleet.SpotFleetRequestConfigDataPropertyAn implementation forCfnSpotFleet.SpotFleetRequestConfigDataPropertyThe tags for a Spot Fleet resource.A builder forCfnSpotFleet.SpotFleetTagSpecificationPropertyAn implementation forCfnSpotFleet.SpotFleetTagSpecificationPropertyThe strategies for managing your Spot Instances that are at an elevated risk of being interrupted.A builder forCfnSpotFleet.SpotMaintenanceStrategiesPropertyAn implementation forCfnSpotFleet.SpotMaintenanceStrategiesPropertyDescribes Spot Instance placement.A builder forCfnSpotFleet.SpotPlacementPropertyAn implementation forCfnSpotFleet.SpotPlacementPropertyDescribes a load balancer target group.A builder forCfnSpotFleet.TargetGroupPropertyAn implementation forCfnSpotFleet.TargetGroupPropertyDescribes the target groups to attach to a Spot Fleet.A builder forCfnSpotFleet.TargetGroupsConfigPropertyAn implementation forCfnSpotFleet.TargetGroupsConfigPropertyThe minimum and maximum amount of total local storage, in GB.A builder forCfnSpotFleet.TotalLocalStorageGBRequestPropertyAn implementation forCfnSpotFleet.TotalLocalStorageGBRequestPropertyThe minimum and maximum number of vCPUs.A builder forCfnSpotFleet.VCpuCountRangeRequestPropertyAn implementation forCfnSpotFleet.VCpuCountRangeRequestPropertyProperties for defining aCfnSpotFleet.A builder forCfnSpotFleetPropsAn implementation forCfnSpotFleetPropsSpecifies a subnet for the specified VPC.Specifies the state of VPC Block Public Access (BPA).A builder forCfnSubnet.BlockPublicAccessStatesPropertyAn implementation forCfnSubnet.BlockPublicAccessStatesPropertyA fluent builder forCfnSubnet.Specifies the options for instance hostnames.A builder forCfnSubnet.PrivateDnsNameOptionsOnLaunchPropertyAn implementation forCfnSubnet.PrivateDnsNameOptionsOnLaunchPropertyAssociates a CIDR block with your subnet.A fluent builder forCfnSubnetCidrBlock.Properties for defining aCfnSubnetCidrBlock.A builder forCfnSubnetCidrBlockPropsAn implementation forCfnSubnetCidrBlockPropsAssociates a subnet with a network ACL.A fluent builder forCfnSubnetNetworkAclAssociation.Properties for defining aCfnSubnetNetworkAclAssociation.A builder forCfnSubnetNetworkAclAssociationPropsAn implementation forCfnSubnetNetworkAclAssociationPropsProperties for defining aCfnSubnet.A builder forCfnSubnetPropsAn implementation forCfnSubnetPropsAssociates a subnet with a route table.A fluent builder forCfnSubnetRouteTableAssociation.Properties for defining aCfnSubnetRouteTableAssociation.A builder forCfnSubnetRouteTableAssociationPropsAn implementation forCfnSubnetRouteTableAssociationPropsSpecifies a Traffic Mirror filter.A fluent builder forCfnTrafficMirrorFilter.Properties for defining aCfnTrafficMirrorFilter.A builder forCfnTrafficMirrorFilterPropsAn implementation forCfnTrafficMirrorFilterPropsCreates a Traffic Mirror filter rule.A fluent builder forCfnTrafficMirrorFilterRule.Describes the Traffic Mirror port range.An implementation forCfnTrafficMirrorFilterRule.TrafficMirrorPortRangePropertyProperties for defining aCfnTrafficMirrorFilterRule.A builder forCfnTrafficMirrorFilterRulePropsAn implementation forCfnTrafficMirrorFilterRulePropsCreates a Traffic Mirror session.A fluent builder forCfnTrafficMirrorSession.Properties for defining aCfnTrafficMirrorSession.A builder forCfnTrafficMirrorSessionPropsAn implementation forCfnTrafficMirrorSessionPropsSpecifies a target for your Traffic Mirror session.A fluent builder forCfnTrafficMirrorTarget.Properties for defining aCfnTrafficMirrorTarget.A builder forCfnTrafficMirrorTargetPropsAn implementation forCfnTrafficMirrorTargetPropsSpecifies a transit gateway.A fluent builder forCfnTransitGateway.Attaches a VPC to a transit gateway.A fluent builder forCfnTransitGatewayAttachment.Describes the VPC attachment options.A builder forCfnTransitGatewayAttachment.OptionsPropertyAn implementation forCfnTransitGatewayAttachment.OptionsPropertyProperties for defining aCfnTransitGatewayAttachment.A builder forCfnTransitGatewayAttachmentPropsAn implementation forCfnTransitGatewayAttachmentPropsCreates a Connect attachment from a specified transit gateway attachment.A fluent builder forCfnTransitGatewayConnect.Describes the Connect attachment options.An implementation forCfnTransitGatewayConnect.TransitGatewayConnectOptionsPropertyDescribes a transit gateway Connect peer.A fluent builder forCfnTransitGatewayConnectPeer.The BGP configuration information.An implementation forCfnTransitGatewayConnectPeer.TransitGatewayAttachmentBgpConfigurationPropertyDescribes the Connect peer details.An implementation forCfnTransitGatewayConnectPeer.TransitGatewayConnectPeerConfigurationPropertyProperties for defining aCfnTransitGatewayConnectPeer.A builder forCfnTransitGatewayConnectPeerPropsAn implementation forCfnTransitGatewayConnectPeerPropsProperties for defining aCfnTransitGatewayConnect.A builder forCfnTransitGatewayConnectPropsAn implementation forCfnTransitGatewayConnectPropsDescribes a transit gateway metering policy.A fluent builder forCfnTransitGatewayMeteringPolicy.Creates an entry in a transit gateway metering policy to define traffic measurement rules.A fluent builder forCfnTransitGatewayMeteringPolicyEntry.Properties for defining aCfnTransitGatewayMeteringPolicyEntry.A builder forCfnTransitGatewayMeteringPolicyEntryPropsAn implementation forCfnTransitGatewayMeteringPolicyEntryPropsProperties for defining aCfnTransitGatewayMeteringPolicy.A builder forCfnTransitGatewayMeteringPolicyPropsAn implementation forCfnTransitGatewayMeteringPolicyPropsCreates a multicast domain using the specified transit gateway.A fluent builder forCfnTransitGatewayMulticastDomain.The options for the transit gateway multicast domain.A builder forCfnTransitGatewayMulticastDomain.OptionsPropertyAn implementation forCfnTransitGatewayMulticastDomain.OptionsPropertyAssociates the specified subnets and transit gateway attachments with the specified transit gateway multicast domain.A fluent builder forCfnTransitGatewayMulticastDomainAssociation.Properties for defining aCfnTransitGatewayMulticastDomainAssociation.A builder forCfnTransitGatewayMulticastDomainAssociationPropsAn implementation forCfnTransitGatewayMulticastDomainAssociationPropsProperties for defining aCfnTransitGatewayMulticastDomain.A builder forCfnTransitGatewayMulticastDomainPropsAn implementation forCfnTransitGatewayMulticastDomainPropsRegisters members (network interfaces) with the transit gateway multicast group.A fluent builder forCfnTransitGatewayMulticastGroupMember.Properties for defining aCfnTransitGatewayMulticastGroupMember.A builder forCfnTransitGatewayMulticastGroupMemberPropsAn implementation forCfnTransitGatewayMulticastGroupMemberPropsRegisters sources (network interfaces) with the specified transit gateway multicast domain.A fluent builder forCfnTransitGatewayMulticastGroupSource.Properties for defining aCfnTransitGatewayMulticastGroupSource.A builder forCfnTransitGatewayMulticastGroupSourcePropsAn implementation forCfnTransitGatewayMulticastGroupSourcePropsRequests a transit gateway peering attachment between the specified transit gateway (requester) and a peer transit gateway (accepter).A fluent builder forCfnTransitGatewayPeeringAttachment.The status of the transit gateway peering attachment.An implementation forCfnTransitGatewayPeeringAttachment.PeeringAttachmentStatusPropertyProperties for defining aCfnTransitGatewayPeeringAttachment.A builder forCfnTransitGatewayPeeringAttachmentPropsAn implementation forCfnTransitGatewayPeeringAttachmentPropsProperties for defining aCfnTransitGateway.A builder forCfnTransitGatewayPropsAn implementation forCfnTransitGatewayPropsSpecifies a static route for a transit gateway route table.A fluent builder forCfnTransitGatewayRoute.Properties for defining aCfnTransitGatewayRoute.A builder forCfnTransitGatewayRoutePropsAn implementation forCfnTransitGatewayRoutePropsSpecifies a route table for a transit gateway.A fluent builder forCfnTransitGatewayRouteTable.Associates the specified attachment with the specified transit gateway route table.A fluent builder forCfnTransitGatewayRouteTableAssociation.Properties for defining aCfnTransitGatewayRouteTableAssociation.A builder forCfnTransitGatewayRouteTableAssociationPropsAn implementation forCfnTransitGatewayRouteTableAssociationPropsEnables the specified attachment to propagate routes to the specified propagation route table.A fluent builder forCfnTransitGatewayRouteTablePropagation.Properties for defining aCfnTransitGatewayRouteTablePropagation.A builder forCfnTransitGatewayRouteTablePropagationPropsAn implementation forCfnTransitGatewayRouteTablePropagationPropsProperties for defining aCfnTransitGatewayRouteTable.A builder forCfnTransitGatewayRouteTablePropsAn implementation forCfnTransitGatewayRouteTablePropsSpecifies a VPC attachment.A fluent builder forCfnTransitGatewayVpcAttachment.Describes the VPC attachment options.A builder forCfnTransitGatewayVpcAttachment.OptionsPropertyAn implementation forCfnTransitGatewayVpcAttachment.OptionsPropertyProperties for defining aCfnTransitGatewayVpcAttachment.A builder forCfnTransitGatewayVpcAttachmentPropsAn implementation forCfnTransitGatewayVpcAttachmentPropsAn AWS Verified Access endpoint specifies the application that AWS Verified Access provides access to.A fluent builder forCfnVerifiedAccessEndpoint.Describes the CIDR options for a Verified Access endpoint.A builder forCfnVerifiedAccessEndpoint.CidrOptionsPropertyAn implementation forCfnVerifiedAccessEndpoint.CidrOptionsPropertyDescribes the load balancer options when creating an AWS Verified Access endpoint using theload-balancertype.A builder forCfnVerifiedAccessEndpoint.LoadBalancerOptionsPropertyAn implementation forCfnVerifiedAccessEndpoint.LoadBalancerOptionsPropertyDescribes the network interface options when creating an AWS Verified Access endpoint using thenetwork-interfacetype.An implementation forCfnVerifiedAccessEndpoint.NetworkInterfaceOptionsPropertyDescribes the port range for a Verified Access endpoint.A builder forCfnVerifiedAccessEndpoint.PortRangePropertyAn implementation forCfnVerifiedAccessEndpoint.PortRangePropertyDescribes the RDS options for a Verified Access endpoint.A builder forCfnVerifiedAccessEndpoint.RdsOptionsPropertyAn implementation forCfnVerifiedAccessEndpoint.RdsOptionsPropertyAWS Verified Access provides server side encryption by default to data at rest using AWS -owned KMS keys.A builder forCfnVerifiedAccessEndpoint.SseSpecificationPropertyAn implementation forCfnVerifiedAccessEndpoint.SseSpecificationPropertyProperties for defining aCfnVerifiedAccessEndpoint.A builder forCfnVerifiedAccessEndpointPropsAn implementation forCfnVerifiedAccessEndpointPropsAn AWS Verified Access group is a collection of AWS Verified Access endpoints who's associated applications have similar security requirements.A fluent builder forCfnVerifiedAccessGroup.AWS Verified Access provides server side encryption by default to data at rest using AWS -owned KMS keys.A builder forCfnVerifiedAccessGroup.SseSpecificationPropertyAn implementation forCfnVerifiedAccessGroup.SseSpecificationPropertyProperties for defining aCfnVerifiedAccessGroup.A builder forCfnVerifiedAccessGroupPropsAn implementation forCfnVerifiedAccessGroupPropsAn AWS Verified Access instance is a regional entity that evaluates application requests and grants access only when your security requirements are met.A fluent builder forCfnVerifiedAccessInstance.Options for CloudWatch Logs as a logging destination.A builder forCfnVerifiedAccessInstance.CloudWatchLogsPropertyAn implementation forCfnVerifiedAccessInstance.CloudWatchLogsPropertyOptions for Kinesis as a logging destination.A builder forCfnVerifiedAccessInstance.KinesisDataFirehosePropertyAn implementation forCfnVerifiedAccessInstance.KinesisDataFirehosePropertyOptions for Amazon S3 as a logging destination.A builder forCfnVerifiedAccessInstance.S3PropertyAn implementation forCfnVerifiedAccessInstance.S3PropertyDescribes the options for Verified Access logs.A builder forCfnVerifiedAccessInstance.VerifiedAccessLogsPropertyAn implementation forCfnVerifiedAccessInstance.VerifiedAccessLogsPropertyA trust provider is a third-party entity that creates, maintains, and manages identity information for users and devices.An implementation forCfnVerifiedAccessInstance.VerifiedAccessTrustProviderPropertyProperties for defining aCfnVerifiedAccessInstance.A builder forCfnVerifiedAccessInstancePropsAn implementation forCfnVerifiedAccessInstancePropsA trust provider is a third-party entity that creates, maintains, and manages identity information for users and devices.A fluent builder forCfnVerifiedAccessTrustProvider.Describes the options for an AWS Verified Access device-identity based trust provider.A builder forCfnVerifiedAccessTrustProvider.DeviceOptionsPropertyAn implementation forCfnVerifiedAccessTrustProvider.DeviceOptionsPropertyDescribes the OpenID Connect (OIDC) options.An implementation forCfnVerifiedAccessTrustProvider.NativeApplicationOidcOptionsPropertyDescribes the options for an OpenID Connect-compatible user-identity trust provider.A builder forCfnVerifiedAccessTrustProvider.OidcOptionsPropertyAn implementation forCfnVerifiedAccessTrustProvider.OidcOptionsPropertyAWS Verified Access provides server side encryption by default to data at rest using AWS -owned KMS keys.A builder forCfnVerifiedAccessTrustProvider.SseSpecificationPropertyAn implementation forCfnVerifiedAccessTrustProvider.SseSpecificationPropertyProperties for defining aCfnVerifiedAccessTrustProvider.A builder forCfnVerifiedAccessTrustProviderPropsAn implementation forCfnVerifiedAccessTrustProviderPropsSpecifies an Amazon Elastic Block Store (Amazon EBS) volume.A fluent builder forCfnVolume.Attaches an Amazon EBS volume to a running instance and exposes it to the instance with the specified device name.A fluent builder forCfnVolumeAttachment.Properties for defining aCfnVolumeAttachment.A builder forCfnVolumeAttachmentPropsAn implementation forCfnVolumeAttachmentPropsProperties for defining aCfnVolume.A builder forCfnVolumePropsAn implementation forCfnVolumePropsSpecifies a virtual private cloud (VPC).A fluent builder forCfnVPC.Create a VPC Block Public Access (BPA) exclusion.A fluent builder forCfnVPCBlockPublicAccessExclusion.Properties for defining aCfnVPCBlockPublicAccessExclusion.A builder forCfnVPCBlockPublicAccessExclusionPropsAn implementation forCfnVPCBlockPublicAccessExclusionPropsVPC Block Public Access (BPA) enables you to block resources in VPCs and subnets that you own in a Region from reaching or being reached from the internet through internet gateways and egress-only internet gateways.A fluent builder forCfnVPCBlockPublicAccessOptions.Properties for defining aCfnVPCBlockPublicAccessOptions.A builder forCfnVPCBlockPublicAccessOptionsPropsAn implementation forCfnVPCBlockPublicAccessOptionsPropsAssociates a CIDR block with your VPC.A fluent builder forCfnVPCCidrBlock.Properties for defining aCfnVPCCidrBlock.A builder forCfnVPCCidrBlockPropsAn implementation forCfnVPCCidrBlockPropsAssociates a set of DHCP options with a VPC, or associates no DHCP options with the VPC.A fluent builder forCfnVPCDHCPOptionsAssociation.Properties for defining aCfnVPCDHCPOptionsAssociation.A builder forCfnVPCDHCPOptionsAssociationPropsAn implementation forCfnVPCDHCPOptionsAssociationPropsDescribes the configuration and state of VPC encryption controls.A fluent builder forCfnVPCEncryptionControl.Information about resource exclusions for the VPC Encryption Control configuration.A builder forCfnVPCEncryptionControl.ResourceExclusionsPropertyAn implementation forCfnVPCEncryptionControl.ResourceExclusionsPropertyDescribes an exclusion configuration for VPC Encryption Control.An implementation forCfnVPCEncryptionControl.VpcEncryptionControlExclusionPropertyProperties for defining aCfnVPCEncryptionControl.A builder forCfnVPCEncryptionControlPropsAn implementation forCfnVPCEncryptionControlPropsSpecifies a VPC endpoint.A fluent builder forCfnVPCEndpoint.Describes the DNS options for an endpoint.A builder forCfnVPCEndpoint.DnsOptionsSpecificationPropertyAn implementation forCfnVPCEndpoint.DnsOptionsSpecificationPropertySpecifies a connection notification for a VPC endpoint or VPC endpoint service.A fluent builder forCfnVPCEndpointConnectionNotification.Properties for defining aCfnVPCEndpointConnectionNotification.A builder forCfnVPCEndpointConnectionNotificationPropsAn implementation forCfnVPCEndpointConnectionNotificationPropsProperties for defining aCfnVPCEndpoint.A builder forCfnVPCEndpointPropsAn implementation forCfnVPCEndpointPropsCreates a VPC endpoint service configuration to which service consumers ( AWS accounts, users, and IAM roles) can connect.A fluent builder forCfnVPCEndpointService.Grant or revoke permissions for service consumers (users, IAM roles, and AWS accounts) to connect to a VPC endpoint service.A fluent builder forCfnVPCEndpointServicePermissions.Properties for defining aCfnVPCEndpointServicePermissions.A builder forCfnVPCEndpointServicePermissionsPropsAn implementation forCfnVPCEndpointServicePermissionsPropsProperties for defining aCfnVPCEndpointService.A builder forCfnVPCEndpointServicePropsAn implementation forCfnVPCEndpointServicePropsAttaches an internet gateway, or a virtual private gateway to a VPC, enabling connectivity between the internet and the VPC.A fluent builder forCfnVPCGatewayAttachment.Properties for defining aCfnVPCGatewayAttachment.A builder forCfnVPCGatewayAttachmentPropsAn implementation forCfnVPCGatewayAttachmentPropsRequests a VPC peering connection between two VPCs: a requester VPC that you own and an accepter VPC with which to create the connection.A fluent builder forCfnVPCPeeringConnection.Properties for defining aCfnVPCPeeringConnection.A builder forCfnVPCPeeringConnectionPropsAn implementation forCfnVPCPeeringConnectionPropsProperties for defining aCfnVPC.A builder forCfnVPCPropsAn implementation forCfnVPCPropsResource Type definition for AWS::EC2::VPNConcentrator.A fluent builder forCfnVPNConcentrator.Properties for defining aCfnVPNConcentrator.A builder forCfnVPNConcentratorPropsAn implementation forCfnVPNConcentratorPropsSpecifies a VPN connection between a virtual private gateway and a VPN customer gateway or a transit gateway and a VPN customer gateway.A fluent builder forCfnVPNConnection.Options for sending VPN tunnel logs to CloudWatch.An implementation forCfnVPNConnection.CloudwatchLogOptionsSpecificationPropertyThe IKE version that is permitted for the VPN tunnel.A builder forCfnVPNConnection.IKEVersionsRequestListValuePropertyAn implementation forCfnVPNConnection.IKEVersionsRequestListValuePropertySpecifies a Diffie-Hellman group number for the VPN tunnel for phase 1 IKE negotiations.An implementation forCfnVPNConnection.Phase1DHGroupNumbersRequestListValuePropertySpecifies the encryption algorithm for the VPN tunnel for phase 1 IKE negotiations.An implementation forCfnVPNConnection.Phase1EncryptionAlgorithmsRequestListValuePropertySpecifies the integrity algorithm for the VPN tunnel for phase 1 IKE negotiations.An implementation forCfnVPNConnection.Phase1IntegrityAlgorithmsRequestListValuePropertySpecifies a Diffie-Hellman group number for the VPN tunnel for phase 2 IKE negotiations.An implementation forCfnVPNConnection.Phase2DHGroupNumbersRequestListValuePropertySpecifies the encryption algorithm for the VPN tunnel for phase 2 IKE negotiations.An implementation forCfnVPNConnection.Phase2EncryptionAlgorithmsRequestListValuePropertySpecifies the integrity algorithm for the VPN tunnel for phase 2 IKE negotiations.An implementation forCfnVPNConnection.Phase2IntegrityAlgorithmsRequestListValuePropertyOptions for logging VPN tunnel activity.An implementation forCfnVPNConnection.VpnTunnelLogOptionsSpecificationPropertyThe tunnel options for a single VPN tunnel.A builder forCfnVPNConnection.VpnTunnelOptionsSpecificationPropertyAn implementation forCfnVPNConnection.VpnTunnelOptionsSpecificationPropertyProperties for defining aCfnVPNConnection.A builder forCfnVPNConnectionPropsAn implementation forCfnVPNConnectionPropsSpecifies a static route for a VPN connection between an existing virtual private gateway and a VPN customer gateway.A fluent builder forCfnVPNConnectionRoute.Properties for defining aCfnVPNConnectionRoute.A builder forCfnVPNConnectionRoutePropsAn implementation forCfnVPNConnectionRoutePropsSpecifies a virtual private gateway.A fluent builder forCfnVPNGateway.Properties for defining aCfnVPNGateway.A builder forCfnVPNGatewayPropsAn implementation forCfnVPNGatewayPropsEnables a virtual private gateway (VGW) to propagate routes to the specified route table of a VPC.A fluent builder forCfnVPNGatewayRoutePropagation.Properties for defining aCfnVPNGatewayRoutePropagation.A builder forCfnVPNGatewayRoutePropagationPropsAn implementation forCfnVPNGatewayRoutePropagationPropsOptions for Client Route Enforcement.A builder forClientRouteEnforcementOptionsAn implementation forClientRouteEnforcementOptionsA client VPN authorization rule.A fluent builder forClientVpnAuthorizationRule.Options for a ClientVpnAuthorizationRule.A builder forClientVpnAuthorizationRuleOptionsAn implementation forClientVpnAuthorizationRuleOptionsProperties for a ClientVpnAuthorizationRule.A builder forClientVpnAuthorizationRulePropsAn implementation forClientVpnAuthorizationRulePropsA client VPN connection.A fluent builder forClientVpnEndpoint.Attributes when importing an existing client VPN endpoint.A builder forClientVpnEndpointAttributesAn implementation forClientVpnEndpointAttributesOptions for a client VPN endpoint.A builder forClientVpnEndpointOptionsAn implementation forClientVpnEndpointOptionsProperties for a client VPN endpoint.A builder forClientVpnEndpointPropsAn implementation forClientVpnEndpointPropsA client VPN route.A fluent builder forClientVpnRoute.Options for a ClientVpnRoute.A builder forClientVpnRouteOptionsAn implementation forClientVpnRouteOptionsProperties for a ClientVpnRoute.A builder forClientVpnRoutePropsAn implementation forClientVpnRoutePropsTarget for a client VPN route.Maximum VPN session duration time.User-based authentication for a client VPN endpoint.A CloudFormation-init configuration.Basic NetworkACL entry props.A builder forCommonNetworkAclEntryOptionsAn implementation forCommonNetworkAclEntryOptionsOptions for CloudFormationInit.withConfigSets.A builder forConfigSetPropsAn implementation forConfigSetPropsOptions passed by the VPC when NAT needs to be configured.A builder forConfigureNatOptionsAn implementation forConfigureNatOptionsExample:A builder forConnectionRuleAn implementation forConnectionRuleManage the allowed network connections for constructs with Security Groups.A fluent builder forConnections.Properties to intialize a new Connections object.A builder forConnectionsPropsAn implementation forConnectionsPropsProvides the options for specifying the CPU credit type for burstable EC2 instance types (T2, T3, T3a, etc).CPU manufacturers supported by EC2 instances.Request for IPv6 CIDR block to be split up.A builder forCreateIpv6CidrBlocksRequestAn implementation forCreateIpv6CidrBlocksRequestThe default tenancy of instances launched into the VPC.Options for writing logs to a destination.A builder forDestinationOptionsAn implementation forDestinationOptionsBlock device options for an EBS volume.A builder forEbsDeviceOptionsAn implementation forEbsDeviceOptionsBase block device options for an EBS volume.A builder forEbsDeviceOptionsBaseAn implementation forEbsDeviceOptionsBaseProperties of an EBS block device.A builder forEbsDevicePropsAn implementation forEbsDevicePropsBlock device options for an EBS volume created from a snapshot.A builder forEbsDeviceSnapshotOptionsAn implementation forEbsDeviceSnapshotOptionsSupported EBS volume types for blockDevices.Options for the Vpc.enableVpnGateway() method.A builder forEnableVpnGatewayOptionsAn implementation forEnableVpnGatewayOptionsOptions when executing a file.A builder forExecuteFileOptionsAn implementation forExecuteFileOptionsA VPC flow log.A fluent builder forFlowLog.The destination type for the flow log.Flow Log Destination configuration.A builder forFlowLogDestinationConfigAn implementation forFlowLogDestinationConfigThe available destination types for Flow Logs.The file format for flow logs written to an S3 bucket destination.The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record.Options to add a flow log to a VPC.A builder forFlowLogOptionsAn implementation forFlowLogOptionsProperties of a VPC Flow Log.A builder forFlowLogPropsAn implementation forFlowLogPropsThe type of resource to create the flow log for.The type of VPC traffic to log.Pair represents a gateway created by NAT Provider.A builder forGatewayConfigAn implementation forGatewayConfigA gateway VPC endpoint.A fluent builder forGatewayVpcEndpoint.An AWS service for a gateway VPC endpoint.Options to add a gateway endpoint to a VPC.A builder forGatewayVpcEndpointOptionsAn implementation forGatewayVpcEndpointOptionsConstruction properties for a GatewayVpcEndpoint.A builder forGatewayVpcEndpointPropsAn implementation forGatewayVpcEndpointPropsConstruct a Linux machine image from an AMI map.A fluent builder forGenericLinuxImage.Configuration options for GenericLinuxImage.A builder forGenericLinuxImagePropsAn implementation forGenericLinuxImagePropsSelect the image based on a given SSM parameter at deployment time of the CloudFormation Stack.Construct a Windows machine image from an AMI map.A fluent builder forGenericWindowsImage.Configuration options for GenericWindowsImage.A builder forGenericWindowsImagePropsAn implementation forGenericWindowsImagePropsThe state of token usage for your instance metadata requests.A connection handler for client VPN endpoints.Internal default implementation forIClientVpnConnectionHandler.A proxy class which represents a concrete javascript instance of this type.A client VPN endpoint.Internal default implementation forIClientVpnEndpoint.A proxy class which represents a concrete javascript instance of this type.An object that has a Connections object.Internal default implementation forIConnectable.A proxy class which represents a concrete javascript instance of this type.A FlowLog.Internal default implementation forIFlowLog.A proxy class which represents a concrete javascript instance of this type.A gateway VPC endpoint.Internal default implementation forIGatewayVpcEndpoint.A proxy class which represents a concrete javascript instance of this type.A service for a gateway VPC endpoint.Internal default implementation forIGatewayVpcEndpointService.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIInstance.A proxy class which represents a concrete javascript instance of this type.An interface VPC endpoint.Internal default implementation forIInterfaceVpcEndpoint.A proxy class which represents a concrete javascript instance of this type.A service for an interface VPC endpoint.Internal default implementation forIInterfaceVpcEndpointService.A proxy class which represents a concrete javascript instance of this type.Implementations for ip address management.Internal default implementation forIIpAddresses.A proxy class which represents a concrete javascript instance of this type.Implementations for IPv6 address management.Internal default implementation forIIpv6Addresses.A proxy class which represents a concrete javascript instance of this type.An EC2 Key Pair.Internal default implementation forIKeyPair.A proxy class which represents a concrete javascript instance of this type.Interface for LaunchTemplate-like objects.Internal default implementation forILaunchTemplate.A proxy class which represents a concrete javascript instance of this type.Interface for classes that can select an appropriate machine image to use.Internal default implementation forIMachineImage.A proxy class which represents a concrete javascript instance of this type.A NetworkAcl.Internal default implementation forINetworkAcl.A proxy class which represents a concrete javascript instance of this type.A NetworkAclEntry.Internal default implementation forINetworkAclEntry.A proxy class which represents a concrete javascript instance of this type.Command to execute on the instance.Options for InitCommand.A builder forInitCommandOptionsAn implementation forInitCommandOptionsRepresents a duration to wait after a command has finished, in case of a reboot (Windows only).A collection of configuration elements.Base class for all CloudFormation Init elements.Create files on the EC2 instance.Additional options for creating an InitFile from an asset.A builder forInitFileAssetOptionsAn implementation forInitFileAssetOptionsOptions for InitFile.A builder forInitFileOptionsAn implementation forInitFileOptionsCreate Linux/UNIX groups and assign group IDs.A package to be installed during cfn-init time.A services that be enabled, disabled or restarted when the instance is launched.Options for an InitService.A builder forInitServiceOptionsAn implementation forInitServiceOptionsAn object that represents reasons to restart an InitService.Extract an archive into a directory.Additional options for an InitSource that builds an asset from local files.A builder forInitSourceAssetOptionsAn implementation forInitSourceAssetOptionsAdditional options for an InitSource.A builder forInitSourceOptionsAn implementation forInitSourceOptionsCreate Linux/UNIX users and to assign user IDs.Optional parameters used when creating a user.A builder forInitUserOptionsAn implementation forInitUserOptionsThis represents a single EC2 instance.A fluent builder forInstance.Identifies an instance's CPU architecture.What class and generation of instance to use.Instance generation categories for EC2.Provides the options for specifying the instance initiated shutdown behavior.Properties of an EC2 Instance.A builder forInstancePropsAn implementation forInstancePropsAspect that applies IMDS configuration on EC2 Instance constructs.A fluent builder forInstanceRequireImdsv2Aspect.Properties forInstanceRequireImdsv2Aspect.A builder forInstanceRequireImdsv2AspectPropsAn implementation forInstanceRequireImdsv2AspectPropsThe attributes for the instance types for a mixed instances policy.A builder forInstanceRequirementsConfigAn implementation forInstanceRequirementsConfigWhat size of instance to use.Instance type for EC2 instances.A interface VPC endpoint.A fluent builder forInterfaceVpcEndpoint.Construction properties for an ImportedInterfaceVpcEndpoint.A builder forInterfaceVpcEndpointAttributesAn implementation forInterfaceVpcEndpointAttributesAn AWS service for an interface VPC endpoint.A fluent builder forInterfaceVpcEndpointAwsService.Optional properties for the InterfaceVpcEndpointAwsService class.A builder forInterfaceVpcEndpointAwsServicePropsAn implementation forInterfaceVpcEndpointAwsServicePropsOptions to add an interface endpoint to a VPC.A builder forInterfaceVpcEndpointOptionsAn implementation forInterfaceVpcEndpointOptionsConstruction properties for an InterfaceVpcEndpoint.A builder forInterfaceVpcEndpointPropsAn implementation forInterfaceVpcEndpointPropsA custom-hosted service for an interface VPC endpoint.An abstract Provider of IpAddresses.IP address types supported for VPC endpoint service.Interface for classes that provide the peer-specification parts of a security group rule.Internal default implementation forIPeer.A proxy class which represents a concrete javascript instance of this type.Determines where your instances are placed on the underlying hardware according to the specified PlacementGroupStrategy.Internal default implementation forIPlacementGroup.A proxy class which represents a concrete javascript instance of this type.The types of IP addresses provisioned in the VPC.A prefix list.Internal default implementation forIPrefixList.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIPrivateSubnet.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIPublicSubnet.A proxy class which represents a concrete javascript instance of this type.An abstract Provider of Ipv6Addresses.An abstract route table.Internal default implementation forIRouteTable.A proxy class which represents a concrete javascript instance of this type.Interface for security group-like objects.Internal default implementation forISecurityGroup.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forISubnet.A proxy class which represents a concrete javascript instance of this type.A SubnetNetworkAclAssociation.Internal default implementation forISubnetNetworkAclAssociation.A proxy class which represents a concrete javascript instance of this type.An EBS Volume in AWS EC2.Internal default implementation forIVolume.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIVpc.A proxy class which represents a concrete javascript instance of this type.A VPC endpoint.Internal default implementation forIVpcEndpoint.A proxy class which represents a concrete javascript instance of this type.A VPC endpoint service.Internal default implementation forIVpcEndpointService.A proxy class which represents a concrete javascript instance of this type.A load balancer that can host a VPC Endpoint Service.Internal default implementation forIVpcEndpointServiceLoadBalancer.A proxy class which represents a concrete javascript instance of this type.Internal default implementation forIVpnConnection.A proxy class which represents a concrete javascript instance of this type.The virtual private gateway interface.Internal default implementation forIVpnGateway.A proxy class which represents a concrete javascript instance of this type.An EC2 Key Pair.A fluent builder forKeyPair.Attributes of a Key Pair.A builder forKeyPairAttributesAn implementation forKeyPairAttributesThe format of the Key Pair.The properties of a Key Pair.A builder forKeyPairPropsAn implementation forKeyPairPropsThe type of the key pair.This represents an EC2 LaunchTemplate.A fluent builder forLaunchTemplate.Attributes for an imported LaunchTemplate.A builder forLaunchTemplateAttributesAn implementation forLaunchTemplateAttributesThe state of token usage for your instance metadata requests.Properties of a LaunchTemplate.A builder forLaunchTemplatePropsAn implementation forLaunchTemplatePropsAspect that applies IMDS configuration on EC2 Launch Template constructs.A fluent builder forLaunchTemplateRequireImdsv2Aspect.Properties forLaunchTemplateRequireImdsv2Aspect.A builder forLaunchTemplateRequireImdsv2AspectPropsAn implementation forLaunchTemplateRequireImdsv2AspectPropsA class that provides convenient access to special version tokens for LaunchTemplate versions.Interface for the Spot market instance options provided in a LaunchTemplate.A builder forLaunchTemplateSpotOptionsAn implementation forLaunchTemplateSpotOptionsOptions when constructing UserData for Linux.A builder forLinuxUserDataOptionsAn implementation forLinuxUserDataOptionsLocal storage support requirements for EC2 instances.Types of local storage available for EC2 instances.Options for InitPackage.rpm/InitPackage.msi.A builder forLocationPackageOptionsAn implementation forLocationPackageOptionsThe following table describes all of the available fields for a flow log record.A machine image whose AMI ID will be searched using DescribeImages.A fluent builder forLookupMachineImage.Properties for looking up an image.A builder forLookupMachineImagePropsAn implementation forLookupMachineImagePropsFactory functions for standard Amazon Machine Image objects.Configuration for a machine image.A builder forMachineImageConfigAn implementation forMachineImageConfigThe base class for all classes which can be used asMultipartUserData.Options when creatingMultipartBody.A builder forMultipartBodyOptionsAn implementation forMultipartBodyOptionsMime multipart user data.A fluent builder forMultipartUserData.Options for creatingMultipartUserData.A builder forMultipartUserDataOptionsAn implementation forMultipartUserDataOptionsOptions for InitPackage.yum/apt/rubyGem/python.A builder forNamedPackageOptionsAn implementation forNamedPackageOptionsProperties for a NAT gateway.A builder forNatGatewayPropsAn implementation forNatGatewayPropsProvider for NAT Gateways.A fluent builder forNatGatewayProvider.Machine image representing the latest NAT instance image.Properties for a NAT instance.A builder forNatInstancePropsAn implementation forNatInstancePropsDeprecated.use NatInstanceProviderV2.Deprecated.Modern NAT provider which uses NAT Instances.A fluent builder forNatInstanceProviderV2.NAT providers.Direction of traffic to allow all by default.Define a new custom network ACL.A fluent builder forNetworkAcl.Define an entry in a Network ACL table.A fluent builder forNetworkAclEntry.Properties to create NetworkAclEntry.A builder forNetworkAclEntryPropsAn implementation forNetworkAclEntryPropsProperties to create NetworkAcl.A builder forNetworkAclPropsAn implementation forNetworkAclPropsThe OS type of a particular image.Peer object factories (to be used in Security Group management).Defines a placement group.A fluent builder forPlacementGroup.Props for a PlacementGroup.A builder forPlacementGroupPropsAn implementation forPlacementGroupPropsDetermines how this placement group spreads instances.Which strategy to use when launching instances.Interface for classes that provide the connection-specification parts of a security group rule.A fluent builder forPort.Properties to create a port range.A builder forPortPropsAn implementation forPortPropsA managed prefix list.A fluent builder forPrefixList.Properties for looking up an existing managed prefix list.A builder forPrefixListLookupOptionsAn implementation forPrefixListLookupOptionsOptions to add a prefix list.A builder forPrefixListOptionsAn implementation forPrefixListOptionsProperties for creating a prefix list.A builder forPrefixListPropsAn implementation forPrefixListPropsRepresents a private VPC subnet resource.A fluent builder forPrivateSubnet.Example:A builder forPrivateSubnetAttributesAn implementation forPrivateSubnetAttributesExample:A builder forPrivateSubnetPropsAn implementation forPrivateSubnetPropsProtocol for use in Connection Rules.Represents a public VPC subnet resource.A fluent builder forPublicSubnet.Example:A builder forPublicSubnetAttributesAn implementation forPublicSubnetAttributesExample:A builder forPublicSubnetPropsAn implementation forPublicSubnetPropsSubnet requested for allocation.A builder forRequestedSubnetAn implementation forRequestedSubnetSelect the image based on a given SSM parameter at instance launch time.A fluent builder forResolveSsmParameterAtLaunchImage.Type of router used in route.The scope and id in which a given SecurityGroup rule should be defined.A builder forRuleScopeAn implementation forRuleScopeOptions for writing logs to a S3 destination.A builder forS3DestinationOptionsAn implementation forS3DestinationOptionsOptions when downloading files from S3.A builder forS3DownloadOptionsAn implementation forS3DownloadOptionsCreates an Amazon EC2 security group within a VPC.A fluent builder forSecurityGroup.Additional options for imported security groups.A builder forSecurityGroupImportOptionsAn implementation forSecurityGroupImportOptionsExample:A builder forSecurityGroupPropsAn implementation forSecurityGroupPropsResult of selecting a subset of subnets from a VPC.A builder forSelectedSubnetsAn implementation forSelectedSubnetsThe service manager that will be used by InitServices.Provides the options for the types of interruption for spot instances.The Spot Instance request type.Properties for GenericSsmParameterImage.A builder forSsmParameterImageOptionsAn implementation forSsmParameterImageOptionsRepresents a new VPC subnet resource.A fluent builder forSubnet.Example:A builder forSubnetAttributesAn implementation forSubnetAttributesSpecify configuration parameters for a single subnet group in a VPC.A builder forSubnetConfigurationAn implementation forSubnetConfigurationContains logic which chooses a set of subnets from a larger list, in conjunction with SubnetSelection, to determine where to place AWS resources such as VPC endpoints, EC2 instances, etc.CIDR Allocated Subnets.A builder forSubnetIpamOptionsAn implementation forSubnetIpamOptionsExample:A fluent builder forSubnetNetworkAclAssociation.Properties to create a SubnetNetworkAclAssociation.A builder forSubnetNetworkAclAssociationPropsAn implementation forSubnetNetworkAclAssociationPropsSpecify configuration parameters for a VPC subnet.A builder forSubnetPropsAn implementation forSubnetPropsCustomize subnets that are selected for placement of ENIs.A builder forSubnetSelectionAn implementation forSubnetSelectionThe type of Subnet.Options for creating a SystemD configuration file.A builder forSystemdConfigFileOptionsAn implementation forSystemdConfigFileOptionsDirection of traffic the AclEntry applies to.Transport protocol for client VPN.Instance User Data.Creates a new EBS Volume in AWS EC2.A fluent builder forVolume.Attributes required to import an existing EBS Volume into the Stack.A builder forVolumeAttributesAn implementation forVolumeAttributesProperties of an EBS Volume.A builder forVolumePropsAn implementation forVolumePropsDefine an AWS Virtual Private Cloud.A fluent builder forVpc.Properties that reference an external Vpc.A builder forVpcAttributesAn implementation forVpcAttributesEnums for all Dns Record IP Address types.IP address type for the endpoint.Indicates whether to enable private DNS only for inbound endpoints.A VPC endpoint service.A fluent builder forVpcEndpointService.Construction properties for a VpcEndpointService.A builder forVpcEndpointServicePropsAn implementation forVpcEndpointServicePropsThe type of VPC endpoint.CIDR Allocated Vpc.A builder forVpcIpamOptionsAn implementation forVpcIpamOptionsProperties for looking up an existing VPC.A builder forVpcLookupOptionsAn implementation forVpcLookupOptionsConfiguration for Vpc.A builder forVpcPropsAn implementation forVpcPropsDefine a VPN Connection.A fluent builder forVpnConnection.Attributes of an imported VpnConnection.A builder forVpnConnectionAttributesAn implementation forVpnConnectionAttributesBase class for Vpn connections.Example:A builder forVpnConnectionOptionsAn implementation forVpnConnectionOptionsExample:A builder forVpnConnectionPropsAn implementation forVpnConnectionPropsThe VPN connection type.The VPN Gateway that shall be added to the VPC.A fluent builder forVpnGateway.The VpnGateway Properties.A builder forVpnGatewayPropsAn implementation forVpnGatewayPropsPort for client VPN.Example:A builder forVpnTunnelOptionAn implementation forVpnTunnelOptionSelect the latest version of the indicated Windows version.A fluent builder forWindowsImage.Configuration options for WindowsImage.A builder forWindowsImagePropsAn implementation forWindowsImagePropsOptions when constructing UserData for Windows.A builder forWindowsUserDataOptionsAn implementation forWindowsUserDataOptionsThe Windows version to use for the WindowsImage.