-
Notifications
You must be signed in to change notification settings - Fork 4k
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(cdk): add AppSync GraphQLSchema and pipeline resolvers as hot swappable #27197
Conversation
23ca8d0
to
4e209c3
Compare
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 pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request
. Additionally, if clarification is needed add Clarification Request
to a comment.
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 really good, overall!
}; | ||
const evaluatedResourceProperties = await evaluateCfnTemplate.evaluateCfnExpression(sdkProperties); | ||
const sdkRequestObject = transformObjectKeys(evaluatedResourceProperties, lowerCaseFirstCharacter); | ||
|
||
// resolve s3 location files as SDK doesn't take in s3 location but inline code | ||
if (sdkRequestObject.requestMappingTemplateS3Location) { | ||
sdkRequestObject.requestMappingTemplate = (await fetchFileFromS3(sdkRequestObject.requestMappingTemplateS3Location, sdk))?.toString('utf8'); |
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.
What does the user flow look like with any of the *S3Location
properties? The MappingTemplate doesn't support an S3 location, and it also doesn't use it under the hood.
Even if it was supported, the user would have to change the s3 location for hotswap to be able to see it, not the object itself; diff will only detect a change in the object's location, not its contents. Users won't want to rename the object every time they make a change to 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.
Tagging @alharris-at for more details. I believe we are using L1 CFN resource here and manually managing the requestMappingTemplateS3Location
properties from our L3 data construct. (Don't know if it's the right reference https://github.com/aws-amplify/amplify-category-api/blob/c6772cfb9c0c68d6de4c04aa8190489fba0557a9/packages/graphql-transformer-core/src/util/SchemaResourceUtil.ts#L37)
In my testing, when updating high level amplify schema that results in a resolver change, I found only *S3Location
properties to have changed. @alharris-at can you provide more details here?
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.
Because Synth produces assets with a hash in the filename, I think the S3Location will change if a resolver or function's code is updated, and yeah we use L1 constructs here.
@comcalvi not urgent, but we might actually want to open the discussion to using S3Location instead of the inline approach for the L2 (when a file is provided), since that means customers will far more quickly hit Cfn template size limits (we see this happen for Amplify customers w/o inlining much of these assets, since with AppSync it's easy to produce a large number of resources quickly, and if we're inlining all code then it's going to expand very quickly).
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.
ahh okay, so the s3 locations are managed through the CDK here. That makes sense, thanks for clarifying.
await simpleRetry( | ||
() => sdk.appsync().updateFunction({ ...sdkRequestObject, functionId: functionId! }).promise(), | ||
3, | ||
'ConcurrentModificationException'); |
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 good workaround for the orchestration / resource dependency problem, nice work
} else { | ||
let schemaCreationResponse: GetSchemaCreationStatusResponse = await sdk.appsync().startSchemaCreation(sdkRequestObject).promise(); | ||
while (schemaCreationResponse.status && ['PROCESSING', 'DELETING'].some(status => status === schemaCreationResponse.status)) { | ||
await new Promise(resolve => setTimeout(resolve, 1000)); // poll every second |
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 make a little helper for this, similar to: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk/lib/util/archive.ts#L84
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.
Good idea, updated.
@Amplifiyer - looks like this doesn't support |
@alharris-at, |
➡️ PR build request submitted to A maintainer must now check the pipeline and add the |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Closes #2659, #24112, #24113.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license