-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat(rds): allow using existing security groups for new instance #4495
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 |
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.
Thanks for the contribution @jogold ! One comment.
* | ||
* @default - a new security group is created | ||
*/ | ||
readonly securityGroup?: ec2.ISecurityGroup; |
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.
You can have an array of SecurityGroups for instance, right? So this should be readonly securityGroups: ec2.ISecurityGroup[]
, correct?
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.
Agree but this is to be consistent with other packages/resources in the CDK, examples are ECS Service, RDS Cluster, ELBV2 Load balancers, Lambda functions, etc. All those resources accept an array of security groups but it's always implemented with a single security group.
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.
The only exception is the AWS CodeBuild project.
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 discussed this with the team, and we came to the conclusion that array is the way to go, and the other places that don't allow arrays are actually the ones that are wrong (and they will have to change, like ECS does in #3985 ).
So, please change it to readonly securityGroups: ISecurityGroup[]
.
Thanks!
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.
Done. Note there's now a BREAKING CHANGE
documented in the PR description, someone of the team will need to squash this PR because mergify
won't take it into account.
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 the breaking change removing the securityGroupId
property?
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.
BREAKING CHANGE: securityGroup: ec2.ISecurityGroup
is now securityGroups: ec2.ISecurityGroup[]
in DatabaseInstanceAttributes
, removed securityGroupId
from IDatabaseInstance
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 think I'm missing something then. Wasn't it possible to use existing security groups with Instance before this PR? When you could pass in a single security group?
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.
Oh, I think I see it now. It's about allowing to use an existing security group for a new Instance, right? Before, it was only possible to pass it for imported Instances?
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, exactly
Something unrelated to this PR, hope that's okay. @jogold I want to ask you something privately. To that end, I sent an email address to the email address you use to sign your GitHub commits (jonathan@***exchange.be). No rush, but in case you don't use that email address anymore, can you please shoot me a quick line from your current address at huijbers@amazon.com ? Thanks a lot! |
@rix0rrr just replied to your email 👍 |
Pull request has been modified.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@@ -935,7 +933,7 @@ export class DatabaseInstanceReadReplica extends DatabaseInstanceNew implements | |||
}); | |||
|
|||
this.connections = new ec2.Connections({ | |||
securityGroups: [this.securityGroup], | |||
securityGroups: this.securityGroups, | |||
defaultPort: ec2.Port.tcp(this.instanceEndpoint.port) |
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 code:
this.connections = new ec2.Connections({
securityGroups: this.securityGroups,
defaultPort: ec2.Port.tcp(this.instanceEndpoint.port)
});
is repeated in DatabaseInstance
, DatabaseInstanceFromSnapshot
and DatabaseInstanceReadReplica
. Is there any way we can reduce this duplication?
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
One more teeny comment, if you'll bear with me :)
|
||
protected readonly vpcPlacement?: ec2.SubnetSelection; | ||
protected readonly newCfnProps: CfnDBInstanceProps; | ||
protected readonly securityGroup: ec2.SecurityGroup; | ||
protected readonly securityGroups: ec2.ISecurityGroup[]; |
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.
So, now that you moved creating connections
here - is there any need to have this field? I believe the field can now be removed, and securityGroups
can be just a local variable of the constructor of DatabaseInstanceNew
, correct?
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.
Correct!
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
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.
Thanks for your patience!
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
@skinny85 it has been merged by mergify... it doesn't have the |
Thanks for letting me know. I'll be doing the CDK release next week (probably Monday or Tuesday), remind me to add this to the Changelog's BREAKING CHANGES section 🙂. |
Closes #2949
BREAKING CHANGE:
securityGroup: ec2.ISecurityGroup
is nowsecurityGroups: ec2.ISecurityGroup[]
inDatabaseInstanceAttributes
, removedsecurityGroupId
fromIDatabaseInstance
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license