Skip to content
v2.275.0

AssetImageCodeProps Struct ​

Properties to initialize a new AssetImage.

Example ​

ts
// 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 assetImageCodeProps: lambda.AssetImageCodeProps = {
  assetName: 'assetName',
  buildArgs: {
    buildArgsKey: 'buildArgs',
  },
  buildContexts: {
    buildContextsKey: 'buildContexts',
  },
  buildSecrets: {
    buildSecretsKey: 'buildSecrets',
  },
  buildSsh: 'buildSsh',
  cacheDisabled: false,
  cacheFrom: [{
    type: 'type',

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

    // the properties below are optional
    params: {
      paramsKey: 'params',
    },
  },
  cmd: ['cmd'],
  displayName: 'displayName',
  entrypoint: ['entrypoint'],
  exclude: ['exclude'],
  extraHash: 'extraHash',
  file: 'file',
  followSymlinks: cdk.SymlinkFollowMode.NEVER,
  ignoreMode: cdk.IgnoreMode.GLOB,
  invalidation: {
    buildArgs: false,
    buildContexts: false,
    buildSecrets: false,
    buildSsh: 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',
};

Properties ​

assetNameoptionalstringasset_nameoptionalstrassetNameoptionalStringAssetNameoptionalstringAssetNameoptional*string#
Unique identifier of the docker image asset and its potential revisions.

Default: no asset name

Required if using AppScopedStagingSynthesizer.

buildArgsoptional{ [key: string]: string }build_argsoptionaltyping.Mapping[str, str]buildArgsoptionalMap<String, String>BuildArgsoptionalIDictionary<string, string>BuildArgsoptional*map[string]*string#
Build args to pass to the `docker build` command.

Default: no build args are passed

Since Docker build arguments are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl).

buildContextsoptional{ [key: string]: string }build_contextsoptionaltyping.Mapping[str, str]buildContextsoptionalMap<String, String>BuildContextsoptionalIDictionary<string, string>BuildContextsoptional*map[string]*string#
Build contexts to pass to the `docker build` command.

Default: no additional build contexts

notes

Build contexts can be used to specify additional directories or images to use during the build. Each entry specifies a named build context and its source (a directory path, a URL, or a docker image).

Since Docker build contexts are resolved before deployment, keys and values cannot refer to unresolved tokens (such as lambda.functionArn or queue.queueUrl).

buildSecretsoptional{ [key: string]: string }build_secretsoptionaltyping.Mapping[str, str]buildSecretsoptionalMap<String, String>BuildSecretsoptionalIDictionary<string, string>BuildSecretsoptional*map[string]*string#
Build secrets.

Default: no build secrets

Docker BuildKit must be enabled to use build secrets.

example
ts
import { DockerBuildSecret } from 'aws-cdk-lib';

const buildSecrets = {
  'MY_SECRET': DockerBuildSecret.fromSrc('file.txt')
};
buildSshoptionalstringbuild_sshoptionalstrbuildSshoptionalStringBuildSshoptionalstringBuildSshoptional*string#
SSH agent socket or keys to pass to the `docker build` command.

Default: no --ssh flag

Docker BuildKit must be enabled to use the ssh flag

cacheDisabledoptionalbooleancache_disabledoptionalboolcacheDisabledoptionalBooleanCacheDisabledoptionalboolCacheDisabledoptional*bool#
Disable the cache and pass `--no-cache` to the `docker build` command.

Default: cache is used

cacheFromoptionalDockerCacheOption[]cache_fromoptionaltyping.List[DockerCacheOption]cacheFromoptionalList<DockerCacheOption>CacheFromoptionalDockerCacheOption[]CacheFromoptional*[]DockerCacheOption#
Cache from options to pass to the `docker build` command.

Default: no cache from options are passed to the build command

cacheTooptionalDockerCacheOptioncache_tooptionalDockerCacheOptioncacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOptionCacheTooptionalDockerCacheOption#
Cache to options to pass to the `docker build` command.

Default: no cache to options are passed to the build command

cmdoptionalstring[]cmdoptionaltyping.List[str]cmdoptionalList<String>Cmdoptionalstring[]Cmdoptional*[]*string#
Specify or override the CMD on the specified Docker image or Dockerfile.

Default: use the CMD specified in the docker image or Dockerfile.

This needs to be in the 'exec form', viz., [ 'executable', 'param1', 'param2' ].

displayNameoptionalstringdisplay_nameoptionalstrdisplayNameoptionalStringDisplayNameoptionalstringDisplayNameoptional*string#
A display name for this asset.

Default: Stack-relative construct path

notes

If supplied, the display name will be used in locations where the asset identifier is printed, like in the CLI progress information. If the same asset is added multiple times, the display name of the first occurrence is used.

If assetName is given, it will also be used as the default displayName. Otherwise, the default is the construct path of the ImageAsset construct, with respect to the enclosing stack. If the asset is produced by a construct helper function (such as lambda.Code.fromAssetImage()), this will look like MyFunction/AssetImage.

We use the stack-relative construct path so that in the common case where you have multiple stacks with the same asset, we won't show something like /MyBetaStack/MyFunction/Code when you are actually deploying to production.

entrypointoptionalstring[]entrypointoptionaltyping.List[str]entrypointoptionalList<String>Entrypointoptionalstring[]Entrypointoptional*[]*string#
Specify or override the ENTRYPOINT on the specified Docker image or Dockerfile.

Default: use the ENTRYPOINT in the docker image or Dockerfile.

An ENTRYPOINT allows you to configure a container that will run as an executable. This needs to be in the 'exec form', viz., [ 'executable', 'param1', 'param2' ].

excludeoptionalstring[]excludeoptionaltyping.List[str]excludeoptionalList<String>Excludeoptionalstring[]Excludeoptional*[]*string#
File paths matching the patterns will be excluded.

Default: nothing is excluded

See ignoreMode to set the matching behavior. Has no effect on Assets bundled using the bundling property.

extraHashoptionalstringextra_hashoptionalstrextraHashoptionalStringExtraHashoptionalstringExtraHashoptional*string#
Extra information to encode into the fingerprint (e.g. build instructions and other inputs).

Default: hash is only based on source content

fileoptionalstringfileoptionalstrfileoptionalStringFileoptionalstringFileoptional*string= 'Dockerfile'#
Path to the Dockerfile (relative to the directory).
ignoreModeoptionalIgnoreModeignore_modeoptionalIgnoreModeignoreModeoptionalIgnoreModeIgnoreModeoptionalIgnoreModeIgnoreModeoptionalIgnoreMode= IgnoreMode.GLOB#
The ignore behavior to use for `exclude` patterns.
Options to control which parameters are used to invalidate the asset hash.

Default: hash all parameters

networkModeoptionalNetworkModenetwork_modeoptionalNetworkModenetworkModeoptionalNetworkModeNetworkModeoptionalNetworkModeNetworkModeoptionalNetworkMode#
Networking mode for the RUN commands during build.

Default: no networking mode specified (the default networking mode NetworkMode.DEFAULT will be used)

Support docker API 1.25+.

outputsoptionalstring[]outputsoptionaltyping.List[str]outputsoptionalList<String>Outputsoptionalstring[]Outputsoptional*[]*string#
Outputs to pass to the `docker build` command.

Default: no outputs are passed to the build command (default outputs are used)

platformoptionalPlatformplatformoptionalPlatformplatformoptionalPlatformPlatformoptionalPlatformPlatformoptionalPlatform#
Platform to build for.

Default: no platform specified (the current machine architecture will be used)

Requires Docker Buildx.

targetoptionalstringtargetoptionalstrtargetoptionalStringTargetoptionalstringTargetoptional*string#
Docker target to build to.

Default: no target

workingDirectoryoptionalstringworking_directoryoptionalstrworkingDirectoryoptionalStringWorkingDirectoryoptionalstringWorkingDirectoryoptional*string#
Specify or override the WORKDIR on the specified Docker image or Dockerfile.

Default: use the WORKDIR in the docker image or Dockerfile.

A WORKDIR allows you to configure the working directory the container will use.