aws-cdk-lib.aws_lambda.AssetImageCode

class AssetImageCode

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

Extends Code

Represents an ECR image that will be constructed from the specified asset and can be bound as Lambda code.

Example

// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as cdk from 'aws-cdk-lib';
import { aws_ecr_assets as ecr_assets } from 'aws-cdk-lib';
import { aws_lambda as lambda } from 'aws-cdk-lib';

declare const networkMode: ecr_assets.NetworkMode;
declare const platform: ecr_assets.Platform;
const assetImageCode = new lambda.AssetImageCode('directory', {
  assetName: 'assetName',
  buildArgs: {
    buildArgsKey: 'buildArgs',
  },
  buildSecrets: {
    buildSecretsKey: 'buildSecrets',
  },
  cacheFrom: [{
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  }],
  cacheTo: {
    type: 'type',

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  cmd: ['cmd'],
  entrypoint: ['entrypoint'],
  exclude: ['exclude'],
  extraHash: 'extraHash',
  file: 'file',
  followSymlinks: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
  invalidation: {
    buildArgs: false,
    buildSecrets: false,
    extraHash: false,
    file: false,
    networkMode: false,
    outputs: false,
    platform: false,
    repositoryName: false,
    target: false,
  },
  networkMode: networkMode,
  outputs: ['outputs'],
  platform: platform,
  target: 'target',
  workingDirectory: 'workingDirectory',
});

Initializer

new AssetImageCode(directory: string, props: AssetImageCodeProps)

Parameters

  • directory string
  • props AssetImageCodeProps

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.