Skip to content

Commit

Permalink
feat(ec2): NatInstanceProviderV2 improvements (#29729)
Browse files Browse the repository at this point in the history
### Issue # (if applicable)

Closes #29720

Might fix other issues, will need check the backlog

### Reason for this change

The user data script used to initialize NAT instances was at present incorrect, assuming an incorrect default interface name. I wanted to both update this script, and allow CDK users to update this user data if needed in the future, both in case of an issue with the script or just to extend/override the initialization procedure.

### Description of changes

Apologies for the non-atomic PR, as I was working on the unit and integration tests, I noticed additional issues and missing features. These are the initially targeted changes:

* Add `userData` field to `NatInstanceProps`, allowing the user to overwrite the NAT instances initialization script
  * Add static `NatInstanceProps.DEFAULT_USER_DATA_COMMANDS` field, allowing the user to more easily extend the default script
* Fix default `userData` to query the instance `default` network interface, instead of always using `eth0`

These were found along the way:

* Add getter `gatewayInstances` method to `NatInstanceProps`, allowing the user to interact with the created NAT instances once they're attached to the VPC
  * This allowed me to give the instance role additional permissions, but has more potential uses
* Fix `creditSpecification` not being implemented correctly
* Updated existing unit and integ tests to increase coverage
* Add warning in `README` about potential issues with NAT instances as is implemented

### Description of how you validated changes

I've updated and added unit and integration tests

### 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
nmussy committed Apr 8, 2024
1 parent 067c4a5 commit 4eb02a4
Show file tree
Hide file tree
Showing 22 changed files with 70,453 additions and 41 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.

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

Loading

0 comments on commit 4eb02a4

Please sign in to comment.