Skip to content

EC2: implement determinstic subnet ID generation #11853

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2024

Conversation

simonrw
Copy link
Contributor

@simonrw simonrw commented Nov 14, 2024

Motivation

In order to support the AWS replicator use case, we need to be able to generate predictable IDs for subnets.

We follow the pattern from the VPC replication (in #11772).

Changes

  • Add predictable ID generation

Testing

Tests are implemented in our ext test suite

@simonrw simonrw added the semver: patch Non-breaking changes which can be included in patch releases label Nov 14, 2024
@simonrw simonrw self-assigned this Nov 14, 2024
Copy link

github-actions bot commented Nov 14, 2024

LocalStack Community integration with Pro

 2 files   2 suites   23s ⏱️
22 tests 20 ✅ 2 💤 0 ❌
24 runs  20 ✅ 4 💤 0 ❌

Results for commit 52cc5c7f.

♻️ This comment has been updated with latest results.

@simonrw simonrw marked this pull request as ready for review November 15, 2024 02:21
Copy link
Contributor

@cloutierMat cloutierMat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM

Comment on lines +32 to +39
@localstack_id
def generate_subnet_id(
resource_identifier: ResourceIdentifier,
existing_ids: ExistingIds = None,
tags: Tags = None,
) -> str:
# We return an empty string here to differentiate between when a custom ID was used, or when it was randomly generated by `moto`.
return ""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Since it only returns an empty string and the signature is shared for all generate function, we could probably implement only one with the purpose of returning an empty string.

A single match_or_blank() could be reused across all resource with this specific need. (The naming ain't right, but I am too tired to come up with a good name right now! 🤣 )

Not blocking, we can definitely keep on improving with the next ones!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that's a great idea! Since I will be working on another resource in the same file, I will implement this change there, thanks!

@simonrw simonrw merged commit 385a141 into master Nov 15, 2024
31 checks passed
@simonrw simonrw deleted the feat/replicator/replicate-subnets branch November 15, 2024 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: patch Non-breaking changes which can be included in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants