java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.services.s3.assets.Asset
All Implemented Interfaces:
IAsset, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:36.636Z") @Stability(Stable) public class Asset extends software.constructs.Construct implements IAsset
An asset represents a local file or directory, which is automatically uploaded to S3 and then can be referenced within a CDK application.

Example:

 import software.amazon.awscdk.*;
 Asset asset = Asset.Builder.create(this, "BundledAsset")
         .path("/path/to/asset")
         .bundling(BundlingOptions.builder()
                 .image(DockerImage.fromRegistry("alpine"))
                 .command(List.of("command-that-produces-an-archive.sh"))
                 .outputType(BundlingOutput.NOT_ARCHIVED)
                 .build())
         .build();
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    A fluent builder for Asset.

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.IAsset

    IAsset.Jsii$Default, IAsset.Jsii$Proxy

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default, software.constructs.IConstruct.Jsii$Proxy
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Asset(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Asset(software.amazon.jsii.JsiiObjectRef objRef)
     
     
    Asset(software.constructs.Construct scope, String id, AssetProps props)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addResourceMetadata(CfnResource resource, String resourceProperty)
    Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.
    A hash of this asset, which is available at construction time.
    The path to the asset, relative to the current Cloud Assembly.
    The S3 bucket in which this asset resides.
    Attribute which represents the S3 HTTP URL of this asset.
    Indicates if this asset is a single file.
    Indicates if this asset is a zip archive.
    Attribute that represents the name of the bucket this asset exists in.
    Attribute which represents the S3 object key of this asset.
    Attribute which represents the S3 URL of this asset.
    void
    Grants read permissions to the principal on the assets bucket.

    Methods inherited from class software.constructs.Construct

    getNode, isConstruct, toString

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • Asset

      protected Asset(software.amazon.jsii.JsiiObjectRef objRef)
    • Asset

      protected Asset(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • Asset

      @Stability(Stable) public Asset(@NotNull software.constructs.Construct scope, @NotNull String id, @NotNull AssetProps props)
      Parameters:
      scope - This parameter is required.
      id - This parameter is required.
      props - This parameter is required.
  • Method Details

    • addResourceMetadata

      @Stability(Stable) public void addResourceMetadata(@NotNull CfnResource resource, @NotNull String resourceProperty)
      Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.

      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.

      Parameters:
      resource - The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface]. This parameter is required.
      resourceProperty - The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function). This parameter is required.
      See Also:
    • grantRead

      @Stability(Stable) public void grantRead(@NotNull IGrantable grantee)
      Grants read permissions to the principal on the assets bucket.

      Parameters:
      grantee - This parameter is required.
    • getAssetHash

      @Stability(Stable) @NotNull public String getAssetHash()
      A hash of this asset, which is available at construction time.

      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.

      Specified by:
      getAssetHash in interface IAsset
    • getAssetPath

      @Stability(Stable) @NotNull public String getAssetPath()
      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.

    • getBucket

      @Stability(Stable) @NotNull public IBucket getBucket()
      The S3 bucket in which this asset resides.
    • getHttpUrl

      @Stability(Stable) @NotNull public String getHttpUrl()
      Attribute which represents the S3 HTTP URL of this asset.

      For example, https://s3.us-west-1.amazonaws.com/bucket/key

    • getIsFile

      @Stability(Stable) @NotNull public Boolean getIsFile()
      Indicates if this asset is a single file.

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

    • getIsZipArchive

      @Stability(Stable) @NotNull public Boolean getIsZipArchive()
      Indicates if this asset is a zip archive.

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

    • getS3BucketName

      @Stability(Stable) @NotNull public String getS3BucketName()
      Attribute that represents the name of the bucket this asset exists in.
    • getS3ObjectKey

      @Stability(Stable) @NotNull public String getS3ObjectKey()
      Attribute which represents the S3 object key of this asset.
    • getS3ObjectUrl

      @Stability(Stable) @NotNull public String getS3ObjectUrl()
      Attribute which represents the S3 URL of this asset.

      For example, s3://bucket/key