-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial commit raw sync lambda * add stacks for raw sync lambda * add publish to sns functionality to raw sync lambda * Add cloudwatch events rule for raw sync lambda * raw sync lambda minor improvements
- Loading branch information
1 parent
ddf509b
commit 2a766e2
Showing
15 changed files
with
1,448 additions
and
2 deletions.
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
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,12 @@ | ||
template: | ||
path: events-rule.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-events-rule-raw-sync" | ||
dependencies: | ||
- develop/namespaced/lambda-raw-sync.yaml | ||
parameters: | ||
RuleName: "{{ stack_group_config.namespace }}-lambda-raw-sync-trigger" | ||
RuleState: DISABLED | ||
LambdaArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-sync::RawSyncFunctionArn" | ||
CronSchedule: cron(0 0 * * ? *) | ||
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,11 @@ | ||
template: | ||
path: lambda-raw-sync-role.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-sync-role" | ||
dependencies: | ||
- develop/namespaced/sns-dispatch.yaml | ||
parameters: | ||
S3SourceBucketName: {{ stack_group_config.input_bucket_name }} | ||
S3TargetBucketName: {{ stack_group_config.raw_bucket_name }} | ||
SNSTopicArn: !stack_output_external "{{ stack_group_config.namespace }}-sns-dispatch::SnsTopicArn" | ||
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,18 @@ | ||
template: | ||
type: sam | ||
path: src/lambda_function/raw_sync/template.yaml | ||
artifact_bucket_name: {{ stack_group_config.template_bucket_name }} | ||
artifact_prefix: "{{ stack_group_config.namespace }}/src/lambda" | ||
dependencies: | ||
- develop/namespaced/lambda-raw-sync-role.yaml | ||
- develop/namespaced/sns-dispatch.yaml | ||
- develop/s3-cloudformation-bucket.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-sync" | ||
parameters: | ||
RoleArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-sync-role::RoleArn" | ||
S3InputBucket: {{ stack_group_config.input_bucket_name }} | ||
S3InputKeyPrefix: "{{ stack_group_config.namespace }}/" | ||
S3RawBucket: {{ stack_group_config.raw_bucket_name }} | ||
S3RawKeyPrefix: "{{ stack_group_config.namespace }}/json/" | ||
SNSTopicArn: !stack_output_external "{{ stack_group_config.namespace }}-sns-dispatch::SnsTopicArn" | ||
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,12 @@ | ||
template: | ||
path: events-rule.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-events-rule-raw-sync" | ||
dependencies: | ||
- prod/namespaced/lambda-raw-sync.yaml | ||
parameters: | ||
RuleName: "{{ stack_group_config.namespace }}-lambda-raw-sync-trigger" | ||
RuleState: DISABLED | ||
LambdaArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-sync::RawSyncFunctionArn" | ||
CronSchedule: cron(0 0 * * ? *) | ||
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,11 @@ | ||
template: | ||
path: lambda-raw-sync-role.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-sync-role" | ||
dependencies: | ||
- prod/namespaced/sns-dispatch.yaml | ||
parameters: | ||
S3SourceBucketName: {{ stack_group_config.input_bucket_name }} | ||
S3TargetBucketName: {{ stack_group_config.raw_bucket_name }} | ||
SNSTopicArn: !stack_output_external "{{ stack_group_config.namespace }}-sns-dispatch::SnsTopicArn" | ||
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,18 @@ | ||
template: | ||
type: sam | ||
path: src/lambda_function/raw_sync/template.yaml | ||
artifact_bucket_name: {{ stack_group_config.template_bucket_name }} | ||
artifact_prefix: "{{ stack_group_config.namespace }}/src/lambda" | ||
dependencies: | ||
- prod/namespaced/lambda-raw-sync-role.yaml | ||
- prod/namespaced/sns-dispatch.yaml | ||
- prod/s3-cloudformation-bucket.yaml | ||
stack_name: "{{ stack_group_config.namespace }}-lambda-raw-sync" | ||
parameters: | ||
RoleArn: !stack_output_external "{{ stack_group_config.namespace }}-lambda-raw-sync-role::RoleArn" | ||
S3InputBucket: {{ stack_group_config.input_bucket_name }} | ||
S3InputKeyPrefix: "{{ stack_group_config.namespace }}/" | ||
S3RawBucket: {{ stack_group_config.raw_bucket_name }} | ||
S3RawKeyPrefix: "{{ stack_group_config.namespace }}/json/" | ||
SNSTopicArn: !stack_output_external "{{ stack_group_config.namespace }}-sns-dispatch::SnsTopicArn" | ||
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,38 @@ | ||
# Raw Sync Lambda | ||
|
||
The raw sync Lambda ensures that the input and raw S3 buckets are synchronized | ||
by verifying that all non-zero sized JSON in each export in the input bucket | ||
have a corresponding object in the raw bucket. | ||
|
||
If a JSON file from an export is found to not have a corresponding object in the raw bucket, | ||
the file is submitted to the raw Lambda (via the dispatch SNS topic) for processing. | ||
|
||
## 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_sync/ | ||
sam build | ||
``` | ||
|
||
## Tests | ||
|
||
Tests are available in `tests/test_lambda_raw_sync.py`. |
Oops, something went wrong.