Class: AWSCDK::Lambda::AssetImageCodeProps

Inherits:
ECRAssets::DockerImageAssetOptions
  • Object
show all
Defined in:
lambda/asset_image_code_props.rb

Overview

Properties to initialize a new AssetImage.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exclude: nil, follow_symlinks: nil, ignore_mode: nil, extra_hash: nil, asset_name: nil, build_args: nil, build_contexts: nil, build_secrets: nil, build_ssh: nil, cache_disabled: nil, cache_from: nil, cache_to: nil, display_name: nil, file: nil, invalidation: nil, network_mode: nil, outputs: nil, platform: nil, target: nil, cmd: nil, entrypoint: nil, working_directory: nil) ⇒ AssetImageCodeProps

Returns a new instance of AssetImageCodeProps.

Parameters:

  • exclude (Array<String>, nil) (defaults to: nil)

    File paths matching the patterns will be excluded.

  • follow_symlinks (AWSCDK::SymlinkFollowMode, nil) (defaults to: nil)

    A strategy for how to handle symlinks.

  • ignore_mode (AWSCDK::IgnoreMode, nil) (defaults to: nil)

    The ignore behavior to use for exclude patterns.

  • extra_hash (String, nil) (defaults to: nil)

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

  • asset_name (String, nil) (defaults to: nil)

    Unique identifier of the docker image asset and its potential revisions.

  • build_args (Hash{String => String}, nil) (defaults to: nil)

    Build args to pass to the docker build command.

  • build_contexts (Hash{String => String}, nil) (defaults to: nil)

    Build contexts to pass to the docker build command.

  • build_secrets (Hash{String => String}, nil) (defaults to: nil)

    Build secrets.

  • build_ssh (String, nil) (defaults to: nil)

    SSH agent socket or keys to pass to the docker build command.

  • cache_disabled (Boolean, nil) (defaults to: nil)

    Disable the cache and pass --no-cache to the docker build command.

  • cache_from (Array<AWSCDK::ECRAssets::DockerCacheOption>, nil) (defaults to: nil)

    Cache from options to pass to the docker build command.

  • cache_to (AWSCDK::ECRAssets::DockerCacheOption, nil) (defaults to: nil)

    Cache to options to pass to the docker build command.

  • display_name (String, nil) (defaults to: nil)

    A display name for this asset.

  • file (String, nil) (defaults to: nil)

    Path to the Dockerfile (relative to the directory).

  • invalidation (AWSCDK::ECRAssets::DockerImageAssetInvalidationOptions, nil) (defaults to: nil)

    Options to control which parameters are used to invalidate the asset hash.

  • network_mode (AWSCDK::ECRAssets::NetworkMode, nil) (defaults to: nil)

    Networking mode for the RUN commands during build.

  • outputs (Array<String>, nil) (defaults to: nil)

    Outputs to pass to the docker build command.

  • platform (AWSCDK::ECRAssets::Platform, nil) (defaults to: nil)

    Platform to build for.

  • target (String, nil) (defaults to: nil)

    Docker target to build to.

  • cmd (Array<String>, nil) (defaults to: nil)

    Specify or override the CMD on the specified Docker image or Dockerfile.

  • entrypoint (Array<String>, nil) (defaults to: nil)

    Specify or override the ENTRYPOINT on the specified Docker image or Dockerfile.

  • working_directory (String, nil) (defaults to: nil)

    Specify or override the WORKDIR on the specified Docker image or Dockerfile.



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lambda/asset_image_code_props.rb', line 29

def initialize(exclude: nil, follow_symlinks: nil, ignore_mode: nil, extra_hash: nil, asset_name: nil, build_args: nil, build_contexts: nil, build_secrets: nil, build_ssh: nil, cache_disabled: nil, cache_from: nil, cache_to: nil, display_name: nil, file: nil, invalidation: nil, network_mode: nil, outputs: nil, platform: nil, target: nil, cmd: nil, entrypoint: nil, working_directory: nil)
  @exclude = exclude
  Jsii::Type.check_type(@exclude, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "exclude") unless @exclude.nil?
  @follow_symlinks = follow_symlinks
  Jsii::Type.check_type(@follow_symlinks, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TeW1saW5rRm9sbG93TW9kZSJ9")), "followSymlinks") unless @follow_symlinks.nil?
  @ignore_mode = ignore_mode
  Jsii::Type.check_type(@ignore_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5JZ25vcmVNb2RlIn0=")), "ignoreMode") unless @ignore_mode.nil?
  @extra_hash = extra_hash
  Jsii::Type.check_type(@extra_hash, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "extraHash") unless @extra_hash.nil?
  @asset_name = asset_name
  Jsii::Type.check_type(@asset_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assetName") unless @asset_name.nil?
  @build_args = build_args
  Jsii::Type.check_type(@build_args, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildArgs") unless @build_args.nil?
  @build_contexts = build_contexts
  Jsii::Type.check_type(@build_contexts, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildContexts") unless @build_contexts.nil?
  @build_secrets = build_secrets
  Jsii::Type.check_type(@build_secrets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoibWFwIn19")), "buildSecrets") unless @build_secrets.nil?
  @build_ssh = build_ssh
  Jsii::Type.check_type(@build_ssh, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "buildSsh") unless @build_ssh.nil?
  @cache_disabled = cache_disabled
  Jsii::Type.check_type(@cache_disabled, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "cacheDisabled") unless @cache_disabled.nil?
  @cache_from = cache_from.is_a?(Array) ? cache_from.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::ECRAssets::DockerCacheOption.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : cache_from
  Jsii::Type.check_type(@cache_from, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lY3JfYXNzZXRzLkRvY2tlckNhY2hlT3B0aW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "cacheFrom") unless @cache_from.nil?
  @cache_to = cache_to.is_a?(Hash) ? ::AWSCDK::ECRAssets::DockerCacheOption.new(**cache_to.transform_keys(&:to_sym)) : cache_to
  Jsii::Type.check_type(@cache_to, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNyX2Fzc2V0cy5Eb2NrZXJDYWNoZU9wdGlvbiJ9")), "cacheTo") unless @cache_to.nil?
  @display_name = display_name
  Jsii::Type.check_type(@display_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "displayName") unless @display_name.nil?
  @file = file
  Jsii::Type.check_type(@file, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "file") unless @file.nil?
  @invalidation = invalidation.is_a?(Hash) ? ::AWSCDK::ECRAssets::DockerImageAssetInvalidationOptions.new(**invalidation.transform_keys(&:to_sym)) : invalidation
  Jsii::Type.check_type(@invalidation, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNyX2Fzc2V0cy5Eb2NrZXJJbWFnZUFzc2V0SW52YWxpZGF0aW9uT3B0aW9ucyJ9")), "invalidation") unless @invalidation.nil?
  @network_mode = network_mode
  Jsii::Type.check_type(@network_mode, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNyX2Fzc2V0cy5OZXR3b3JrTW9kZSJ9")), "networkMode") unless @network_mode.nil?
  @outputs = outputs
  Jsii::Type.check_type(@outputs, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "outputs") unless @outputs.nil?
  @platform = platform
  Jsii::Type.check_type(@platform, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNyX2Fzc2V0cy5QbGF0Zm9ybSJ9")), "platform") unless @platform.nil?
  @target = target
  Jsii::Type.check_type(@target, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "target") unless @target.nil?
  @cmd = cmd
  Jsii::Type.check_type(@cmd, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "cmd") unless @cmd.nil?
  @entrypoint = entrypoint
  Jsii::Type.check_type(@entrypoint, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7InByaW1pdGl2ZSI6InN0cmluZyJ9LCJraW5kIjoiYXJyYXkifX0=")), "entrypoint") unless @entrypoint.nil?
  @working_directory = working_directory
  Jsii::Type.check_type(@working_directory, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "workingDirectory") unless @working_directory.nil?
end

Instance Attribute Details

#asset_nameString? (readonly)

Note:

Default: - no asset name

Unique identifier of the docker image asset and its potential revisions.

Required if using AppScopedStagingSynthesizer.

Returns:

  • (String, nil)


105
106
107
# File 'lambda/asset_image_code_props.rb', line 105

def asset_name
  @asset_name
end

#build_argsHash{String => String}? (readonly)

Note:

Default: - no build args are passed

Build args to pass to the docker build command.

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

Returns:

  • (Hash{String => String}, nil)


114
115
116
# File 'lambda/asset_image_code_props.rb', line 114

def build_args
  @build_args
end

#build_contextsHash{String => String}? (readonly)

Note:

Default: - no additional build contexts

Build contexts to pass to the docker build command.

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).

Returns:

  • (Hash{String => String}, nil)

See Also:



128
129
130
# File 'lambda/asset_image_code_props.rb', line 128

def build_contexts
  @build_contexts
end

#build_secretsHash{String => String}? (readonly)

Note:

Default: - no build secrets

Build secrets.

Docker BuildKit must be enabled to use build secrets.

Examples:

require 'aws-cdk-lib'

build_secrets = {
    "MY_SECRET" => AWSCDK::DockerBuildSecret.from_src("file.txt"),
}

Returns:

  • (Hash{String => String}, nil)

See Also:



142
143
144
# File 'lambda/asset_image_code_props.rb', line 142

def build_secrets
  @build_secrets
end

#build_sshString? (readonly)

Note:

Default: - no --ssh flag

SSH agent socket or keys to pass to the docker build command.

Docker BuildKit must be enabled to use the ssh flag

Returns:

  • (String, nil)

See Also:



150
151
152
# File 'lambda/asset_image_code_props.rb', line 150

def build_ssh
  @build_ssh
end

#cache_disabledBoolean? (readonly)

Note:

Default: - cache is used

Disable the cache and pass --no-cache to the docker build command.

Returns:

  • (Boolean, nil)


155
156
157
# File 'lambda/asset_image_code_props.rb', line 155

def cache_disabled
  @cache_disabled
end

#cache_fromArray<AWSCDK::ECRAssets::DockerCacheOption>? (readonly)

Note:

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

Cache from options to pass to the docker build command.



161
162
163
# File 'lambda/asset_image_code_props.rb', line 161

def cache_from
  @cache_from
end

#cache_toAWSCDK::ECRAssets::DockerCacheOption? (readonly)

Note:

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

Cache to options to pass to the docker build command.



167
168
169
# File 'lambda/asset_image_code_props.rb', line 167

def cache_to
  @cache_to
end

#cmdArray<String>? (readonly)

Note:

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

Specify or override the CMD on the specified Docker image or Dockerfile.

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

Returns:

  • (Array<String>, nil)

See Also:



231
232
233
# File 'lambda/asset_image_code_props.rb', line 231

def cmd
  @cmd
end

#display_nameString? (readonly)

Note:

Default: - Stack-relative construct path

A display name for this asset.

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 asset_name is given, it will also be used as the default display_name. 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.

Returns:

  • (String, nil)


188
189
190
# File 'lambda/asset_image_code_props.rb', line 188

def display_name
  @display_name
end

#entrypointArray<String>? (readonly)

Note:

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

Specify or override the ENTRYPOINT on the specified 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' ].

Returns:

  • (Array<String>, nil)

See Also:



240
241
242
# File 'lambda/asset_image_code_props.rb', line 240

def entrypoint
  @entrypoint
end

#excludeArray<String>? (readonly)

Note:

Default: - nothing is excluded

File paths matching the patterns will be excluded.

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

Returns:

  • (Array<String>, nil)


83
84
85
# File 'lambda/asset_image_code_props.rb', line 83

def exclude
  @exclude
end

#extra_hashString? (readonly)

Note:

Default: - hash is only based on source content

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

Returns:

  • (String, nil)


98
99
100
# File 'lambda/asset_image_code_props.rb', line 98

def extra_hash
  @extra_hash
end

#fileString? (readonly)

Note:

Default: 'Dockerfile'

Path to the Dockerfile (relative to the directory).

Returns:

  • (String, nil)


193
194
195
# File 'lambda/asset_image_code_props.rb', line 193

def file
  @file
end
Note:

Default: SymlinkFollowMode.NEVER

A strategy for how to handle symlinks.

Returns:



88
89
90
# File 'lambda/asset_image_code_props.rb', line 88

def follow_symlinks
  @follow_symlinks
end

#ignore_modeAWSCDK::IgnoreMode? (readonly)

Note:

Default: IgnoreMode.GLOB

The ignore behavior to use for exclude patterns.

Returns:



93
94
95
# File 'lambda/asset_image_code_props.rb', line 93

def ignore_mode
  @ignore_mode
end

#invalidationAWSCDK::ECRAssets::DockerImageAssetInvalidationOptions? (readonly)

Note:

Default: - hash all parameters

Options to control which parameters are used to invalidate the asset hash.



198
199
200
# File 'lambda/asset_image_code_props.rb', line 198

def invalidation
  @invalidation
end

#network_modeAWSCDK::ECRAssets::NetworkMode? (readonly)

Note:

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

Networking mode for the RUN commands during build.

Support docker API 1.25+.



205
206
207
# File 'lambda/asset_image_code_props.rb', line 205

def network_mode
  @network_mode
end

#outputsArray<String>? (readonly)

Note:

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

Outputs to pass to the docker build command.



211
212
213
# File 'lambda/asset_image_code_props.rb', line 211

def outputs
  @outputs
end

#platformAWSCDK::ECRAssets::Platform? (readonly)

Note:

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

Platform to build for.

Requires Docker Buildx.

Returns:



218
219
220
# File 'lambda/asset_image_code_props.rb', line 218

def platform
  @platform
end

#targetString? (readonly)

Note:

Default: - no target

Docker target to build to.

Returns:

  • (String, nil)


223
224
225
# File 'lambda/asset_image_code_props.rb', line 223

def target
  @target
end

#working_directoryString? (readonly)

Note:

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

Specify or override the WORKDIR on the specified Docker image or Dockerfile.

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



248
249
250
# File 'lambda/asset_image_code_props.rb', line 248

def working_directory
  @working_directory
end

Class Method Details

.jsii_propertiesObject



250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lambda/asset_image_code_props.rb', line 250

def self.jsii_properties
  {
    :exclude => "exclude",
    :follow_symlinks => "followSymlinks",
    :ignore_mode => "ignoreMode",
    :extra_hash => "extraHash",
    :asset_name => "assetName",
    :build_args => "buildArgs",
    :build_contexts => "buildContexts",
    :build_secrets => "buildSecrets",
    :build_ssh => "buildSsh",
    :cache_disabled => "cacheDisabled",
    :cache_from => "cacheFrom",
    :cache_to => "cacheTo",
    :display_name => "displayName",
    :file => "file",
    :invalidation => "invalidation",
    :network_mode => "networkMode",
    :outputs => "outputs",
    :platform => "platform",
    :target => "target",
    :cmd => "cmd",
    :entrypoint => "entrypoint",
    :working_directory => "workingDirectory",
  }
end

Instance Method Details

#to_jsiiObject



277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lambda/asset_image_code_props.rb', line 277

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "exclude" => @exclude,
    "followSymlinks" => @follow_symlinks,
    "ignoreMode" => @ignore_mode,
    "extraHash" => @extra_hash,
    "assetName" => @asset_name,
    "buildArgs" => @build_args,
    "buildContexts" => @build_contexts,
    "buildSecrets" => @build_secrets,
    "buildSsh" => @build_ssh,
    "cacheDisabled" => @cache_disabled,
    "cacheFrom" => @cache_from,
    "cacheTo" => @cache_to,
    "displayName" => @display_name,
    "file" => @file,
    "invalidation" => @invalidation,
    "networkMode" => @network_mode,
    "outputs" => @outputs,
    "platform" => @platform,
    "target" => @target,
    "cmd" => @cmd,
    "entrypoint" => @entrypoint,
    "workingDirectory" => @working_directory,
  })
  result.compact
end