-
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) Add Ingress rule for VPC Endpoints & CIDR Blocks #4591
Conversation
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
I'm not sure that allowing traffic from all addresses in the VPC CIDR is a good default here (security-wise). One must use the aws-cdk/packages/@aws-cdk/aws-ec2/test/integ.vpc-endpoint.lit.ts Lines 38 to 41 in 0bce4d6
|
@jogold Can you provide an example where that is a security risk? I think the code you just referenced is more of a security risk than using the VPC CIDR, and I can't think of a scenario where I would want some resources in my VPC to use a private endpoint but others not. The code changes here are more in-line with AWS documentation, such as: |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
The code I referenced is indeed not best practice but was just to illustrate the usage of the Regarding the security: VPC endpoints allow you to deploy an application in a VPC completely isolated from the internet but still provide access to AWS services. It could be that in that isolated VPC you want to guarantee that your database can never access an AWS service (even if it has been compromised, bad code, injection) or can access one service but not another. Working with the |
@jogold - That is an awesome point, I did not think of that. I don’t know I have enough context on where all (or how) the Connections object is used, so I’m not going to try and fit these changes on to that (unless otherwise encouraged). It’s probably fair to close this PR, but I’ll leave it open for now as a means to discuss options for #2232. If there are valid things in here which should be kept, happy to amend the PR as necessary. Otherwise it can just be closed. |
@@ -938,9 +971,12 @@ export class Vpc extends VpcBase { | |||
|
|||
this.vpcDefaultNetworkAcl = this.resource.attrDefaultNetworkAcl; | |||
this.vpcCidrBlockAssociations = this.resource.attrCidrBlockAssociations; | |||
this.vpcCidrBlock = this.resource.attrCidrBlock; | |||
this.vpcCidrBlock = cidrBlock; |
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.
Why this change? What is wrong with attrCidrBlock
?
@@ -363,6 +364,17 @@ export class InterfaceVpcEndpoint extends VpcEndpoint implements IInterfaceVpcEn | |||
const securityGroup = new SecurityGroup(this, 'SecurityGroup', { | |||
vpc: props.vpc | |||
}); | |||
|
|||
if (props.vpc.vpcCidrBlock) { |
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 do not feel comfortable with doing this outright. I would feel better if it's behind a flag (suggested name: allowAllVpcTraffic: true|false
).
It would be nicer to implement as:
this.connections.allowDefaultPortFrom(Peer.ipv4(props.vpc.vpcCidrBlock));
But even doing this only works for securitygroups that have an outbound rule. If not, you would still need to do the following:
endpoint.connections.allowDefaultPortFrom(myAsg);
So is this even worth it?
@@ -44,6 +44,8 @@ export = nodeunit.testCase({ | |||
// THEN | |||
test.deepEqual(result, { | |||
vpcId: 'vpc-1234567', | |||
vpcCidrBlock: '10.0.0.0/16', |
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'm all in favor of this, but be aware there is a concurrent PR changing the VPC provider, and these changes will have to be integrated across PRs: #4544
I'm not seeing it? |
Closing this until we see a need to reopen. |
@rix0rrr @jd-carroll with PR #4554 merged now, can this one be progressed? because i don't see the possibility to get the CIDRs of an imported VPC at the moment. (or am i missing sth.?) |
IVpc
(Consider providing CIDR in IVpc #2232)