Skip to content
v2.277.0

OperatingSystemType Enum ​

The OS type of a particular image.

Example ​

ts
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
const amznLinux = ec2.MachineImage.latestAmazonLinux({
  generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX,
  edition: ec2.AmazonLinuxEdition.STANDARD,
  virtualization: ec2.AmazonLinuxVirt.HVM,
  storage: ec2.AmazonLinuxStorage.GENERAL_PURPOSE,
  cpuType: ec2.AmazonLinuxCpuType.X86_64,
});

// Pick a Windows edition to use
const windows = ec2.MachineImage.latestWindows(ec2.WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);

// Read AMI id from SSM parameter store
const ssm = ec2.MachineImage.fromSsmParameter('/my/ami', { os: ec2.OperatingSystemType.LINUX });

// 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:
const natAmi = ec2.MachineImage.lookup({
  name: 'amzn-ami-vpc-nat-*',
  owners: ['amazon'],
});

// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
const linux = ec2.MachineImage.genericLinux({
  '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:
const genericWindows = ec2.MachineImage.genericWindows({
  'us-east-1': 'ami-97785bed',
  'eu-west-1': 'ami-12345678',
  // ...
});
python
# Pick the right Amazon Linux edition. All arguments shown are optional
# and will default to these values when omitted.
amzn_linux = ec2.MachineImage.latest_amazon_linux(
    generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX,
    edition=ec2.AmazonLinuxEdition.STANDARD,
    virtualization=ec2.AmazonLinuxVirt.HVM,
    storage=ec2.AmazonLinuxStorage.GENERAL_PURPOSE,
    cpu_type=ec2.AmazonLinuxCpuType.X86_64
)

# Pick a Windows edition to use
windows = ec2.MachineImage.latest_windows(ec2.WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE)

# Read AMI id from SSM parameter store
ssm = ec2.MachineImage.from_ssm_parameter("/my/ami", os=ec2.OperatingSystemType.LINUX)

# 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:
nat_ami = ec2.MachineImage.lookup(
    name="amzn-ami-vpc-nat-*",
    owners=["amazon"]
)

# For other custom (Linux) images, instantiate a `GenericLinuxImage` with
# a map giving the AMI to in for each region:
linux = ec2.MachineImage.generic_linux({
    "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:
generic_windows = ec2.MachineImage.generic_windows({
    "us-east-1": "ami-97785bed",
    "eu-west-1": "ami-12345678"
})
java
// 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"));
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
var amznLinux = MachineImage.LatestAmazonLinux(new AmazonLinuxImageProps {
    Generation = AmazonLinuxGeneration.AMAZON_LINUX,
    Edition = AmazonLinuxEdition.STANDARD,
    Virtualization = AmazonLinuxVirt.HVM,
    Storage = AmazonLinuxStorage.GENERAL_PURPOSE,
    CpuType = AmazonLinuxCpuType.X86_64
});

// Pick a Windows edition to use
var windows = MachineImage.LatestWindows(WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);

// Read AMI id from SSM parameter store
var ssm = MachineImage.FromSsmParameter("/my/ami", new SsmParameterImageOptions { Os = OperatingSystemType.LINUX });

// 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:
var natAmi = MachineImage.Lookup(new LookupMachineImageProps {
    Name = "amzn-ami-vpc-nat-*",
    Owners = new [] { "amazon" }
});

// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
var linux = MachineImage.GenericLinux(new Dictionary<string, string> {
    { "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:
var genericWindows = MachineImage.GenericWindows(new Dictionary<string, string> {
    { "us-east-1", "ami-97785bed" },
    { "eu-west-1", "ami-12345678" }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
amznLinux := ec2.MachineImage_LatestAmazonLinux(&AmazonLinuxImageProps{
	Generation: ec2.AmazonLinuxGeneration_AMAZON_LINUX,
	Edition: ec2.AmazonLinuxEdition_STANDARD,
	Virtualization: ec2.AmazonLinuxVirt_HVM,
	Storage: ec2.AmazonLinuxStorage_GENERAL_PURPOSE,
	CpuType: ec2.AmazonLinuxCpuType_X86_64,
})

// Pick a Windows edition to use
windows := ec2.MachineImage_LatestWindows(ec2.WindowsVersion_WINDOWS_SERVER_2019_ENGLISH_FULL_BASE)

// Read AMI id from SSM parameter store
ssm := ec2.MachineImage_FromSsmParameter(jsii.String("/my/ami"), &SsmParameterImageOptions{
	Os: ec2.OperatingSystemType_LINUX,
})

// 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:
natAmi := ec2.MachineImage_Lookup(&LookupMachineImageProps{
	Name: jsii.String("amzn-ami-vpc-nat-*"),
	Owners: []*string{
		jsii.String("amazon"),
	},
})

// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
linux := ec2.MachineImage_GenericLinux(map[string]*string{
	"us-east-1": jsii.String("ami-97785bed"),
	"eu-west-1": jsii.String("ami-12345678"),
})

// For other custom (Windows) images, instantiate a `GenericWindowsImage` with
// a map giving the AMI to in for each region:
genericWindows := ec2.MachineImage_GenericWindows(map[string]*string{
	"us-east-1": jsii.String("ami-97785bed"),
	"eu-west-1": jsii.String("ami-12345678"),
})

Members ​

MemberDescription
LINUX
WINDOWS
UNKNOWNUsed when the type of the operating system is not known (for example, for imported Auto-Scaling Groups).

Referenced by ​