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

revert(rds): document DatabaseInstance.fromDatabaseInstanceAttributes() #12091

Merged
merged 4 commits into from
Dec 15, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 15 additions & 24 deletions packages/@aws-cdk/aws-rds/lib/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,23 @@ export interface DatabaseInstanceAttributes {
export abstract class DatabaseInstanceBase extends Resource implements IDatabaseInstance {
/**
* Import an existing database instance.
*
* @deprecated use DatabaseInstance.fromDatabaseInstanceAttributes
*/
public static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance {
return DatabaseInstance.fromDatabaseInstanceAttributes(scope, id, attrs);
class Import extends DatabaseInstanceBase implements IDatabaseInstance {
public readonly defaultPort = ec2.Port.tcp(attrs.port);
iliapolo marked this conversation as resolved.
Show resolved Hide resolved
public readonly connections = new ec2.Connections({
securityGroups: attrs.securityGroups,
defaultPort: this.defaultPort,
});
public readonly instanceIdentifier = attrs.instanceIdentifier;
public readonly dbInstanceEndpointAddress = attrs.instanceEndpointAddress;
public readonly dbInstanceEndpointPort = attrs.port.toString();
public readonly instanceEndpoint = new Endpoint(attrs.instanceEndpointAddress, attrs.port);
public readonly engine = attrs.engine;
protected enableIamAuthentication = true;
}

return new Import(scope, id);
}

public abstract readonly instanceIdentifier: string;
Expand Down Expand Up @@ -926,27 +938,6 @@ export interface DatabaseInstanceProps extends DatabaseInstanceSourceProps {
* @resource AWS::RDS::DBInstance
*/
export class DatabaseInstance extends DatabaseInstanceSource implements IDatabaseInstance {
/**
* Import an existing database instance.
*/
public static fromDatabaseInstanceAttributes(scope: Construct, id: string, attrs: DatabaseInstanceAttributes): IDatabaseInstance {
class Import extends DatabaseInstanceBase implements IDatabaseInstance {
public readonly defaultPort = ec2.Port.tcp(attrs.port);
public readonly connections = new ec2.Connections({
securityGroups: attrs.securityGroups,
defaultPort: this.defaultPort,
});
public readonly instanceIdentifier = attrs.instanceIdentifier;
public readonly dbInstanceEndpointAddress = attrs.instanceEndpointAddress;
public readonly dbInstanceEndpointPort = attrs.port.toString();
public readonly instanceEndpoint = new Endpoint(attrs.instanceEndpointAddress, attrs.port);
public readonly engine = attrs.engine;
protected enableIamAuthentication = true;
}

return new Import(scope, id);
}

public readonly instanceIdentifier: string;
public readonly dbInstanceEndpointAddress: string;
public readonly dbInstanceEndpointPort: string;
Expand Down