awslabs / awslabs/aws-solutions-constructs

Slow to synthesize CloudFrontToS3 pattern with other patterns

Open
#229 2 comments 0 reactions 1 assignee Claimed by @biffgaut View on GitHub
Backlog bug question Researching
Dominant language
TypeScript
Stars
1.4k
Forks
268
Avg merge
5h 18m
Merged PRs (30d)
5

Description

I'm using several patterns, and one of them, `CloudFrontToS3` pattern is really slow to create a CloudFormation template when I run `cdk synth`. I put the simple `console.time` and `console.timeEnd` to see how long it takes, and I found the below one caused the most time:

https://github.com/awslabs/aws-solutions-constructs/blob/233d3ff1f03805651478ad3cd3f7def880f4e530/source/patterns/%40aws-solutions-constructs/core/lib/utils.ts#L63-L68

### Reproduction Steps
The below one is the source code from my project (part of the source code):

```typescript
console.time('CloudFrontToS3')
const cloudFrontToS3 = new CloudFrontToS3(this, 'CloudFrontToS3', {
bucketProps: {
serverAccessLogsBucket: props.s3LoggingBucket,
serverAccessLogsPrefix: 's3/'
},
cloudFrontDistributionProps: {
enableLogging: true,
logBucket: props.s3LoggingBucket,
logFilePrefix: 'cf/'
},
insertHttpSecurityHeaders: false
});
console.time('CloudFrontToS3')
```

### Environment

- **CDK CLI Version :** 1.107.0
- **CDK Framework Version:** 1.107.0
- **AWS Solutions Constructs Version :** 1.107.0
- **OS :** macOS Catalina Version 10.15.7
- **Language :** TypeScript

### Other

This is the time that I measured for different patterns used at the same time:
```
overrideProps: 0.107ms
KinesisStreamsToKinesisFirehoseToS3: 24.668ms
overrideProps: 0.149ms
overrideProps: 0.084ms
SqsToLambda: 16.71ms
overrideProps: 0.358ms
LambdaToDynamoDB: 8.115ms
overrideProps: 0.139ms
overrideProps: 0.293ms
LambdaToDynamoDB: 4.523ms
overrideProps: 0.089ms
**overrideProps: 6:34.080 (m:ss.mmm)**
(node:36831) Warning: Label 'deepdiff' already exists for console.time()
(node:36831) Warning: Label 'deepdiff' already exists for console.time()
(node:36831) Warning: Label 'deepdiff' already exists for console.time()
(node:36831) Warning: Label 'deepdiff' already exists for console.time()
(node:36831) Warning: Label 'deepdiff' already exists for console.time()
(node:36831) Warning: Label 'CloudFrontToS3' already exists for console.time()
```

And I don't know what caused the above warning (haven't investigated deeply), but it seems like somewhere, it's looping for the below source code because I only put the time measurement for `CloudFrontToS3` once.
https://github.com/awslabs/aws-solutions-constructs/blob/233d3ff1f03805651478ad3cd3f7def880f4e530/source/patterns/%40aws-solutions-constructs/core/lib/override-warning-service.ts#L61-L62

If you need more information, please let me know.

---

This is :bug: Bug Report

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.