Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 7 additions & 3 deletions cdk/PatchManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export class PatchManagerStack extends Stack {
},
);

const instanceIds = props.pgbouncerParamNames.map((paramName) =>
ssm.StringParameter.valueForStringParameter(this, paramName)
);

// Target EC2 instances by Name tag
const target = new ssm.CfnMaintenanceWindowTarget(
this,
Expand All @@ -47,7 +51,7 @@ export class PatchManagerStack extends Stack {
targets: [
{
key: 'InstanceIds',
values: [...props.instanceIds],
values: instanceIds,
},
],
},
Expand Down Expand Up @@ -81,7 +85,7 @@ export class PatchManagerStack extends Stack {

export interface Props extends StackProps {
/**
* Instance IDs to target for patching.
* SSM parameter names storing the PgBouncer EC2 instance IDs to target for patching.
*/
instanceIds: string[];
pgbouncerParamNames: string[];
}
8 changes: 6 additions & 2 deletions cdk/PgStacInfra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
aws_cloudfront as cloudfront,
aws_cloudfront_origins as origins,
aws_cloudwatch as cloudwatch,
aws_ssm as ssm,
} from "aws-cdk-lib";
import { Aws, Duration, RemovalPolicy, Stack, StackProps } from "aws-cdk-lib";
import { Construct } from "constructs";
Expand All @@ -27,7 +28,6 @@ import { load } from "js-yaml";
import { DpsStacItemGenerator } from "./constructs/DpsStacItemGenerator";

export class PgStacInfra extends Stack {
public readonly pgbouncerInstanceId: string;
constructor(scope: Construct, id: string, props: Props) {
super(scope, id, props);

Expand Down Expand Up @@ -71,7 +71,11 @@ export class PgStacInfra extends Stack {
bootstrapperLambdaFunctionOptions: { timeout: Duration.minutes(15) },
});
if (pgstacDb.pgbouncerInstanceId) {
this.pgbouncerInstanceId = pgstacDb.pgbouncerInstanceId;
new ssm.StringParameter(this, "pgbouncer-instance-id-param", {
parameterName: `/maap-eoapi/${stage}/${type}/pgbouncer-instance-id`,
stringValue: pgstacDb.pgbouncerInstanceId,
description: `PgBouncer EC2 instance ID for MAAP eoAPI ${type} stack (${stage})`,
});
}

const apiSubnetSelection: ec2.SubnetSelection = {
Expand Down
10 changes: 6 additions & 4 deletions cdk/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,12 @@ const userInfrastructure = new PgStacInfra(app, buildStackName("userSTAC"), {
terminationProtection: false,
});

new PatchManagerStack(app, buildStackName("patch-manager"), {
instanceIds: [
coreInfrastructure.pgbouncerInstanceId,
userInfrastructure.pgbouncerInstanceId,
const patchManager = new PatchManagerStack(app, buildStackName("patch-manager"), {
pgbouncerParamNames: [
`/maap-eoapi/${stage}/public/pgbouncer-instance-id`,
`/maap-eoapi/${stage}/internal/pgbouncer-instance-id`,
],
terminationProtection: false,
});
patchManager.addDependency(coreInfrastructure);
patchManager.addDependency(userInfrastructure);
2 changes: 1 addition & 1 deletion cdk/dockerfiles/Dockerfile.raster
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG PYTHON_VERSION=3.12

FROM --platform=linux/amd64 public.ecr.aws/lambda/python:${PYTHON_VERSION}
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/
COPY --from=ghcr.io/astral-sh/uv:0.10.9 /uv /uvx /bin/

# Install system dependencies to compile (numexpr)
RUN dnf install -y gcc-c++
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dependencies": {
"aws-cdk-lib": "^2.220.0",
"constructs": "^10.3.0",
"eoapi-cdk": "^11.2.0",
"eoapi-cdk": "^11.3.0",
"source-map-support": "^0.5.16"
}
}
Loading