This file contains hidden or 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
| # Mock S3 new file uploaded event | |
| def s3_upload_event(self, file_name): | |
| return { | |
| "Records":[ | |
| { | |
| "eventVersion":"2.1", | |
| "eventSource":"aws:s3", | |
| "awsRegion":"us-east-1", | |
| "eventTime":"2021-06-18T16:03:17.567Z", |
This file contains hidden or 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
| import os | |
| import boto3 | |
| # Explicitly specifying where the default AWS region is found | |
| # (as an environment variable) to be able to mock it in the test | |
| s3_client = boto3.client('s3', region_name=os.environ['AWS_REGION']) | |
| translate_client = boto3.client('translate', region_name=os.environ['AWS_REGION']) | |
| def lambda_handler(event, context): | |
| print(event) |
This file contains hidden or 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
| import os | |
| import boto3 | |
| import datetime | |
| from typing import List, Dict | |
| from dataclasses import dataclass | |
| from boto3.dynamodb.conditions import Key | |
| @dataclass | |
| class Subscription: | |
| list_name: str |
This file contains hidden or 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
| import json | |
| import boto3 | |
| # Specify your table name and the region your table is in | |
| export_table_name = "ExportDataTable" | |
| dynamodb = boto3.resource('dynamodb', region_name='us-east-1') | |
| table = dynamodb.Table(export_table_name) | |
| def export_table_data(): | |
| print(f"Exporting data from {export_table_name}") |
This file contains hidden or 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
| import json | |
| import boto3 | |
| # Specify your existing (export) and new (import) table names and the region your tables are in | |
| export_table_name = "ExportDataTable" | |
| import_table_name = "ImportDataTable" | |
| dynamodb = boto3.resource('dynamodb', region_name='us-east-1') | |
| table = dynamodb.Table(import_table_name) | |
| def import_table_data(): |
This file contains hidden or 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
| { | |
| "ModelName": "full-table-design", | |
| "ModelMetadata": { | |
| "Author": "", | |
| "DateCreated": "Jun 04, 2021, 05:33 PM", | |
| "DateLastModified": "Jun 16, 2021, 11:01 PM", | |
| "Description": "", | |
| "AWSService": "Amazon DynamoDB", | |
| "Version": "3.0" | |
| }, |
This file contains hidden or 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
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: 'AWS::Serverless-2016-10-31' | |
| Description: An example deployment for migrating data between DynamoDB tables | |
| Resources: | |
| ExistingTable: | |
| Type: AWS::DynamoDB::Table | |
| DeletionPolicy: Retain | |
| Properties: | |
| TableName: ExportDataTable |
This file contains hidden or 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
| { | |
| "Comment": "Generates and save audio files for a given list ID.", | |
| "StartAt": "Get word list", | |
| "States": { | |
| "Get word list": { | |
| "Type": "Task", | |
| "Resource": "arn:aws:states:::lambda:invoke", | |
| "OutputPath": "$.Payload", | |
| "Parameters": { | |
| "Payload": { |
This file contains hidden or 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
| GenerateAudioStateMachine: | |
| Type: AWS::Serverless::StateMachine | |
| Properties: | |
| Name: !Sub GenerateAudioStateMachine-${Stage} | |
| DefinitionUri: src/generate_audio_state_machine.asl.json | |
| DefinitionSubstitutions: | |
| TableName: !Ref DynamoDBTable | |
| GetWordsForListIdFunction: !Ref GetWordsForListId | |
| PronunciationAudioBucket: !Ref PronunciationAudioBucket | |
| Policies: |
This file contains hidden or 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
| # Given a list id, retrieve an array with word ids and simplified characters for that list | |
| # This function is part of a state machine that generates pronunciation audio files for a given list | |
| import list_word_service | |
| def lambda_handler(event, context): | |
| list_id = event['list_id'] | |
| last_word_token = event['last_word_token'] | |
| # Call to list_word_service, a shared service in the application | |
| # for querying DynamoDB for words by list ID |