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

fix(rds): Add engine to IDatabaseInstance, IClusterInstance #9257

Closed
wants to merge 1 commit into from
Closed

fix(rds): Add engine to IDatabaseInstance, IClusterInstance #9257

wants to merge 1 commit into from

Conversation

civilizeddev
Copy link
Contributor

fixes #9195
related to #8686

BREAKING CHANGE: Constructs for imported resources take additional parameters in props

  • rds: DatabaseCluster.fromDatabaseClusterAttributes takes engine: IClusterEngine
  • rds: DatabaseInstanceBase.fromDatabaseInstanceAttributes takes engine: IInstanceEngine

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

fixes #9195
related to #8686

BREAKING CHANGE: Constructs for imported resources take additional parameters in props

- **rds**: `DatabaseCluster.fromDatabaseClusterAttributes` takes `engine: IClusterEngine`
- **rds**: `DatabaseInstanceBase.fromDatabaseInstanceAttributes` takes `engine: IInstanceEngine`
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-qxepHUsryhcu
  • Commit ID: 7ffd696
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@skinny85 skinny85 self-assigned this Jul 27, 2020
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @civilizeddev , but I don't think this is the correct way to go here.

Instead, I think the solution here is to add optional parameters to ProxyTarget's fromInstance and fromCluster methods, of type IInstanceEngine and IClusterEngine, respectively.

@civilizeddev
Copy link
Contributor Author

Thank you for reviewing @skinny85

But that way still lead to a weird interface,

then cdk users will not be able to .addProxy() with their imported instance or cluster.

I just want to achieve the goal mentioned below:

We should be able to interpret this automatically from the underlying engine of the given instance or cluster. How hard would that be?

cc @skinny85

Originally posted by @nija-at in #8476 (comment)

And to remove these ulgy and unstable implementation.

if (this.dbCluster && this.dbInstance) {
throw new Error('Proxy cannot target both database cluster and database instance.');
} else if (this.dbCluster) {
engine = (this.dbCluster.node.defaultChild as CfnDBCluster).engine;
} else if (this.dbInstance) {
engine = (this.dbInstance.node.defaultChild as CfnDBInstance).engine;
}


Likewise, the property vpc can also be derived from the instance or cluster, so that users don't have to pass to the props redundantly.

So I think it's better to have vpc, engine in IInstance and ICluster

But It might affect users of Import resources.

@civilizeddev
Copy link
Contributor Author

Precedent cases

aws-ecs

interface ICluster

/**
* The VPC associated with the cluster.
*/
readonly vpc: ec2.IVpc;

this.vpc

this.vpc = props.vpc || new ec2.Vpc(this, 'Vpc', { maxAzs: 2 });

Cluster. fromClusterAttributes(attrs: ClusterAttributes)

export class Cluster extends Resource implements ICluster {
/**
* Import an existing cluster to the stack from its attributes.
*/
public static fromClusterAttributes(scope: Construct, id: string, attrs: ClusterAttributes): ICluster {
return new ImportedCluster(scope, id, attrs);
}

interface ClusterAttributes

/**
* The VPC associated with the cluster.
*/
readonly vpc: ec2.IVpc;

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

@civilizeddev I will take your opinion up with the team, and we'll make a group decision, so it's not only up to me.

Marking as "Request changes" for now to stop if from being merged until we came up with a decision.

@civilizeddev
Copy link
Contributor Author

Related Issue

[rds] rds proxy only works with certain version, check at compile time

IEngine is very required.

@skinny85
Copy link
Contributor

Hey @civilizeddev ,

I've talked this over with the team, and unfortunately they sided with me 🙂.

The problem in your solution is that you are now requiring everyone who imports IDatabaseCluster and IDatabaseInstanceto provide the engine, even if they have no intention of using it! That seems like a very harsh thing to do.

So, I think adding them into fromInstance and fromCluster methods in ProxyTarget is the way to go.

Thanks,
Adam

@skinny85
Copy link
Contributor

Hey @civilizeddev ,

I took the liberty of submitting my version of this functionality in #10488 . I went a very similar way to you, I just made engine optional in IDatabaseInstance and IDatabaseCluster.

Let me know what you think of my version!

@civilizeddev
Copy link
Contributor Author

@skinny85

It looks better for now. You can go on with your version.

@civilizeddev civilizeddev deleted the civilizeddev/aws-rds-9195 branch September 23, 2020 03:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws-cdk] rds module not able to add proxy
3 participants