-
Notifications
You must be signed in to change notification settings - Fork 14
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
Typescript support workers #6480
base: main
Are you sure you want to change the base?
Conversation
Size Change: 0 B Total Size: 1.89 MB ℹ️ View Unchanged
|
4865852
to
ab74f26
Compare
98a1a59
to
7860f54
Compare
cfd14ef
to
0324201
Compare
32d6a8b
to
1bf2ef2
Compare
1bf2ef2
to
52c75a7
Compare
"PreparePaymentMethodForReuse" | ||
).addCatch(failureHandler, catchProps); | ||
|
||
const createPaymentMethodLambda = createLambda( | ||
const createPaymentMethodLambda = createTypescriptLambda( |
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 the first and only (for now) lambda migrated to Typescript
5e7fbb5
to
0434c11
Compare
@@ -0,0 +1,13 @@ | |||
S3_BUCKET="membership-dist" |
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 a shell script to simplify deploying the zipped artifact to CODE for a quicker testing cycle
"check-formatting": "prettier --check **.ts", | ||
"build": "tsc", | ||
"clean-target": "rm -rf target && mkdir -p target", | ||
"install-runtime-dependencies": "yarn install --modules-folder target/typescript/node_modules --production", |
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 line installs only the runtime (non-dev) dependencies into the target directory so they can be zipped up into the deployment artifact
26037ea
to
48f39b0
Compare
@@ -0,0 +1,194 @@ | |||
import { combinedAddressLine } from '../model/address'; |
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.
Lambda and application code start here
@@ -0,0 +1,94 @@ | |||
import { |
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.
Tests and json fixtures from here on except for some small utility classes and the tsconfig file at the end
fileName: `support-workers.jar`, | ||
runtime: Runtime.JAVA_21, | ||
handler: `com.gu.support.workers.lambdas.${lambdaName}::handleRequest`, | ||
functionName: `${this.stack}-${lambdaName}Lambda-${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.
assume everything is just a duplicate between scala->ts other than these 4 lines?
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.
The functionName is the same so it's just the three lines difference
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.
consider making it a function that only takes those 3 parameters, to make it clearer they are the same
}); | ||
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.
this probably doesn't make sense any more does it?
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.
The comment? I think it's roughly accurate, what else would we put?
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.
so it's a permanent change? (I realise it was not added from your PR)
In my mind I thought it needed to be overridden during the switch over to avoid clashes and then it could be removed?
Maybe if it's needed to match up with log group names or state machine definitions it would be something like
"Align function name with state machine definition"
?
48f39b0
to
773b901
Compare
@@ -97,6 +102,13 @@ jobs: | |||
- "-PreparePaymentMethodForReuseLambda-" | |||
fileName: support-workers.jar | |||
dependencies: [cfn] | |||
support-workers-typescript: |
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'm glad you've distinguished them by their language as it's clearer 👍 (vs the change from product-move-api -> product-switch-api)
S3_BUCKET="membership-dist" | ||
S3_KEY="support/CODE/support-workers-typescript/support-workers.zip" | ||
LAMBDA_FUNCTIONS=( | ||
"-CreatePaymentMethodLambda-" |
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 not put the -
where it's used rather than in (every) function name?
support-${function}-CODE
Otherwise it gets serialised to a date time which the Scala code can't deserialise. Once we are using TS lambdas for the whole state machine we could revisit this.
8c4140a
to
1811f3a
Compare
1811f3a
to
7657069
Compare
What are you doing in this PR?
This PR is the first step in migrating the support-workers state machine from Scala to Typescript.
There are a lot of changes in this PR, but they broadly break down into the following categories:
In retrospect it probably would have been better to do the infrastructure stuff on its own as a separate PR but I did a lot of this over 2 days of a hack day so I didn't have time to make and merge incremental PRs.
Once this PR is merged, the CreatePaymentMethod step of the state machine will run from the Typescript lambda whilst all the others continue to run from the Scala ones. We can then swap the other lambdas out one by one, and delete the old scala code.
I have tested this in code with the following: