# InstanceType

Instance type for EC2 instances.

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

Superclass of: [OptimalInstanceType](/cdk/api/v2/docs/aws-cdk-lib.aws_batch.OptimalInstanceType.html)
Obtainable from: InstanceType.of

- Source: [`aws-ec2/lib/instance-types.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-ec2/lib/instance-types.ts#L1853)
- Type last changed: v2.131.0 · 1 Mar 2024

## Example

TypeScript:

```ts
declare const vpc: ec2.Vpc;

const cluster = new docdb.DatabaseCluster(this, 'Database', {
  masterUser: {
    username: 'myuser',
  },
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.MEMORY5, ec2.InstanceSize.LARGE),
  vpcSubnets: {
    subnetType: ec2.SubnetType.PUBLIC,
  },
  vpc,
  removalPolicy: RemovalPolicy.SNAPSHOT,
});
```

Python:

```python
# vpc: ec2.Vpc

cluster = docdb.DatabaseCluster(self, "Database",
    master_user=docdb.Login(
        username="myuser"
    ),
    instance_type=ec2.InstanceType.of(ec2.InstanceClass.MEMORY5, ec2.InstanceSize.LARGE),
    vpc_subnets=ec2.SubnetSelection(
        subnet_type=ec2.SubnetType.PUBLIC
    ),
    vpc=vpc,
    removal_policy=RemovalPolicy.SNAPSHOT
)
```

Java:

```java
Vpc vpc;

DatabaseCluster cluster = DatabaseCluster.Builder.create(this, "Database")
        .masterUser(Login.builder()
                .username("myuser")
                .build())
        .instanceType(InstanceType.of(InstanceClass.MEMORY5, InstanceSize.LARGE))
        .vpcSubnets(SubnetSelection.builder()
                .subnetType(SubnetType.PUBLIC)
                .build())
        .vpc(vpc)
        .removalPolicy(RemovalPolicy.SNAPSHOT)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Vpc vpc;

var cluster = new DatabaseCluster(this, "Database", new DatabaseClusterProps {
    MasterUser = new Login {
        Username = "myuser"
    },
    InstanceType = InstanceType.Of(InstanceClass.MEMORY5, InstanceSize.LARGE),
    VpcSubnets = new SubnetSelection {
        SubnetType = SubnetType.PUBLIC
    },
    Vpc = vpc,
    RemovalPolicy = RemovalPolicy.SNAPSHOT
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var vpc Vpc

cluster := docdb.NewDatabaseCluster(this, jsii.String("Database"), &DatabaseClusterProps{
	MasterUser: &Login{
		Username: jsii.String("myuser"),
	},
	InstanceType: ec2.InstanceType_Of(ec2.InstanceClass_MEMORY5, ec2.InstanceSize_LARGE),
	VpcSubnets: &SubnetSelection{
		SubnetType: ec2.SubnetType_PUBLIC,
	},
	Vpc: Vpc,
	RemovalPolicy: awscdk.RemovalPolicy_SNAPSHOT,
})
```

## Initializer

TypeScript:

```ts
new InstanceType(instanceTypeIdentifier: string)
```

Python:

```python
InstanceType(instance_type_identifier: str)
```

Java:

```java
new InstanceType(String instanceTypeIdentifier)
```

C# / .NET:

```csharp
new InstanceType(string instanceTypeIdentifier)
```

Golang:

```go
NewInstanceType(InstanceTypeIdentifier *string)
```

## Properties

- `architecture`: [InstanceArchitecture](/cdk/api/v2/docs/aws-cdk-lib.aws_ec2.InstanceArchitecture.html) — The instance's CPU architecture.

## Methods

- `isBurstable(): boolean` — Return whether this instance type is a burstable instance type.

- `of(instanceClass: InstanceClass, instanceSize: InstanceSize): InstanceType // chainable` (static) — 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.

- `sameInstanceClassAs(other: InstanceType): boolean`

- `toString(): string` — Return the instance type as a dotted string.
