@gradientedge/cdk-utils 6.0.0 → 6.2.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.
@@ -351,11 +351,12 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
351
351
  return;
352
352
  }
353
353
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
354
- logGroupName: `/custom/api/${this.id}-rest-api-access-${this.props.stage}`,
354
+ logGroupName: `/custom/api/${this.id}-rest-api-access`,
355
355
  removalPolicy: cdk.RemovalPolicy.DESTROY,
356
356
  });
357
357
  this.apiToEventBridgeTargetRestApi.api = new apig.RestApi(this, `${this.id}-rest-api`, {
358
358
  ...{
359
+ cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
359
360
  defaultIntegration: this.apiToEventBridgeTargetRestApi.integration,
360
361
  defaultMethodOptions: {
361
362
  methodResponses: [
@@ -364,7 +365,8 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
364
365
  ],
365
366
  },
366
367
  deployOptions: {
367
- dataTraceEnabled: true,
368
+ tracingEnabled: this.props.api.restApi?.deployOptions?.tracingEnabled,
369
+ dataTraceEnabled: this.props.api.restApi?.deployOptions?.dataTraceEnabled,
368
370
  description: `${this.id} - ${this.props.stage} stage`,
369
371
  loggingLevel: apig.MethodLoggingLevel.INFO,
370
372
  metricsEnabled: true,
@@ -382,7 +384,7 @@ class ApiToEventBridgeTarget extends common_1.CommonConstruct {
382
384
  },
383
385
  restApiName: `${this.id}-rest-api-${this.props.stage}`,
384
386
  },
385
- ...this.props.api,
387
+ ...this.props.api.restApi,
386
388
  });
387
389
  this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId);
388
390
  this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToEventBridgeTargetRestApi.api.root.resourceId);
@@ -152,7 +152,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
152
152
  if (this.props.api.useExisting)
153
153
  return;
154
154
  this.apiDestinedLambda.policy = new iam.PolicyDocument({
155
- statements: [this.iamManager.statementForReadSecrets(this), this.iamManager.statementForPutEvents()],
155
+ statements: [this.iamManager.statementForPutEvents([this.apiEvent.eventBus.eventBusArn])],
156
156
  });
157
157
  }
158
158
  /**
@@ -481,7 +481,7 @@ class ApiToEventBridgeTargetWithSns extends common_1.CommonConstruct {
481
481
  return;
482
482
  }
483
483
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-sns-rest-api-access-log`, this, {
484
- logGroupName: `/custom/api/${this.id}-destined-rest-api-access-${this.props.stage}`,
484
+ logGroupName: `/custom/api/${this.id}-destined-rest-api-access`,
485
485
  removalPolicy: cdk.RemovalPolicy.DESTROY,
486
486
  });
487
487
  this.apiDestinedRestApi.api = new apig.RestApi(this, `${this.id}-sns-rest-api`, {
@@ -120,7 +120,7 @@ class GraphQLApiLambda extends common_1.CommonConstruct {
120
120
  */
121
121
  createLambdaPolicy() {
122
122
  this.graphQLApiLambdaPolicy = new iam.PolicyDocument({
123
- statements: [this.iamManager.statementForReadSecrets(this)],
123
+ statements: [this.iamManager.statementForCreateAnyLogStream()],
124
124
  });
125
125
  }
126
126
  /**
@@ -166,7 +166,7 @@ class SiteWithEcsBackend extends common_1.CommonConstruct {
166
166
  */
167
167
  createEcsPolicy() {
168
168
  this.siteEcsPolicy = new iam.PolicyDocument({
169
- statements: [this.iamManager.statementForReadSecrets(this)],
169
+ statements: [this.iamManager.statementForCreateAnyLogStream()],
170
170
  });
171
171
  }
172
172
  /**
@@ -75,8 +75,9 @@ export declare class CloudFrontManager {
75
75
  * @param {s3.IBucket?} logBucket
76
76
  * @param {acm.ICertificate?} certificate
77
77
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
78
+ * @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
78
79
  */
79
- createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[]): cdk.aws_cloudfront.Distribution;
80
+ createDistributionWithHttpOrigin(id: string, scope: common.CommonConstruct, props: types.DistributionProps, origin: origins.HttpOrigin, domainNames: string[], logBucket?: s3.IBucket, certificate?: acm.ICertificate, defaultFunctionAssociations?: cloudfront.FunctionAssociation[], responseHeadersPolicy?: cloudfront.IResponseHeadersPolicy): cdk.aws_cloudfront.Distribution;
80
81
  /**
81
82
  * @summary Method to provision a Lambda@Edge function
82
83
  *
@@ -173,8 +173,9 @@ class CloudFrontManager {
173
173
  * @param {s3.IBucket?} logBucket
174
174
  * @param {acm.ICertificate?} certificate
175
175
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
176
+ * @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
176
177
  */
177
- createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations) {
178
+ createDistributionWithHttpOrigin(id, scope, props, origin, domainNames, logBucket, certificate, defaultFunctionAssociations, responseHeadersPolicy) {
178
179
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
179
180
  certificate: certificate,
180
181
  comment: `${id} - ${scope.props.stage} stage`,
@@ -184,6 +185,7 @@ class CloudFrontManager {
184
185
  originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
185
186
  functionAssociations: defaultFunctionAssociations ?? undefined,
186
187
  viewerProtocolPolicy: props.defaultBehavior ? props.defaultBehavior.viewerProtocolPolicy : undefined,
188
+ responseHeadersPolicy: responseHeadersPolicy ?? undefined,
187
189
  },
188
190
  additionalBehaviors: props.additionalBehaviors,
189
191
  defaultRootObject: props.defaultRootObject,
@@ -60,6 +60,11 @@ class EcsManager {
60
60
  const ecsCluster = new ecs.Cluster(scope, `${id}`, {
61
61
  clusterName: `${props.clusterName}-${scope.props.stage}`,
62
62
  vpc: vpc,
63
+ defaultCloudMapNamespace: props.defaultCloudMapNamespace,
64
+ capacity: props.capacity,
65
+ enableFargateCapacityProviders: props.enableFargateCapacityProviders,
66
+ containerInsights: props.containerInsights,
67
+ executeCommandConfiguration: props.executeCommandConfiguration,
63
68
  });
64
69
  utils.createCfnOutput(`${id}-clusterArn`, scope, ecsCluster.clusterArn);
65
70
  utils.createCfnOutput(`${id}-clusterName`, scope, ecsCluster.clusterName);
@@ -115,6 +115,7 @@ class LambdaManager {
115
115
  timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
116
116
  vpc: vpc,
117
117
  vpcSubnets: vpcSubnets,
118
+ tracing: props.tracing,
118
119
  },
119
120
  });
120
121
  utils.createCfnOutput(`${id}-lambdaArn`, scope, lambdaFunction.functionArn);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradientedge/cdk-utils",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "Utilities for AWS CDK provisioning",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
@@ -377,12 +377,13 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
377
377
  }
378
378
 
379
379
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-rest-api-access-log`, this, {
380
- logGroupName: `/custom/api/${this.id}-rest-api-access-${this.props.stage}`,
380
+ logGroupName: `/custom/api/${this.id}-rest-api-access`,
381
381
  removalPolicy: cdk.RemovalPolicy.DESTROY,
382
382
  })
383
383
 
384
384
  this.apiToEventBridgeTargetRestApi.api = new apig.RestApi(this, `${this.id}-rest-api`, {
385
385
  ...{
386
+ cloudWatchRole: this.props.api.restApi?.cloudWatchRole ?? true,
386
387
  defaultIntegration: this.apiToEventBridgeTargetRestApi.integration,
387
388
  defaultMethodOptions: {
388
389
  methodResponses: [
@@ -391,7 +392,8 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
391
392
  ],
392
393
  },
393
394
  deployOptions: {
394
- dataTraceEnabled: true,
395
+ tracingEnabled: this.props.api.restApi?.deployOptions?.tracingEnabled,
396
+ dataTraceEnabled: this.props.api.restApi?.deployOptions?.dataTraceEnabled,
395
397
  description: `${this.id} - ${this.props.stage} stage`,
396
398
  loggingLevel: apig.MethodLoggingLevel.INFO,
397
399
  metricsEnabled: true,
@@ -409,7 +411,7 @@ export class ApiToEventBridgeTarget extends CommonConstruct {
409
411
  },
410
412
  restApiName: `${this.id}-rest-api-${this.props.stage}`,
411
413
  },
412
- ...this.props.api,
414
+ ...this.props.api.restApi,
413
415
  })
414
416
  this.addCfnOutput(`${this.id}-restApiId`, this.apiToEventBridgeTargetRestApi.api.restApiId)
415
417
  this.addCfnOutput(`${this.id}-restApiRootResourceId`, this.apiToEventBridgeTargetRestApi.api.root.resourceId)
@@ -162,7 +162,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
162
162
  protected createApiDestinedLambdaPolicy() {
163
163
  if (this.props.api.useExisting) return
164
164
  this.apiDestinedLambda.policy = new iam.PolicyDocument({
165
- statements: [this.iamManager.statementForReadSecrets(this), this.iamManager.statementForPutEvents()],
165
+ statements: [this.iamManager.statementForPutEvents([this.apiEvent.eventBus.eventBusArn])],
166
166
  })
167
167
  }
168
168
 
@@ -536,7 +536,7 @@ export class ApiToEventBridgeTargetWithSns extends CommonConstruct {
536
536
  }
537
537
 
538
538
  const accessLogGroup = this.logManager.createLogGroup(`${this.id}-sns-rest-api-access-log`, this, {
539
- logGroupName: `/custom/api/${this.id}-destined-rest-api-access-${this.props.stage}`,
539
+ logGroupName: `/custom/api/${this.id}-destined-rest-api-access`,
540
540
  removalPolicy: cdk.RemovalPolicy.DESTROY,
541
541
  })
542
542
 
@@ -125,7 +125,7 @@ export class GraphQLApiLambda extends CommonConstruct {
125
125
  */
126
126
  protected createLambdaPolicy() {
127
127
  this.graphQLApiLambdaPolicy = new iam.PolicyDocument({
128
- statements: [this.iamManager.statementForReadSecrets(this)],
128
+ statements: [this.iamManager.statementForCreateAnyLogStream()],
129
129
  })
130
130
  }
131
131
 
@@ -177,7 +177,7 @@ export class SiteWithEcsBackend extends CommonConstruct {
177
177
  */
178
178
  protected createEcsPolicy() {
179
179
  this.siteEcsPolicy = new iam.PolicyDocument({
180
- statements: [this.iamManager.statementForReadSecrets(this)],
180
+ statements: [this.iamManager.statementForCreateAnyLogStream()],
181
181
  })
182
182
  }
183
183
 
@@ -180,6 +180,7 @@ export class CloudFrontManager {
180
180
  * @param {s3.IBucket?} logBucket
181
181
  * @param {acm.ICertificate?} certificate
182
182
  * @param {cloudfront.FunctionAssociation?} defaultFunctionAssociations
183
+ * @param {cloudfront.IResponseHeadersPolicy?} responseHeadersPolicy
183
184
  */
184
185
  public createDistributionWithHttpOrigin(
185
186
  id: string,
@@ -189,7 +190,8 @@ export class CloudFrontManager {
189
190
  domainNames: string[],
190
191
  logBucket?: s3.IBucket,
191
192
  certificate?: acm.ICertificate,
192
- defaultFunctionAssociations?: cloudfront.FunctionAssociation[]
193
+ defaultFunctionAssociations?: cloudfront.FunctionAssociation[],
194
+ responseHeadersPolicy?: cloudfront.IResponseHeadersPolicy
193
195
  ) {
194
196
  const distribution = new cloudfront.Distribution(scope, `${id}`, {
195
197
  certificate: certificate,
@@ -200,6 +202,7 @@ export class CloudFrontManager {
200
202
  originRequestPolicy: props.defaultBehavior ? props.defaultBehavior.originRequestPolicy : undefined,
201
203
  functionAssociations: defaultFunctionAssociations ?? undefined,
202
204
  viewerProtocolPolicy: props.defaultBehavior ? props.defaultBehavior.viewerProtocolPolicy : undefined,
205
+ responseHeadersPolicy: responseHeadersPolicy ?? undefined,
203
206
  },
204
207
  additionalBehaviors: props.additionalBehaviors,
205
208
  defaultRootObject: props.defaultRootObject,
@@ -40,6 +40,11 @@ export class EcsManager {
40
40
  const ecsCluster = new ecs.Cluster(scope, `${id}`, {
41
41
  clusterName: `${props.clusterName}-${scope.props.stage}`,
42
42
  vpc: vpc,
43
+ defaultCloudMapNamespace: props.defaultCloudMapNamespace,
44
+ capacity: props.capacity,
45
+ enableFargateCapacityProviders: props.enableFargateCapacityProviders,
46
+ containerInsights: props.containerInsights,
47
+ executeCommandConfiguration: props.executeCommandConfiguration,
43
48
  })
44
49
 
45
50
  utils.createCfnOutput(`${id}-clusterArn`, scope, ecsCluster.clusterArn)
@@ -114,6 +114,7 @@ export class LambdaManager {
114
114
  timeout: props.timeoutInSecs ? cdk.Duration.seconds(props.timeoutInSecs) : cdk.Duration.minutes(1),
115
115
  vpc: vpc,
116
116
  vpcSubnets: vpcSubnets,
117
+ tracing: props.tracing,
117
118
  },
118
119
  })
119
120