@gradientedge/cdk-utils 8.80.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.
@@ -35,6 +35,7 @@ export declare class CommonConstruct extends Construct {
35
35
  elasticacheManager: aws.ElastiCacheManager;
36
36
  eventManager: aws.EventManager;
37
37
  eventTargetManager: aws.EventTargetManager;
38
+ evidentlyManager: aws.EvidentlyManager;
38
39
  iamManager: aws.IamManager;
39
40
  kmsManager: aws.KmsManager;
40
41
  lambdaManager: aws.LambdaManager;
@@ -60,6 +60,7 @@ class CommonConstruct extends constructs_1.Construct {
60
60
  elasticacheManager;
61
61
  eventManager;
62
62
  eventTargetManager;
63
+ evidentlyManager;
63
64
  iamManager;
64
65
  kmsManager;
65
66
  lambdaManager;
@@ -92,6 +93,7 @@ class CommonConstruct extends constructs_1.Construct {
92
93
  this.elasticacheManager = new aws.ElastiCacheManager();
93
94
  this.eventManager = new aws.EventManager();
94
95
  this.eventTargetManager = new aws.EventTargetManager();
96
+ this.evidentlyManager = new aws.EvidentlyManager();
95
97
  this.iamManager = new aws.IamManager();
96
98
  this.kmsManager = new aws.KmsManager();
97
99
  this.lambdaManager = new aws.LambdaManager();
@@ -6,4 +6,5 @@ export * from './graphql-api-lambda-with-cache';
6
6
  export * from './rest-api-lambda';
7
7
  export * from './rest-api-lambda-with-cache';
8
8
  export * from './site-with-ecs-backend';
9
+ export * from './static-asset-deployment';
9
10
  export * from './static-site';
@@ -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,2 @@
1
+ export * from './main';
2
+ export * from './types';
@@ -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
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,60 @@
1
+ import * as evidently from 'aws-cdk-lib/aws-evidently';
2
+ import * as common from '../../common';
3
+ import * as types from '../../types/aws';
4
+ /**
5
+ * @stability stable
6
+ * @category cdk-utils.evidently-manager
7
+ * @subcategory Construct
8
+ * @classdesc Provides operations on AWS Evidently.
9
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
10
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
11
+ * @example
12
+ * import * as common from '@gradientedge/cdk-utils'
13
+ *
14
+ * class CustomConstruct extends common.common.CommonConstruct {
15
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
16
+ * super(parent, id, props)
17
+ * this.props = props
18
+ * this.evidentlyManager.createProject('MyNewProhect', this, props)
19
+ * }
20
+ * }
21
+ *
22
+ * @see [CDK Evidently Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_evidently-readme.html}
23
+ */
24
+ export declare class EvidentlyManager {
25
+ /**
26
+ * @summary Method to create a project
27
+ * @param {string} id scoped id of the resource
28
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
29
+ * @param {EvidentlyProjectProps} props the project properties
30
+ */
31
+ createProject(id: string, scope: common.CommonConstruct, props: types.EvidentlyProjectProps): evidently.CfnProject;
32
+ /**
33
+ * @summary Method to create a feature
34
+ * @param {string} id scoped id of the resource
35
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
36
+ * @param {EvidentlyFeatureProps} props the feature properties
37
+ */
38
+ createFeature(id: string, scope: common.CommonConstruct, props: types.EvidentlyFeatureProps): evidently.CfnFeature;
39
+ /**
40
+ * @summary Method to create a launch
41
+ * @param {string} id scoped id of the resource
42
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
43
+ * @param {EvidentlyLaunchProps} props the launch properties
44
+ */
45
+ createLaunch(id: string, scope: common.CommonConstruct, props: types.EvidentlyLaunchProps): evidently.CfnLaunch;
46
+ /**
47
+ * @summary Method to create an experiment
48
+ * @param {string} id scoped id of the resource
49
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
50
+ * @param {EvidentlyExperimentProps} props the experiment properties
51
+ */
52
+ createExperiment(id: string, scope: common.CommonConstruct, props: types.EvidentlyExperimentProps): evidently.CfnExperiment;
53
+ /**
54
+ * @summary Method to create a segment
55
+ * @param {string} id scoped id of the resource
56
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
57
+ * @param {EvidentlySegmentProps} props the segment properties
58
+ */
59
+ createSegment(id: string, scope: common.CommonConstruct, props: types.EvidentlySegmentProps): evidently.CfnSegment;
60
+ }
@@ -0,0 +1,127 @@
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.EvidentlyManager = void 0;
27
+ const evidently = __importStar(require("aws-cdk-lib/aws-evidently"));
28
+ const utils = __importStar(require("../../utils"));
29
+ /**
30
+ * @stability stable
31
+ * @category cdk-utils.evidently-manager
32
+ * @subcategory Construct
33
+ * @classdesc Provides operations on AWS Evidently.
34
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
35
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
36
+ * @example
37
+ * import * as common from '@gradientedge/cdk-utils'
38
+ *
39
+ * class CustomConstruct extends common.common.CommonConstruct {
40
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
41
+ * super(parent, id, props)
42
+ * this.props = props
43
+ * this.evidentlyManager.createProject('MyNewProhect', this, props)
44
+ * }
45
+ * }
46
+ *
47
+ * @see [CDK Evidently Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_evidently-readme.html}
48
+ */
49
+ class EvidentlyManager {
50
+ /**
51
+ * @summary Method to create a project
52
+ * @param {string} id scoped id of the resource
53
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
54
+ * @param {EvidentlyProjectProps} props the project properties
55
+ */
56
+ createProject(id, scope, props) {
57
+ const project = new evidently.CfnProject(scope, `${id}`, {
58
+ ...props,
59
+ name: `${props.name}-${scope.props.stage}`,
60
+ description: `${props.description} ${scope.props.stage}`,
61
+ });
62
+ utils.createCfnOutput(`${id}-projectArn`, scope, project.attrArn);
63
+ utils.createCfnOutput(`${id}-projectName`, scope, project.name);
64
+ return project;
65
+ }
66
+ /**
67
+ * @summary Method to create a feature
68
+ * @param {string} id scoped id of the resource
69
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
70
+ * @param {EvidentlyFeatureProps} props the feature properties
71
+ */
72
+ createFeature(id, scope, props) {
73
+ const feature = new evidently.CfnFeature(scope, `${id}`, props);
74
+ utils.createCfnOutput(`${id}-featureArn`, scope, feature.attrArn);
75
+ utils.createCfnOutput(`${id}-featureName`, scope, feature.name);
76
+ return feature;
77
+ }
78
+ /**
79
+ * @summary Method to create a launch
80
+ * @param {string} id scoped id of the resource
81
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
82
+ * @param {EvidentlyLaunchProps} props the launch properties
83
+ */
84
+ createLaunch(id, scope, props) {
85
+ const launch = new evidently.CfnLaunch(scope, `${id}`, {
86
+ ...props,
87
+ name: `${props.name}-${scope.props.stage}`,
88
+ description: `${props.description} ${scope.props.stage}`,
89
+ });
90
+ utils.createCfnOutput(`${id}-launchArn`, scope, launch.attrArn);
91
+ utils.createCfnOutput(`${id}-launchName`, scope, launch.name);
92
+ return launch;
93
+ }
94
+ /**
95
+ * @summary Method to create an experiment
96
+ * @param {string} id scoped id of the resource
97
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
98
+ * @param {EvidentlyExperimentProps} props the experiment properties
99
+ */
100
+ createExperiment(id, scope, props) {
101
+ const experiment = new evidently.CfnExperiment(scope, `${id}`, {
102
+ ...props,
103
+ name: `${props.name}-${scope.props.stage}`,
104
+ description: `${props.description} ${scope.props.stage}`,
105
+ });
106
+ utils.createCfnOutput(`${id}-experimentArn`, scope, experiment.attrArn);
107
+ utils.createCfnOutput(`${id}-experimentName`, scope, experiment.name);
108
+ return experiment;
109
+ }
110
+ /**
111
+ * @summary Method to create a segment
112
+ * @param {string} id scoped id of the resource
113
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
114
+ * @param {EvidentlySegmentProps} props the segment properties
115
+ */
116
+ createSegment(id, scope, props) {
117
+ const segment = new evidently.CfnSegment(scope, `${id}`, {
118
+ ...props,
119
+ name: `${props.name}-${scope.props.stage}`,
120
+ description: `${props.description} ${scope.props.stage}`,
121
+ });
122
+ utils.createCfnOutput(`${id}-segmentArn`, scope, segment.attrArn);
123
+ utils.createCfnOutput(`${id}-segmentName`, scope, segment.name);
124
+ return segment;
125
+ }
126
+ }
127
+ exports.EvidentlyManager = EvidentlyManager;
@@ -13,6 +13,7 @@ export * from './eks-manager';
13
13
  export * from './elasticache-manager';
14
14
  export * from './event-manager';
15
15
  export * from './event-target-manager';
16
+ export * from './evidently-manager';
16
17
  export * from './iam-manager';
17
18
  export * from './kms-manager';
18
19
  export * from './lambda-manager';
@@ -29,6 +29,7 @@ __exportStar(require("./eks-manager"), exports);
29
29
  __exportStar(require("./elasticache-manager"), exports);
30
30
  __exportStar(require("./event-manager"), exports);
31
31
  __exportStar(require("./event-target-manager"), exports);
32
+ __exportStar(require("./evidently-manager"), exports);
32
33
  __exportStar(require("./iam-manager"), exports);
33
34
  __exportStar(require("./kms-manager"), exports);
34
35
  __exportStar(require("./lambda-manager"), exports);
@@ -30,6 +30,7 @@ import * as wafv2 from 'aws-cdk-lib/aws-wafv2';
30
30
  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
+ import * as evidently from 'aws-cdk-lib/aws-evidently';
33
34
  /**
34
35
  * @category cdk-utils.app-config-manager
35
36
  * @subcategory Properties
@@ -716,7 +717,7 @@ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutio
716
717
  retries?: SfnRetryProps[];
717
718
  }
718
719
  /**
719
- }
720
+ }
720
721
  * @category cdk-utils.event-manager
721
722
  * @subcategory Properties
722
723
  */
@@ -740,6 +741,36 @@ export interface EventRuleProps extends events.RuleProps {
740
741
  */
741
742
  export interface EventBusProps extends events.EventBusProps {
742
743
  }
744
+ /**
745
+ * @category cdk-utils.evidently-manager
746
+ * @subcategory Properties
747
+ */
748
+ export interface EvidentlyProjectProps extends evidently.CfnProjectProps {
749
+ }
750
+ /**
751
+ * @category cdk-utils.evidently-manager
752
+ * @subcategory Properties
753
+ */
754
+ export interface EvidentlyFeatureProps extends evidently.CfnFeatureProps {
755
+ }
756
+ /**
757
+ * @category cdk-utils.evidently-manager
758
+ * @subcategory Properties
759
+ */
760
+ export interface EvidentlyLaunchProps extends evidently.CfnLaunchProps {
761
+ }
762
+ /**
763
+ * @category cdk-utils.evidently-manager
764
+ * @subcategory Properties
765
+ */
766
+ export interface EvidentlyExperimentProps extends evidently.CfnExperimentProps {
767
+ }
768
+ /**
769
+ * @category cdk-utils.evidently-manager
770
+ * @subcategory Properties
771
+ */
772
+ export interface EvidentlySegmentProps extends evidently.CfnSegmentProps {
773
+ }
743
774
  /**
744
775
  * @category cdk-utils.common-stack
745
776
  * @subcategory Properties
@@ -822,6 +853,14 @@ export interface LifecycleRule extends s3.LifecycleRule {
822
853
  expirationInDays?: number;
823
854
  noncurrentVersionExpirationInDays?: number;
824
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
+ }
825
864
  /**
826
865
  * @category cdk-utils.dynamodb-manager
827
866
  * @subcategory Properties
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "8.80.0",
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.348.0",
49
+ "@aws-sdk/client-secrets-manager": "^3.350.0",
50
50
  "@types/lodash": "^4.14.195",
51
- "@types/node": "^20.2.5",
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.0",
55
- "constructs": "^10.2.47",
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.9",
69
- "@typescript-eslint/parser": "^5.59.9",
70
- "aws-cdk": "^2.83.0",
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.3",
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",
@@ -37,6 +37,7 @@ export class CommonConstruct extends Construct {
37
37
  elasticacheManager: aws.ElastiCacheManager
38
38
  eventManager: aws.EventManager
39
39
  eventTargetManager: aws.EventTargetManager
40
+ evidentlyManager: aws.EvidentlyManager
40
41
  iamManager: aws.IamManager
41
42
  kmsManager: aws.KmsManager
42
43
  lambdaManager: aws.LambdaManager
@@ -71,6 +72,7 @@ export class CommonConstruct extends Construct {
71
72
  this.elasticacheManager = new aws.ElastiCacheManager()
72
73
  this.eventManager = new aws.EventManager()
73
74
  this.eventTargetManager = new aws.EventTargetManager()
75
+ this.evidentlyManager = new aws.EvidentlyManager()
74
76
  this.iamManager = new aws.IamManager()
75
77
  this.kmsManager = new aws.KmsManager()
76
78
  this.lambdaManager = new aws.LambdaManager()
@@ -6,4 +6,5 @@ export * from './graphql-api-lambda-with-cache'
6
6
  export * from './rest-api-lambda'
7
7
  export * from './rest-api-lambda-with-cache'
8
8
  export * from './site-with-ecs-backend'
9
+ export * from './static-asset-deployment'
9
10
  export * from './static-site'
@@ -0,0 +1,2 @@
1
+ export * from './main'
2
+ export * from './types'
@@ -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
+ }
@@ -0,0 +1,108 @@
1
+ import * as evidently from 'aws-cdk-lib/aws-evidently'
2
+ import * as common from '../../common'
3
+ import * as types from '../../types/aws'
4
+ import * as utils from '../../utils'
5
+ import { EvidentlyExperimentProps, EvidentlySegmentProps } from '../../types'
6
+
7
+ /**
8
+ * @stability stable
9
+ * @category cdk-utils.evidently-manager
10
+ * @subcategory Construct
11
+ * @classdesc Provides operations on AWS Evidently.
12
+ * - A new instance of this class is injected into {@link common.CommonConstruct} constructor.
13
+ * - If a custom construct extends {@link common.CommonConstruct}, an instance is available within the context.
14
+ * @example
15
+ * import * as common from '@gradientedge/cdk-utils'
16
+ *
17
+ * class CustomConstruct extends common.common.CommonConstruct {
18
+ * constructor(parent: cdk.Construct, id: string, props: common.CommonStackProps) {
19
+ * super(parent, id, props)
20
+ * this.props = props
21
+ * this.evidentlyManager.createProject('MyNewProhect', this, props)
22
+ * }
23
+ * }
24
+ *
25
+ * @see [CDK Evidently Module]{@link https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_evidently-readme.html}
26
+ */
27
+ export class EvidentlyManager {
28
+ /**
29
+ * @summary Method to create a project
30
+ * @param {string} id scoped id of the resource
31
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
32
+ * @param {EvidentlyProjectProps} props the project properties
33
+ */
34
+ public createProject(id: string, scope: common.CommonConstruct, props: types.EvidentlyProjectProps) {
35
+ const project = new evidently.CfnProject(scope, `${id}`, {
36
+ ...props,
37
+ name: `${props.name}-${scope.props.stage}`,
38
+ description: `${props.description} ${scope.props.stage}`,
39
+ })
40
+ utils.createCfnOutput(`${id}-projectArn`, scope, project.attrArn)
41
+ utils.createCfnOutput(`${id}-projectName`, scope, project.name)
42
+ return project
43
+ }
44
+
45
+ /**
46
+ * @summary Method to create a feature
47
+ * @param {string} id scoped id of the resource
48
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
49
+ * @param {EvidentlyFeatureProps} props the feature properties
50
+ */
51
+ public createFeature(id: string, scope: common.CommonConstruct, props: types.EvidentlyFeatureProps) {
52
+ const feature = new evidently.CfnFeature(scope, `${id}`, props)
53
+ utils.createCfnOutput(`${id}-featureArn`, scope, feature.attrArn)
54
+ utils.createCfnOutput(`${id}-featureName`, scope, feature.name)
55
+ return feature
56
+ }
57
+
58
+ /**
59
+ * @summary Method to create a launch
60
+ * @param {string} id scoped id of the resource
61
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
62
+ * @param {EvidentlyLaunchProps} props the launch properties
63
+ */
64
+ public createLaunch(id: string, scope: common.CommonConstruct, props: types.EvidentlyLaunchProps) {
65
+ const launch = new evidently.CfnLaunch(scope, `${id}`, {
66
+ ...props,
67
+ name: `${props.name}-${scope.props.stage}`,
68
+ description: `${props.description} ${scope.props.stage}`,
69
+ })
70
+ utils.createCfnOutput(`${id}-launchArn`, scope, launch.attrArn)
71
+ utils.createCfnOutput(`${id}-launchName`, scope, launch.name)
72
+ return launch
73
+ }
74
+
75
+ /**
76
+ * @summary Method to create an experiment
77
+ * @param {string} id scoped id of the resource
78
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
79
+ * @param {EvidentlyExperimentProps} props the experiment properties
80
+ */
81
+ public createExperiment(id: string, scope: common.CommonConstruct, props: types.EvidentlyExperimentProps) {
82
+ const experiment = new evidently.CfnExperiment(scope, `${id}`, {
83
+ ...props,
84
+ name: `${props.name}-${scope.props.stage}`,
85
+ description: `${props.description} ${scope.props.stage}`,
86
+ })
87
+ utils.createCfnOutput(`${id}-experimentArn`, scope, experiment.attrArn)
88
+ utils.createCfnOutput(`${id}-experimentName`, scope, experiment.name)
89
+ return experiment
90
+ }
91
+
92
+ /**
93
+ * @summary Method to create a segment
94
+ * @param {string} id scoped id of the resource
95
+ * @param {common.CommonConstruct} scope scope in which this resource is defined
96
+ * @param {EvidentlySegmentProps} props the segment properties
97
+ */
98
+ public createSegment(id: string, scope: common.CommonConstruct, props: types.EvidentlySegmentProps) {
99
+ const segment = new evidently.CfnSegment(scope, `${id}`, {
100
+ ...props,
101
+ name: `${props.name}-${scope.props.stage}`,
102
+ description: `${props.description} ${scope.props.stage}`,
103
+ })
104
+ utils.createCfnOutput(`${id}-segmentArn`, scope, segment.attrArn)
105
+ utils.createCfnOutput(`${id}-segmentName`, scope, segment.name)
106
+ return segment
107
+ }
108
+ }
@@ -13,6 +13,7 @@ export * from './eks-manager'
13
13
  export * from './elasticache-manager'
14
14
  export * from './event-manager'
15
15
  export * from './event-target-manager'
16
+ export * from './evidently-manager'
16
17
  export * from './iam-manager'
17
18
  export * from './kms-manager'
18
19
  export * from './lambda-manager'
@@ -30,6 +30,7 @@ import * as wafv2 from 'aws-cdk-lib/aws-wafv2'
30
30
  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
+ import * as evidently from 'aws-cdk-lib/aws-evidently'
33
34
 
34
35
  /**
35
36
  * @category cdk-utils.app-config-manager
@@ -765,7 +766,7 @@ export interface SfnStartExecutionProps extends tasks.StepFunctionsStartExecutio
765
766
  }
766
767
 
767
768
  /**
768
- }
769
+ }
769
770
  * @category cdk-utils.event-manager
770
771
  * @subcategory Properties
771
772
  */
@@ -791,6 +792,36 @@ export interface EventRuleProps extends events.RuleProps {
791
792
  */
792
793
  export interface EventBusProps extends events.EventBusProps {}
793
794
 
795
+ /**
796
+ * @category cdk-utils.evidently-manager
797
+ * @subcategory Properties
798
+ */
799
+ export interface EvidentlyProjectProps extends evidently.CfnProjectProps {}
800
+
801
+ /**
802
+ * @category cdk-utils.evidently-manager
803
+ * @subcategory Properties
804
+ */
805
+ export interface EvidentlyFeatureProps extends evidently.CfnFeatureProps {}
806
+
807
+ /**
808
+ * @category cdk-utils.evidently-manager
809
+ * @subcategory Properties
810
+ */
811
+ export interface EvidentlyLaunchProps extends evidently.CfnLaunchProps {}
812
+
813
+ /**
814
+ * @category cdk-utils.evidently-manager
815
+ * @subcategory Properties
816
+ */
817
+ export interface EvidentlyExperimentProps extends evidently.CfnExperimentProps {}
818
+
819
+ /**
820
+ * @category cdk-utils.evidently-manager
821
+ * @subcategory Properties
822
+ */
823
+ export interface EvidentlySegmentProps extends evidently.CfnSegmentProps {}
824
+
794
825
  /**
795
826
  * @category cdk-utils.common-stack
796
827
  * @subcategory Properties
@@ -883,6 +914,15 @@ export interface LifecycleRule extends s3.LifecycleRule {
883
914
  noncurrentVersionExpirationInDays?: number
884
915
  }
885
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
+
886
926
  /**
887
927
  * @category cdk-utils.dynamodb-manager
888
928
  * @subcategory Properties