From ec36ada78418dd35790e23a7326f24c290082e71 Mon Sep 17 00:00:00 2001 From: Shane Earley Date: Thu, 16 Feb 2023 12:09:59 -0500 Subject: [PATCH] Add cognito user pool to cdk --- infrastructure/cdk/src/providers/auth.ts | 11 ++++++++++- infrastructure/cdk/src/providers/landing.ts | 2 +- infrastructure/cdk/src/providers/nodes.ts | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/infrastructure/cdk/src/providers/auth.ts b/infrastructure/cdk/src/providers/auth.ts index f8c68bb01..3e055c250 100644 --- a/infrastructure/cdk/src/providers/auth.ts +++ b/infrastructure/cdk/src/providers/auth.ts @@ -1,5 +1,6 @@ import { Construct } from 'constructs' import { Duration, Stack } from 'aws-cdk-lib' +import * as cognito from 'aws-cdk-lib/aws-cognito' import * as ec2 from 'aws-cdk-lib/aws-ec2' import * as ecs from 'aws-cdk-lib/aws-ecs' import * as ecsPatterns from 'aws-cdk-lib/aws-ecs-patterns' @@ -37,9 +38,17 @@ export class AuthStack extends Stack { const { project, stage, domain, dnsRecords, hostedZone } = props - // Use casimir.co for prod and dev.casimir.co for dev + /** Use casimir.co for prod and dev.casimir.co for dev */ const serviceDomain = stage === 'Prod' ? domain : [stage.toLowerCase(), domain].join('.') + /** Create a Cognito pool and use CUSTOM_AUTH provider */ + const pool = new cognito.UserPool(this, `${project}${this.service}Pool${stage}`) + pool.addClient(`${project}${this.service}PoolCustomClient${stage}`, { + authFlows: { + custom: true + } + }) + /** Create an EC2 VPC and an ECS cluster */ const vpc = new ec2.Vpc(this, `${project}${this.service}Vpc${stage}`) const cluster = new ecs.Cluster(this, `${project}${this.service}Cluster${stage}`, { vpc }) diff --git a/infrastructure/cdk/src/providers/landing.ts b/infrastructure/cdk/src/providers/landing.ts index 466565ba0..d0552352f 100644 --- a/infrastructure/cdk/src/providers/landing.ts +++ b/infrastructure/cdk/src/providers/landing.ts @@ -38,7 +38,7 @@ export class LandingStack extends Stack { const { project, stage, domain, dnsRecords, hostedZone } = props - // Use casimir.co for prod and dev.casimir.co for dev + /** Use casimir.co for prod and dev.casimir.co for dev */ const serviceDomain = stage === 'Prod' ? domain : [stage.toLowerCase(), domain].join('.') const certificate = new certmgr.Certificate(this, `${project}${this.service}Cert${stage}`, { diff --git a/infrastructure/cdk/src/providers/nodes.ts b/infrastructure/cdk/src/providers/nodes.ts index c00f16d6b..12d02d33c 100644 --- a/infrastructure/cdk/src/providers/nodes.ts +++ b/infrastructure/cdk/src/providers/nodes.ts @@ -32,7 +32,7 @@ export class NodesStack extends Stack { const { project, stage, domain, dnsRecords, hostedZone, nodesIp } = props - // Use casimir.co for prod and dev.casimir.co for dev + /** Use casimir.co for prod and dev.casimir.co for dev */ const serviceDomain = stage === 'Prod' ? domain : [stage.toLowerCase(), domain].join('.') new route53.ARecord(this, `${project}${this.service}DnsARecordApi${stage}`, {