@gradientedge/cdk-utils 8.81.0 → 8.82.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/lib/construct/index.d.ts +1 -0
- package/dist/src/lib/construct/index.js +1 -0
- package/dist/src/lib/construct/static-asset-deployment/index.d.ts +2 -0
- package/dist/src/lib/construct/static-asset-deployment/index.js +18 -0
- package/dist/src/lib/construct/static-asset-deployment/main.d.ts +45 -0
- package/dist/src/lib/construct/static-asset-deployment/main.js +94 -0
- package/dist/src/lib/construct/static-asset-deployment/types.d.ts +11 -0
- package/dist/src/lib/construct/static-asset-deployment/types.js +2 -0
- package/dist/src/lib/types/aws/index.d.ts +9 -1
- package/package.json +9 -9
- package/src/lib/construct/index.ts +1 -0
- package/src/lib/construct/static-asset-deployment/index.ts +2 -0
- package/src/lib/construct/static-asset-deployment/main.ts +78 -0
- package/src/lib/construct/static-asset-deployment/types.ts +13 -0
- package/src/lib/types/aws/index.ts +10 -2
|
@@ -22,4 +22,5 @@ __exportStar(require("./graphql-api-lambda-with-cache"), exports);
|
|
|
22
22
|
__exportStar(require("./rest-api-lambda"), exports);
|
|
23
23
|
__exportStar(require("./rest-api-lambda-with-cache"), exports);
|
|
24
24
|
__exportStar(require("./site-with-ecs-backend"), exports);
|
|
25
|
+
__exportStar(require("./static-asset-deployment"), exports);
|
|
25
26
|
__exportStar(require("./static-site"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./main"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CommonConstruct } from '../../common';
|
|
2
|
+
import { Construct } from 'constructs';
|
|
3
|
+
import * as s3 from 'aws-cdk-lib/aws-s3';
|
|
4
|
+
import { StaticAssetDeploymentProps } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* @stability stable
|
|
7
|
+
* @category cdk-utils.static-asset-deployment
|
|
8
|
+
* @subcategory construct
|
|
9
|
+
* @classdesc Provides a construct to create and deploy static assets into S3 bucket
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* import { StaticAssetDeployment, StaticAssetDeploymentProps } '@gradientedge/cdk-utils'
|
|
13
|
+
* import { Construct } from 'constructs'
|
|
14
|
+
*
|
|
15
|
+
* class CustomConstruct extends StaticAssetDeployment {
|
|
16
|
+
* constructor(parent: Construct, id: string, props: StaticAssetDeploymentProps) {
|
|
17
|
+
* super(parent, id, props)
|
|
18
|
+
* this.props = props
|
|
19
|
+
* this.id = id
|
|
20
|
+
* this.initResources()
|
|
21
|
+
* }
|
|
22
|
+
* }
|
|
23
|
+
* @mixin
|
|
24
|
+
*/
|
|
25
|
+
export declare class StaticAssetDeployment extends CommonConstruct {
|
|
26
|
+
props: StaticAssetDeploymentProps;
|
|
27
|
+
id: string;
|
|
28
|
+
staticAssetBucket: s3.IBucket;
|
|
29
|
+
constructor(parent: Construct, id: string, props: StaticAssetDeploymentProps);
|
|
30
|
+
/**
|
|
31
|
+
* @summary Initialise and provision resources
|
|
32
|
+
* @protected
|
|
33
|
+
*/
|
|
34
|
+
protected initResources(): void;
|
|
35
|
+
/**
|
|
36
|
+
* @summary Create the static asset bucket
|
|
37
|
+
* @protected
|
|
38
|
+
*/
|
|
39
|
+
protected createAssetBucket(): void;
|
|
40
|
+
/**
|
|
41
|
+
* @summary Deploy the static assests into the static asset bucket
|
|
42
|
+
* @protected
|
|
43
|
+
*/
|
|
44
|
+
protected deployStaticAssets(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.StaticAssetDeployment = void 0;
|
|
27
|
+
const common_1 = require("../../common");
|
|
28
|
+
const s3deploy = __importStar(require("aws-cdk-lib/aws-s3-deployment"));
|
|
29
|
+
/**
|
|
30
|
+
* @stability stable
|
|
31
|
+
* @category cdk-utils.static-asset-deployment
|
|
32
|
+
* @subcategory construct
|
|
33
|
+
* @classdesc Provides a construct to create and deploy static assets into S3 bucket
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* import { StaticAssetDeployment, StaticAssetDeploymentProps } '@gradientedge/cdk-utils'
|
|
37
|
+
* import { Construct } from 'constructs'
|
|
38
|
+
*
|
|
39
|
+
* class CustomConstruct extends StaticAssetDeployment {
|
|
40
|
+
* constructor(parent: Construct, id: string, props: StaticAssetDeploymentProps) {
|
|
41
|
+
* super(parent, id, props)
|
|
42
|
+
* this.props = props
|
|
43
|
+
* this.id = id
|
|
44
|
+
* this.initResources()
|
|
45
|
+
* }
|
|
46
|
+
* }
|
|
47
|
+
* @mixin
|
|
48
|
+
*/
|
|
49
|
+
class StaticAssetDeployment extends common_1.CommonConstruct {
|
|
50
|
+
/* construct properties */
|
|
51
|
+
props;
|
|
52
|
+
id;
|
|
53
|
+
/* construct resources */
|
|
54
|
+
staticAssetBucket;
|
|
55
|
+
constructor(parent, id, props) {
|
|
56
|
+
super(parent, id, props);
|
|
57
|
+
this.props = props;
|
|
58
|
+
this.id = id;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* @summary Initialise and provision resources
|
|
62
|
+
* @protected
|
|
63
|
+
*/
|
|
64
|
+
initResources() {
|
|
65
|
+
this.createAssetBucket();
|
|
66
|
+
this.deployStaticAssets();
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @summary Create the static asset bucket
|
|
70
|
+
* @protected
|
|
71
|
+
*/
|
|
72
|
+
createAssetBucket() {
|
|
73
|
+
this.staticAssetBucket = this.s3Manager.createS3Bucket(`${this.id}-sa-bucket`, this, this.props.staticAssetBucket);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @summary Deploy the static assests into the static asset bucket
|
|
77
|
+
* @protected
|
|
78
|
+
*/
|
|
79
|
+
deployStaticAssets() {
|
|
80
|
+
new s3deploy.BucketDeployment(this, `${this.id}-static-deployment`, {
|
|
81
|
+
...this.props.staticAssetDeployment,
|
|
82
|
+
destinationBucket: this.staticAssetBucket,
|
|
83
|
+
sources: this.props.staticAssetSources,
|
|
84
|
+
});
|
|
85
|
+
const staticAssetsForExport = this.props.staticAssetsForExport;
|
|
86
|
+
if (!staticAssetsForExport)
|
|
87
|
+
return;
|
|
88
|
+
/* optional additional exports needed for asset urls */
|
|
89
|
+
staticAssetsForExport.forEach(asset => {
|
|
90
|
+
this.addCfnOutput(asset.key, this.staticAssetBucket.s3UrlForObject(asset.value));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.StaticAssetDeployment = StaticAssetDeployment;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BucketDeploymentProps, CommonStackProps, S3BucketProps } from '../../types';
|
|
2
|
+
export interface AssetExport {
|
|
3
|
+
key: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
export interface StaticAssetDeploymentProps extends CommonStackProps {
|
|
7
|
+
staticAssetDeployment: BucketDeploymentProps;
|
|
8
|
+
staticAssetSources: any[];
|
|
9
|
+
staticAssetBucket: S3BucketProps;
|
|
10
|
+
staticAssetsForExport?: AssetExport[];
|
|
11
|
+
}
|
|
@@ -717,7 +717,7 @@ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutio
|
|
|
717
717
|
retries?: SfnRetryProps[];
|
|
718
718
|
}
|
|
719
719
|
/**
|
|
720
|
-
|
|
720
|
+
}
|
|
721
721
|
* @category cdk-utils.event-manager
|
|
722
722
|
* @subcategory Properties
|
|
723
723
|
*/
|
|
@@ -853,6 +853,14 @@ export interface LifecycleRule extends s3.LifecycleRule {
|
|
|
853
853
|
expirationInDays?: number;
|
|
854
854
|
noncurrentVersionExpirationInDays?: number;
|
|
855
855
|
}
|
|
856
|
+
/**
|
|
857
|
+
* @category cdk-utils.s3-manager
|
|
858
|
+
* @subcategory Properties
|
|
859
|
+
*/
|
|
860
|
+
export interface BucketDeploymentProps extends s3deploy.BucketDeploymentProps {
|
|
861
|
+
expirationInDays?: number;
|
|
862
|
+
noncurrentVersionExpirationInDays?: number;
|
|
863
|
+
}
|
|
856
864
|
/**
|
|
857
865
|
* @category cdk-utils.dynamodb-manager
|
|
858
866
|
* @subcategory Properties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.82.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -46,13 +46,13 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@aws-sdk/client-secrets-manager": "^3.
|
|
49
|
+
"@aws-sdk/client-secrets-manager": "^3.350.0",
|
|
50
50
|
"@types/lodash": "^4.14.195",
|
|
51
|
-
"@types/node": "^20.
|
|
51
|
+
"@types/node": "^20.3.0",
|
|
52
52
|
"@types/uuid": "^9.0.2",
|
|
53
53
|
"app-root-path": "^3.1.0",
|
|
54
|
-
"aws-cdk-lib": "^2.83.
|
|
55
|
-
"constructs": "^10.2.
|
|
54
|
+
"aws-cdk-lib": "^2.83.1",
|
|
55
|
+
"constructs": "^10.2.50",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"moment": "^2.29.4",
|
|
58
58
|
"nconf": "^0.12.0",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"@babel/eslint-parser": "^7.22.5",
|
|
66
66
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
67
67
|
"@types/jest": "^29.5.2",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.59.
|
|
69
|
-
"@typescript-eslint/parser": "^5.59.
|
|
70
|
-
"aws-cdk": "^2.83.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.59.11",
|
|
69
|
+
"@typescript-eslint/parser": "^5.59.11",
|
|
70
|
+
"aws-cdk": "^2.83.1",
|
|
71
71
|
"better-docs": "^2.7.2",
|
|
72
72
|
"codecov": "^3.8.3",
|
|
73
73
|
"commitizen": "^4.3.0",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"prettier": "^2.8.8",
|
|
90
90
|
"prettier-plugin-organize-imports": "^3.2.2",
|
|
91
91
|
"rimraf": "^5.0.1",
|
|
92
|
-
"semantic-release": "^21.0.
|
|
92
|
+
"semantic-release": "^21.0.5",
|
|
93
93
|
"taffydb": "^2.7.3",
|
|
94
94
|
"ts-jest": "^29.1.0",
|
|
95
95
|
"ts-node": "^10.9.1",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { CommonConstruct } from '../../common'
|
|
2
|
+
import { Construct } from 'constructs'
|
|
3
|
+
import * as s3 from 'aws-cdk-lib/aws-s3'
|
|
4
|
+
import * as s3deploy from 'aws-cdk-lib/aws-s3-deployment'
|
|
5
|
+
import { StaticAssetDeploymentProps } from './types'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @stability stable
|
|
9
|
+
* @category cdk-utils.static-asset-deployment
|
|
10
|
+
* @subcategory construct
|
|
11
|
+
* @classdesc Provides a construct to create and deploy static assets into S3 bucket
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* import { StaticAssetDeployment, StaticAssetDeploymentProps } '@gradientedge/cdk-utils'
|
|
15
|
+
* import { Construct } from 'constructs'
|
|
16
|
+
*
|
|
17
|
+
* class CustomConstruct extends StaticAssetDeployment {
|
|
18
|
+
* constructor(parent: Construct, id: string, props: StaticAssetDeploymentProps) {
|
|
19
|
+
* super(parent, id, props)
|
|
20
|
+
* this.props = props
|
|
21
|
+
* this.id = id
|
|
22
|
+
* this.initResources()
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
* @mixin
|
|
26
|
+
*/
|
|
27
|
+
export class StaticAssetDeployment extends CommonConstruct {
|
|
28
|
+
/* construct properties */
|
|
29
|
+
props: StaticAssetDeploymentProps
|
|
30
|
+
id: string
|
|
31
|
+
|
|
32
|
+
/* construct resources */
|
|
33
|
+
staticAssetBucket: s3.IBucket
|
|
34
|
+
|
|
35
|
+
constructor(parent: Construct, id: string, props: StaticAssetDeploymentProps) {
|
|
36
|
+
super(parent, id, props)
|
|
37
|
+
|
|
38
|
+
this.props = props
|
|
39
|
+
this.id = id
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @summary Initialise and provision resources
|
|
44
|
+
* @protected
|
|
45
|
+
*/
|
|
46
|
+
protected initResources() {
|
|
47
|
+
this.createAssetBucket()
|
|
48
|
+
this.deployStaticAssets()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* @summary Create the static asset bucket
|
|
53
|
+
* @protected
|
|
54
|
+
*/
|
|
55
|
+
protected createAssetBucket() {
|
|
56
|
+
this.staticAssetBucket = this.s3Manager.createS3Bucket(`${this.id}-sa-bucket`, this, this.props.staticAssetBucket)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* @summary Deploy the static assests into the static asset bucket
|
|
61
|
+
* @protected
|
|
62
|
+
*/
|
|
63
|
+
protected deployStaticAssets() {
|
|
64
|
+
new s3deploy.BucketDeployment(this, `${this.id}-static-deployment`, {
|
|
65
|
+
...this.props.staticAssetDeployment,
|
|
66
|
+
destinationBucket: this.staticAssetBucket,
|
|
67
|
+
sources: this.props.staticAssetSources,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const staticAssetsForExport = this.props.staticAssetsForExport
|
|
71
|
+
if (!staticAssetsForExport) return
|
|
72
|
+
|
|
73
|
+
/* optional additional exports needed for asset urls */
|
|
74
|
+
staticAssetsForExport.forEach(asset => {
|
|
75
|
+
this.addCfnOutput(asset.key, this.staticAssetBucket.s3UrlForObject(asset.value))
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { BucketDeploymentProps, CommonStackProps, S3BucketProps } from '../../types'
|
|
2
|
+
|
|
3
|
+
export interface AssetExport {
|
|
4
|
+
key: string
|
|
5
|
+
value: string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface StaticAssetDeploymentProps extends CommonStackProps {
|
|
9
|
+
staticAssetDeployment: BucketDeploymentProps
|
|
10
|
+
staticAssetSources: any[]
|
|
11
|
+
staticAssetBucket: S3BucketProps
|
|
12
|
+
staticAssetsForExport?: AssetExport[]
|
|
13
|
+
}
|
|
@@ -31,7 +31,6 @@ import * as types from '../index'
|
|
|
31
31
|
import * as appAutoscaling from 'aws-cdk-lib/aws-applicationautoscaling'
|
|
32
32
|
import * as pipes from 'aws-cdk-lib/aws-pipes'
|
|
33
33
|
import * as evidently from 'aws-cdk-lib/aws-evidently'
|
|
34
|
-
import { CfnExperimentProps, CfnFeatureProps, CfnSegmentProps } from 'aws-cdk-lib/aws-evidently/lib/evidently.generated'
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* @category cdk-utils.app-config-manager
|
|
@@ -767,7 +766,7 @@ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutio
|
|
|
767
766
|
}
|
|
768
767
|
|
|
769
768
|
/**
|
|
770
|
-
|
|
769
|
+
}
|
|
771
770
|
* @category cdk-utils.event-manager
|
|
772
771
|
* @subcategory Properties
|
|
773
772
|
*/
|
|
@@ -915,6 +914,15 @@ export interface LifecycleRule extends s3.LifecycleRule {
|
|
|
915
914
|
noncurrentVersionExpirationInDays?: number
|
|
916
915
|
}
|
|
917
916
|
|
|
917
|
+
/**
|
|
918
|
+
* @category cdk-utils.s3-manager
|
|
919
|
+
* @subcategory Properties
|
|
920
|
+
*/
|
|
921
|
+
export interface BucketDeploymentProps extends s3deploy.BucketDeploymentProps {
|
|
922
|
+
expirationInDays?: number
|
|
923
|
+
noncurrentVersionExpirationInDays?: number
|
|
924
|
+
}
|
|
925
|
+
|
|
918
926
|
/**
|
|
919
927
|
* @category cdk-utils.dynamodb-manager
|
|
920
928
|
* @subcategory Properties
|