UNPKG

@incdevco/framework

Version:
270 lines 7.5 kB
{ "AWSTemplateFormatVersion": "2010-09-09", "Description": "action poller function stack", "Parameters": { "CodeS3ObjectKey": { "Type": "String" }, "CodeS3ObjectVersion": { "Type": "String" }, "CustomCFResourceFunctionArn": { "Type": "String" }, "DeadLetterQueueArn": { "Default": "", "Type": "String" }, "DurationAlarmPeriod": { "Default": 300, "Type": "Number" }, "DurationAlarmThreshold": { "Default": 150000.0, "Type": "Number" }, "EventLogArn": { "Default": "", "Type": "String" }, "EventLogSubscriptionRoleArn": { "Default": "", "Type": "String" }, "InvocationAlarmPeriod": { "Default": 300, "Type": "Number" }, "InvocationAlarmThreshold": { "Default": 15.0, "Type": "Number" }, "MemorySize": { "Default": 128, "Type": "Number" }, "RoleArn": { "Default": "", "Type": "String" }, "RoleName": { "Default": "", "Type": "String" }, "Runtime": { "Default": "nodejs6.10", "Type": "String" }, "ScheduleExpression": { "Default": "rate(1 minute)", "Type": "String" }, "Timeout": { "Default": "120", "Type": "String" } }, "Conditions": { "NeedsRole": {"Fn::Equals": ["", {"Ref": "RoleArn"}]} }, "Mappings": {}, "Outputs": { "FunctionArn": { "Value": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionArn"]} }, "FunctionName": { "Value": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionName"]} }, "RoleArn": { "Condition": "NeedsRole", "Value": {"Ref": "Role"} } }, "Resources": { "FunctionStack": { "Type": "AWS::CloudFormation::Stack", "Properties": { "NotificationARNs": {"Ref": "AWS::NotificationARNs"}, "Parameters": { "AlarmActionsArn": {"Fn::ImportValue": "AssetsAlarmArn"}, "CodeS3Bucket": {"Fn::ImportValue": "AssetsBucket"}, "CodeS3ObjectKey": {"Ref": "CodeS3ObjectKey"}, "CodeS3ObjectVersion": {"Ref": "CodeS3ObjectVersion"}, "CustomCFResourceFunctionArn": {"Ref": "CustomCFResourceFunctionArn"}, "DeadLetterQueueArn": {"Ref": "DeadLetterQueueArn"}, "Description": "function for polling the action queue", "DurationAlarmPeriod": {"Ref": "DurationAlarmPeriod"}, "DurationAlarmThreshold": {"Ref": "DurationAlarmThreshold"}, "EventLogArn": {"Ref": "EventLogArn"}, "EventLogSubscriptionRoleArn": {"Ref": "EventLogSubscriptionRoleArn"}, "InvocationAlarmPeriod": {"Ref": "InvocationAlarmPeriod"}, "InvocationAlarmThreshold": {"Ref": "InvocationAlarmThreshold"}, "MemorySize": {"Ref": "MemorySize"}, "RoleArn": {"Fn::If": [ "NeedsRole", {"Fn::GetAtt": ["Role", "Arn"]}, {"Ref": "RoleArn"} ]}, "RoleName": {"Fn::If": [ "NeedsRole", {"Ref": "Role"}, {"Ref": "RoleName"} ]}, "Runtime": {"Ref": "Runtime"}, "Timeout": {"Ref": "Timeout"} }, "TemplateURL": {"Fn::Join": ["", [ "https://s3-", {"Ref": "AWS::Region"}, ".amazonaws.com/", {"Fn::ImportValue": "AssetsBucket"}, "/incdevco-cf-templates/lambda/function/stack.json" ]]} } }, "PollingEvent": { "Type": "AWS::Events::Rule", "DependsOn": [ "FunctionStack" ], "Properties": { "Description": "polling event for action queue", "ScheduleExpression": {"Ref": "ScheduleExpression"}, "State": "ENABLED", "Targets": [ { "Arn": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionArn"]}, "Id": "polling-function" } ] } }, "PollingEventPermission": { "Type": "AWS::Lambda::Permission", "Properties": { "FunctionName": {"Fn::GetAtt": ["FunctionStack", "Outputs.FunctionName"]}, "Principal": "events.amazonaws.com", "Action": "lambda:InvokeFunction", "SourceArn": {"Fn::GetAtt": ["PollingEvent", "Arn"]} } }, "Role": { "Type": "AWS::IAM::Role", "Condition": "NeedsRole", "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": "*" } ] } } ] } } } }