aws-cdk-lib.aws_ec2.InstanceType

class InstanceType

LanguageType name
.NETAmazon.CDK.AWS.EC2.InstanceType
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awsec2#InstanceType
Javasoftware.amazon.awscdk.services.ec2.InstanceType
Pythonaws_cdk.aws_ec2.InstanceType
TypeScript (source)aws-cdk-lib » aws_ec2 » InstanceType

Instance type for EC2 instances.

This class takes a literal string, good if you already know the identifier of the type you want.

Example

declare const vpc: ec2.Vpc;

const mySecurityGroup = new ec2.SecurityGroup(this, 'SecurityGroup', { vpc });
new autoscaling.AutoScalingGroup(this, 'ASG', {
  vpc,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
  machineImage: ec2.MachineImage.latestAmazonLinux({
    generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
  }),
  securityGroup: mySecurityGroup,
});

Initializer

new InstanceType(instanceTypeIdentifier: string)

Parameters

  • instanceTypeIdentifier string

Properties

NameTypeDescription
architectureInstanceArchitectureThe instance's CPU architecture.

architecture

Type: InstanceArchitecture

The instance's CPU architecture.

Methods

NameDescription
sameInstanceClassAs(other)
toString()Return the instance type as a dotted string.
static of(instanceClass, instanceSize)Instance type for EC2 instances.

sameInstanceClassAs(other)

public sameInstanceClassAs(other: InstanceType): boolean

Parameters

  • other InstanceType

Returns

  • boolean

toString()

public toString(): string

Returns

  • string

Return the instance type as a dotted string.


static of(instanceClass, instanceSize)

public static of(instanceClass: InstanceClass, instanceSize: InstanceSize): InstanceType

Parameters

  • instanceClass InstanceClass
  • instanceSize InstanceSize

Returns

  • InstanceType

Instance type for EC2 instances.

This class takes a combination of a class and size.

Be aware that not all combinations of class and size are available, and not all classes are available in all regions.