# AmazonLinuxImage

Selects the latest version of Amazon Linux.

This Machine Image automatically updates to the latest version on every
deployment. Be aware this will cause your instances to be replaced when a
new version of the image becomes available. Do not store stateful information
on the instance if you are using this image.

The AMI ID is selected using the values published to the SSM parameter store.

Extends: GenericSSMParameterImage › AmazonLinuxImage
Implements: IMachineImage

- Source: [`aws-ec2/lib/machine-image/machine-image.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-ec2/lib/machine-image/machine-image.ts#L493)

## Example

```ts
declare const vpc: ec2.IVpc;
const lb = new elb.LoadBalancer(this, 'LB', {
  vpc,
  internetFacing: true,
});

// instance to add as the target for load balancer.
const instance = new ec2.Instance(this, 'targetInstance', {
  vpc: vpc,
  instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
  machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 }),
});
lb.addTarget(new elb.InstanceTarget(instance));
```

## Initializer

```ts
new AmazonLinuxImage(props?: AmazonLinuxImageProps)
```

## Properties

- `parameterName`: string — Name of the SSM parameter we're looking up.

## Methods

- `getImage(scope: Construct): MachineImageConfig` — Return the image to use in the given context.

- `ssmParameterName(props?: AmazonLinuxImageProps): string` (static) — Return the SSM parameter name that will contain the Amazon Linux image with the given attributes.
