Created
November 26, 2019 12:50
-
-
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
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" | |
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