Socket
Socket
Sign inDemoInstall

@aws-cdk/custom-resources

Package Overview
Dependencies
Maintainers
4
Versions
248
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/custom-resources

Constructs for implementing CDK custom resources


Version published
Weekly downloads
106K
increased by19.21%
Maintainers
4
Weekly downloads
 
Created

What is @aws-cdk/custom-resources?

@aws-cdk/custom-resources is an AWS CDK module that allows you to create custom AWS CloudFormation resources. This package enables you to define custom logic that can be executed during the deployment of your AWS infrastructure. It is particularly useful for operations that are not natively supported by CloudFormation.

What are @aws-cdk/custom-resources's main functionalities?

AWS SDK Calls

This feature allows you to make AWS SDK calls during the deployment of your stack. In this example, an SSM parameter is retrieved using the AWS SDK.

{"TypeScript":"import * as cdk from 'aws-cdk-lib';\nimport * as cr from 'aws-cdk-lib/custom-resources';\nimport { Construct } from 'constructs';\n\nclass MyStack extends cdk.Stack {\n  constructor(scope: Construct, id: string, props?: cdk.StackProps) {\n    super(scope, id, props);\n\n    const getParameter = new cr.AwsCustomResource(this, 'GetParameter', {\n      onUpdate: {\n        service: 'SSM',\n        action: 'getParameter',\n        parameters: {\n          Name: 'my-parameter',\n        },\n        physicalResourceId: cr.PhysicalResourceId.of('my-parameter'),\n      },\n      policy: cr.AwsCustomResourcePolicy.fromSdkCalls({resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE}),\n    });\n  }\n}\n\nconst app = new cdk.App();\nnew MyStack(app, 'MyStack');"}

Custom Lambda Resource

This feature allows you to create custom resources backed by AWS Lambda functions. In this example, a Lambda function is used to handle custom resource events.

{"TypeScript":"import * as cdk from 'aws-cdk-lib';\nimport * as lambda from 'aws-cdk-lib/aws-lambda';\nimport * as cr from 'aws-cdk-lib/custom-resources';\nimport { Construct } from 'constructs';\n\nclass MyStack extends cdk.Stack {\n  constructor(scope: Construct, id: string, props?: cdk.StackProps) {\n    super(scope, id, props);\n\n    const myFunction = new lambda.Function(this, 'MyFunction', {\n      runtime: lambda.Runtime.NODEJS_14_X,\n      handler: 'index.handler',\n      code: lambda.Code.fromInline(`\n        exports.handler = async function(event) {\n          console.log('Event: ', event);\n          return { PhysicalResourceId: 'my-custom-resource' };\n        };\n      `),\n    });\n\n    new cr.Provider(this, 'MyProvider', {\n      onEventHandler: myFunction,\n    });\n  }\n}\n\nconst app = new cdk.App();\nnew MyStack(app, 'MyStack');"}
0

Keywords

FAQs

Package last updated on 30 Dec 2022

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