Prepare Resources

Prepare Resources

  1. Create a folder: First, create a new folder.
  2. Open Visual Studio Code: After creating the folder, open it with Visual Studio Code.
  3. Open Terminal: In Visual Studio Code, select Terminal from the menu bar to start working.

Cognito

Create AWS Access Key

To create an AWS Access Key, follow these steps:

  1. Log in to AWS: Go to the AWS management console and log in with your account.
  2. Select IAM: In the AWS console, find and select the IAM (Identity and Access Management) service.
  3. Select IAM User: From the left menu, select IAM users to view the list of users.
  4. Select user: Find and select the user you created previously (with AdministratorAccess permissions).
  5. Select Security Credentials: In the user details page, find the ‘Security Credentials’ section.
  6. Create Access Key: Select Create Access Key to create a new access key.

Note to keep your access key safe and do not share it with others.

Cognito

  1. Then, select Command Line Interface (CLI) and check I understand the above recommendation and want to proceed to create an access key.. Select Next.

Cognito

  1. Finally, select Create access key.

Cognito

  1. You can download the Download.csv file to your personal computer. Then, select Done.

Cognito

  1. Go back to the Visual Studio Code interface:

    • Run aws configure and fill in the information from the Download.csv file.

    • Clone the workshop repository to your personal computer.

    • To clone the repository to your personal computer, run the following command:

git clone https://github.com/AWS-First-Cloud-Journey/aws_cognito_cross_sites.git

Cognito

  1. Navigate to the workshop path:
cd aws_cognito_cross_sites
cd cdk 

Cognito

  1. Install CDK using npm:
npm install -g aws-cdk

Cognito

  1. You can verify if the CDK installation was successful via the command:
cdk  --version

Cognito

  1. Then, you install some necessary libraries,…
npm i @types/node

Cognito

  1. Bootstrapping in AWS CloudFormation. Bootstrapping involves deploying an AWS CloudFormation template into a specific AWS environment (account and region). Use the cdk bootstrap command of the AWS CDK Toolkit:
cdk bootstrap aws://ACCOUNT-NUMBER-1/REGION-1 aws://ACCOUNT-NUMBER-2/REGION-2 ...

Cognito

  1. Complete CDK initialization.

Cognito

  1. Go to the AWS interface, check the stack in CloudFormation.

    • We will see a stack named CDKToolKit
    • You can view and learn more about the CDK Tool Kit components.

Cognito

  1. Now deploy CDK via the command:
npm run cdk deploy
  • After the command completes, you will see the returned results CognitoStack.userPoolClientId and CognitoStack.userPoolId

Cognito

  1. To be sure, verify the infrastructure initialization by CDK is successful.

    • Go to the AWS interface and select CloudFormation
    • Select CognitoStack and view the Output section.
    • Note down the values of userPoolClientId and userPoolId

Cognito