Skip to content

Commit

Permalink
fixup: fix bootstrapper issues
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Oct 26, 2022
1 parent 1421fec commit fc7ff20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/bootstrapper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ function hasVpc(
return (instance as aws_rds.DatabaseInstance).vpc !== undefined;
}

const DEFAULT_PGSTAC_VERSION = "0.6.8";

/**
* Bootstraps a database instance, installing pgSTAC onto the database.
*/
Expand All @@ -26,12 +28,13 @@ export class BootstrapPgStac extends Construct {
constructor(scope: Construct, id: string, props: BootstrapPgStacProps) {
super(scope, id);

const { pgstacVersion = DEFAULT_PGSTAC_VERSION } = props;
const handler = new aws_lambda.Function(this, "lambda", {
handler: "handler.handler",
runtime: aws_lambda.Runtime.PYTHON_3_8,
code: aws_lambda.Code.fromDockerBuild(__dirname, {
file: "runtime/Dockerfile",
buildArgs: { PGSTAC_VERSION: props.pgstacVersion || "0.6.8" },
buildArgs: { PGSTAC_VERSION: pgstacVersion },
}),
timeout: Duration.minutes(2),
vpc: hasVpc(props.database) ? props.database.vpc : props.vpc,
Expand Down Expand Up @@ -74,7 +77,7 @@ export class BootstrapPgStac extends Construct {
properties: {
// By setting pgstac_version in the properties assures
// that Create/Update events will be passed to the service token
pgstac_version: props.pgstacVersion,
pgstac_version: pgstacVersion,
conn_secret_arn: props.dbSecret.secretArn,
new_user_secret_arn: this.secret.secretArn,
},
Expand Down
4 changes: 4 additions & 0 deletions lib/bootstrapper/runtime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ COPY runtime/handler.py /asset/handler.py
# https://stackoverflow.com/a/61746719
# Tip from eoAPI: turns out, asyncio is part of python
RUN rm -rf /asset/asyncio*

# A command must be present avoid the following error on CDK deploy:
# Error response from daemon: No command specified
CMD [ "echo", "ready to go!" ]
3 changes: 2 additions & 1 deletion lib/bootstrapper/runtime/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def handler(event, context):

except Exception as e:
print(f"Unable to bootstrap database with exception={e}")
return send(event, context, "FAILED", {"message": str(e)})
send(event, context, "FAILED", {"message": str(e)})
raise e

print("Complete.")
return send(event, context, "SUCCESS", {})

0 comments on commit fc7ff20

Please sign in to comment.