-
Notifications
You must be signed in to change notification settings - Fork 1
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
[ETL-636] Raw Lambda #138
Merged
Merged
[ETL-636] Raw Lambda #138
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0aa8f6a
raw lambda initial commit
philerooski a3bf5cb
yield compressed data up to part threshold
philerooski efb79fe
complete implementation and add tests
philerooski 6ac1233
minor update to dispatch lambda module docstring
philerooski 29e77ac
Add analogous prod stacks
philerooski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
template: | ||
path: lambda-raw-role.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-role" | ||
dependencies: | ||
- develop/namespaced/sqs-dispatch-to-raw.yaml | ||
- develop/s3-cloudformation-bucket.yaml | ||
- develop/s3-raw-bucket.yaml | ||
parameters: | ||
SQSQueueArn: !stack_output_external "{{ stack_group_config.namespace }}-sqs-dispatch-to-raw::PrimaryQueueArn" | ||
S3SourceBucketName: {{ stack_group_config.input_bucket_name }} | ||
S3TargetBucketName: {{ stack_group_config.raw_bucket_name }} | ||
stack_tags: | ||
{{ stack_group_config.default_stack_tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
template: | ||
type: sam | ||
path: src/lambda_function/raw/template.yaml | ||
artifact_bucket_name: {{ stack_group_config.template_bucket_name }} | ||
artifact_prefix: "{{ stack_group_config.namespace }}/src/lambda" | ||
dependencies: | ||
- develop/namespaced/lambda-raw-role.yaml | ||
- develop/namespaced/sqs-dispatch-to-raw.yaml | ||
- develop/s3-cloudformation-bucket.yaml | ||
- develop/s3-raw-bucket.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw" | ||
parameters: | ||
RoleArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-role::RoleArn" | ||
SQSQueueArn: !stack_output_external "{{ stack_group_config.namespace }}-sqs-dispatch-to-raw::PrimaryQueueArn" | ||
S3RawBucket: {{ stack_group_config.raw_bucket_name }} | ||
S3RawKeyPrefix: "{{ stack_group_config.namespace }}/json/" | ||
stack_tags: {{ stack_group_config.default_stack_tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
template: | ||
path: lambda-raw-role.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-role" | ||
dependencies: | ||
- prod/namespaced/sqs-dispatch-to-raw.yaml | ||
- prod/s3-cloudformation-bucket.yaml | ||
- prod/s3-raw-bucket.yaml | ||
parameters: | ||
SQSQueueArn: !stack_output_external "{{ stack_group_config.namespace }}-sqs-dispatch-to-raw::PrimaryQueueArn" | ||
S3SourceBucketName: {{ stack_group_config.input_bucket_name }} | ||
S3TargetBucketName: {{ stack_group_config.raw_bucket_name }} | ||
stack_tags: | ||
{{ stack_group_config.default_stack_tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
template: | ||
type: sam | ||
path: src/lambda_function/raw/template.yaml | ||
artifact_bucket_name: {{ stack_group_config.template_bucket_name }} | ||
artifact_prefix: "{{ stack_group_config.namespace }}/src/lambda" | ||
dependencies: | ||
- prod/namespaced/lambda-raw-role.yaml | ||
- prod/namespaced/sqs-dispatch-to-raw.yaml | ||
- prod/s3-cloudformation-bucket.yaml | ||
- prod/s3-raw-bucket.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw" | ||
parameters: | ||
RoleArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-role::RoleArn" | ||
SQSQueueArn: !stack_output_external "{{ stack_group_config.namespace }}-sqs-dispatch-to-raw::PrimaryQueueArn" | ||
S3RawBucket: {{ stack_group_config.raw_bucket_name }} | ||
S3RawKeyPrefix: "{{ stack_group_config.namespace }}/json/" | ||
stack_tags: {{ stack_group_config.default_stack_tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Raw Lambda | ||
|
||
The raw Lambda polls the dispatch-to-raw SQS queue and uploads an object to the raw S3 bucket. | ||
Its purpose is to compress a single JSON file from an export (zip archive) and store it to S3. | ||
It makes heavy use of Python file objects and multipart uploads and can download/compress/upload | ||
with a relatively low, fixed memory overhead with respect to the size of the uncompressed JSON. | ||
|
||
## Development | ||
|
||
The Serverless Application Model Command Line Interface (SAM CLI) is an | ||
extension of the AWS CLI that adds functionality for building and testing | ||
Lambda applications. | ||
|
||
To use the SAM CLI, you need the following tools. | ||
|
||
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html) | ||
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community) | ||
|
||
You may need the following for local testing. | ||
* [Python 3 installed](https://www.python.org/downloads/) | ||
|
||
You will also need to configure your AWS credentials, if you have not already done so. | ||
|
||
## Creating a local build | ||
|
||
Use the SAM CLI to build and test your lambda locally. | ||
Build your application with the `sam build` command. | ||
|
||
```bash | ||
cd src/lambda_function/raw/ | ||
sam build | ||
``` | ||
|
||
## Tests | ||
|
||
Tests are available in `tests/test_raw_lambda.py`. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 speak to the increase 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.
We don't know yet how long it could take for this Lambda to run on prod-sized data. Especially given the relatively small memory I've allotted. So I've set the Lambda timeout to it's maximum (900). Since the Lambda could take up to 900 seconds to complete, we also need the associated SQS event to show up in the queue again even if the Lambda fails at 899 seconds, hence we set the visibility timeout on the SQS queue to the timeout of the Lambda. AWS actually enforces this server side, so the deployment will fail if we use a smaller value.