DEV Community

lou
lou

Posted on

Part 1 : Serverless project with CDK, AWS Lambda@Edge, Cognito and Amplify

**** Create your aws user and give them access to the CLI

Start by creating a user
Image description
We need our user to be able to deploy ressources and to do that they will need Administrator Access
Click on attach policies

Image description

And Select the AdministratorAccess policy

Image description

After you've created your user go to security credentials and create an access key, we will need it to configure the user to access the cli

Image description

Image description

Select the first option and store your key because you won't be able to access it again

Image description

Link to install AWS CLI if you don't have it installed

To configure the user run the commande :
aws configure
It takes the following parameters :

The public access key
The private access key
The Region
And the default output format
Image description

To install the AWS CDK CLI, open your terminal and run the following command

 sudo npm install -g aws-cdk
Enter fullscreen mode Exit fullscreen mode

AWS provides variety of project examples for different languages.

GitHub logo aws-samples / aws-cdk-examples

Example projects using the AWS CDK

AWS CDK Examples

This repository contains a set of example projects for the AWS Cloud Development Kit.

Table of Contents

  1. About this Repo
  2. Examples
  3. Learning Resources
  4. Additional Examples
  5. License

About this Repo

This repo is our official list of CDK example code. The repo is subdivided into sections for each language (see "Examples"). Each language has its own subsection of examples with the ultimate aim of complete language parity (same subset of examples exist in each language). These examples each provide a demonstration of a common service implementation, or infrastructure pattern that could be useful in your use of the CDK for building your own infrastructure.

We welcome contributions to this repo in the form of fixes to existing examples or addition of new examples. For more information on contributing, please see the CONTRIBUTING guide.

This is considered an intermediate learning resource and should typically be referenced after…

Before we create our first CDK project you can check the supported languages here in the official documentation

The AWS CDK supports several languages including TypeScript, JavaScript, Python, Java, and C#.

To create the CDK project run this commande, replacing $LANGUAGE with your preferred programming language, and it will initialize it with the necessary files and directories for that language

cdk -init --language=$LANGUAGE
Enter fullscreen mode Exit fullscreen mode

Before deploying your CDK project, you need to bootstrap your environment.

Bootstrapping is the process of preparing an environment for deployment. Bootstrapping is a one-time action that you must perform for every environment that you deploy resources into.


cdk bootstrap
Enter fullscreen mode Exit fullscreen mode

Now that your environment is prepared, you can deploy your project to your AWS account using the following command

cdk deploy
Enter fullscreen mode Exit fullscreen mode

Now if you go back to the console and select the configured region then search your CloudFormation you will see your deployed stack

Image description

Top comments (0)