All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awscdk.services.s3.assets.Asset Maven / Gradle / Ivy

There is a newer version: 1.204.0
Show newest version
package software.amazon.awscdk.services.s3.assets;

/**
 * An asset represents a local file or directory, which is automatically uploaded to S3 and then can be referenced within a CDK application.
 * 
 * EXPERIMENTAL
 */
@javax.annotation.Generated(value = "jsii-pacmak/0.20.11 (build d4fd44f)", date = "2019-12-17T13:05:39.461Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.s3.assets.$Module.class, fqn = "@aws-cdk/aws-s3-assets.Asset")
public class Asset extends software.amazon.awscdk.core.Construct implements software.amazon.awscdk.assets.IAsset {

    protected Asset(final software.amazon.jsii.JsiiObjectRef objRef) {
        super(objRef);
    }

    protected Asset(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
        super(initializationMode);
    }

    /**
     * EXPERIMENTAL
     * 
     * @param scope This parameter is required.
     * @param id This parameter is required.
     * @param props This parameter is required.
     */
    @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
    public Asset(final software.amazon.awscdk.core.Construct scope, final java.lang.String id, final software.amazon.awscdk.services.s3.assets.AssetProps props) {
        super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
        software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(props, "props is required") });
    }

    /**
     * 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.

* * EXPERIMENTAL * * @see https://github.com/aws/aws-cdk/issues/1432 * @param resource The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface]. This parameter is required. * @param resourceProperty The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function). This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void addResourceMetadata(final software.amazon.awscdk.core.CfnResource resource, final java.lang.String resourceProperty) { this.jsiiCall("addResourceMetadata", Void.class, new Object[] { java.util.Objects.requireNonNull(resource, "resource is required"), java.util.Objects.requireNonNull(resourceProperty, "resourceProperty is required") }); } /** * Grants read permissions to the principal on the assets bucket. * * EXPERIMENTAL * * @param grantee This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public void grantRead(final software.amazon.awscdk.services.iam.IGrantable grantee) { this.jsiiCall("grantRead", Void.class, new Object[] { java.util.Objects.requireNonNull(grantee, "grantee is required") }); } /** * The path to the asset (stringinfied token). * *

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

* * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.String getAssetPath() { return this.jsiiGet("assetPath", java.lang.String.class); } /** * The S3 bucket in which this asset resides. * * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public software.amazon.awscdk.services.s3.IBucket getBucket() { return this.jsiiGet("bucket", software.amazon.awscdk.services.s3.IBucket.class); } /** * Indicates if this asset is a zip archive. * *

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

* * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.Boolean getIsZipArchive() { return this.jsiiGet("isZipArchive", java.lang.Boolean.class); } /** * Attribute that represents the name of the bucket this asset exists in. * * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.String getS3BucketName() { return this.jsiiGet("s3BucketName", java.lang.String.class); } /** * Attribute which represents the S3 object key of this asset. * * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.String getS3ObjectKey() { return this.jsiiGet("s3ObjectKey", java.lang.String.class); } /** * Attribute which represents the S3 URL of this asset. * * Example: * *
{@code
     * // This example is in TypeScript, examples in Java are coming soon.
     * https://s3.us-west-1.amazonaws.com/bucket/key
     * }
* * EXPERIMENTAL */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.String getS3Url() { return this.jsiiGet("s3Url", java.lang.String.class); } /** * A hash of the source 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.

* * EXPERIMENTAL */ @Override @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public java.lang.String getSourceHash() { return this.jsiiGet("sourceHash", java.lang.String.class); } /** * A fluent builder for {@link software.amazon.awscdk.services.s3.assets.Asset}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder { /** * EXPERIMENTAL * * @return a new instance of {@link Builder}. * @param scope This parameter is required. * @param id This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static Builder create(final software.amazon.awscdk.core.Construct scope, final java.lang.String id) { return new Builder(scope, id); } private final software.amazon.awscdk.core.Construct scope; private final java.lang.String id; private final software.amazon.awscdk.services.s3.assets.AssetProps.Builder props; private Builder(final software.amazon.awscdk.core.Construct scope, final java.lang.String id) { this.scope = scope; this.id = id; this.props = new software.amazon.awscdk.services.s3.assets.AssetProps.Builder(); } /** * Glob patterns to exclude from the copy. * * Default: nothing is excluded * * EXPERIMENTAL * * @return {@code this} * @param exclude Glob patterns to exclude from the copy. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder exclude(final java.util.List exclude) { this.props.exclude(exclude); return this; } /** * A strategy for how to handle symlinks. * * Default: Never * * EXPERIMENTAL * * @return {@code this} * @param follow A strategy for how to handle symlinks. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder follow(final software.amazon.awscdk.assets.FollowMode follow) { this.props.follow(follow); return this; } /** * A list of principals that should be able to read this asset from S3. You can use `asset.grantRead(principal)` to grant read permissions later. * * Default: - No principals that can read file asset. * * EXPERIMENTAL * * @return {@code this} * @param readers A list of principals that should be able to read this asset from S3. You can use `asset.grantRead(principal)` to grant read permissions later. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder readers(final java.util.List readers) { this.props.readers(readers); return this; } /** * Custom source hash to use when identifying the specific version of the asset. * *

NOTE: the source 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 source hash, * you will need to make sure it is updated every time the source changes, or otherwise * it is possible that some deployments will not be invalidated.

* * Default: - automatically calculate source hash based on the contents * of the source file or directory. * * EXPERIMENTAL * * @return {@code this} * @param sourceHash Custom source hash to use when identifying the specific version of the asset. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder sourceHash(final java.lang.String sourceHash) { this.props.sourceHash(sourceHash); return this; } /** * 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 S3.
  • *
  • A directory, in which case it will be archived into a .zip file and uploaded to S3.
  • *
* * EXPERIMENTAL * * @return {@code this} * @param path The disk location of the asset. This parameter is required. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder path(final java.lang.String path) { this.props.path(path); return this; } /** * @returns a newly built instance of {@link software.amazon.awscdk.services.s3.assets.Asset}. */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public software.amazon.awscdk.services.s3.assets.Asset build() { return new software.amazon.awscdk.services.s3.assets.Asset( this.scope, this.id, this.props.build() ); } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy