Skip to content

Instantly share code, notes, and snippets.

@anhtv08
Created August 25, 2019 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anhtv08/9e0316b932e29d407f047ef2649bb8fd to your computer and use it in GitHub Desktop.
Save anhtv08/9e0316b932e29d407f047ef2649bb8fd to your computer and use it in GitHub Desktop.
AWSTemplateFormatVersion: 2010-09-09
Transform: 'AWS::Serverless-2016-10-31'
#Parameters:
# LambdaExecutionRole:
Resources:
ruleEvaluationDev:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'cost-controller-function'
Description: 'Integrating lambda with Parameter Store'
Handler: 'cost_controller.cost_controller_handlers.lambda_handler'
Runtime: 'python3.6'
Role: 'arn:aws:iam::674028589551:role/service-role/my-rule-evaluation-function'
Timeout: 5
Tracing: 'Active'
userManagement:
Type: 'AWS::Serverless::Function'
Properties:
FunctionName: 'user-management'
Description: 'user management function'
Handler: 'dynamo.DynamoServices.lambda_handler'
Runtime: 'python3.6'
Role: 'arn:aws:iam::674028589551:role/service-role/my-rule-evaluation-function'
Timeout: 5
Tracing: 'Active'
EventRule:
Type: AWS::Events::Rule
Properties:
Description: "evaluate ec2 instance state changes"
Name: "ec2-resource-evaluation-rule"
EventPattern:
source:
- "aws.ec2"
detail-type:
- "EC2 Instance State-change Notification"
State: "ENABLED"
Targets:
- Arn:
Fn::GetAtt:
- "ruleEvaluationDev"
- "Arn"
Id: "TargetFunctionV1"
PermissionForEventsToInvokeLambda:
Type: AWS::Lambda::Permission
Properties:
FunctionName:
Ref: "ruleEvaluationDev"
Action: "lambda:InvokeFunction"
Principal: "events.amazonaws.com"
SourceArn:
Fn::GetAtt:
- "EventRule"
- "Arn"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment