To create CDK, I used the following code:
mkdir cdk
cd cdk
npm install -g aws-cdk
cdk init app --language typescript
constructs directory
The directory is structured to maintain modular constructs, making the infrastructure code more manageable and scalable. I created constructs directory in the lib folder and added auth.ts
file.
Key Componenets:
- UserPool: Defines the user pool with specific password policies and sign-in options, facilitating self-signup and ensuring security standards.
- UserPoolClient: Creates a client application within the user pool to manage user interactions and session handling.
Outputs:
- UserPoolId: The identifier for the created user pool.
- UserPoolClientId: The identifier for the user pool client application.
The Auth construct is integrated into the main CDK stack, ChinguTalkStack
, to provision the necessary AWS Cognito resources:
const auth = new Auth(this, "Auth");
After defining our infrastructure as code using AWS CDK, we proceed with deploying our resources to the cloud. This process is handled by the cdk deploy
command. Here’s how we executed the deployment for our project:
-
Navigate to your project's root directory in the terminal.
-
Run the
cdk deploy
command.bashCopy code cdk deploy