Skip to content

Commit

Permalink
chore(ec2): choose NAT instance v2 machineImage cpuType automatically…
Browse files Browse the repository at this point in the history
… from instanceType (#30558)

### Issue # (if applicable)
n/a

### Reason for this change

When configuring NAT instance v2, currently we have to set machineImage manually when we want to use a graviton instance.

Like this:

```ts
const vpc = new Vpc(this, 'Vpc', {
  natGatewayProvider: NatProvider.instanceV2({
    instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.NANO),
    // we should be able to omit this line!
    machineImage: MachineImage.latestAmazonLinux2023({ cpuType: AmazonLinuxCpuType.ARM_64 }),
  }),
});
```

This can be easily avoided if Nat instance v2 construct decides which cpu type to use for the given instance type.

### Description of changes

Use `instanceType.architecture` to choose cpu type of a machine image.

Now we can remove the redundant code:

```ts
const vpc = new Vpc(this, 'Vpc', {
  natGatewayProvider: NatProvider.instanceV2({
    instanceType: InstanceType.of(InstanceClass.T4G, InstanceSize.NANO),
  }),
});
```

### Description of how you validated changes

Added an integ test.
### Checklist
- [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
tmokmss authored Jun 21, 2024
1 parent a598508 commit f93c2ef
Show file tree
Hide file tree
Showing 11 changed files with 34,181 additions and 3 deletions.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f93c2ef

Please # to comment.