@incdevco/framework
Version:
node.js lambda framework
198 lines (197 loc) • 5.57 kB
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Template For Action Resources",
"Parameters": {
"PackageS3ObjectKey": {
"Type": "String"
},
"PackageS3ObjectVersion": {
"Type": "String"
}
},
"Conditions": {},
"Mappings": {},
"Resources": {
"DeadLetterQueue": {
"Type": "AWS::SQS::Queue",
"DeletionPolicy": "Retain",
"Properties": {
"MessageRetentionPeriod": 1209600
}
},
"Permission": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"FunctionName": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionName"]},
"Principal": "sns.amazonaws.com",
"Action": "lambda:InvokeFunction",
"SourceArn": {"Ref": "Topic"}
}
},
"FunctionRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
},
"Path": "/",
"Policies": [
{
"PolicyName": "cloudwatch",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents",
"logs:DescribeLogStreams"
],
"Resource": [
"arn:aws:logs:*:*:*"
]
}
]
}
},
{
"PolicyName": "dynamodb",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"dynamodb:BatchGetItem",
"dynamodb:BatchWriteItem",
"dynamodb:DeleteItem",
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:Query",
"dynamodb:Scan",
"dynamodb:UpdateItem"
],
"Resource": "*"
}
]
}
},
{
"PolicyName": "firehose",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "firehose:PutRecord",
"Resource": "*"
}
]
}
},
{
"PolicyName": "kms",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"kms:Encrypt"
],
"Resource": "*"
}
]
}
},
{
"PolicyName": "sns",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sns:*",
"Resource": "*"
}
]
}
},
{
"PolicyName": "sqs",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "sqs:*",
"Resource": "*"
}
]
}
}
]
}
},
"FunctionStack": {
"Type": "AWS::CloudFormation::Stack",
"Properties": {
"NotificationARNs": {"Ref": "AWS::NotificationARNs"},
"Parameters": {
"AlarmActionsArn": {"Fn::ImportValue": "AssetsAlarmArn"},
"CodeS3Bucket": {"Fn::ImportValue": "AssetsBucket"},
"CodeS3ObjectKey": {"Ref": "PackageS3ObjectKey"},
"CodeS3ObjectVersion": {"Ref": "PackageS3ObjectVersion"},
"DeadLetterQueueArn": {"Fn::GetAtt": ["DeadLetterQueue", "Arn"]},
"Description": "function for listening to table streams",
"DurationAlarmThreshold": 150000.0,
"InvocationAlarmThreshold": 10.0,
"MemorySize": 128,
"RoleArn": {"Fn::GetAtt": ["FunctionRole", "Arn"]},
"Runtime": "nodejs6.10",
"Timeout": "120"
},
"TemplateURL": {"Fn::Join": ["", [
"https://s3-",
{"Ref": "AWS::Region"},
".amazonaws.com/",
{"Fn::ImportValue": "AssetsBucket"},
"/incdevco-cf-templates/lambda/function/stack.json"
]]}
}
},
"Subscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionArn"]},
"Protocol": "lambda",
"TopicArn": {"Ref": "Topic"}
}
},
"Topic": {
"Type": "AWS::SNS::Topic",
"Properties": {
}
}
},
"Outputs": {
"ProducerFunctionName": {
"Value": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionName"]}
},
"TopicArn": {
"Value": {"Ref": "Topic"}
}
}
}