-
Notifications
You must be signed in to change notification settings - Fork 113
Add support for AppSync events. #187
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
Conversation
Can one of the admins verify this patch? |
3 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Co-authored-by: Laurent Gaches <[email protected]>
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.
Thanks @DwayneCoussement for the pr and thanks @lgaches for the first round of reviews!
@DwayneCoussement would you mind running swiftformat .
once on your code (please make sure you are in the project directory before you run it)? This should make the soundness
check succeed.
Further I left a small number of comments. Do you know of any documentation of the AppSync Lambda Event types that we can link in the top of the file? Comparable to what we have done here:
swift-aws-lambda-runtime/Sources/AWSLambdaEvents/DynamoDB.swift
Lines 17 to 20 in bfdeb75
// https://docs.aws.amazon.com/lambda/latest/dg/with-ddb.html | |
public struct DynamoDB { | |
public struct Event: Decodable { | |
public let records: [EventRecord] |
Co-authored-by: Laurent Gaches <[email protected]>
@lgaches also thanks for the suggestions and first code review. @fabianfett, thank you for the second review, I've applied the requested changes as well! :) |
@swift-server-bot test this please |
} | ||
|
||
public let identity: Identity? | ||
public struct Identity: Codable { |
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 documentation in https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html#aws-appsync-resolver-context-reference-identity says:
Identity
The identity section contains information about the caller. The shape of this section depends on the authorization type of your AWS AppSync API.
For more information about this section and how it can be used, see Security.
API_KEY authorization
The identity field isn’t populated.
AWS_IAM authorization
The identity has the following shape:
{
"accountId" : "string",
"cognitoIdentityPoolId" : "string",
"cognitoIdentityId" : "string",
"sourceIp" : ["string"],
"username" : "string", // IAM user principal
"userArn" : "string",
"cognitoIdentityAuthType" : "string", // authenticated/unauthenticated based on the identity type
"cognitoIdentityAuthProvider" : "string" // the auth provider that was used to obtain the credentials
}
AMAZON_COGNITO_USER_POOLS authorization
The identity has the following shape:
{
"sub" : "uuid",
"issuer" : "string",
"username" : "string"
"claims" : { ... },
"sourceIp" : ["x.x.x.x"],
"defaultAuthStrategy" : "string"
}
Should we model this differently?
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 point! I've updated the model slightly here to take this all into account. Some updates were needed for AWS_IAM authorization. Please see the latest commit
@swift-server-bot test this please |
1 similar comment
@swift-server-bot test this please |
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.
lgtm @fabianfett ?
LGTM |
Add support for AppSync.
Motivation:
AppSync is a common AWS Service, so it might be nice to support OOB support.
Modifications:
This is a purely additive change to support AWS AppSync. An AppSync.Request and AppSync.Response was added.
Result:
You'll be able to listen to AppSync requests as follows: