Preparing Resources

Preparing Resources

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

Cognito

Creating AWS Access Key

Follow these steps to create an AWS Access Key:

  1. Log into AWS: Access the AWS management page and log in with your account.
  2. Select IAM: In the AWS dashboard, find and select the IAM (Identity and Access Management) service.
  3. Select User: From the left-hand menu, choose Users to view the list of users.
  4. Select a user: Find and select the user you had previously created.
  5. Select Security Credentials: In the user’s detail page, locate the ‘Security Credentials’ section.
  6. Create Access Key: Click on Create Access Key to generate a new access key.

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

Cognito

  1. Then, choose Command Line Interface (CLI) and click Next.

Cognito

  1. Finally, select Create access key.

Cognito

  1. You can Download.csv file to your personal computer. Then, click Done.

Cognito

  1. Return to the Visual Studio Code interface:

    • Execute 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, execute the following command:

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

Cognito

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

Cognito

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

Cognito

  1. You can verify the successful installation of CDK with this command:
cdk --version

Cognito

  1. Then, install some additional necessary libraries:
npm i @types/node

Cognito

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

Cognito

  1. Complete the CDK initialization.

Cognito

  1. In the AWS interface, check the stack in CloudFormation.

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

Cognito

  1. Now proceed to deploy CDK through the command:
npm run cdk deploy
  • After executing the command successfully, you will see the return results CognitoStack.userPoolClientId and CognitoStack.userPoolId

Cognito

  1. To ensure the successful initialization of infrastructure with CDK:

    • Go to the AWS interface and select CloudFormation.
    • Choose CognitoStack and view the Output section.
    • Take note of the userPoolClinetId and userPoolId values.

Cognito