Skip to content

Instantly share code, notes, and snippets.

@yossale
Created July 28, 2020 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yossale/bfd7a3f7523591ac9a535f0ebacfdb98 to your computer and use it in GitHub Desktop.
Save yossale/bfd7a3f7523591ac9a535f0ebacfdb98 to your computer and use it in GitHub Desktop.
Scalable Webhook - Basic CloudFormation Template (Before limiting concurrency and adding DLQ)
{
"AWSTemplateFormatVersion": "2010-09-09",
"Transform": "AWS::Serverless-2016-10-31",
"Resources": {
"ApiGateway01": {
"Type": "AWS::Serverless::Api",
"Properties": {
"StageName": "Prod"
}
},
"RequestsProcessor01": {
"Type": "AWS::Serverless::Function",
"Properties": {
"CodeUri": "./",
"Handler": "functions/requestsProcessor.handler",
"Runtime": "nodejs12.x",
"MemorySize": 512,
"Timeout": 6,
"Environment": {
"Variables": {
"TABLE_REQUESTSTABLE01": {
"Ref": "RequestsTable01"
}
}
},
"Policies": [
{
"DynamoDBCrudPolicy": {
"TableName": {
"Ref": "RequestsTable01"
}
}
}
],
"Events": {
"RequestsQueue01": {
"Type": "SQS",
"Properties": {
"Queue": {
"Fn::GetAtt": [
"RequestsQueue01",
"Arn"
]
}
}
}
}
}
},
"RequestsQueue01": {
"Type": "AWS::SQS::Queue",
"Properties": {
"DelaySeconds": 0,
"MaximumMessageSize": 262144,
"MessageRetentionPeriod": 345600
}
},
"RequestsTable01": {
"Type": "AWS::Serverless::SimpleTable",
"Properties": {
"PrimaryKey": {
"Name": "id",
"Type": "String"
},
"ProvisionedThroughput": {
"ReadCapacityUnits": 5,
"WriteCapacityUnits": 5
}
}
},
"RequestsVerifier01": {
"Type": "AWS::Serverless::Function",
"Properties": {
"CodeUri": "./",
"Handler": "functions/requestsVerifier.handler",
"Runtime": "nodejs12.x",
"MemorySize": 512,
"Timeout": 6,
"Environment": {
"Variables": {
"QUEUE_REQUESTSQUEUE01": {
"Ref": "RequestsQueue01"
}
}
},
"Layers": [],
"Events": {
"ApiEndpoint01": {
"Type": "Api",
"Properties": {
"Path": "/messages",
"RestApiId": {
"Ref": "ApiGateway01"
},
"Method": "post"
}
}
},
"Policies": [
{
"SQSSendMessagePolicy": {
"QueueName": {
"Fn::GetAtt": [
"RequestsQueue01",
"QueueName"
]
}
}
}
]
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment