Class: AWSCDK::S3Assets::Asset
- Inherits:
-
Constructs::Construct
- Object
- Constructs::Construct
- AWSCDK::S3Assets::Asset
- Includes:
- IAsset
- Defined in:
- s3_assets/asset.rb
Overview
An asset represents a local file or directory, which is automatically uploaded to S3 and then can be referenced within a CDK application.
Class Method Summary collapse
Instance Method Summary collapse
-
#add_resource_metadata(resource, resource_property) ⇒ void
Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset.
-
#asset_hash ⇒ String
A hash of this asset, which is available at construction time.
-
#asset_path ⇒ String
The path to the asset, relative to the current Cloud Assembly.
-
#bucket ⇒ AWSCDK::S3::IBucket
The S3 bucket in which this asset resides.
-
#grant_read(grantee) ⇒ void
Grants read permissions to the principal on the assets bucket.
-
#http_url ⇒ String
Attribute which represents the S3 HTTP URL of this asset.
-
#initialize(scope, id, props) ⇒ Asset
constructor
A new instance of Asset.
-
#is_file ⇒ Boolean
Indicates if this asset is a single file.
-
#is_zip_archive ⇒ Boolean
Indicates if this asset is a zip archive.
-
#node ⇒ Constructs::Node
The tree node.
-
#s3_bucket_name ⇒ String
Attribute that represents the name of the bucket this asset exists in.
-
#s3_object_key ⇒ String
Attribute which represents the S3 object key of this asset.
-
#s3_object_url ⇒ String
Attribute which represents the S3 URL of this asset.
-
#to_string ⇒ String
Returns a string representation of this construct.
-
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Constructor Details
#initialize(scope, id, props) ⇒ Asset
Returns a new instance of Asset.
12 13 14 15 16 17 18 |
# File 's3_assets/asset.rb', line 12 def initialize(scope, id, props) props = props.is_a?(Hash) ? ::AWSCDK::S3Assets::AssetProps.new(**props.transform_keys(&:to_sym)) : props Jsii::Type.check_type(scope, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLkNvbnN0cnVjdCJ9")), "scope") Jsii::Type.check_type(id, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "id") Jsii::Type.check_type(props, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfczNfYXNzZXRzLkFzc2V0UHJvcHMifQ==")), "props") Jsii::Object.instance_method(:initialize).bind(self).call(scope, id, props) end |
Class Method Details
.jsii_overridable_methods ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 's3_assets/asset.rb', line 20 def self.jsii_overridable_methods { :node => { kind: :property, name: "node", is_optional: false }, :asset_hash => { kind: :property, name: "assetHash", is_optional: false }, :asset_path => { kind: :property, name: "assetPath", is_optional: false }, :bucket => { kind: :property, name: "bucket", is_optional: false }, :http_url => { kind: :property, name: "httpUrl", is_optional: false }, :is_file => { kind: :property, name: "isFile", is_optional: false }, :is_zip_archive => { kind: :property, name: "isZipArchive", is_optional: false }, :s3_bucket_name => { kind: :property, name: "s3BucketName", is_optional: false }, :s3_object_key => { kind: :property, name: "s3ObjectKey", is_optional: false }, :s3_object_url => { kind: :property, name: "s3ObjectUrl", is_optional: false }, :to_string => { kind: :method, name: "toString", is_optional: false }, :with => { kind: :method, name: "with", is_optional: false }, :add_resource_metadata => { kind: :method, name: "addResourceMetadata", is_optional: false }, :grant_read => { kind: :method, name: "grantRead", is_optional: false }, } end |
Instance Method Details
#add_resource_metadata(resource, resource_property) ⇒ void
This method returns an undefined value.
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.
162 163 164 165 166 |
# File 's3_assets/asset.rb', line 162 def (resource, resource_property) Jsii::Type.check_type(resource, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5DZm5SZXNvdXJjZSJ9")), "resource") Jsii::Type.check_type(resource_property, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "resourceProperty") jsii_call_method("addResourceMetadata", [resource, resource_property]) end |
#asset_hash ⇒ String
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.
53 54 55 |
# File 's3_assets/asset.rb', line 53 def asset_hash() jsii_get_property("assetHash") end |
#asset_path ⇒ 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.
63 64 65 |
# File 's3_assets/asset.rb', line 63 def asset_path() jsii_get_property("assetPath") end |
#bucket ⇒ AWSCDK::S3::IBucket
The S3 bucket in which this asset resides.
70 71 72 |
# File 's3_assets/asset.rb', line 70 def bucket() jsii_get_property("bucket") end |
#grant_read(grantee) ⇒ void
This method returns an undefined value.
Grants read permissions to the principal on the assets bucket.
[disable-awslint:no-grants]
174 175 176 177 |
# File 's3_assets/asset.rb', line 174 def grant_read(grantee) Jsii::Type.check_type(grantee, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklHcmFudGFibGUifQ==")), "grantee") jsii_call_method("grantRead", [grantee]) end |
#http_url ⇒ String
Attribute which represents the S3 HTTP URL of this asset.
For example, https://s3.us-west-1.amazonaws.com/bucket/key
79 80 81 |
# File 's3_assets/asset.rb', line 79 def http_url() jsii_get_property("httpUrl") end |
#is_file ⇒ Boolean
Indicates if this asset is a single file.
Allows constructs to ensure that the correct file type was used.
89 90 91 |
# File 's3_assets/asset.rb', line 89 def is_file() jsii_get_property("isFile") end |
#is_zip_archive ⇒ Boolean
Indicates if this asset is a zip archive.
Allows constructs to ensure that the correct file type was used.
99 100 101 |
# File 's3_assets/asset.rb', line 99 def is_zip_archive() jsii_get_property("isZipArchive") end |
#node ⇒ Constructs::Node
The tree node.
42 43 44 |
# File 's3_assets/asset.rb', line 42 def node() jsii_get_property("node") end |
#s3_bucket_name ⇒ String
Attribute that represents the name of the bucket this asset exists in.
106 107 108 |
# File 's3_assets/asset.rb', line 106 def s3_bucket_name() jsii_get_property("s3BucketName") end |
#s3_object_key ⇒ String
Attribute which represents the S3 object key of this asset.
113 114 115 |
# File 's3_assets/asset.rb', line 113 def s3_object_key() jsii_get_property("s3ObjectKey") end |
#s3_object_url ⇒ String
Attribute which represents the S3 URL of this asset.
For example, s3://bucket/key
122 123 124 |
# File 's3_assets/asset.rb', line 122 def s3_object_url() jsii_get_property("s3ObjectUrl") end |
#to_string ⇒ String
Returns a string representation of this construct.
129 130 131 |
# File 's3_assets/asset.rb', line 129 def to_string() jsii_call_method("toString", []) end |
#with(*mixins) ⇒ Constructs::IConstruct
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.
142 143 144 145 146 147 |
# File 's3_assets/asset.rb', line 142 def with(*mixins) mixins.each_with_index do |item, index| Jsii::Type.check_type(item, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJjb25zdHJ1Y3RzLklNaXhpbiJ9")), "mixins[#{index}]") end jsii_call_method("with", [*mixins]) end |