@gradientedge/cdk-utils 7.20.0 → 7.22.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/graphql-api-lambda-with-cache/main.d.ts +1 -1
- package/dist/src/lib/construct/graphql-api-lambda-with-cache/main.js +3 -3
- package/dist/src/lib/manager/aws/elasticache-manager.d.ts +10 -0
- package/dist/src/lib/manager/aws/elasticache-manager.js +42 -0
- package/dist/src/lib/types/aws/index.d.ts +7 -1
- package/package.json +13 -13
- package/src/lib/construct/graphql-api-lambda-with-cache/main.ts +4 -4
- package/src/lib/manager/aws/elasticache-manager.ts +55 -0
- package/src/lib/types/aws/index.ts +7 -1
|
@@ -28,7 +28,7 @@ export declare class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
28
28
|
props: GraphQlApiLambdaWithCacheProps;
|
|
29
29
|
id: string;
|
|
30
30
|
graphQLVpc: ec2.IVpc;
|
|
31
|
-
graphQLElastiCache: elasticache.
|
|
31
|
+
graphQLElastiCache: elasticache.CfnReplicationGroup;
|
|
32
32
|
graphQLSecurityGroup: ec2.ISecurityGroup;
|
|
33
33
|
securityGroupExportName: string;
|
|
34
34
|
constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps);
|
|
@@ -104,7 +104,7 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
104
104
|
* @protected
|
|
105
105
|
*/
|
|
106
106
|
createElastiCache() {
|
|
107
|
-
this.graphQLElastiCache = this.elasticacheManager.
|
|
107
|
+
this.graphQLElastiCache = this.elasticacheManager.createReplicatedElastiCache(`${this.id}-elasticache`, this, this.props.graphQLElastiCache, this.graphQLVpc.privateSubnets.map(subnet => subnet.subnetId), [this.graphQLSecurityGroup.securityGroupId]);
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Create Lambda Role
|
|
@@ -120,8 +120,8 @@ class GraphQLApiLambdaWithCache extends __1.GraphQLApiLambda {
|
|
|
120
120
|
*/
|
|
121
121
|
createLambdaEnvironment() {
|
|
122
122
|
this.graphQLApiLambdaEnvironment = {
|
|
123
|
-
CACHE_REDIS_HOST: `${this.graphQLElastiCache.
|
|
124
|
-
CACHE_REDIS_PORT: `${this.graphQLElastiCache.
|
|
123
|
+
CACHE_REDIS_HOST: `${this.graphQLElastiCache.attrPrimaryEndPointAddress}`,
|
|
124
|
+
CACHE_REDIS_PORT: `${this.graphQLElastiCache.attrPrimaryEndPointPort}`,
|
|
125
125
|
NODE_ENV: this.props.nodeEnv,
|
|
126
126
|
LOG_LEVEL: this.props.logLevel,
|
|
127
127
|
TZ: this.props.timezone,
|
|
@@ -39,4 +39,14 @@ export declare class ElastiCacheManager {
|
|
|
39
39
|
* @param {string[]} logDeliveryConfigurations
|
|
40
40
|
*/
|
|
41
41
|
createElastiCache(id: string, scope: common.CommonConstruct, props: types.ElastiCacheProps, subnetIds: string[], securityGroupIds: string[], logDeliveryConfigurations?: any): elasticache.CfnCacheCluster;
|
|
42
|
+
/**
|
|
43
|
+
* @summary Method to create an replicated elasticache resource
|
|
44
|
+
* @param {string} id scoped id of the resource
|
|
45
|
+
* @param {common.CommonConstruct} scope scope in which scope resource is defined
|
|
46
|
+
* @param {types.ReplicatedElastiCacheProps} props
|
|
47
|
+
* @param {string[]} subnetIds
|
|
48
|
+
* @param {string[]} securityGroupIds
|
|
49
|
+
* @param {string[]} logDeliveryConfigurations
|
|
50
|
+
*/
|
|
51
|
+
createReplicatedElastiCache(id: string, scope: common.CommonConstruct, props: types.ReplicatedElastiCacheProps, subnetIds: string[], securityGroupIds: string[], logDeliveryConfigurations?: any): elasticache.CfnReplicationGroup;
|
|
42
52
|
}
|
|
@@ -95,10 +95,52 @@ class ElastiCacheManager {
|
|
|
95
95
|
snapshotWindow: props.snapshotWindow,
|
|
96
96
|
logDeliveryConfigurations: logDeliveryConfigurations,
|
|
97
97
|
});
|
|
98
|
+
elasticacheCluster.addDependsOn(subnetGroup);
|
|
98
99
|
utils.createCfnOutput(`${id}-clusterName`, scope, elasticacheCluster.clusterName);
|
|
99
100
|
utils.createCfnOutput(`${id}-redisEndpointPort`, scope, elasticacheCluster.attrRedisEndpointPort);
|
|
100
101
|
utils.createCfnOutput(`${id}-redisEndpointAddress`, scope, elasticacheCluster.attrRedisEndpointAddress);
|
|
101
102
|
return elasticacheCluster;
|
|
102
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* @summary Method to create an replicated elasticache resource
|
|
106
|
+
* @param {string} id scoped id of the resource
|
|
107
|
+
* @param {common.CommonConstruct} scope scope in which scope resource is defined
|
|
108
|
+
* @param {types.ReplicatedElastiCacheProps} props
|
|
109
|
+
* @param {string[]} subnetIds
|
|
110
|
+
* @param {string[]} securityGroupIds
|
|
111
|
+
* @param {string[]} logDeliveryConfigurations
|
|
112
|
+
*/
|
|
113
|
+
createReplicatedElastiCache(id, scope, props, subnetIds, securityGroupIds, logDeliveryConfigurations) {
|
|
114
|
+
if (!props)
|
|
115
|
+
throw `ElastiCache props undefined`;
|
|
116
|
+
const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds);
|
|
117
|
+
const elasticacheCluster = new elasticache.CfnReplicationGroup(scope, `${id}`, {
|
|
118
|
+
replicationGroupDescription: `${id} Redis Replication Cluster`,
|
|
119
|
+
replicationGroupId: `${id}-${scope.props.stage}`,
|
|
120
|
+
cacheNodeType: props.cacheNodeType,
|
|
121
|
+
engine: props.engine,
|
|
122
|
+
cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
|
|
123
|
+
securityGroupIds: securityGroupIds,
|
|
124
|
+
numNodeGroups: props.numNodeGroups,
|
|
125
|
+
replicasPerNodeGroup: props.replicasPerNodeGroup,
|
|
126
|
+
automaticFailoverEnabled: props.automaticFailoverEnabled,
|
|
127
|
+
multiAzEnabled: props.multiAzEnabled,
|
|
128
|
+
cacheParameterGroupName: props.cacheParameterGroupName,
|
|
129
|
+
cacheSecurityGroupNames: props.cacheSecurityGroupNames,
|
|
130
|
+
engineVersion: props.engineVersion,
|
|
131
|
+
globalReplicationGroupId: props.globalReplicationGroupId,
|
|
132
|
+
logDeliveryConfigurations: props.logDeliveryConfigurations,
|
|
133
|
+
numCacheClusters: props.numCacheClusters,
|
|
134
|
+
port: props.port,
|
|
135
|
+
preferredCacheClusterAZs: props.preferredCacheClusterAZs,
|
|
136
|
+
preferredMaintenanceWindow: props.preferredMaintenanceWindow,
|
|
137
|
+
primaryClusterId: props.primaryClusterId,
|
|
138
|
+
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
|
|
139
|
+
});
|
|
140
|
+
elasticacheCluster.addDependsOn(subnetGroup);
|
|
141
|
+
utils.createCfnOutput(`${id}-primaryEndPointPort`, scope, elasticacheCluster.attrPrimaryEndPointPort);
|
|
142
|
+
utils.createCfnOutput(`${id}-primaryEndPointAddress`, scope, elasticacheCluster.attrPrimaryEndPointAddress);
|
|
143
|
+
return elasticacheCluster;
|
|
144
|
+
}
|
|
103
145
|
}
|
|
104
146
|
exports.ElastiCacheManager = ElastiCacheManager;
|
|
@@ -246,7 +246,7 @@ export interface GraphQlApiLambdaProps extends CommonStackProps {
|
|
|
246
246
|
*/
|
|
247
247
|
export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
248
248
|
graphQLVpc: ec2.VpcProps;
|
|
249
|
-
graphQLElastiCache:
|
|
249
|
+
graphQLElastiCache: ReplicatedElastiCacheProps;
|
|
250
250
|
securityGroupExportName: string;
|
|
251
251
|
useExistingVpc: boolean;
|
|
252
252
|
vpcName?: string;
|
|
@@ -673,6 +673,12 @@ export interface WafWebACLProps extends wafv2.CfnWebACLProps {
|
|
|
673
673
|
*/
|
|
674
674
|
export interface ElastiCacheProps extends elasticache.CfnCacheClusterProps {
|
|
675
675
|
}
|
|
676
|
+
/**
|
|
677
|
+
* @category cdk-utils.elasticache-manager
|
|
678
|
+
* @category Compute
|
|
679
|
+
*/
|
|
680
|
+
export interface ReplicatedElastiCacheProps extends elasticache.CfnReplicationGroupProps {
|
|
681
|
+
}
|
|
676
682
|
/**
|
|
677
683
|
* @category cdk-utils.sqs-manager
|
|
678
684
|
* @subcategory Properties
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradientedge/cdk-utils",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.22.0",
|
|
4
4
|
"description": "Utilities for AWS CDK provisioning",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -48,11 +48,11 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@types/lodash": "^4.14.191",
|
|
51
|
-
"@types/node": "^18.11.
|
|
51
|
+
"@types/node": "^18.11.18",
|
|
52
52
|
"app-root-path": "^3.1.0",
|
|
53
|
-
"aws-cdk-lib": "^2.
|
|
54
|
-
"aws-sdk": "^2.
|
|
55
|
-
"constructs": "^10.1.
|
|
53
|
+
"aws-cdk-lib": "^2.58.1",
|
|
54
|
+
"aws-sdk": "^2.1286.0",
|
|
55
|
+
"constructs": "^10.1.208",
|
|
56
56
|
"lodash": "^4.17.21",
|
|
57
57
|
"moment": "^2.29.4",
|
|
58
58
|
"nconf": "^0.12.0",
|
|
@@ -61,21 +61,21 @@
|
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
64
|
-
"@types/jest": "^29.2.
|
|
65
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
66
|
-
"@typescript-eslint/parser": "^5.
|
|
64
|
+
"@types/jest": "^29.2.5",
|
|
65
|
+
"@typescript-eslint/eslint-plugin": "^5.48.0",
|
|
66
|
+
"@typescript-eslint/parser": "^5.48.0",
|
|
67
67
|
"aws-cdk": "*",
|
|
68
68
|
"babel-eslint": "^10.1.0",
|
|
69
69
|
"better-docs": "^2.7.2",
|
|
70
70
|
"codecov": "^3.8.3",
|
|
71
71
|
"commitizen": "^4.2.6",
|
|
72
72
|
"dotenv": "^16.0.3",
|
|
73
|
-
"eslint": "^8.
|
|
74
|
-
"eslint-config-prettier": "^8.
|
|
73
|
+
"eslint": "^8.31.0",
|
|
74
|
+
"eslint-config-prettier": "^8.6.0",
|
|
75
75
|
"eslint-plugin-import": "^2.26.0",
|
|
76
|
-
"husky": "^8.0.
|
|
76
|
+
"husky": "^8.0.3",
|
|
77
77
|
"jest": "^29.3.1",
|
|
78
|
-
"jest-extended": "^3.2.
|
|
78
|
+
"jest-extended": "^3.2.1",
|
|
79
79
|
"jest-junit": "^15.0.0",
|
|
80
80
|
"jsdoc": "^4.0.0",
|
|
81
81
|
"jsdoc-babel": "^0.5.0",
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"typescript": "4.9.4"
|
|
92
92
|
},
|
|
93
93
|
"optionalDependencies": {
|
|
94
|
-
"@babel/core": "^7.20.
|
|
94
|
+
"@babel/core": "^7.20.7",
|
|
95
95
|
"prop-types": "^15.8.1",
|
|
96
96
|
"react": "^18.2.0",
|
|
97
97
|
"react-dom": "^18.2.0"
|
|
@@ -35,7 +35,7 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
35
35
|
|
|
36
36
|
/* graphql restApi resources */
|
|
37
37
|
graphQLVpc: ec2.IVpc
|
|
38
|
-
graphQLElastiCache: elasticache.
|
|
38
|
+
graphQLElastiCache: elasticache.CfnReplicationGroup
|
|
39
39
|
graphQLSecurityGroup: ec2.ISecurityGroup
|
|
40
40
|
securityGroupExportName: string
|
|
41
41
|
|
|
@@ -93,7 +93,7 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
93
93
|
* @protected
|
|
94
94
|
*/
|
|
95
95
|
protected createElastiCache() {
|
|
96
|
-
this.graphQLElastiCache = this.elasticacheManager.
|
|
96
|
+
this.graphQLElastiCache = this.elasticacheManager.createReplicatedElastiCache(
|
|
97
97
|
`${this.id}-elasticache`,
|
|
98
98
|
this,
|
|
99
99
|
this.props.graphQLElastiCache,
|
|
@@ -120,8 +120,8 @@ export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
|
120
120
|
*/
|
|
121
121
|
protected createLambdaEnvironment() {
|
|
122
122
|
this.graphQLApiLambdaEnvironment = {
|
|
123
|
-
CACHE_REDIS_HOST: `${this.graphQLElastiCache.
|
|
124
|
-
CACHE_REDIS_PORT: `${this.graphQLElastiCache.
|
|
123
|
+
CACHE_REDIS_HOST: `${this.graphQLElastiCache.attrPrimaryEndPointAddress}`,
|
|
124
|
+
CACHE_REDIS_PORT: `${this.graphQLElastiCache.attrPrimaryEndPointPort}`,
|
|
125
125
|
NODE_ENV: this.props.nodeEnv,
|
|
126
126
|
LOG_LEVEL: this.props.logLevel,
|
|
127
127
|
TZ: this.props.timezone,
|
|
@@ -83,10 +83,65 @@ export class ElastiCacheManager {
|
|
|
83
83
|
logDeliveryConfigurations: logDeliveryConfigurations,
|
|
84
84
|
})
|
|
85
85
|
|
|
86
|
+
elasticacheCluster.addDependsOn(subnetGroup)
|
|
87
|
+
|
|
86
88
|
utils.createCfnOutput(`${id}-clusterName`, scope, elasticacheCluster.clusterName)
|
|
87
89
|
utils.createCfnOutput(`${id}-redisEndpointPort`, scope, elasticacheCluster.attrRedisEndpointPort)
|
|
88
90
|
utils.createCfnOutput(`${id}-redisEndpointAddress`, scope, elasticacheCluster.attrRedisEndpointAddress)
|
|
89
91
|
|
|
90
92
|
return elasticacheCluster
|
|
91
93
|
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @summary Method to create an replicated elasticache resource
|
|
97
|
+
* @param {string} id scoped id of the resource
|
|
98
|
+
* @param {common.CommonConstruct} scope scope in which scope resource is defined
|
|
99
|
+
* @param {types.ReplicatedElastiCacheProps} props
|
|
100
|
+
* @param {string[]} subnetIds
|
|
101
|
+
* @param {string[]} securityGroupIds
|
|
102
|
+
* @param {string[]} logDeliveryConfigurations
|
|
103
|
+
*/
|
|
104
|
+
public createReplicatedElastiCache(
|
|
105
|
+
id: string,
|
|
106
|
+
scope: common.CommonConstruct,
|
|
107
|
+
props: types.ReplicatedElastiCacheProps,
|
|
108
|
+
subnetIds: string[],
|
|
109
|
+
securityGroupIds: string[],
|
|
110
|
+
logDeliveryConfigurations?: any
|
|
111
|
+
) {
|
|
112
|
+
if (!props) throw `ElastiCache props undefined`
|
|
113
|
+
|
|
114
|
+
const subnetGroup = this.createElastiCacheSubnetGroup(`${id}-subnetGroup`, scope, subnetIds)
|
|
115
|
+
|
|
116
|
+
const elasticacheCluster = new elasticache.CfnReplicationGroup(scope, `${id}`, {
|
|
117
|
+
replicationGroupDescription: `${id} Redis Replication Cluster`,
|
|
118
|
+
replicationGroupId: `${id}-${scope.props.stage}`,
|
|
119
|
+
cacheNodeType: props.cacheNodeType,
|
|
120
|
+
engine: props.engine,
|
|
121
|
+
cacheSubnetGroupName: subnetGroup.cacheSubnetGroupName,
|
|
122
|
+
securityGroupIds: securityGroupIds,
|
|
123
|
+
numNodeGroups: props.numNodeGroups,
|
|
124
|
+
replicasPerNodeGroup: props.replicasPerNodeGroup,
|
|
125
|
+
automaticFailoverEnabled: props.automaticFailoverEnabled,
|
|
126
|
+
multiAzEnabled: props.multiAzEnabled,
|
|
127
|
+
cacheParameterGroupName: props.cacheParameterGroupName,
|
|
128
|
+
cacheSecurityGroupNames: props.cacheSecurityGroupNames,
|
|
129
|
+
engineVersion: props.engineVersion,
|
|
130
|
+
globalReplicationGroupId: props.globalReplicationGroupId,
|
|
131
|
+
logDeliveryConfigurations: props.logDeliveryConfigurations,
|
|
132
|
+
numCacheClusters: props.numCacheClusters,
|
|
133
|
+
port: props.port,
|
|
134
|
+
preferredCacheClusterAZs: props.preferredCacheClusterAZs,
|
|
135
|
+
preferredMaintenanceWindow: props.preferredMaintenanceWindow,
|
|
136
|
+
primaryClusterId: props.primaryClusterId,
|
|
137
|
+
autoMinorVersionUpgrade: props.autoMinorVersionUpgrade,
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
elasticacheCluster.addDependsOn(subnetGroup)
|
|
141
|
+
|
|
142
|
+
utils.createCfnOutput(`${id}-primaryEndPointPort`, scope, elasticacheCluster.attrPrimaryEndPointPort)
|
|
143
|
+
utils.createCfnOutput(`${id}-primaryEndPointAddress`, scope, elasticacheCluster.attrPrimaryEndPointAddress)
|
|
144
|
+
|
|
145
|
+
return elasticacheCluster
|
|
146
|
+
}
|
|
92
147
|
}
|
|
@@ -266,7 +266,7 @@ export interface GraphQlApiLambdaProps extends CommonStackProps {
|
|
|
266
266
|
*/
|
|
267
267
|
export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
268
268
|
graphQLVpc: ec2.VpcProps
|
|
269
|
-
graphQLElastiCache:
|
|
269
|
+
graphQLElastiCache: ReplicatedElastiCacheProps
|
|
270
270
|
securityGroupExportName: string
|
|
271
271
|
useExistingVpc: boolean
|
|
272
272
|
vpcName?: string
|
|
@@ -716,6 +716,12 @@ export interface WafWebACLProps extends wafv2.CfnWebACLProps {}
|
|
|
716
716
|
*/
|
|
717
717
|
export interface ElastiCacheProps extends elasticache.CfnCacheClusterProps {}
|
|
718
718
|
|
|
719
|
+
/**
|
|
720
|
+
* @category cdk-utils.elasticache-manager
|
|
721
|
+
* @category Compute
|
|
722
|
+
*/
|
|
723
|
+
export interface ReplicatedElastiCacheProps extends elasticache.CfnReplicationGroupProps {}
|
|
724
|
+
|
|
719
725
|
/**
|
|
720
726
|
* @category cdk-utils.sqs-manager
|
|
721
727
|
* @subcategory Properties
|