@gradientedge/cdk-utils 8.158.0 → 8.160.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/app/api-destined-function/package.json +1 -1
- package/dist/src/lib/aws/construct/index.d.ts +0 -2
- package/dist/src/lib/aws/construct/index.js +0 -2
- package/dist/src/lib/aws/construct/rest-api-lambda/main.d.ts +0 -4
- package/dist/src/lib/aws/construct/rest-api-lambda/main.js +0 -7
- package/dist/src/lib/aws/services/elastic-container-service/main.js +0 -3
- package/dist/src/lib/aws/services/elastic-container-service/types.d.ts +9 -2
- package/dist/src/lib/aws/services/lambda/main.js +13 -4
- package/eslint.config.mjs +5 -0
- package/package.json +29 -29
- package/src/lib/aws/construct/index.ts +0 -2
- package/src/lib/aws/construct/rest-api-lambda/main.ts +0 -8
- package/src/lib/aws/services/elastic-container-service/main.ts +0 -3
- package/src/lib/aws/services/elastic-container-service/types.ts +16 -2
- package/src/lib/aws/services/lambda/main.ts +15 -4
- package/dist/src/lib/aws/construct/graphql-api-lambda/index.d.ts +0 -2
- package/dist/src/lib/aws/construct/graphql-api-lambda/index.js +0 -18
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.d.ts +0 -96
- package/dist/src/lib/aws/construct/graphql-api-lambda/main.js +0 -177
- package/dist/src/lib/aws/construct/graphql-api-lambda/types.d.ts +0 -26
- package/dist/src/lib/aws/construct/graphql-api-lambda/types.js +0 -2
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/index.d.ts +0 -2
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/index.js +0 -18
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.d.ts +0 -57
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/main.js +0 -137
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/types.d.ts +0 -12
- package/dist/src/lib/aws/construct/graphql-api-lambda-with-cache/types.js +0 -2
- package/src/lib/aws/construct/graphql-api-lambda/index.ts +0 -2
- package/src/lib/aws/construct/graphql-api-lambda/main.ts +0 -244
- package/src/lib/aws/construct/graphql-api-lambda/types.ts +0 -27
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/index.ts +0 -2
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/main.ts +0 -147
- package/src/lib/aws/construct/graphql-api-lambda-with-cache/types.ts +0 -13
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CommonStackProps } from '../../common'
|
|
2
|
-
import { AcmProps, LambdaEnvironment, LambdaProps } from '../../services'
|
|
3
|
-
import { LambdaRestApiProps } from 'aws-cdk-lib/aws-apigateway'
|
|
4
|
-
import { AssetCode } from 'aws-cdk-lib/aws-lambda'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use RestApiLambdaEnvironment instead. This will be removed in a future release.
|
|
8
|
-
*/
|
|
9
|
-
export interface GraphQlApiLambdaEnvironment extends LambdaEnvironment {}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use RestApiLambdaProps instead. This will be removed in a future release.
|
|
13
|
-
*/
|
|
14
|
-
export interface GraphQlApiLambdaProps extends CommonStackProps {
|
|
15
|
-
apiRootPaths?: string[]
|
|
16
|
-
apiSubDomain: string
|
|
17
|
-
graphQLApiCertificate: AcmProps
|
|
18
|
-
graphQLApiHandler: string
|
|
19
|
-
graphQLApiSource: AssetCode
|
|
20
|
-
graphqlApi: LambdaProps
|
|
21
|
-
graphqlApiLambdaLayerSources?: AssetCode[]
|
|
22
|
-
graphqlRestApi: LambdaRestApiProps
|
|
23
|
-
logLevel: string
|
|
24
|
-
nodeEnv: string
|
|
25
|
-
timezone: string
|
|
26
|
-
useExistingHostedZone: boolean
|
|
27
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { Fn } from 'aws-cdk-lib'
|
|
2
|
-
import { ISecurityGroup, IVpc, Peer, Port, SecurityGroup } from 'aws-cdk-lib/aws-ec2'
|
|
3
|
-
import { CfnReplicationGroup } from 'aws-cdk-lib/aws-elasticache'
|
|
4
|
-
import { ManagedPolicy } from 'aws-cdk-lib/aws-iam'
|
|
5
|
-
import { Construct } from 'constructs'
|
|
6
|
-
import _ from 'lodash'
|
|
7
|
-
import { GraphQLApiLambda } from '..'
|
|
8
|
-
import * as utils from '../../utils'
|
|
9
|
-
import { GraphQlApiLambdaWithCacheProps } from './types'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated Use RestApiLambdaWithCache instead. This will be removed in a future release.
|
|
13
|
-
* @classdesc Provides a construct to create and deploy a Graphql API as Lambda with Caching
|
|
14
|
-
*
|
|
15
|
-
* <b>Architecture</b><br/> 
|
|
16
|
-
* @example
|
|
17
|
-
* import { GraphQlApiLambdaWithCacheProps } '@gradientedge/cdk-utils'
|
|
18
|
-
* import { Construct } from 'constructs'
|
|
19
|
-
*
|
|
20
|
-
* class CustomConstruct extends GraphQLApiLambdaWithCache {
|
|
21
|
-
* constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps) {
|
|
22
|
-
* super(parent, id, props)
|
|
23
|
-
* this.props = props
|
|
24
|
-
* this.id = id
|
|
25
|
-
* this.initResources()
|
|
26
|
-
* }
|
|
27
|
-
* }
|
|
28
|
-
*/
|
|
29
|
-
export class GraphQLApiLambdaWithCache extends GraphQLApiLambda {
|
|
30
|
-
/* graphql restApi props */
|
|
31
|
-
props: GraphQlApiLambdaWithCacheProps
|
|
32
|
-
id: string
|
|
33
|
-
|
|
34
|
-
/* graphql restApi resources */
|
|
35
|
-
graphQLVpc: IVpc
|
|
36
|
-
graphQLElastiCache: CfnReplicationGroup
|
|
37
|
-
graphQLSecurityGroup: ISecurityGroup
|
|
38
|
-
securityGroupExportName: string
|
|
39
|
-
|
|
40
|
-
constructor(parent: Construct, id: string, props: GraphQlApiLambdaWithCacheProps) {
|
|
41
|
-
super(parent, id, props)
|
|
42
|
-
|
|
43
|
-
this.props = props
|
|
44
|
-
this.id = id
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected initResources() {
|
|
48
|
-
this.setVpc()
|
|
49
|
-
this.setSecurityGroup()
|
|
50
|
-
this.createElastiCache()
|
|
51
|
-
super.initResources()
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Create VPC
|
|
56
|
-
*/
|
|
57
|
-
protected setVpc() {
|
|
58
|
-
if (this.props.useExistingVpc) {
|
|
59
|
-
this.graphQLVpc = this.vpcManager.retrieveCommonVpc(`${this.id}`, this, this.props.vpcName)
|
|
60
|
-
} else {
|
|
61
|
-
this.graphQLVpc = this.vpcManager.createCommonVpc(this, this.props.graphQLVpc, this.props.graphQLVpc.vpcName)
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Resolve Security Group
|
|
67
|
-
*/
|
|
68
|
-
protected setSecurityGroup() {
|
|
69
|
-
if (this.props.securityGroupExportName) {
|
|
70
|
-
this.graphQLSecurityGroup = SecurityGroup.fromSecurityGroupId(
|
|
71
|
-
this,
|
|
72
|
-
`${this.id}`,
|
|
73
|
-
Fn.importValue(this.props.securityGroupExportName)
|
|
74
|
-
)
|
|
75
|
-
} else {
|
|
76
|
-
this.graphQLSecurityGroup = new SecurityGroup(this, `${this.id}-security-group-${this.props.stage}`, {
|
|
77
|
-
securityGroupName: `${this.id}-security-group-${this.props.stage}`,
|
|
78
|
-
vpc: this.graphQLVpc,
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
this.graphQLSecurityGroup.addIngressRule(Peer.anyIpv4(), Port.allTraffic(), 'All Traffic')
|
|
82
|
-
if (this.props.graphQLVpc.isIPV6) {
|
|
83
|
-
this.graphQLSecurityGroup.addIngressRule(Peer.anyIpv6(), Port.allTraffic(), 'All Traffic')
|
|
84
|
-
} else {
|
|
85
|
-
this.graphQLSecurityGroup.addIngressRule(Peer.anyIpv4(), Port.allTraffic(), 'All Traffic')
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
utils.createCfnOutput(`${this.id}-security-group-id`, this, this.graphQLSecurityGroup.securityGroupId)
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Create ElastiCache
|
|
94
|
-
*/
|
|
95
|
-
protected createElastiCache() {
|
|
96
|
-
this.graphQLElastiCache = this.elasticacheManager.createReplicatedElastiCache(
|
|
97
|
-
`${this.id}-elasticache`,
|
|
98
|
-
this,
|
|
99
|
-
this.props.graphQLElastiCache,
|
|
100
|
-
_.map(this.graphQLVpc.privateSubnets, subnet => subnet.subnetId),
|
|
101
|
-
[this.graphQLSecurityGroup.securityGroupId]
|
|
102
|
-
)
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Create Lambda Role
|
|
107
|
-
*/
|
|
108
|
-
protected createLambdaRole() {
|
|
109
|
-
super.createLambdaRole()
|
|
110
|
-
|
|
111
|
-
this.graphQLApiLambdaRole.addManagedPolicy(
|
|
112
|
-
ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole')
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @summary Method to create environment variables for GraphQL Lambda function
|
|
118
|
-
*/
|
|
119
|
-
protected createLambdaEnvironment() {
|
|
120
|
-
this.graphQLApiLambdaEnvironment = {
|
|
121
|
-
LOG_LEVEL: this.props.logLevel,
|
|
122
|
-
NODE_ENV: this.props.nodeEnv,
|
|
123
|
-
TZ: this.props.timezone,
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* @summary Method to create lambda function for GraphQL API
|
|
129
|
-
*/
|
|
130
|
-
protected createLambdaFunction() {
|
|
131
|
-
this.graphQLApiLambdaFunction = this.lambdaManager.createLambdaFunction(
|
|
132
|
-
`${this.id}-graphql-server`,
|
|
133
|
-
this,
|
|
134
|
-
this.props.graphqlApi,
|
|
135
|
-
this.graphQLApiLambdaRole,
|
|
136
|
-
this.graphQLApiLambdaLayers,
|
|
137
|
-
this.props.graphQLApiSource,
|
|
138
|
-
this.props.graphQLApiHandler || 'index.handler',
|
|
139
|
-
this.graphQLApiLambdaEnvironment,
|
|
140
|
-
this.graphQLVpc,
|
|
141
|
-
[this.graphQLSecurityGroup],
|
|
142
|
-
undefined,
|
|
143
|
-
undefined,
|
|
144
|
-
this.graphQLVpc
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ReplicatedElastiCacheProps, VpcProps } from '../../services'
|
|
2
|
-
import { GraphQlApiLambdaProps } from '../graphql-api-lambda'
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated Use RestApiLambdaWithCacheProps instead. This will be removed in a future release.
|
|
6
|
-
*/
|
|
7
|
-
export interface GraphQlApiLambdaWithCacheProps extends GraphQlApiLambdaProps {
|
|
8
|
-
graphQLElastiCache: ReplicatedElastiCacheProps
|
|
9
|
-
graphQLVpc: VpcProps
|
|
10
|
-
securityGroupExportName: string
|
|
11
|
-
useExistingVpc: boolean
|
|
12
|
-
vpcName?: string
|
|
13
|
-
}
|