Skip to content
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

(rds): Instance support for addSecurityGroup #17684

Closed
1 of 2 tasks
markussiebert opened this issue Nov 24, 2021 · 5 comments
Closed
1 of 2 tasks

(rds): Instance support for addSecurityGroup #17684

markussiebert opened this issue Nov 24, 2021 · 5 comments
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. feature-request A feature should be added or improved. p2

Comments

@markussiebert
Copy link
Contributor

markussiebert commented Nov 24, 2021

Description

RDS Instances (maybe Clusters, didn't checked that) should allow adding Securitygroups

Use Case

We have predefined SGs we want to add to all Resources. We do this by creating aspects, that add our special SecurityGroups. For RDS it's a hack accessing raw cfn resources and manipulate them. But it would be great to implement the same behaviour as several other resources.

Proposed Solution

RDS Instances should stick to the implementation of EC2 Instances

public addSecurityGroup(securityGroup: ISecurityGroup): void {

private readonly securityGroups: ISecurityGroup[] = [];

instead of holding the securitygroups only inside the constructor and than lazy map this

vpcSecurityGroups: securityGroups.map(s => s.securityGroupId),

const securityGroupsToken = Lazy.list({ produce: () => this.securityGroups.map(sg => sg.securityGroupId) });

Other information

no

Acknowledge

  • I may be able to implement this feature request
  • This feature might incur a breaking change
@markussiebert markussiebert added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Nov 24, 2021
@markussiebert markussiebert changed the title (module name): short issue description (rds): support for add securitygroup Nov 24, 2021
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Nov 24, 2021
@peterwoodworth peterwoodworth added the effort/medium Medium work item – several days of effort label Nov 24, 2021
@peterwoodworth peterwoodworth changed the title (rds): support for add securitygroup (rds): Instance support for addSecurityGroup Nov 24, 2021
@peterwoodworth peterwoodworth added the feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. label Nov 24, 2021
@skinny85
Copy link
Contributor

skinny85 commented Nov 24, 2021

Thanks for opening the issue @markussiebert. Actually, I think the problem is here . Instead of using this.securityGroups here, we should use this.connections.securityGroups instead. That would allow you to go instance.connections.addSecurityGroup().

@skinny85 skinny85 added effort/small Small work item – less than a day of effort p2 and removed @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/medium Medium work item – several days of effort needs-triage This issue or PR still needs to be triaged. labels Nov 24, 2021
@markussiebert
Copy link
Contributor Author

markussiebert commented Nov 25, 2021

Good point @skinny85 - first I thought the same! But, now I think the way it's implement for EC2 Instances is actually really good.

While thinking about this I found:
aws/aws-cdk-rfcs#51
really interesting

If I read this:

/**
 * The goal of this module is to make possible to write statements like this:
 *
 *  ```ts
 *  database.connections.allowFrom(fleet);
 *  fleet.connections.allowTo(database);
 *  rdgw.connections.allowFromCidrIp('0.3.1.5/86');
 *  rgdw.connections.allowTrafficTo(fleet, new AllPorts());
 *  ```
 *
 * The insight here is that some connecting peers have information on what ports should
 * be involved in the connection, and some don't.
 */

I personally don't want to have all Securitygroups in the connections. If I write a statement database.connections.allowFrom(myec2Instance) I don't want my Securitygroup granting access for administrators extended the same way.

  /**
   * What securityGroup(s) this object is managing connections for
   *
   * @default No security groups
   */
  readonly securityGroups?: ISecurityGroup[];

I don't want those securitygroups to be "managed" by the rds. Those securitygroups are somehow special and should be immutable!

That's how the ec2 way works.

But I would like to see all L2/L3 Constructs work the same way :-) (some Constructs say addSecurityGroup, others say addSecurityGroups ... some won't allow this...)

@skinny85
Copy link
Contributor

skinny85 commented Nov 29, 2021

I don't understand what's the final proposal from your post, but feel free to open a PR 😉.

@markussiebert
Copy link
Contributor Author

Sorry - at the moment I have no proposal. I would like that all resources behave in the same way. So I think I have to look into how to contribute to the rfcs ...

Because every cdk resource behaves in a different way I was not able to add my SecurityGroup to a lot resources apart from some ec2 resources and now using another approach with prefix lists and an aspect, that creates an ingress for each security group found in the cdk app.

@github-actions
Copy link

github-actions bot commented Dec 5, 2022

This issue has not received any attention in 1 year. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Dec 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature/enhancement A new API to make things easier or more intuitive. A catch-all for general feature requests. feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

4 participants