-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support workers CDK #6449
base: main
Are you sure you want to change the base?
Support workers CDK #6449
Conversation
Size Change: 0 B Total Size: 2.29 MB ℹ️ View Unchanged
|
], | ||
s3Files: [ | ||
"arn:aws:s3:::gu-zuora-catalog/PROD/Zuora-CODE/catalog.json", | ||
"arn:aws:s3:::support-workers-private/*", |
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.
I assume this is just copied from elsewhere but it does seem a little generous
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.
👍 looks good
this.overrideLogicalId(lambda, { | ||
logicalId: lambdaId, | ||
reason: "Moving existing lambda to CDK", | ||
}); |
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.
that's a clever trick, it's always tricky to get around this kind of auto generated IDs thing normally. I assume this is a permanent override though?
this.overrideLogicalId(lambda, { | |
logicalId: lambdaId, | |
reason: "Moving existing lambda to CDK", | |
}); | |
this.overrideLogicalId(lambda, { | |
logicalId: lambdaId, | |
reason: "Retain pre-CDK logical ID", | |
}); |
}); | ||
return new LambdaInvoke(this, lambdaName, { | ||
lambdaFunction: lambda, | ||
outputPath: "$.Payload", // Without this, LambdaInvoke wraps the output state as described here: https://github.com/aws/aws-cdk/issues/29473 |
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.
I couldn't make sense of the bug, but the documentation[1] says that if we set the arn to lambda:invoke.... as we do with the above CDK construct, rather than the arn of the function as we did before, you get that wrapping.
[1] https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html
outputPath: "$.Payload", // Without this, LambdaInvoke wraps the output state as described here: https://github.com/aws/aws-cdk/issues/29473 | |
outputPath: "$.Payload", // LambdaInvoke wraps the output state, so we have to unwrap for the next state as described here: https://docs.aws.amazon.com/step-functions/latest/dg/connect-lambda.html |
having said that, could we keep the old way of specifying the ARN directly, as that's what the docs seem to suggest?
); | ||
const checkoutSuccess = new Succeed(this, "CheckoutSuccess"); | ||
|
||
const parallelSteps = new Parallel(this, "Parallel") |
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.
const parallelSteps = new Parallel(this, "Parallel") | |
const postAcquisitionSteps = new Parallel(this, "Parallel") |
.branch(sendAcquisitionEvent) | ||
.branch(checkoutSuccess); | ||
|
||
const commonSteps = createZuoraSubscription.next(parallelSteps); |
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.
common in what way?
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.
Steps that are carried out for all users whether they have an existing account or not
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.
postAccountExistsSteps ?
cdk/lib/support-workers.ts
Outdated
.next(createSalesforceContactLambda) | ||
.next(commonSteps); | ||
|
||
const startPoint = shouldClonePaymentMethodChoice |
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.
slightly more mathematic perhaps?
const startPoint = shouldClonePaymentMethodChoice | |
const initialState = shouldClonePaymentMethodChoice |
cdk/lib/support-workers.ts
Outdated
.otherwise(stepsForNewAccount); | ||
|
||
const stateMachine = new StateMachine(this, "SupportWorkers", { | ||
stateMachineName: `${app}-${this.stage}`, |
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 is used by support frontend to find the state machine I think? might be worth a comment, now we're blessed with that ability
stateMachineName: `${app}-${this.stage}`, | |
stateMachineName: `${app}-${this.stage}`,// used by support-frontend to find the state machine |
const stateMachine = new StateMachine(this, "SupportWorkers", { | ||
stateMachineName: `${app}-${this.stage}`, | ||
definitionBody: DefinitionBody.fromChainable(startPoint), | ||
}); |
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't see the overall (24h) timeout anywhere.
}; | ||
|
||
const checkoutFailure = new Pass(this, "CheckoutFailure"); // This is a failed execution we don't want to alert on | ||
const failState = new Fail(this, "FailState"); // This is a failed execution we do want to alert on |
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.
I assume the alarms are still going to be defined in the existing CFN for now (and will still match up with the retained IDs)
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.
Great catch, I'd missed the alarms off. Will add them.
@@ -1,24 +1,17 @@ | |||
#!/bin/bash | |||
|
|||
./build-cloudformation.sh |
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.
do we need to run pnpm build or similar at this point?
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.
Yes, it's running yarn synth
@@ -232,5 +242,304 @@ export class SupportWorkers extends GuStack { | |||
logicalId: `SupportWorkers${this.stage}`, | |||
reason: "Moving existing step function to CDK", | |||
}); | |||
|
|||
// Alarms |
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.
would it make sense to split it out into several files rather than relying on comments? or is that not the done thing for CDK?
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.
I think it would make it more difficult to get a full picture of what's going on
|
||
new GuAlarm(this, "ExecutionFailureAlarm", { | ||
app, | ||
actionsEnabled: isProd, |
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.
I prefer how you've done it as then CODE and PROD are more similar, but I remember there was some debate recently about whether we not have the alarm created at all in CODE, I can't remember whether it was causing an irritation for the alarms handler?
evaluationPeriods: 4, | ||
treatMissingData: TreatMissingData.BREACHING, | ||
threshold: 0, | ||
}).node.addDependency(stateMachine); |
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.
why does this depend on stateMachine but the above ones don't?
}), | ||
comparisonOperator: ComparisonOperator.LESS_THAN_OR_EQUAL_TO_THRESHOLD, | ||
evaluationPeriods: 4, | ||
treatMissingData: TreatMissingData.BREACHING, |
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.
I assume this is how the alarm was already set up rather than a change you made, but actually this will take a fair bit longer than 3600s * 4 (4 hours) to go off, as when there is missing data it looks back to find more data earlier. The usual solution is to use a calculated metric and use FILL(m1, 0)
as the expression, where m1
is the actual PaymentSuccess metric.
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.
see example on line 453 (although that also SUMs several metric which is not needed here)
What are you doing in this PR?
This PR replaces the existing home rolled way of generating the cloudformation for support-workers with CDK.
This is more standard and a lot simpler generally as the previous approach involved messing about with handlebar templates. It has been successfully tested on CODE.