-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(ec2-alpha): readme updates, new unit tests, logic update #33086
Conversation
c2f2e6b
to
252fcec
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33086 +/- ##
=======================================
Coverage 80.78% 80.78%
=======================================
Files 232 232
Lines 14111 14111
Branches 2453 2453
=======================================
Hits 11400 11400
Misses 2431 2431
Partials 280 280
Flags with carried forward coverage won't be shown. Click here to find out more.
|
5f3b3c6
to
bf65780
Compare
d0d5d22
to
186fa82
Compare
186fa82
to
e273b35
Compare
@@ -514,7 +514,7 @@ export class Ipam extends Resource { | |||
if (props?.ipamName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible for ipamName
to be a token?
@@ -514,7 +514,7 @@ export class Ipam extends Resource { | |||
if (props?.ipamName) { | |||
Tags.of(this).add(NAME_TAG, props.ipamName); | |||
} | |||
if (!props?.operatingRegion && !Stack.of(this).region) { | |||
if (!props?.operatingRegion && Token.isUnresolved(Stack.of(this).region)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 questions:
- The
!props?.operatingRegion
condition catch the case where theoperatingRegion
prop is not provided by user (i.e. value beingundefined
). What ifoperatingRegion
is an empty array? - For the 2nd condition, why do we add
Token.isUnresolved
? I would thought that if user is not providing any regions, then we can useStack.of(this).region
, even if it is a token. I see further down on line 521 that token is allowed as a value assigned tothis.operatingRegions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point for 1, changed the condition to check for empty array as well.
For 2, I wanted to prevent the deployment for stacks that has any unresolved token reference while synth, but looking at the template again i think even with no environment variable, it will look like below which is going to be resolved at deployment time which should be okay, in any case there will be always be a region value and i don't think we need to check for this, updated the condition.
{
"RegionName": {
"Ref": "AWS::Region"
}
}
@@ -608,12 +608,8 @@ export class RouteTargetType { | |||
readonly endpoint?: IVpcEndpoint; | |||
|
|||
constructor(props: RouteTargetProps) { | |||
if ((props.gateway && props.endpoint) || (!props.gateway && !props.endpoint)) { | |||
throw new Error('Exactly one of `gateway` or `endpoint` must be specified.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this is moved into the Route
constructor. Curious about the reasoning
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While adding unit tests, stack was not throwing expected error while using addRoute method with both endpoint and target as an input, so moved it from RouteTargetType class to Route
addRoute
this.addDefaultInternetRoute(subnet, igw, options); | ||
processedSubnets.add(subnet.node.id); | ||
}; | ||
}); // If there are no input subnets defined, default route will be added to all public subnets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My understanding is that if a subnet has a route to the internet, then it becomes a public subnet.
So should we allow adding internet gateway to private subnets? If we do, should we warn the users so that they do not accidentally make their subnets, intended to be private, public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this was my understanding as well but after talking to service team there can be cases with VPNGW type of attachment where customer might be leveraging their on-premises network to route the traffic to internet.
I was thinking of adding warning as well for private subnets, but there can be different categories under private subnets too. But I still think notifying is good idea, so added a warning for all kinds of subnets except PUBLIC.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there can be cases with VPNGW type of attachment where customer might be leveraging their on-premises network to route the traffic to internet.
And in such case, it won't be a private subnet? Is it correct to say that "Private Subnet" is a concept to describe a subnet that is configured to not able to access the internet? I am thinking if we should keep the public vs private subnet concept in CDK since, say, a private subnet may become public due to drifting.
Anyways, this is not a blocking comment. We can discuss further offline. Thank you for explaining.
e273b35
to
b258ed7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
b258ed7
to
e7125f3
Compare
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
this.addDefaultInternetRoute(subnet, igw, options); | ||
processedSubnets.add(subnet.node.id); | ||
}; | ||
}); // If there are no input subnets defined, default route will be added to all public subnets |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there can be cases with VPNGW type of attachment where customer might be leveraging their on-premises network to route the traffic to internet.
And in such case, it won't be a private subnet? Is it correct to say that "Private Subnet" is a concept to describe a subnet that is configured to not able to access the internet? I am thinking if we should keep the public vs private subnet concept in CDK since, say, a private subnet may become public due to drifting.
Anyways, this is not a blocking comment. We can discuss further offline. Thank you for explaining.
@@ -511,7 +511,7 @@ export class Ipam extends Resource { | |||
if (props?.ipamName) { | |||
Tags.of(this).add(NAME_TAG, props.ipamName); | |||
} | |||
if (!props?.operatingRegion && !Stack.of(this).region) { | |||
if (props?.operatingRegion && (props.operatingRegion.length === 0)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: The operatingRegion
is a list so it should be named operatingRegions
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addressed in latest rev but this would be breaking change which should be okay for alpha, added in PR description
BREAKING CHANGE: operatingRegion property under IPAM class is now renamed to operatingRegions.
* | ||
* @default - route created for all subnets with Type `SubnetType.Public` | ||
*/ | ||
readonly subnets?: SubnetSelection[]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Naming this subnetSelections
seems better so users are not confused that it may be of the type SubnetV2[]
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, tried to keep it consistent per the functions in main lib with the current options in main lib for adding interfaces and endpoints, https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ec2/lib/vpc-endpoint.ts#L110 , where mySubnet is a new subnet defined using SubnetV2.
myVpc.addInternetGateway({
ipv4Destination: '192.168.0.0/16',
subnets: [mySubnet],
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
6da0263
to
9f997a6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. LGTM
Code looks good. I missed that the title needs to be updated as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This review is outdated)
Dismissing outdated PRLinter review.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
@Mergifyio update |
☑️ Nothing to do
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Comments on closed issues and PRs are hard for our team to see. |
Issue # (if applicable)
Closes #30762 .
Reason for this change
Adding more unit tests to meet the global coverage before module graduation to
developer-preview
.Description of changes
Add more unit test case to cover all
if branches
test cases.As per the discussion with service team, added optional field under IGW to allow users to choose the subnets for gateway routing, as there can be Public Subnet without an IGW attached( eg. using VPNGW to access internet).
Update IPAM README to higlight the problem of IPAM pool deletion as discussed with service team.
Update SubnetV2 README to higlight that a custom route table is being created through CDK.
Describe any new or updated permissions being added
No changes to IAM permissions.
Description of how you validated changes
yarn build
yarn test
Checklist
BREAKING CHANGE:
operatingRegion
property under IPAM class is now renamed tooperatingRegions
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license