Skip to content

Instantly share code, notes, and snippets.

@lantrix
Created November 26, 2019 12:50
Show Gist options
  • Save lantrix/ad1abc631ae78f9bf40a6ca1917da9d8 to your computer and use it in GitHub Desktop.
Save lantrix/ad1abc631ae78f9bf40a6ca1917da9d8 to your computer and use it in GitHub Desktop.
Example of invoking a lambda by ARN and providing fixed input JSON to the lambda as the event - for AWS CloudFormation in YAML
AWSTemplateFormatVersion: "2010-09-09"
Description: A Schedule to invoke a Lambda
Parameters:
LambdaArn:
Type: String
Description: ARN of the lambda to be invoked
Resources:
InvokeLambdaRole:
Type: AWS::IAM::Role
Properties:
RoleName: invoke-lambda-role
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- events.amazonaws.com
InvokeLambdaRule:
Type: AWS::Events::Rule
Properties:
Name: invoke-lambda-rule
Description: Schedule for invocating the Lambda
ScheduleExpression: rate(5 minutes)
RoleArn:
Fn::GetAtt: [ InvokeLambdaRole, Arn ]
Targets:
- Arn:
Ref: LambdaArn
Id: splunk-dbreader-lambda
Input: '{"SecretsArn": "arn:aws:secretsmanager:ap-southeast-2:123456789012:secret:mysecret", "S3Bucket": "my-bucket"}'
InvokeLambdaRulePermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: LambdaArn
Action: lambda:InvokeFunction
Principal: events.amazonaws.com
SourceArn:
Fn::GetAtt: [ InvokeLambdaRule, Arn ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment