-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(synthetics): add RunConfig parameters to Cloudwatch Synthetics Canary L2 construct #11865
Conversation
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
…cdk into flochaz/syntheticsRunConfig
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest using the defaults set by the service.
Thanks for submitting this, before I review, have you seen this issue: #9300, which discuss adding the |
Im also wondering about the impact of the added Lambda config to the function being updated. For example, if the environment variables are modified, will the function be redeployed? We have a lot of logic that handles this edge cases in the aws lambda construct. Wondering how we can avoid duplicating this logic |
Since those properties are not set to the lambda but to the Canary CFN resource I expect this change to be handled directly in the service. But good point, I will make a test to make sure of it. |
I would actually assume that all Lambda properties are passed to the function as is by the Synthetics service, if that's the case we need to think how we can reuse the logic which handles these properties updates from the aws-lambda module. |
I did some test using raw cloud Formation and creation, deletion and update of environment variables are properly propagated on stack update. Do you mind to point me to the logic in lambda construct ? |
…haz/aws-cdk into flochaz/syntheticsRunConfig
If the env vars are modified, CloudWatch Synthetics updates the function. |
Right, thanks @NetaNir -- we're gonna hold off on canaries until this lands. Take your time. Thanks for all the work here gang! |
Hey guys, this looks very helpful. We are deploying some canaries right now and would love to be able to ditch the L1 escape hatch code. Did this just drop off the radar? |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
We have seen some odd behavior on function update when using the Sorry for the inconvenience, in the meantime please use escape hatches |
adding an env var looks like this: const cfnCanary = canary.node.defaultChild as synthetics.CfnCanary
cfnCanary.addPropertyOverride('RunConfig.EnvironmentVariables', {
API_URL: "someurl"
}) |
@flochaz thank you for the work you've done so far on this feature! We would like to continue this work but in a more segmented manner – would you be willing to split out just the environment variable portion of this PR? If not, I am happy to modify your changes and cite you as a collaborator :) I'll have more feedback on the implementation itself after the split |
Sure, I can do that next week.
…On Thu, 3 Jun 2021 at 18:02, Ben Chaimberg ***@***.***> wrote:
@flochaz <https://github.com/flochaz> thank you for the work you've done
so far on this feature! We would like to continue this work but in a more
segmented manner – would you be willing to split out just the environment
variable portion of this PR? If not, I am happy to modify your changes and
cite you as a collaborator :)
I'll have more feedback on the implementation itself after the split
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11865 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJLIULAKZDVQ4YYRGRLE5TTQ6RQLANCNFSM4UNCXO7Q>
.
--
Florian Chazal
|
* | ||
* @default 128 | ||
*/ | ||
readonly memorySize?: number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should use Size from @aws-cdk/core and also please add checks for the multiple of 64 and the min and max values
* Specifies whether this canary is to use active AWS X-Ray tracing when it runs. | ||
* Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Specifies whether this canary is to use active AWS X-Ray tracing when it runs. | |
* Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps | |
* Specifies whether this canary is to use active AWS X-Ray tracing when it runs. | |
* | |
* Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps |
* | ||
* @default false | ||
*/ | ||
readonly tracing?: boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please note that if a role is provided, it must also have permissions documented here: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_tracing.html
* Active tracing enables this canary run to be displayed in the ServiceLens and X-Ray service maps | ||
* even if the canary does not hit an endpoint that has X-ray tracing enabled. | ||
* | ||
* You can enable active tracing only for canaries that use version syn-nodejs-2.0 or later for their canary runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a check for this? it should be version != SYNTHETICS_1_0
* | ||
* @default - No environment variables. | ||
*/ | ||
readonly environment?: { [key: string]: string }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove when merging from master
const MAX_CANARY_TIMEOUT = 840; | ||
const RATE_IN_SECONDS = Schedule.expressionToRateInSeconds(schedule.expression); | ||
const DEFAULT_CANARY_TIMEOUT_IN_SECONDS = RATE_IN_SECONDS <= MAX_CANARY_TIMEOUT ? RATE_IN_SECONDS : MAX_CANARY_TIMEOUT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for all caps here
|
||
/** | ||
* The maximum amount of memory that the canary can use while running. This value | ||
* must be a multiple of 64. The range is 960 to 3008. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* must be a multiple of 64. The range is 960 to 3008. | |
* must be a multiple of 64. The range is 960 to 3008. |
const DEFAULT_CANARY_TIMEOUT_IN_SECONDS = RATE_IN_SECONDS <= MAX_CANARY_TIMEOUT ? RATE_IN_SECONDS : MAX_CANARY_TIMEOUT; | ||
|
||
return { | ||
timeoutInSeconds: props.timeout?.toSeconds() ?? DEFAULT_CANARY_TIMEOUT_IN_SECONDS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs to check this is smaller than the rate
const regularExpression = /^rate\(([0-9]*) ([a-z]*)\)/; | ||
const split = regularExpression.exec(expression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer using just string checks instead of a regular expression
* | ||
* @param expression Schedule expression such as 'rate(2 minutes)' | ||
*/ | ||
public static expressionToRateInSeconds(expression: string): number { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
convert to a Duration
924c117
to
ebfd5f2
Compare
Is this PR still actively moving forward? Is this something I could help pick up again? |
if you can please do. I didn't ended up doing the split requested due to
lack of time ...
…On Wed, Jan 12, 2022, 18:06 Richard Simpson ***@***.***> wrote:
Is this PR still actively moving forward? Is this something I could help
pick up again?
—
Reply to this email directly, view it on GitHub
<#11865 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJLIUID3HEDIYNPRQZCZLLUVWYHTANCNFSM4UNCXO7Q>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This PR is a continuation of aws#11865 with the intention of filling out the remaining RunConfig values as well as adding missing VpcConfig properties. I wasn't sure whether VPC settings should be top level (like Lambda) or in their own configuration object, so I made them seperate for now.
I've created a follow up here: #18447 |
Closing this PR since it looks like it's getting picked up in separate pieces by other members of the community |
This PR adds vpc support to synthetics and is a continuation of #11865. See [Running a canary on a vpc](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries_VPC.html). Fixes #9954 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Cloudwatch Synthetics recently added Environment Variables injection feature.
This PR add all new RunConfig properties (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-synthetics-canary-runconfig.html) to the Canary L2 Construct.
Those new properties are all about lambda configuration so used same naming and docs as lambda equivalent.
Fixes #10515
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license