Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aws-cdk-lib

Package Overview
Dependencies
Maintainers
1
Versions
271
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-cdk-lib

Version 2 of the AWS Cloud Development Kit library

  • 2.151.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.7M
decreased by-4.7%
Maintainers
1
Weekly downloads
 
Created

What is aws-cdk-lib?

The aws-cdk-lib package is the primary library for the AWS Cloud Development Kit (AWS CDK), which is a software development framework for defining cloud infrastructure in code and provisioning it through AWS CloudFormation. It provides high-level components called constructs that preconfigure cloud resources with sensible defaults, making it easier to build cloud applications.

What are aws-cdk-lib's main functionalities?

Defining Infrastructure

This feature allows you to define AWS infrastructure using high-level constructs. In the code sample, a new S3 bucket is defined within a stack.

const app = new cdk.App();
const stack = new cdk.Stack(app, 'MyFirstStack');
new s3.Bucket(stack, 'MyFirstBucket', {
  removalPolicy: cdk.RemovalPolicy.DESTROY,
});

Configuring IAM Policies

This feature enables the creation and configuration of IAM roles and policies. The code sample creates an IAM role and grants it permissions to perform all actions on S3 resources.

const role = new iam.Role(stack, 'MyRole', {
  assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com'),
});
role.addToPolicy(new iam.PolicyStatement({
  actions: ['s3:*'],
  resources: ['*'],
}));

Creating Serverless Functions

This feature is used to define AWS Lambda functions. The code sample shows how to create a new Lambda function with Node.js runtime and specifies the source code directory.

new lambda.Function(stack, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_14_X,
  handler: 'index.handler',
  code: lambda.Code.fromAsset('lambda'),
});

Setting up API Gateway

This feature allows you to set up an API Gateway to create RESTful APIs. The code sample demonstrates how to create an API Gateway and integrate it with a Lambda function.

const api = new apigateway.RestApi(stack, 'MyApi', {
  restApiName: 'My Service',
});
const getWidgetsIntegration = new apigateway.LambdaIntegration(myLambdaFunction);
api.root.addMethod('GET', getWidgetsIntegration);

Other packages similar to aws-cdk-lib

Keywords

FAQs

Package last updated on 02 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc