Skip to content

Commit

Permalink
chore: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nmussy committed Apr 4, 2024
1 parent fa4c5a9 commit 62248ec
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion packages/aws-cdk-lib/aws-ec2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ If you prefer to use a custom AMI, use `machineImage:
MachineImage.genericLinux({ ... })` and configure the right AMI ID for the
regions you want to deploy to.

> **Warning**
> The NAT instances created using this method will be **unmonitored**.
> They are not part of an Auto Scaling Group,
> and if they become unavailable or are terminated for any reason,
> will not be restarted or replaced.
By default, the NAT instances will route all traffic. To control what traffic
gets routed, pass a custom value for `defaultAllowedTraffic` and access the
`NatInstanceProvider.connections` member after having passed the NAT provider to
Expand All @@ -212,9 +218,36 @@ new ec2.Vpc(this, 'TheVPC', {
provider.connections.allowFrom(ec2.Peer.ipv4('1.2.3.4/8'), ec2.Port.tcp(80));
```

You can also customize the characteritics of your NAT instances, as well as their initialization scripts:

```ts
declare const bucket: s3.Bucket;

const userData = ec2.UserData.forLinux();
userData.addCommands(
...ec2.NatInstanceProviderV2.DEFAULT_USER_DATA_COMMANDS,
'echo "hello world!" > hello.txt',
`aws s3 cp hello.txt s3://${bucket.bucketName}`,
);

const provider = ec2.NatProvider.instanceV2({
instanceType: new ec2.InstanceType('t3.small'),
creditSpecification: ec2.CpuCredits.UNLIMITED,
});

new ec2.Vpc(this, 'TheVPC', {
natGatewayProvider: provider,
natGateways: 2,
});

for (const gateway of natGatewayProvider.gatewayInstances) {
bucket.grantWrite(gateway);
}
```

[using NAT instances](test/integ.nat-instances.lit.ts) [Deprecated]

The construct will use the AWS official NAT instance AMI, which has already
The V1 `NatProvider.instance` construct will use the AWS official NAT instance AMI, which has already
reached EOL on Dec 31, 2023. For more information, see the following blog post:
[Amazon Linux AMI end of life](https://aws.amazon.com/blogs/aws/update-on-amazon-linux-ami-end-of-life/).

Expand Down

0 comments on commit 62248ec

Please sign in to comment.