Skip to content

fix (Throwing Error('Duration.toString()) from CloudfrontToS3/Kinesisstreams-Kinesisfirehose-s3) #223

Closed
@biffgaut

Description

@biffgaut

This code:

export class ClientStack extends cdk.Stack {
  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);
    new KinesisStreamsToKinesisFirehoseToS3(this, 'stream', {});
    const logBucket = new s3.Bucket(this, 'separate-bucket', {});
    /**
     * Throws Error('Duration.toString() was used, but .toSeconds, .toMinutes 
     * or .toDays should have been called instead');
     */
    new CloudFrontToS3(this, 'CloudFrontToS3', {
      // bucketProps: {
      //   serverAccessLogsBucket: logBucket,
      //   serverAccessLogsPrefix: 'ui-s3/'
      // },
      cloudFrontDistributionProps: {
        // enableLogging: true,
        errorResponses: [
          { httpStatus: 403, responseHttpStatus: 200, responsePagePath: '/index.html' },
          { httpStatus: 404, responseHttpStatus: 200, responsePagePath: '/index.html' }
        ],
        logBucket: logBucket,
        logFilePrefix: 'ui-cf/'
      },
      insertHttpSecurityHeaders: false
    });
  }
}

Throws this error:

  public toJSON(): any {
            ^
Error: Argument to Intrinsic must be a plain value object, got () => {
            throw new Error('Duration.toString() was used, but .toSeconds, .toMinutes or .toDays should have been called instead');
        }
    at new Intrinsic (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-cdk/core/lib/private/intrinsic.ts:37:13)
    at Function.asAny (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-cdk/core/lib/token.ts:102:48)
    at Function.asString (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-cdk/core/lib/token.ts:79:53)
    at Duration.toString (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-cdk/core/lib/duration.ts:219:18)
    at realTypeOf (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-solutions-constructs/core/node_modules/deep-diff/index.js:117:81)
    at deepDiff (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-solutions-constructs/core/node_modules/deep-diff/index.js:193:9)
    at deepDiff (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-solutions-constructs/core/node_modules/deep-diff/index.js:255:15)
    at deepDiff (/Users/biffgaut/Documents/Active/AWS/Constructs/beomseok/client/node_modules/@aws-solutions-constructs/core/node_modules/deep-diff/index.js:255:15)

Reproduction Steps

Error Log

Environment

  • CDK CLI Version : 1.06.1
  • CDK Framework Version: 1.106.1
  • AWS Solutions Constructs Version : 1.106.1
  • OS : iOS
  • Language : Typescript

Other


This is 🐛 Bug Report

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingin-progressThis issue is being actively worked on

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions