Skip to content

Commit

Permalink
feat(synthetics): add activeTracing, memory and timeout property to C…
Browse files Browse the repository at this point in the history
…anary class (#30556)

### Issue # (if applicable)

Closes #9300, #14086, #28152

### Reason for this change
In order to make the properties in the [runConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.CfnCanary.RunConfigProperty.html) of the L1 Construct configurable in the L2 Construct.

* [activeTracing](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.CfnCanary.RunConfigProperty.html#activetracing)
* [memoryInMb](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.CfnCanary.RunConfigProperty.html#memoryinmb)
* [timeoutInSeconds](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.CfnCanary.RunConfigProperty.html#timeoutinseconds)

At the moment, the L2 [Canary](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.Canary.html) Class only supports [environmentVariables](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_synthetics.CfnCanary.RunConfigProperty.html#environmentvariables) in the `runConfig`.



### Description of changes
Add missing properties.

* `activeTracing`
* `memory`
* `timeout`

Note:  The following is stated in #9300, but when tested, it was possible to set only `memoryInMb` (`memory`).

> The difficulty is that timeoutInSeconds is required if runConfig is set, so one cannot only specify memoryInMb.

Test code is here.

```ts
class TestStack extends Stack {
  constructor(scope: Construct, id: string, props?: StackProps) {
    super(scope, id, props);

    new synthetics.Canary(this, 'Canary', {
      canaryName: 'next',
      runtime: synthetics.Runtime.SYNTHETICS_NODEJS_PUPPETEER_7_0,
      test: synthetics.Test.custom({
        handler: 'index.handler',
        code: synthetics.Code.fromInline(`
          exports.handler = async () => {
            console.log(\'hello world\');
          };`),
      }),
      cleanup: synthetics.Cleanup.LAMBDA,
      memory: Size.mebibytes(2048),
    });
  }
}
```



### Description of how you validated changes
Add unit tests and integ tests.



### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mazyu36 authored Jul 31, 2024
1 parent 28fbc82 commit 9295a85
Show file tree
Hide file tree
Showing 13 changed files with 1,500 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9295a85

Please sign in to comment.