diff --git a/packages/@aws-cdk/aws-rds/lib/instance.ts b/packages/@aws-cdk/aws-rds/lib/instance.ts index a165a2834760a..feb44facab4d2 100644 --- a/packages/@aws-cdk/aws-rds/lib/instance.ts +++ b/packages/@aws-cdk/aws-rds/lib/instance.ts @@ -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); + 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; @@ -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;