aws-cdk-lib.aws_lambda.InlineCode

class InlineCode

LanguageType name
.NETAmazon.CDK.AWS.Lambda.InlineCode
Gogithub.com/aws/aws-cdk-go/awscdk/v2/awslambda#InlineCode
Javasoftware.amazon.awscdk.services.lambda.InlineCode
Pythonaws_cdk.aws_lambda.InlineCode
TypeScript (source)aws-cdk-lib » aws_lambda » InlineCode

Extends Code

Lambda code from an inline string.

Example

const layer = new lambda.LayerVersion(stack, 'MyLayer', {
  code: lambda.Code.fromAsset(path.join(__dirname, 'layer-code')),
  compatibleRuntimes: [lambda.Runtime.NODEJS_14_X],
  license: 'Apache-2.0',
  description: 'A layer to test the L2 construct',
});

// To grant usage by other AWS accounts
layer.addPermission('remote-account-grant', { accountId: awsAccountId });

// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });

new lambda.Function(stack, 'MyLayeredLambda', {
  code: new lambda.InlineCode('foo'),
  handler: 'index.handler',
  runtime: lambda.Runtime.NODEJS_14_X,
  layers: [layer],
});

Initializer

new InlineCode(code: string)

Parameters

  • code string

Properties

NameTypeDescription
isInlinebooleanDetermines whether this Code is inline code or not.

isInline

Type: boolean

Determines whether this Code is inline code or not.

Methods

NameDescription
bind(_scope)Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
bindToResource(_resource, _options?)Called after the CFN function resource has been created to allow the code class to bind to it.

bind(_scope)

public bind(_scope: Construct): CodeConfig

Parameters

  • _scope Construct

Returns

  • CodeConfig

Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.


bindToResource(_resource, _options?)

public bindToResource(_resource: CfnResource, _options?: ResourceBindOptions): void

Parameters

  • _resource CfnResource
  • _options ResourceBindOptions

Called after the CFN function resource has been created to allow the code class to bind to it.

Specifically it's required to allow assets to add metadata for tooling like SAM CLI to be able to find their origins.