GenericLinuxImage Class
Construct a Linux machine image from an AMI map.
Linux images IDs are not published to SSM parameter store yet, so you'll have to manually specify an AMI map.
Example
ts
// Pick a Windows edition to use
const windows = new ec2.WindowsImage(ec2.WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
const amznLinux = new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX,
edition: ec2.AmazonLinuxEdition.STANDARD,
virtualization: ec2.AmazonLinuxVirt.HVM,
storage: ec2.AmazonLinuxStorage.GENERAL_PURPOSE,
});
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
const linux = new ec2.GenericLinuxImage({
'us-east-1': 'ami-97785bed',
'eu-west-1': 'ami-12345678',
// ...
});
python
# Pick a Windows edition to use
windows = ec2.WindowsImage(ec2.WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE)
# Pick the right Amazon Linux edition. All arguments shown are optional
# and will default to these values when omitted.
amzn_linux = ec2.AmazonLinuxImage(
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX,
edition=ec2.AmazonLinuxEdition.STANDARD,
virtualization=ec2.AmazonLinuxVirt.HVM,
storage=ec2.AmazonLinuxStorage.GENERAL_PURPOSE
)
# For other custom (Linux) images, instantiate a `GenericLinuxImage` with
# a map giving the AMI to in for each region:
linux = ec2.GenericLinuxImage({
"us-east-1": "ami-97785bed",
"eu-west-1": "ami-12345678"
})
java
// Pick a Windows edition to use
WindowsImage windows = new WindowsImage(WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
AmazonLinuxImage amznLinux = AmazonLinuxImage.Builder.create()
.generation(AmazonLinuxGeneration.AMAZON_LINUX)
.edition(AmazonLinuxEdition.STANDARD)
.virtualization(AmazonLinuxVirt.HVM)
.storage(AmazonLinuxStorage.GENERAL_PURPOSE)
.build();
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
GenericLinuxImage linux = new GenericLinuxImage(Map.of(
"us-east-1", "ami-97785bed",
"eu-west-1", "ami-12345678"));
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Pick a Windows edition to use
var windows = new WindowsImage(WindowsVersion.WINDOWS_SERVER_2019_ENGLISH_FULL_BASE);
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
var amznLinux = new AmazonLinuxImage(new AmazonLinuxImageProps {
Generation = AmazonLinuxGeneration.AMAZON_LINUX,
Edition = AmazonLinuxEdition.STANDARD,
Virtualization = AmazonLinuxVirt.HVM,
Storage = AmazonLinuxStorage.GENERAL_PURPOSE
});
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
var linux = new GenericLinuxImage(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 a Windows edition to use
windows := ec2.NewWindowsImage(ec2.WindowsVersion_WINDOWS_SERVER_2019_ENGLISH_FULL_BASE)
// Pick the right Amazon Linux edition. All arguments shown are optional
// and will default to these values when omitted.
amznLinux := ec2.NewAmazonLinuxImage(&AmazonLinuxImageProps{
Generation: ec2.AmazonLinuxGeneration_AMAZON_LINUX,
Edition: ec2.AmazonLinuxEdition_STANDARD,
Virtualization: ec2.AmazonLinuxVirt_HVM,
Storage: ec2.AmazonLinuxStorage_GENERAL_PURPOSE,
})
// For other custom (Linux) images, instantiate a `GenericLinuxImage` with
// a map giving the AMI to in for each region:
linux := ec2.NewGenericLinuxImage(map[string]*string{
"us-east-1": jsii.String("ami-97785bed"),
"eu-west-1": jsii.String("ami-12345678"),
})
Initializer
ts
new GenericLinuxImage(amiMap: { [key: string]: string }, props?: GenericLinuxImageProps)
python
GenericLinuxImage(ami_map: typing.Mapping[str, str], props: typing.Optional[GenericLinuxImageProps] = None)
java
new GenericLinuxImage(Map<String, String> amiMap, GenericLinuxImageProps props)
csharp
new GenericLinuxImage(IDictionary<string, string> amiMap, GenericLinuxImageProps? props = null)
go
NewGenericLinuxImage(AmiMap *map[string]*string, Props GenericLinuxImageProps)
Methods
getImage(scope: Construct): MachineImageConfigdef get_image(self, scope: Construct) -> MachineImageConfigpublic MachineImageConfig getImage(Construct scope)public MachineImageConfig GetImage(Construct scope)func GetImage(Scope Construct) MachineImageConfig#Return the image to use in the given context.