Class InlineCode
Lambda code from an inline string.
Inherited Members
Namespace: Amazon.CDK.AWS.Lambda
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class InlineCode : Code
Syntax (vb)
Public Class InlineCode Inherits Code
Remarks
ExampleMetadata: lit=aws-lambda/test/integ.layer-version.lit.ts infused
Examples
var layer = new LayerVersion(stack, "MyLayer", new LayerVersionProps {
Code = Code.FromAsset(Join(__dirname, "layer-code")),
CompatibleRuntimes = new [] { Runtime.NODEJS_LATEST },
License = "Apache-2.0",
Description = "A layer to test the L2 construct"
});
// To grant usage by other AWS accounts
layer.AddPermission("remote-account-grant", new LayerVersionPermission { AccountId = awsAccountId });
// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });
// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });
new Function(stack, "MyLayeredLambda", new FunctionProps {
Code = new InlineCode("foo"),
Handler = "index.handler",
Runtime = Runtime.NODEJS_LATEST,
Layers = new [] { layer }
});
Synopsis
Constructors
| InlineCode(string) | Lambda code from an inline string. |
Properties
| IsInline | Determines whether this Code is inline code or not. |
Methods
| Bind(Construct) | Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun. |
Constructors
InlineCode(string)
Lambda code from an inline string.
public InlineCode(string code)
Parameters
- code string
Remarks
ExampleMetadata: lit=aws-lambda/test/integ.layer-version.lit.ts infused
Examples
var layer = new LayerVersion(stack, "MyLayer", new LayerVersionProps {
Code = Code.FromAsset(Join(__dirname, "layer-code")),
CompatibleRuntimes = new [] { Runtime.NODEJS_LATEST },
License = "Apache-2.0",
Description = "A layer to test the L2 construct"
});
// To grant usage by other AWS accounts
layer.AddPermission("remote-account-grant", new LayerVersionPermission { AccountId = awsAccountId });
// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });
// To grant usage to all accounts in some AWS Ogranization
// layer.grantUsage({ accountId: '*', organizationId });
new Function(stack, "MyLayeredLambda", new FunctionProps {
Code = new InlineCode("foo"),
Handler = "index.handler",
Runtime = Runtime.NODEJS_LATEST,
Layers = new [] { layer }
});
Properties
IsInline
Determines whether this Code is inline code or not.
public virtual bool IsInline { get; }
Property Value
Remarks
ExampleMetadata: lit=aws-lambda/test/integ.layer-version.lit.ts infused
Methods
Bind(Construct)
Called when the lambda or layer is initialized to allow this object to bind to the stack, add resources and have fun.
public override ICodeConfig Bind(Construct scope)
Parameters
- scope Construct
Returns
Overrides
Remarks
ExampleMetadata: lit=aws-lambda/test/integ.layer-version.lit.ts infused