# InstanceSize

What size of instance to use.

Used as argument in: [AcceleratorType.of](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_stepfunctions_tasks.AcceleratorType.html#of), [InstanceType.of](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceType.html#of)

- Source: [`aws-ec2/lib/instance-types.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ec2/lib/instance-types.ts#L1700)
- Type last changed: v2.174.0 · 4 Jan 2025

## Example

TypeScript:

```ts
// Creates a distribution from an EC2 instance
declare const vpc: ec2.Vpc;
// Create an EC2 instance in a VPC. 'subnetType' can be private.
const instance = new ec2.Instance(this, 'Instance', {
  vpc,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MICRO),
  machineImage: ec2.MachineImage.latestAmazonLinux2023(),
  vpcSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
});
new cloudfront.Distribution(this, 'myDist', {
  defaultBehavior: { origin: origins.VpcOrigin.withEc2Instance(instance) },
});
```

Python:

```python
# Creates a distribution from an EC2 instance
# vpc: ec2.Vpc

# Create an EC2 instance in a VPC. 'subnetType' can be private.
instance = ec2.Instance(self, "Instance",
    vpc=vpc,
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE3, ec2.InstanceSize.MICRO),
    machine_image=ec2.MachineImage.latest_amazon_linux2023(),
    vpc_subnets=ec2.SubnetSelection(subnet_type=ec2.SubnetType.PRIVATE_WITH_EGRESS)
)
cloudfront.Distribution(self, "myDist",
    default_behavior=cloudfront.BehaviorOptions(origin=origins.VpcOrigin.with_ec2_instance(instance))
)
```

Java:

```java
// Creates a distribution from an EC2 instance
Vpc vpc;

// Create an EC2 instance in a VPC. 'subnetType' can be private.
Instance instance = Instance.Builder.create(this, "Instance")
        .vpc(vpc)
        .instanceType(InstanceType.of(InstanceClass.BURSTABLE3, InstanceSize.MICRO))
        .machineImage(MachineImage.latestAmazonLinux2023())
        .vpcSubnets(SubnetSelection.builder().subnetType(SubnetType.PRIVATE_WITH_EGRESS).build())
        .build();
Distribution.Builder.create(this, "myDist")
        .defaultBehavior(BehaviorOptions.builder().origin(VpcOrigin.withEc2Instance(instance)).build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// Creates a distribution from an EC2 instance
Vpc vpc;

// Create an EC2 instance in a VPC. 'subnetType' can be private.
var instance = new Instance(this, "Instance", new InstanceProps {
    Vpc = vpc,
    InstanceType = InstanceType.Of(InstanceClass.BURSTABLE3, InstanceSize.MICRO),
    MachineImage = MachineImage.LatestAmazonLinux2023(),
    VpcSubnets = new SubnetSelection { SubnetType = SubnetType.PRIVATE_WITH_EGRESS }
});
new Distribution(this, "myDist", new DistributionProps {
    DefaultBehavior = new BehaviorOptions { Origin = VpcOrigin.WithEc2Instance(instance) }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Creates a distribution from an EC2 instance
var vpc Vpc

// Create an EC2 instance in a VPC. 'subnetType' can be private.
instance := ec2.NewInstance(this, jsii.String("Instance"), &InstanceProps{
	Vpc: Vpc,
	InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_BURSTABLE3, ec2.InstanceSize_MICRO),
	MachineImage: ec2.MachineImage_LatestAmazonLinux2023(),
	VpcSubnets: &SubnetSelection{
		SubnetType: ec2.SubnetType_PRIVATE_WITH_EGRESS,
	},
})
cloudfront.NewDistribution(this, jsii.String("myDist"), &DistributionProps{
	DefaultBehavior: &BehaviorOptions{
		Origin: origins.VpcOrigin_WithEc2Instance(instance),
	},
})
```

## Members

| Member | Description |
| --- | --- |
| `NANO` | Instance size NANO (nano). |
| `MICRO` | Instance size MICRO (micro). |
| `SMALL` | Instance size SMALL (small). |
| `MEDIUM` | Instance size MEDIUM (medium). |
| `LARGE` | Instance size LARGE (large). |
| `XLARGE` | Instance size XLARGE (xlarge). |
| `XLARGE2` | Instance size XLARGE2 (2xlarge). |
| `XLARGE3` | Instance size XLARGE3 (3xlarge). |
| `XLARGE4` | Instance size XLARGE4 (4xlarge). |
| `XLARGE6` | Instance size XLARGE6 (6xlarge). |
| `XLARGE8` | Instance size XLARGE8 (8xlarge). |
| `XLARGE9` | Instance size XLARGE9 (9xlarge). |
| `XLARGE10` | Instance size XLARGE10 (10xlarge). |
| `XLARGE12` | Instance size XLARGE12 (12xlarge). |
| `XLARGE16` | Instance size XLARGE16 (16xlarge). |
| `XLARGE18` | Instance size XLARGE18 (18xlarge). |
| `XLARGE24` | Instance size XLARGE24 (24xlarge). |
| `XLARGE32` | Instance size XLARGE32 (32xlarge). |
| `XLARGE48` | Instance size XLARGE48 (48xlarge). |
| `XLARGE56` | Instance size XLARGE56 (56xlarge). |
| `XLARGE96` | Instance size XLARGE96 (96xlarge). |
| `XLARGE112` | Instance size XLARGE112 (112xlarge). |
| `XLARGE224` | Instance size XLARGE224 (224xlarge). |
| `XLARGE480` | Instance size XLARGE480 (480xlarge). |
| `METAL` | Instance size METAL (metal). |
| `XLARGE16METAL` | Instance size XLARGE16METAL (metal-16xl). |
| `XLARGE24METAL` | Instance size XLARGE24METAL (metal-24xl). |
| `XLARGE32METAL` | Instance size XLARGE32METAL (metal-32xl). |
| `XLARGE48METAL` | Instance size XLARGE48METAL (metal-48xl). |
