infrastructure updates
This commit is contained in:
@@ -3,6 +3,7 @@ import "source-map-support/register";
|
||||
import * as cdk from "aws-cdk-lib";
|
||||
import { ConditionCheckLambdaStack } from "../lib/condition-check-lambda-stack";
|
||||
import { ImageProcessorLambdaStack } from "../lib/image-processor-lambda-stack";
|
||||
import { VpcStack } from "../lib/vpc-stack";
|
||||
|
||||
const app = new cdk.App();
|
||||
|
||||
@@ -17,6 +18,7 @@ const envConfig: Record<
|
||||
frontendUrl: string;
|
||||
sesFromEmail: string;
|
||||
emailEnabled: boolean;
|
||||
natGateways: number;
|
||||
}
|
||||
> = {
|
||||
staging: {
|
||||
@@ -27,6 +29,7 @@ const envConfig: Record<
|
||||
frontendUrl: "https://staging.villageshare.app",
|
||||
sesFromEmail: "noreply@villageshare.app",
|
||||
emailEnabled: true,
|
||||
natGateways: 1, // Single NAT gateway for cost optimization in staging
|
||||
},
|
||||
prod: {
|
||||
databaseUrl:
|
||||
@@ -35,6 +38,7 @@ const envConfig: Record<
|
||||
frontendUrl: "https://villageshare.app",
|
||||
sesFromEmail: "noreply@villageshare.app",
|
||||
emailEnabled: true,
|
||||
natGateways: 2, // Multi-AZ NAT gateways for high availability in production
|
||||
},
|
||||
};
|
||||
|
||||
@@ -44,38 +48,71 @@ if (!config) {
|
||||
throw new Error(`Unknown environment: ${environment}`);
|
||||
}
|
||||
|
||||
// Create the Condition Check Lambda stack
|
||||
new ConditionCheckLambdaStack(app, `ConditionCheckLambdaStack-${environment}`, {
|
||||
environment,
|
||||
databaseUrl: config.databaseUrl,
|
||||
frontendUrl: config.frontendUrl,
|
||||
sesFromEmail: config.sesFromEmail,
|
||||
emailEnabled: config.emailEnabled,
|
||||
const envProps = {
|
||||
env: {
|
||||
account: process.env.CDK_DEFAULT_ACCOUNT,
|
||||
region: process.env.CDK_DEFAULT_REGION || "us-east-1",
|
||||
},
|
||||
description: `Condition Check Reminder Lambda infrastructure (${environment})`,
|
||||
};
|
||||
|
||||
// Create the VPC stack first (other stacks depend on it)
|
||||
const vpcStack = new VpcStack(app, `VpcStack-${environment}`, {
|
||||
environment,
|
||||
natGateways: config.natGateways,
|
||||
maxAzs: 2,
|
||||
...envProps,
|
||||
description: `VPC infrastructure with private subnets and VPC endpoints (${environment})`,
|
||||
tags: {
|
||||
Environment: environment,
|
||||
Project: "village-share",
|
||||
Service: "condition-check-reminder",
|
||||
Service: "networking",
|
||||
},
|
||||
});
|
||||
|
||||
// Create the Condition Check Lambda stack
|
||||
const conditionCheckStack = new ConditionCheckLambdaStack(
|
||||
app,
|
||||
`ConditionCheckLambdaStack-${environment}`,
|
||||
{
|
||||
environment,
|
||||
databaseUrl: config.databaseUrl,
|
||||
frontendUrl: config.frontendUrl,
|
||||
sesFromEmail: config.sesFromEmail,
|
||||
emailEnabled: config.emailEnabled,
|
||||
vpc: vpcStack.vpc,
|
||||
lambdaSecurityGroup: vpcStack.lambdaSecurityGroup,
|
||||
...envProps,
|
||||
description: `Condition Check Reminder Lambda infrastructure (${environment})`,
|
||||
tags: {
|
||||
Environment: environment,
|
||||
Project: "village-share",
|
||||
Service: "condition-check-reminder",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// Add dependency on VPC stack
|
||||
conditionCheckStack.addDependency(vpcStack);
|
||||
|
||||
// Create the Image Processor Lambda stack
|
||||
new ImageProcessorLambdaStack(app, `ImageProcessorLambdaStack-${environment}`, {
|
||||
environment,
|
||||
databaseUrl: config.databaseUrl,
|
||||
frontendUrl: config.frontendUrl,
|
||||
env: {
|
||||
account: process.env.CDK_DEFAULT_ACCOUNT,
|
||||
region: process.env.CDK_DEFAULT_REGION || "us-east-1",
|
||||
},
|
||||
description: `Image Processor Lambda infrastructure (${environment})`,
|
||||
tags: {
|
||||
Environment: environment,
|
||||
Project: "village-share",
|
||||
Service: "image-processor",
|
||||
},
|
||||
});
|
||||
const imageProcessorStack = new ImageProcessorLambdaStack(
|
||||
app,
|
||||
`ImageProcessorLambdaStack-${environment}`,
|
||||
{
|
||||
environment,
|
||||
databaseUrl: config.databaseUrl,
|
||||
frontendUrl: config.frontendUrl,
|
||||
vpc: vpcStack.vpc,
|
||||
lambdaSecurityGroup: vpcStack.lambdaSecurityGroup,
|
||||
...envProps,
|
||||
description: `Image Processor Lambda infrastructure (${environment})`,
|
||||
tags: {
|
||||
Environment: environment,
|
||||
Project: "village-share",
|
||||
Service: "image-processor",
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
// Add dependency on VPC stack
|
||||
imageProcessorStack.addDependency(vpcStack);
|
||||
|
||||
Reference in New Issue
Block a user