-
-
Save matthew-andrews/27873becff678ba45df3dddc6e82de1b to your computer and use it in GitHub Desktop.
EventRule bug CloudFormation script
This file contains 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", | |
"Parameters": { | |
"FunctionName": { | |
"Type": "String", | |
"Default": "testcase" | |
}, | |
"RoleName": { | |
"Type": "String", | |
"Default": "ApplicationRoleFor_testcase" | |
}, | |
"PolicyName": { | |
"Type": "String", | |
"Default": "ApplicationPolicyFor_testcase" | |
}, | |
"RuleName": { | |
"Type": "String", | |
"Default": "testcase_every-hour" | |
} | |
}, | |
"Resources": { | |
"LambdaFunction": { | |
"Type": "AWS::Lambda::Function", | |
"DependsOn": "Role", | |
"Properties": { | |
"Code": { | |
"ZipFile": "exports.handler = (event, context, callback) => callback(undefined, 'all ok');" | |
}, | |
"FunctionName": { "Ref": "FunctionName" }, | |
"Handler": "index.handler", | |
"Role": { "Fn::GetAtt" : [ "Role", "Arn" ] }, | |
"Runtime": "nodejs4.3" | |
} | |
}, | |
"Role": { | |
"Type": "AWS::IAM::Role", | |
"Properties": { | |
"AssumeRolePolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Principal": { | |
"Service": "lambda.amazonaws.com" | |
}, | |
"Action": "sts:AssumeRole" | |
} | |
] | |
} | |
} | |
}, | |
"Policy": { | |
"Type": "AWS::IAM::Policy", | |
"DependsOn": "Role", | |
"Properties": { | |
"PolicyDocument": { | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Effect": "Allow", | |
"Action": "lambda:InvokeFunction", | |
"Resource": { "Fn::Join": [ "", [ "arn:aws:lambda:", { "Ref" : "AWS::Region" }, ":", { "Ref" : "AWS::AccountId" }, ":function:", { "Ref": "FunctionName" } ] ] } | |
}, | |
{ | |
"Effect": "Allow", | |
"Action": [ | |
"logs:CreateLogGroup", | |
"logs:CreateLogStream", | |
"logs:DescribeLogGroups", | |
"logs:DescribeLogStreams", | |
"logs:FilterLogEvents", | |
"logs:GetLogEvents", | |
"logs:PutLogEvents" | |
], | |
"Resource": "*" | |
} | |
] | |
}, | |
"Roles": [ { "Ref" : "Role" } ], | |
"PolicyName": { "Ref": "PolicyName" } | |
} | |
}, | |
"Rule": { | |
"Type": "AWS::Events::Rule", | |
"DependsOn": "LambdaFunction", | |
"Properties": { | |
"Name": { "Ref": "RuleName" }, | |
"ScheduleExpression": "cron(0 * * * ? *)", | |
"State": "ENABLED", | |
"Targets": [ | |
{ | |
"Arn": { "Fn::GetAtt" : [ "LambdaFunction", "Arn" ] }, | |
"Id": "ScheduledRuleTarget" | |
} | |
] | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment