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 ros_cdk_ossassets
ros_cdk_ossassets.Asset(
scope: Construct,
id: str,
exclude: typing.List[str] = None,
follow_symlinks: SymlinkFollowMode = None,
ignore_mode: IgnoreMode = None,
asset_hash: str = None,
asset_hash_type: AssetHashType = None,
bundling: BundlingOptions = None,
deploy_time: bool = None,
path: str
)
Name | Type | Description |
---|---|---|
scope |
ros_cdk_core.Construct |
No description. |
id |
str |
No description. |
exclude |
typing.List[str] |
File paths matching the patterns will be excluded. |
follow_symlinks |
ros_cdk_core.SymlinkFollowMode |
A strategy for how to handle symlinks. |
ignore_mode |
ros_cdk_core.IgnoreMode |
The ignore behavior to use for exclude patterns. |
asset_hash |
str |
Specify a custom hash for this asset. |
asset_hash_type |
ros_cdk_core.AssetHashType |
Specifies the type of hash to calculate for this asset. |
bundling |
ros_cdk_core.BundlingOptions |
Bundle the asset by executing a command in a Docker container or a custom bundling provider. |
deploy_time |
bool |
Whether or not the asset needs to exist beyond deployment time; |
path |
str |
The disk location of the asset. |
scope
Required
- Type: ros_cdk_core.Construct
id
Required
- Type: str
exclude
Optional
- Type: typing.List[str]
- 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.
follow_symlinks
Optional
- Type: ros_cdk_core.SymlinkFollowMode
- Default: SymlinkFollowMode.NEVER
A strategy for how to handle symlinks.
ignore_mode
Optional
- Type: ros_cdk_core.IgnoreMode
- Default: IgnoreMode.GLOB
The ignore behavior to use for exclude
patterns.
asset_hash
Optional
- Type: str
- 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.
asset_hash_type
Optional
- Type: ros_cdk_core.AssetHashType
- Default: the default is
AssetHashType.SOURCE
, but ifassetHash
is explicitly specified this value defaults toAssetHashType.CUSTOM
.
Specifies the type of hash to calculate for this asset.
If assetHash
is configured, this option must be undefined
or
AssetHashType.CUSTOM
.
bundling
Optional
- Type: 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.
deploy_time
Optional
- Type: bool
- 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.
path
Required
- Type: str
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 |
---|---|
to_string |
Returns a string representation of this construct. |
synthesize |
Allows this construct to emit artifacts into the cloud assembly during synthesis. |
add_condition |
No description. |
add_count |
No description. |
add_dependency |
No description. |
add_resource_desc |
No description. |
apply_removal_policy |
No description. |
get_att |
No description. |
set_metadata |
No description. |
add_resource_metadata |
Adds ROS template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. |
to_string
def to_string() -> str
Returns a string representation of this construct.
synthesize
def synthesize(
session: ISynthesisSession
) -> None
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.
- Type: ros_cdk_core.ISynthesisSession
The synthesis session.
add_condition
def add_condition(
condition: RosCondition
) -> None
- Type: ros_cdk_core.RosCondition
add_count
def add_count(
count: typing.Union[typing.Union[int, float], IResolvable]
) -> None
- Type: typing.Union[typing.Union[int, float], ros_cdk_core.IResolvable]
add_dependency
def add_dependency(
resource: Resource
) -> None
- Type: ros_cdk_core.Resource
add_resource_desc
def add_resource_desc(
desc: str
) -> None
- Type: str
apply_removal_policy
def apply_removal_policy(
policy: RemovalPolicy
) -> None
- Type: ros_cdk_core.RemovalPolicy
get_att
def get_att(
name: str
) -> IResolvable
- Type: str
set_metadata
def set_metadata(
key: str,
value: typing.Any
) -> None
- Type: str
- Type: typing.Any
add_resource_metadata
def add_resource_metadata(
resource: RosResource,
resource_property: str
) -> None
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.
- Type: ros_cdk_core.RosResource
The ROS resource which is using this asset.
- Type: str
The property name where this asset is referenced.
Static Functions
Name | Description |
---|---|
is_construct |
Return whether the given object is a Construct. |
is_construct
import ros_cdk_ossassets
ros_cdk_ossassets.Asset.is_construct(
x: typing.Any
)
Return whether the given object is a Construct.
- Type: typing.Any
Properties
Name | Type | Description |
---|---|---|
node |
ros_cdk_core.ConstructNode |
The construct tree node associated with this construct. |
ref |
str |
No description. |
stack |
ros_cdk_core.Stack |
The stack in which this resource is defined. |
resource |
ros_cdk_core.RosResource |
No description. |
asset_hash |
str |
A cryptographic hash of the asset. |
asset_path |
str |
The path to the asset, relative to the current Cloud Assembly. |
bucket_name |
str |
Attribute that represents the name of the OSS bucket this asset exists in. |
http_url |
str |
Attribute which represents the OSS HTTP URL of this asset. |
is_file |
bool |
Indicates if this asset is a single file. |
is_zip_archive |
bool |
Indicates if this asset is a zip archive. |
object_key |
str |
Attribute which represents the OSS object key of this asset. |
node
Required
node: ConstructNode
- Type: ros_cdk_core.ConstructNode
The construct tree node associated with this construct.
ref
Required
ref: str
- Type: str
stack
Required
stack: Stack
- Type: ros_cdk_core.Stack
The stack in which this resource is defined.
resource
Optional
resource: RosResource
- Type: ros_cdk_core.RosResource
asset_hash
Required
asset_hash: str
- Type: str
A cryptographic hash of the asset.
asset_path
Required
asset_path: str
- Type: str
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.
bucket_name
Required
bucket_name: str
- Type: str
Attribute that represents the name of the OSS bucket this asset exists in.
http_url
Required
http_url: str
- Type: str
Attribute which represents the OSS HTTP URL of this asset.
For example, https://${bucketName}.oss-${region}.aliyuncs.com/${objectKey}
is_file
Required
is_file: bool
- Type: bool
Indicates if this asset is a single file.
Allows constructs to ensure that the correct file type was used.
is_zip_archive
Required
is_zip_archive: bool
- Type: bool
Indicates if this asset is a zip archive.
Allows constructs to ensure that the correct file type was used.
object_key
Required
object_key: str
- Type: str
Attribute which represents the OSS object key of this asset.