Class Asset
An asset represents a local file or directory, which is automatically uploaded to S3 and then can be referenced within a CDK application.
Inherited Members
Namespace: Amazon.CDK.AWS.S3.Assets
Assembly: Amazon.CDK.AWS.S3.Assets.dll
Syntax (csharp)
public class Asset : Construct, IConstruct, IDependable, IAsset
Syntax (vb)
Public Class Asset
Inherits Construct
Implements IConstruct, IDependable, IAsset
Remarks
ExampleMetadata: infused
Examples
using Amazon.CDK.AWS.S3.Assets;
Cluster cluster;
var chartAsset = new Asset(this, "ChartAsset", new AssetProps {
Path = "/path/to/asset"
});
cluster.AddHelmChart("test-chart", new HelmChartOptions {
ChartAsset = chartAsset
});
Synopsis
Constructors
Asset(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Asset(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Asset(Construct, String, IAssetProps) |
Properties
AssetHash | A hash of this asset, which is available at construction time. |
AssetPath | The path to the asset, relative to the current Cloud Assembly. |
Bucket | The S3 bucket in which this asset resides. |
HttpUrl | Attribute which represents the S3 HTTP URL of this asset. |
IsFile | Indicates if this asset is a single file. |
IsZipArchive | Indicates if this asset is a zip archive. |
S3BucketName | Attribute that represents the name of the bucket this asset exists in. |
S3ObjectKey | Attribute which represents the S3 object key of this asset. |
S3ObjectUrl | Attribute which represents the S3 URL of this asset. |
S3Url | (deprecated) Attribute which represents the S3 URL of this asset. |
SourceHash | (deprecated) A cryptographic hash of the asset. |
Methods
AddResourceMetadata(CfnResource, String) | Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. |
GrantRead(IGrantable) | Grants read permissions to the principal on the assets bucket. |
Constructors
Asset(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Asset(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Asset(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Asset(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Asset(Construct, String, IAssetProps)
public Asset(Construct scope, string id, IAssetProps props)
Parameters
- scope Constructs.Construct
- id System.String
- props IAssetProps
Properties
AssetHash
A hash of this asset, which is available at construction time.
public virtual string AssetHash { get; }
Property Value
System.String
Remarks
As this is a plain string, it can be used in construct IDs in order to enforce creation of a new resource when the content hash has changed.
AssetPath
The path to the asset, relative to the current Cloud Assembly.
public virtual string AssetPath { get; }
Property Value
System.String
Remarks
If asset staging is disabled, this will just be the original path. If asset staging is enabled it will be the staged path.
Bucket
The S3 bucket in which this asset resides.
public virtual IBucket Bucket { get; }
Property Value
HttpUrl
Attribute which represents the S3 HTTP URL of this asset.
public virtual string HttpUrl { get; }
Property Value
System.String
Remarks
For example, https://s3.us-west-1.amazonaws.com/bucket/key
IsFile
Indicates if this asset is a single file.
public virtual bool IsFile { get; }
Property Value
System.Boolean
Remarks
Allows constructs to ensure that the correct file type was used.
IsZipArchive
Indicates if this asset is a zip archive.
public virtual bool IsZipArchive { get; }
Property Value
System.Boolean
Remarks
Allows constructs to ensure that the correct file type was used.
S3BucketName
Attribute that represents the name of the bucket this asset exists in.
public virtual string S3BucketName { get; }
Property Value
System.String
S3ObjectKey
Attribute which represents the S3 object key of this asset.
public virtual string S3ObjectKey { get; }
Property Value
System.String
S3ObjectUrl
Attribute which represents the S3 URL of this asset.
public virtual string S3ObjectUrl { get; }
Property Value
System.String
Remarks
For example, s3://bucket/key
S3Url
(deprecated) Attribute which represents the S3 URL of this asset.
public virtual string S3Url { get; }
Property Value
System.String
Remarks
Stability: Deprecated
SourceHash
(deprecated) A cryptographic hash of the asset.
public virtual string SourceHash { get; }
Property Value
System.String
Remarks
Stability: Deprecated
Methods
AddResourceMetadata(CfnResource, String)
Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.
public virtual void AddResourceMetadata(CfnResource resource, string resourceProperty)
Parameters
- resource CfnResource
The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface].
- resourceProperty System.String
The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function).
Remarks
This can be used by tools such as SAM CLI to provide local experience such as local invocation and debugging of Lambda functions.
Asset metadata will only be included if the stack is synthesized with the "aws:cdk:enable-asset-metadata" context key defined, which is the default behavior when synthesizing via the CDK Toolkit.
GrantRead(IGrantable)
Grants read permissions to the principal on the assets bucket.
public virtual void GrantRead(IGrantable grantee)
Parameters
- grantee IGrantable