-
Notifications
You must be signed in to change notification settings - Fork 553
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
Add S3ObjectLambdaEvent #536
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #536 +/- ##
=======================================
Coverage 72.93% 72.93%
=======================================
Files 26 26
Lines 1456 1456
=======================================
Hits 1062 1062
Misses 322 322
Partials 72 72 ☔ View full report in Codecov by Sentry. |
events/s3_object_lambda.go
Outdated
type GetObjectContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
OutputRoute string `json:"outputRoute"` | ||
OutputToken string `json:"outputToken"` | ||
} | ||
|
||
type ListObjectsContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type ListObjectsV2Context struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type HeadObjectContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type Configuration struct { |
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.
All the new structs in the PR should be prefixed with something like S3ObjectLambda
, to avoid polluting the shared event namespace with very generic names like Configuration
.
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 for the suggestion, I added the prefix.
events/README_S3_Object_Lambda.md
Outdated
RequestToken: &event.GetObjectContext.OutputToken, | ||
Body: strings.NewReader(string(jsonData)), | ||
} | ||
return svc.WriteGetObjectResponse(ctx, input) |
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.
At a glance this doesn't look right as an example return value.
Looking at the docs https://docs.aws.amazon.com/AmazonS3/latest/userguide/olap-writing-lambda.html#olap-headobject
I see python functions returning things like {statusCode: 200, <otherfields>}
and at least on java function defined with a void
return type.
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.
Changed this function just to return error.
events/s3_object_lambda.go
Outdated
type GetObjectContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
OutputRoute string `json:"outputRoute"` | ||
OutputToken string `json:"outputToken"` | ||
} | ||
|
||
type ListObjectsContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type ListObjectsV2Context struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type HeadObjectContext struct { | ||
InputS3Url string `json:"inputS3Url"` | ||
} | ||
|
||
type S3ObjectLambdaConfiguration struct { | ||
AccessPointARN string `json:"accessPointArn"` | ||
SupportingAccessPointARN string `json:"supportingAccessPointArn"` | ||
Payload string `json:"payload"` | ||
} | ||
|
||
type UserRequest struct { | ||
URL string `json:"url"` | ||
Headers map[string]string `json:"headers"` | ||
} | ||
|
||
type UserIdentity struct { | ||
Type string `json:"type"` | ||
PrincipalID string `json:"principalId"` | ||
ARN string `json:"arn"` | ||
AccountID string `json:"accountId"` | ||
AccessKeyID string `json:"accessKeyId"` | ||
SessionContext *SessionContext `json:"sessionContext,omitempty"` | ||
} | ||
|
||
type SessionContext struct { | ||
Attributes map[string]string `json:"attributes"` | ||
SessionIssuer *SessionIssuer `json:"sessionIssuer,omitempty"` | ||
} | ||
|
||
type SessionIssuer struct { | ||
Type string `json:"type"` | ||
PrincipalID string `json:"principalId"` | ||
ARN string `json:"arn"` | ||
AccountID string `json:"accountId"` | ||
UserName string `json:"userName"` | ||
} |
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.
All of these structs should be prefixed with S3ObjectLambda
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 fixed them!
GetObjectContext *S3ObjectLambdaGetObjectContext `json:"getObjectContext,omitempty"` | ||
ListObjectsContext *S3ObjectLambdaListObjectsContext `json:"listObjectsContext,omitempty"` | ||
ListObjectsV2Context *S3ObjectLambdaListObjectsV2Context `json:"listObjectsV2Context,omitempty"` | ||
HeadObjectContext *S3ObjectLambdaHeadObjectContext `json:"headObjectContext,omitempty"` |
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.
Looking for another reference for these fields. The documentation I found so far only shows getObjectContext
https://docs.aws.amazon.com/AmazonS3/latest/userguide/olap-event-context.html
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.
PR for the rust event calavera/aws-lambda-events#127 didn't contain additional docs for List/Head object.
Guess I gotta check this by hand, or ask the service team for a pointer.
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 followed these examples in the documentation.
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.
My bad! I forgot that I referenced that exact documentation when reviewing one of your previous commits! #536 (comment)
events/s3_object_lambda.go
Outdated
} | ||
|
||
type S3ObjectLambdaGetObjectContext struct { | ||
InputS3Url string `json:"inputS3Url"` |
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.
Linter should have flagged this 🧐 Should be InputS3URL
instead of InputS3Url
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, I fixed them.
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.
FYI: @kdnakt it looks like the README.md was not updated with this change
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 for letting me know!
I'll create another pull request for that.
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, thanks!
Issue #, if available:
#525
Description of changes:
I used JSON files for testing, similar to the repository below.
https://github.com/awslabs/aws-lambda-rust-runtime/tree/main/lambda-events/src/fixtures
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.