diff --git a/infrastructure/cdk/src/providers/network.ts b/infrastructure/cdk/src/providers/network.ts index 5bea9714b..277920cff 100644 --- a/infrastructure/cdk/src/providers/network.ts +++ b/infrastructure/cdk/src/providers/network.ts @@ -23,8 +23,11 @@ export class NetworkStack extends cdk.Stack { const config = new Config() /** Create a stage-specific Ec2 VPC and ECS cluster */ - this.vpc = new ec2.Vpc(this, config.getFullStackResourceName(this.name, 'vpc')) - this.cluster = new ecs.Cluster(this, config.getFullStackResourceName(this.name, 'cluster'), { vpc: this.vpc }) - + this.vpc = new ec2.Vpc(this, config.getFullStackResourceName(this.name, 'vpc'), { + natGateways: 0 + }) + this.cluster = new ecs.Cluster(this, config.getFullStackResourceName(this.name, 'cluster'), { + vpc: this.vpc + }) } } \ No newline at end of file diff --git a/infrastructure/cdk/src/providers/users.ts b/infrastructure/cdk/src/providers/users.ts index 0938b232e..3505129d7 100644 --- a/infrastructure/cdk/src/providers/users.ts +++ b/infrastructure/cdk/src/providers/users.ts @@ -22,7 +22,8 @@ export class UsersStack extends cdk.Stack { const { certificate, cluster, hostedZone } = props /** Create a load-balanced service for the users express API */ - new ecsPatterns.ApplicationLoadBalancedFargateService(this, config.getFullStackResourceName(this.name, 'fargate'), { + const usersService = new ecsPatterns.ApplicationLoadBalancedFargateService(this, config.getFullStackResourceName(this.name, 'fargate'), { + assignPublicIp: true, certificate, cluster, domainName: `${subdomains.users}.${rootDomain}`, // e.g. users.casimir.co or users.dev.casimir.co @@ -36,5 +37,10 @@ export class UsersStack extends cdk.Stack { } } }) + + /** Override the default health check path */ + usersService.targetGroup.configureHealthCheck({ + path: '/health' + }) } } \ No newline at end of file diff --git a/services/users/src/index.ts b/services/users/src/index.ts index d2dd8212f..90912376a 100644 --- a/services/users/src/index.ts +++ b/services/users/src/index.ts @@ -3,6 +3,7 @@ import cors from 'cors' import login from './routes/login' import auth from './routes/auth' import users from './routes/users' +import health from './routes/health' const port = process.env.PUBLIC_AUTH_PORT || 4000 @@ -13,6 +14,7 @@ app.use(cors()) app.use('/login', login) app.use('/auth', auth) app.use('/users', users) +app.use('/health', health) app.listen(port) console.log(`Auth server listening on port ${port}`) \ No newline at end of file diff --git a/services/users/src/routes/health.ts b/services/users/src/routes/health.ts new file mode 100644 index 000000000..96de84e2d --- /dev/null +++ b/services/users/src/routes/health.ts @@ -0,0 +1,9 @@ +import express from 'express' + +const router = express.Router() + +router.get('/', (_req, res) => { + res.status(200).send('OK') +}) + +export default router \ No newline at end of file