Skip to content

VPC attachment for InternetGateway #48

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 4 commits into from
Mar 31, 2022

Conversation

RedbackThomson
Copy link
Contributor

Closes aws-controllers-k8s/community#1216

Description of changes:
Add support for attaching an InternetGateway to a VPC. The EC2 API exposes a list of Attachments when you describe InternetGateway, but manual testing shows that you can only attach a gateway to a single VPC - so this is treated as a list of at most one element. I had to create a new VPC for integration tests, since the default VPC we use for all of the other tests already contains an IGW, and you can have at most 1 per VPC.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-bot ack-bot requested review from brycahta and bwagner5 March 30, 2022 21:22
@RedbackThomson
Copy link
Contributor Author

/retest

Copy link

@vijtrip2 vijtrip2 left a comment

Choose a reason for hiding this comment

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

Looks good.

# In the case where it shows the attachment as being in detached state
if len(igw["Attachments"]) == 1:
assert igw["Attachments"][0]["VpcId"] == vpc_id
assert igw["Attachments"][0]["State"] == "detached"
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be an or check? "detached" or "detaching"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It only takes a few fractions of a second to detach. Our sleep above should suffice for this.

def test_vpc_association(self, ec2_client):
resource_name = random_suffix_name("ig-ack-test", 24)

test_vpc = get_bootstrap_resources().EmptyVPC
Copy link
Contributor

@brycahta brycahta Mar 31, 2022

Choose a reason for hiding this comment

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

If this VPC is only used here, then would you be opposed to creating the VPC in this test and exercise the resource reference code paths?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah happy to move it into the test as a fixture, itself. Not sure about using it as a ref, though. I think we need to have a holistic discussion around testing references in general. Adding a test for every field, and then another test for every ref, is going to blow up the size of our tests and I don't know how much value it actually brings (since the reference resolution code is generated deterministically). I'll leave that for another day, though.

Copy link
Contributor

@brycahta brycahta left a comment

Choose a reason for hiding this comment

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

changes look solid 👍

just a couple nits/questions on the test

Copy link
Contributor

@brycahta brycahta left a comment

Choose a reason for hiding this comment

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

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 31, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Mar 31, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brycahta, RedbackThomson, vijtrip2

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [RedbackThomson,brycahta,vijtrip2]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit b5c4c9f into aws-controllers-k8s:main Mar 31, 2022
@RedbackThomson RedbackThomson deleted the vpc-ig-attach branch March 31, 2022 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support attachment of InternetGateway to VPC
4 participants