@aws-cdk/asset-awscli-v1
Advanced tools
Comparing version 2.1.26 to 2.2.0
295
API.md
# API Reference <a name="API Reference" id="api-reference"></a> | ||
## Constructs <a name="Constructs" id="Constructs"></a> | ||
### AwsCliAsset <a name="AwsCliAsset" id="@aws-cdk/asset-awscli-v1.AwsCliAsset"></a> | ||
A CDK Asset construct that contains the AWS CLI. | ||
#### Initializers <a name="Initializers" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer"></a> | ||
```typescript | ||
import { AwsCliAsset } from '@aws-cdk/asset-awscli-v1' | ||
new AwsCliAsset(scope: Construct, id: string, options?: AssetOptions) | ||
``` | ||
| **Name** | **Type** | **Description** | | ||
| --- | --- | --- | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.scope">scope</a></code> | <code>constructs.Construct</code> | *No description.* | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.id">id</a></code> | <code>string</code> | *No description.* | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.options">options</a></code> | <code>aws-cdk-lib.aws_s3_assets.AssetOptions</code> | *No description.* | | ||
--- | ||
##### `scope`<sup>Required</sup> <a name="scope" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.scope"></a> | ||
- *Type:* constructs.Construct | ||
--- | ||
##### `id`<sup>Required</sup> <a name="id" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.id"></a> | ||
- *Type:* string | ||
--- | ||
##### `options`<sup>Optional</sup> <a name="options" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.Initializer.parameter.options"></a> | ||
- *Type:* aws-cdk-lib.aws_s3_assets.AssetOptions | ||
--- | ||
#### Methods <a name="Methods" id="Methods"></a> | ||
| **Name** | **Description** | | ||
| --- | --- | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.toString">toString</a></code> | Returns a string representation of this construct. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.addResourceMetadata">addResourceMetadata</a></code> | Adds CloudFormation template metadata to the specified resource with information that indicates which resource property is mapped to this local asset. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.grantRead">grantRead</a></code> | Grants read permissions to the principal on the assets bucket. | | ||
--- | ||
##### `toString` <a name="toString" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.toString"></a> | ||
```typescript | ||
public toString(): string | ||
``` | ||
Returns a string representation of this construct. | ||
##### `addResourceMetadata` <a name="addResourceMetadata" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.addResourceMetadata"></a> | ||
```typescript | ||
public addResourceMetadata(resource: CfnResource, resourceProperty: string): void | ||
``` | ||
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. | ||
> [https://github.com/aws/aws-cdk/issues/1432](https://github.com/aws/aws-cdk/issues/1432) | ||
###### `resource`<sup>Required</sup> <a name="resource" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.addResourceMetadata.parameter.resource"></a> | ||
- *Type:* aws-cdk-lib.CfnResource | ||
The CloudFormation resource which is using this asset [disable-awslint:ref-via-interface]. | ||
--- | ||
###### `resourceProperty`<sup>Required</sup> <a name="resourceProperty" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.addResourceMetadata.parameter.resourceProperty"></a> | ||
- *Type:* string | ||
The property name where this asset is referenced (e.g. "Code" for AWS::Lambda::Function). | ||
--- | ||
##### `grantRead` <a name="grantRead" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.grantRead"></a> | ||
```typescript | ||
public grantRead(grantee: IGrantable): void | ||
``` | ||
Grants read permissions to the principal on the assets bucket. | ||
###### `grantee`<sup>Required</sup> <a name="grantee" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.grantRead.parameter.grantee"></a> | ||
- *Type:* aws-cdk-lib.aws_iam.IGrantable | ||
--- | ||
#### Static Functions <a name="Static Functions" id="Static Functions"></a> | ||
| **Name** | **Description** | | ||
| --- | --- | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.isConstruct">isConstruct</a></code> | Checks if `x` is a construct. | | ||
--- | ||
##### ~~`isConstruct`~~ <a name="isConstruct" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.isConstruct"></a> | ||
```typescript | ||
import { AwsCliAsset } from '@aws-cdk/asset-awscli-v1' | ||
AwsCliAsset.isConstruct(x: any) | ||
``` | ||
Checks if `x` is a construct. | ||
###### `x`<sup>Required</sup> <a name="x" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.isConstruct.parameter.x"></a> | ||
- *Type:* any | ||
Any object. | ||
--- | ||
#### Properties <a name="Properties" id="Properties"></a> | ||
| **Name** | **Type** | **Description** | | ||
| --- | --- | --- | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.node">node</a></code> | <code>constructs.Node</code> | The tree node. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.assetHash">assetHash</a></code> | <code>string</code> | A hash of this asset, which is available at construction time. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.assetPath">assetPath</a></code> | <code>string</code> | The path to the asset, relative to the current Cloud Assembly. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.bucket">bucket</a></code> | <code>aws-cdk-lib.aws_s3.IBucket</code> | The S3 bucket in which this asset resides. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.httpUrl">httpUrl</a></code> | <code>string</code> | Attribute which represents the S3 HTTP URL of this asset. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.isFile">isFile</a></code> | <code>boolean</code> | Indicates if this asset is a single file. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.isZipArchive">isZipArchive</a></code> | <code>boolean</code> | Indicates if this asset is a zip archive. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3BucketName">s3BucketName</a></code> | <code>string</code> | Attribute that represents the name of the bucket this asset exists in. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3ObjectKey">s3ObjectKey</a></code> | <code>string</code> | Attribute which represents the S3 object key of this asset. | | ||
| <code><a href="#@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3ObjectUrl">s3ObjectUrl</a></code> | <code>string</code> | Attribute which represents the S3 URL of this asset. | | ||
--- | ||
##### `node`<sup>Required</sup> <a name="node" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.node"></a> | ||
```typescript | ||
public readonly node: Node; | ||
``` | ||
- *Type:* constructs.Node | ||
The tree node. | ||
--- | ||
##### `assetHash`<sup>Required</sup> <a name="assetHash" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.assetHash"></a> | ||
```typescript | ||
public readonly assetHash: string; | ||
``` | ||
- *Type:* 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. | ||
--- | ||
##### `assetPath`<sup>Required</sup> <a name="assetPath" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.assetPath"></a> | ||
```typescript | ||
public readonly assetPath: string; | ||
``` | ||
- *Type:* 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. | ||
--- | ||
##### `bucket`<sup>Required</sup> <a name="bucket" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.bucket"></a> | ||
```typescript | ||
public readonly bucket: IBucket; | ||
``` | ||
- *Type:* aws-cdk-lib.aws_s3.IBucket | ||
The S3 bucket in which this asset resides. | ||
--- | ||
##### `httpUrl`<sup>Required</sup> <a name="httpUrl" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.httpUrl"></a> | ||
```typescript | ||
public readonly httpUrl: string; | ||
``` | ||
- *Type:* string | ||
Attribute which represents the S3 HTTP URL of this asset. | ||
--- | ||
*Example* | ||
```typescript | ||
https://s3.us-west-1.amazonaws.com/bucket/key | ||
``` | ||
##### `isFile`<sup>Required</sup> <a name="isFile" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.isFile"></a> | ||
```typescript | ||
public readonly isFile: boolean; | ||
``` | ||
- *Type:* boolean | ||
Indicates if this asset is a single file. | ||
Allows constructs to ensure that the | ||
correct file type was used. | ||
--- | ||
##### `isZipArchive`<sup>Required</sup> <a name="isZipArchive" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.isZipArchive"></a> | ||
```typescript | ||
public readonly isZipArchive: boolean; | ||
``` | ||
- *Type:* boolean | ||
Indicates if this asset is a zip archive. | ||
Allows constructs to ensure that the | ||
correct file type was used. | ||
--- | ||
##### `s3BucketName`<sup>Required</sup> <a name="s3BucketName" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3BucketName"></a> | ||
```typescript | ||
public readonly s3BucketName: string; | ||
``` | ||
- *Type:* string | ||
Attribute that represents the name of the bucket this asset exists in. | ||
--- | ||
##### `s3ObjectKey`<sup>Required</sup> <a name="s3ObjectKey" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3ObjectKey"></a> | ||
```typescript | ||
public readonly s3ObjectKey: string; | ||
``` | ||
- *Type:* string | ||
Attribute which represents the S3 object key of this asset. | ||
--- | ||
##### `s3ObjectUrl`<sup>Required</sup> <a name="s3ObjectUrl" id="@aws-cdk/asset-awscli-v1.AwsCliAsset.property.s3ObjectUrl"></a> | ||
```typescript | ||
public readonly s3ObjectUrl: string; | ||
``` | ||
- *Type:* string | ||
Attribute which represents the S3 URL of this asset. | ||
--- | ||
*Example* | ||
```typescript | ||
s3://bucket/key | ||
``` | ||
@@ -1,8 +0,2 @@ | ||
import * as s3_assets from 'aws-cdk-lib/aws-s3-assets'; | ||
import { Construct } from 'constructs'; | ||
/** | ||
* A CDK Asset construct that contains the AWS CLI. | ||
*/ | ||
export declare class AwsCliAsset extends s3_assets.Asset { | ||
constructor(scope: Construct, id: string, options?: s3_assets.AssetOptions); | ||
} | ||
export declare const ASSET_FILE: string; | ||
export declare const LAYER_SOURCE_DIR: string; |
"use strict"; | ||
var _a; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AwsCliAsset = void 0; | ||
const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti"); | ||
exports.LAYER_SOURCE_DIR = exports.ASSET_FILE = void 0; | ||
const path = require("path"); | ||
const aws_cdk_lib_1 = require("aws-cdk-lib"); | ||
const s3_assets = require("aws-cdk-lib/aws-s3-assets"); | ||
/** | ||
* A CDK Asset construct that contains the AWS CLI. | ||
*/ | ||
class AwsCliAsset extends s3_assets.Asset { | ||
constructor(scope, id, options = {}) { | ||
super(scope, id, { | ||
path: path.join(__dirname, 'layer.zip'), | ||
// we hash the layer directory (it contains the tools versions and Dockerfile) because hashing the zip is non-deterministic | ||
assetHash: aws_cdk_lib_1.FileSystem.fingerprint(path.join(__dirname, '../layer')), | ||
...options, | ||
}); | ||
} | ||
} | ||
exports.AwsCliAsset = AwsCliAsset; | ||
_a = JSII_RTTI_SYMBOL_1; | ||
AwsCliAsset[_a] = { fqn: "@aws-cdk/asset-awscli-v1.AwsCliAsset", version: "2.1.26" }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXdzY2xpLWFzc2V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2F3c2NsaS1hc3NldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLDZCQUE2QjtBQUM3Qiw2Q0FBeUM7QUFDekMsdURBQXVEO0FBR3ZEOztHQUVHO0FBQ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GxheWVyIGRpcmVjdG9yeSAoaXQgY29udGFpbnMgdGhlIHRvb2xzIHZlcnNpb25zIGFuZCBEb2NrZXJmaWxlKSBiZWNhdXNlIGhhc2hpbmcgdGhlIHppcCBpcyBub24tZGV0ZXJtaW5pc3RpY1xuICAgICAgYXNzZXRIYXNoOiBGaWxlU3lzdGVtLmZpbmdlcnByaW50KHBhdGguam9pbihfX2Rpcm5hbWUsICcuLi9sYXllcicpKSxcbiAgICAgIC4uLm9wdGlvbnMsXG4gICAgfSk7XG4gIH1cbn1cbiJdfQ== | ||
exports.ASSET_FILE = path.join(__dirname, 'layer.zip'); | ||
exports.LAYER_SOURCE_DIR = path.join(__dirname, '..', 'layer'); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYXdzY2xpLWFzc2V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2F3c2NsaS1hc3NldC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSw2QkFBNkI7QUFFaEIsUUFBQSxVQUFVLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxTQUFTLEVBQUUsV0FBVyxDQUFDLENBQUM7QUFDL0MsUUFBQSxnQkFBZ0IsR0FBRyxJQUFJLENBQUMsSUFBSSxDQUFDLFNBQVMsRUFBRSxJQUFJLEVBQUUsT0FBTyxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgKiBhcyBwYXRoIGZyb20gJ3BhdGgnO1xuXG5leHBvcnQgY29uc3QgQVNTRVRfRklMRSA9IHBhdGguam9pbihfX2Rpcm5hbWUsICdsYXllci56aXAnKTtcbmV4cG9ydCBjb25zdCBMQVlFUl9TT1VSQ0VfRElSID0gcGF0aC5qb2luKF9fZGlybmFtZSwgJy4uJywgJ2xheWVyJyk7XG4iXX0= |
{ | ||
"name": "@aws-cdk/asset-awscli-v1", | ||
"description": "An Asset construct that contains the AWS CLI, for use in Lambda Layers", | ||
"description": "A library that contains the AWS CLI for use in Lambda Layers", | ||
"repository": { | ||
@@ -52,4 +52,4 @@ "type": "git", | ||
"aws-cdk": "^2", | ||
"aws-cdk-lib": "2.0.0", | ||
"constructs": "10.0.5", | ||
"aws-cdk-lib": "^2.0.0", | ||
"constructs": "^10.0.5", | ||
"eslint": "^8", | ||
@@ -73,6 +73,2 @@ "eslint-import-resolver-node": "^0.3.6", | ||
}, | ||
"peerDependencies": { | ||
"aws-cdk-lib": "^2.0.0", | ||
"constructs": "^10.0.5" | ||
}, | ||
"keywords": [ | ||
@@ -87,3 +83,3 @@ "cdk" | ||
}, | ||
"version": "2.1.26", | ||
"version": "2.2.0", | ||
"jest": { | ||
@@ -90,0 +86,0 @@ "testMatch": [ |
@@ -12,7 +12,9 @@ # Asset with AWS CLI v1 | ||
This module bundles the AWS CLI v1 as a local asset. It exposes | ||
constants `ASSET_FILE` and `LAYER_SOURCE_DIR` that can be consumed | ||
via the CDK `Asset` construct. | ||
This module exports a single class called `AwsCliAsset` which is an `s3_assets.Asset` that bundles the AWS CLI v1. | ||
Any Lambda Function that uses uses this asset must use a Python 3.x | ||
runtime. | ||
Any Lambda Function that uses a LayerVersion created from this Asset must use a Python 3.x runtime. | ||
Usage: | ||
@@ -22,8 +24,14 @@ | ||
// AwsCliLayer bundles the AWS CLI in a lambda layer | ||
import { AwsCliAsset } from '@aws-cdk/asset-awscli-v1'; | ||
import { ASSET_FILE, LAYER_SOURCE_DIR } from '@aws-cdk/asset-awscli-v1'; | ||
import * as lambda from 'aws-cdk-lib/aws-lambda'; | ||
import * as s3_assets from 'aws-cdk-lib/aws-s3-assets'; | ||
import { FileSystem } from 'aws-cdk-lib'; | ||
declare const fn: lambda.Function; | ||
const awscli = new AwsCliAsset(this, 'AwsCliCode'); | ||
const asset = new s3_assets.Asset(this, 'layer-asset', { | ||
path: ASSET_FILE, | ||
assetHash: FileSystem.fingerprint(LAYER_SOURCE_DIR), | ||
}); | ||
fn.addLayers(new lambda.LayerVersion(this, 'AwsCliLayer', { | ||
code: lambda.Code.fromBucket(awscli.bucket, awscli.s3ObjectKey), | ||
code: lambda.Code.fromBucket(asset.bucket, asset.s3ObjectKey), | ||
})); | ||
@@ -30,0 +38,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
0
39
13967936
22