- Drop both these files in the same folder.
- Deploy using AWS SAM
sam deploy --guided
| openapi: "3.0.1" | |
| info: | |
| title: "vtl-example" | |
| version: "1.0" | |
| servers: | |
| - url: "https://r5aji4fod4.execute-api.us-west-2.amazonaws.com/{basePath}" | |
| variables: | |
| basePath: | |
| default: "/Prod" | |
| paths: |
| import boto3 | |
| import json | |
| import requests | |
| from requests_aws4auth import AWS4Auth | |
| def lambda_handler(event, context): | |
| signature = get_signature() | |
| return fetch(signature) | |
| def get_signature(): |
| { | |
| "apiId": "xxxxxxxxxxxxxxxxxxxxxxxxxx", | |
| "name": "sync_step_function", | |
| "description": "step function test", | |
| "type": "HTTP", | |
| "serviceRoleArn": "arn:aws:iam::xxxxxxx:role/appsync-step-function", | |
| "httpConfig": { | |
| "endpoint": "https://sync-states.us-east-2.amazonaws.com", | |
| "authorizationConfig": { | |
| "authorizationType": "AWS_IAM", |
| curl -L https://github.com/aws/aws-sam-cli/releases/latest/download/aws-sam-cli-linux-x86_64.zip -o aws-sam-cli-linux-x86_64.zip | |
| unzip aws-sam-cli-linux-x86_64.zip -d sam-installation | |
| sudo ./sam-installation/install | |
| where sam | |
| sam --version |
| #! /usr/bin/env python | |
| # Use at your own risk and reward. | |
| # requires boto3 to be installed | |
| # example `./get-vars.py MyStack > vars.json` | |
| import sys, json | |
| import boto3 | |
| if len(sys.argv) == 1: |
| # You don't need this, but here it is anyways :) | |
| openapi: "3.0.1" | |
| info: | |
| title: "Translation API (Async)" | |
| version: "1.0.0" | |
| paths: | |
| /: | |
| post: | |
| summary: Create new translation request |
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: AWS::Serverless-2016-10-31 | |
| Description: Event Bridge -> API Gateway | |
| Resources: | |
| RestApiGateway: | |
| Type: AWS::Serverless::Api | |
| Properties: | |
| StageName: Prod | |
| ## This examples converts the millisecond epoch of API Gateway | |
| ## to the seconds epoch of DynamoDB and adds 5 minutes for the TTL. | |
| #set( $epoch = $context.requestTimeEpoch / 1000 + 300 ) | |
| { | |
| "TableName":"Epoch", | |
| "Item":{ | |
| "id":{"S":"$context.requestId"}, | |
| "ttlTime":{"N":"$epoch"} | |
| } |
| AWSTemplateFormatVersion: '2010-09-09' | |
| Transform: AWS::Serverless-2016-10-31 | |
| Description: DDB example | |
| Resources: | |
| Table: | |
| Type: AWS::DynamoDB::Table | |
| Properties: | |
| AttributeDefinitions: | |
| - AttributeName: id |