Skip to content

Commit

Permalink
feat: Support customizing bootstrap args
Browse files Browse the repository at this point in the history
from pgStacDatabase.

Improve docs
  • Loading branch information
alukach committed Oct 26, 2022
1 parent 8657662 commit a23356f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
14 changes: 8 additions & 6 deletions lib/bootstrap-pgstac/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class BootstrapPgStac extends Construct {
runtime: aws_lambda.Runtime.PYTHON_3_8,
code: aws_lambda.Code.fromDockerBuild(__dirname, {
file: "runtime/Dockerfile",
buildArgs: { PGSTAC_VERSION: props.pgstacVersion },
buildArgs: { PGSTAC_VERSION: props.pgstacVersion || "0.6.8" },
}),
timeout: Duration.minutes(2),
vpc: hasVpc(props.database) ? props.database.vpc : props.vpc,
Expand Down Expand Up @@ -112,26 +112,28 @@ export interface BootstrapPgStacProps {
/**
* Name of database that is to be created and onto which pgSTAC will be installed.
*
* @default - "pgstac"
* @default pgstac
*/
readonly pgstacDbName?: string;

/**
* Name of user that will be generated for connecting to the pgSTAC database.
*
* @default - "pgstac_user"
* @default pgstac_user
*/
readonly pgstacUsername?: string;

/**
* pgSTAC version to be installed.
*
* @default 0.6.8
*/
readonly pgstacVersion: string;
readonly pgstacVersion?: string;

/**
* Prefix to assign to the generated `secrets_manager.Secret`
*
* @default - "pgstac"
* @default pgstac
*/
readonly secretsPrefix: string;
readonly secretsPrefix?: string;
}
24 changes: 14 additions & 10 deletions lib/database.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import {
Stack,
aws_ec2 as ec2,
aws_rds as rds,
aws_secretsmanager as secretsmanager,
} from "aws-cdk-lib";
import { Construct } from "constructs";
import { BootstrapPgStac } from "./bootstrap-pgstac";
import { BootstrapPgStac, BootstrapPgStacProps } from "./bootstrap-pgstac";

/**
* An RDS instance with pgSTAC installed.
*
* Will default to installing a `t3.small` Postgres instance.
* An RDS instance with pgSTAC installed. This is a wrapper around the
* `rds.DatabaseInstance` higher-level construct making use
* of the BootstrapPgStac construct.
*/
export class PgStacDatabase extends Construct {
db: rds.DatabaseInstance;
Expand Down Expand Up @@ -38,14 +37,19 @@ export class PgStacDatabase extends Construct {
vpc: props.vpc,
database: this.db,
dbSecret: this.db.secret!,
pgstacDbName: "pgstac",
pgstacVersion: "0.6.8",
pgstacUsername: "pgstac_user",
secretsPrefix: "pgstac",
pgstacDbName: props.pgstacDbName,
pgstacVersion: props.pgstacVersion,
pgstacUsername: props.pgstacUsername,
secretsPrefix: props.secretsPrefix,
});

this.pgstacSecret = bootstrap.secret;
}
}

export interface PgStacDatabaseProps extends rds.DatabaseInstanceProps {}
export interface PgStacDatabaseProps extends rds.DatabaseInstanceProps {
readonly pgstacDbName?: BootstrapPgStacProps["pgstacDbName"];
readonly pgstacVersion?: BootstrapPgStacProps["pgstacVersion"];
readonly pgstacUsername?: BootstrapPgStacProps["pgstacUsername"];
readonly secretsPrefix?: BootstrapPgStacProps["secretsPrefix"];
}

0 comments on commit a23356f

Please sign in to comment.