Class: AWSCDK::AssetOptions

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
asset_options.rb

Overview

Asset hash options.

Direct Known Subclasses

S3Assets::AssetOptions

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(asset_hash: nil, asset_hash_type: nil, bundling: nil) ⇒ AssetOptions

Returns a new instance of AssetOptions.

Parameters:

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

    Specify a custom hash for this asset.

  • asset_hash_type (AWSCDK::AssetHashType, nil) (defaults to: nil)

    Specifies the type of hash to calculate for this asset.

  • bundling (AWSCDK::BundlingOptions, nil) (defaults to: nil)

    Bundle the asset by executing a command in a Docker container or a custom bundling provider.



10
11
12
13
14
15
16
17
# File 'asset_options.rb', line 10

def initialize(asset_hash: nil, asset_hash_type: nil, bundling: nil)
  @asset_hash = asset_hash
  Jsii::Type.check_type(@asset_hash, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "assetHash") unless @asset_hash.nil?
  @asset_hash_type = asset_hash_type
  Jsii::Type.check_type(@asset_hash_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5Bc3NldEhhc2hUeXBlIn0=")), "assetHashType") unless @asset_hash_type.nil?
  @bundling = bundling.is_a?(Hash) ? ::AWSCDK::BundlingOptions.new(**bundling.transform_keys(&:to_sym)) : bundling
  Jsii::Type.check_type(@bundling, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5CdW5kbGluZ09wdGlvbnMifQ==")), "bundling") unless @bundling.nil?
end

Instance Attribute Details

#asset_hashString? (readonly)

Note:

Default: - based on assetHashType

Specify a custom hash for this asset.

If asset_hash_type is set it must be set to AssetHashType.CUSTOM. For consistency, this custom hash will be SHA256 hashed and encoded as hex. The resulting hash will be the asset hash.

NOTE: the hash is used in order to identify a specific revision of the asset, and used for optimizing and caching deployment activities related to this asset such as packaging, uploading to Amazon S3, etc. If you chose to customize the hash, you will need to make sure it is updated every time the asset changes, or otherwise it is possible that some deployments will not be invalidated.

Returns:

  • (String, nil)


34
35
36
# File 'asset_options.rb', line 34

def asset_hash
  @asset_hash
end

#asset_hash_typeAWSCDK::AssetHashType? (readonly)

Note:

Default: - the default is AssetHashType.SOURCE, but if assetHash is explicitly specified this value defaults to AssetHashType.CUSTOM.

Specifies the type of hash to calculate for this asset.

If asset_hash is configured, this option must be undefined or AssetHashType.CUSTOM.

Returns:



42
43
44
# File 'asset_options.rb', line 42

def asset_hash_type
  @asset_hash_type
end

#bundlingAWSCDK::BundlingOptions? (readonly)

Note:

Default: - uploaded as-is to S3 if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to S3 otherwise

Bundle the asset by executing a command in a Docker container or a custom bundling provider.

The asset path will be mounted at /asset-input. The Docker container is responsible for putting content at /asset-output. The content at /asset-output will be zipped and used as the final asset.

Returns:



52
53
54
# File 'asset_options.rb', line 52

def bundling
  @bundling
end

Class Method Details

.jsii_propertiesObject



54
55
56
57
58
59
60
# File 'asset_options.rb', line 54

def self.jsii_properties
  {
    :asset_hash => "assetHash",
    :asset_hash_type => "assetHashType",
    :bundling => "bundling",
  }
end

Instance Method Details

#to_jsiiObject



62
63
64
65
66
67
68
69
70
# File 'asset_options.rb', line 62

def to_jsii
  result = {}
  result.merge!({
    "assetHash" => @asset_hash,
    "assetHashType" => @asset_hash_type,
    "bundling" => @bundling,
  })
  result.compact
end