Skip to content

Asset

An asset represents a local file or directory, which is automatically uploaded to OSS bucket and then can be referenced within a CDK application.

Initializers

import com.aliyun.ros.cdk.ossassets.Asset;
Asset.Builder.create(Construct scope, java.lang.String id)
//  .exclude(java.util.List<java.lang.String>)
//  .followSymlinks(SymlinkFollowMode)
//  .ignoreMode(IgnoreMode)
//  .assetHash(java.lang.String)
//  .assetHashType(AssetHashType)
//  .bundling(BundlingOptions)
//  .deployTime(java.lang.Boolean)
    .path(java.lang.String)
    .build();
Name Type Description
scope com.aliyun.ros.cdk.core.Construct No description.
id java.lang.String No description.
exclude java.util.List File paths matching the patterns will be excluded.
followSymlinks com.aliyun.ros.cdk.core.SymlinkFollowMode A strategy for how to handle symlinks.
ignoreMode com.aliyun.ros.cdk.core.IgnoreMode The ignore behavior to use for exclude patterns.
assetHash java.lang.String Specify a custom hash for this asset.
assetHashType com.aliyun.ros.cdk.core.AssetHashType Specifies the type of hash to calculate for this asset.
bundling com.aliyun.ros.cdk.core.BundlingOptions Bundle the asset by executing a command in a Docker container or a custom bundling provider.
deployTime java.lang.Boolean Whether or not the asset needs to exist beyond deployment time;
path java.lang.String The disk location of the asset.

scopeRequired

  • Type: com.aliyun.ros.cdk.core.Construct

idRequired

  • Type: java.lang.String

excludeOptional

  • Type: java.util.List
  • Default: nothing is excluded

File paths matching the patterns will be excluded.

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


followSymlinksOptional

  • Type: com.aliyun.ros.cdk.core.SymlinkFollowMode
  • Default: SymlinkFollowMode.NEVER

A strategy for how to handle symlinks.


ignoreModeOptional

  • Type: com.aliyun.ros.cdk.core.IgnoreMode
  • Default: IgnoreMode.GLOB

The ignore behavior to use for exclude patterns.


assetHashOptional

  • Type: java.lang.String
  • Default: based on assetHashType

Specify a custom hash for this asset.

If assetHashType 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 OSS bucket, 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.


assetHashTypeOptional

  • Type: com.aliyun.ros.cdk.core.AssetHashType
  • 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 assetHash is configured, this option must be undefined or AssetHashType.CUSTOM.


bundlingOptional

  • Type: com.aliyun.ros.cdk.core.BundlingOptions
  • Default: uploaded as-is to OSS bucket if the asset is a regular file or a .zip file, archived into a .zip file and uploaded to OSS bucket 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.


deployTimeOptional

  • Type: java.lang.Boolean
  • Default: false

Whether or not the asset needs to exist beyond deployment time;

i.e. are copied over to a different location and not needed afterwards. Setting this property to true has an impact on the lifecycle of the asset, because we will assume that it is safe to delete after the ROS deployment succeeds.

For example, FC Function assets are copied over to Function during deployment. Therefore, it is not necessary to store the asset in OSS bucket, so we consider those deployTime assets.


pathRequired

  • Type: java.lang.String

The disk location of the asset.

The path should refer to one of the following:

  • A regular file or a .zip file, in which case the file will be uploaded as-is to OSS bucket.
  • A directory, in which case it will be archived into a .zip file and uploaded to OSS bucket.

Methods

Name Description
toString Returns a string representation of this construct.
synthesize Allows this construct to emit artifacts into the cloud assembly during synthesis.
addCondition No description.
addCount No description.
addDependency No description.
addResourceDesc No description.
applyRemovalPolicy No description.
getAtt No description.
setMetadata No description.
addResourceMetadata Adds ROS template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.

toString

public java.lang.String toString()

Returns a string representation of this construct.

synthesize

public void synthesize(ISynthesisSession session)

Allows this construct to emit artifacts into the cloud assembly during synthesis.

This method is usually implemented by framework-level constructs such as Stack and Asset as they participate in synthesizing the cloud assembly.

sessionRequired

  • Type: com.aliyun.ros.cdk.core.ISynthesisSession

The synthesis session.


addCondition

public void addCondition(RosCondition condition)

conditionRequired

  • Type: com.aliyun.ros.cdk.core.RosCondition

addCount

public void addCount(java.lang.Number OR IResolvable count)

countRequired

  • Type: java.lang.Number OR com.aliyun.ros.cdk.core.IResolvable

addDependency

public void addDependency(Resource resource)

resourceRequired

  • Type: com.aliyun.ros.cdk.core.Resource

addResourceDesc

public void addResourceDesc(java.lang.String desc)

descRequired

  • Type: java.lang.String

applyRemovalPolicy

public void applyRemovalPolicy(RemovalPolicy policy)

policyRequired

  • Type: com.aliyun.ros.cdk.core.RemovalPolicy

getAtt

public IResolvable getAtt(java.lang.String name)

nameRequired

  • Type: java.lang.String

setMetadata

public void setMetadata(java.lang.String key, java.lang.Object value)

keyRequired

  • Type: java.lang.String

valueRequired

  • Type: java.lang.Object

addResourceMetadata

public void addResourceMetadata(RosResource resource, java.lang.String resourceProperty)

Adds ROS template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.

Asset metadata will only be included if the stack is synthesized with the "ros:cdk:enable-asset-metadata" context key defined, which is the default behavior when synthesizing via the CDK Toolkit.

resourceRequired

  • Type: com.aliyun.ros.cdk.core.RosResource

The ROS resource which is using this asset.


resourcePropertyRequired

  • Type: java.lang.String

The property name where this asset is referenced.


Static Functions

Name Description
isConstruct Return whether the given object is a Construct.

isConstruct

import com.aliyun.ros.cdk.ossassets.Asset;
Asset.isConstruct(java.lang.Object x)

Return whether the given object is a Construct.

xRequired

  • Type: java.lang.Object

Properties

Name Type Description
node com.aliyun.ros.cdk.core.ConstructNode The construct tree node associated with this construct.
ref java.lang.String No description.
stack com.aliyun.ros.cdk.core.Stack The stack in which this resource is defined.
resource com.aliyun.ros.cdk.core.RosResource No description.
assetHash java.lang.String A cryptographic hash of the asset.
assetPath java.lang.String The path to the asset, relative to the current Cloud Assembly.
bucketName java.lang.String Attribute that represents the name of the OSS bucket this asset exists in.
httpUrl java.lang.String Attribute which represents the OSS HTTP URL of this asset.
isFile java.lang.Boolean Indicates if this asset is a single file.
isZipArchive java.lang.Boolean Indicates if this asset is a zip archive.
objectKey java.lang.String Attribute which represents the OSS object key of this asset.

nodeRequired

public ConstructNode getNode();
  • Type: com.aliyun.ros.cdk.core.ConstructNode

The construct tree node associated with this construct.


refRequired

public java.lang.String getRef();
  • Type: java.lang.String

stackRequired

public Stack getStack();
  • Type: com.aliyun.ros.cdk.core.Stack

The stack in which this resource is defined.


resourceOptional

public RosResource getResource();
  • Type: com.aliyun.ros.cdk.core.RosResource

assetHashRequired

public java.lang.String getAssetHash();
  • Type: java.lang.String

A cryptographic hash of the asset.


assetPathRequired

public java.lang.String getAssetPath();
  • Type: java.lang.String

The path to the asset, relative to the current Cloud Assembly.

If asset staging is disabled, this will just be the original path. If asset staging is enabled it will be the staged path.


bucketNameRequired

public java.lang.String getBucketName();
  • Type: java.lang.String

Attribute that represents the name of the OSS bucket this asset exists in.


httpUrlRequired

public java.lang.String getHttpUrl();
  • Type: java.lang.String

Attribute which represents the OSS HTTP URL of this asset.

For example, https://${bucketName}.oss-${region}.aliyuncs.com/${objectKey}


isFileRequired

public java.lang.Boolean getIsFile();
  • Type: java.lang.Boolean

Indicates if this asset is a single file.

Allows constructs to ensure that the correct file type was used.


isZipArchiveRequired

public java.lang.Boolean getIsZipArchive();
  • Type: java.lang.Boolean

Indicates if this asset is a zip archive.

Allows constructs to ensure that the correct file type was used.


objectKeyRequired

public java.lang.String getObjectKey();
  • Type: java.lang.String

Attribute which represents the OSS object key of this asset.


Structs