Skip to content

Instantly share code, notes, and snippets.

@furuya02
Last active May 17, 2019 15:55
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 furuya02/aed2ac866fb7441fd99190719840fe87 to your computer and use it in GitHub Desktop.
Save furuya02/aed2ac866fb7441fd99190719840fe87 to your computer and use it in GitHub Desktop.
CloudFormation Sample with Lambda function
AWSTemplateFormatVersion: 2010-09-09
Description: CloudFormation Sample with Lambda function
Resources:
LambdaFunction:
Type: AWS::Lambda::Function
DependsOn:
- LambdaRole
Properties:
Description: Lambda sample called from Connect
Code:
ZipFile: !Sub |
exports.handler = async function(event, context) {
return {message: "Welcome to Class Method Inc."};
}
Handler: index.handler
Role: !GetAtt
- LambdaRole
- Arn
Runtime: nodejs8.10
Timeout: 8
MemorySize: 128
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: 2012-10-17
Statement:
Effect: Allow
Principal:
Service:
- lambda.amazonaws.com
Action:
- sts:AssumeRole
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
# Connectから呼び出すためのパーミッション
LambdaFunctionInvokePermission:
Type: AWS::Lambda::Permission
DependsOn: LambdaFunction
Properties:
FunctionName:
Ref: LambdaFunction
Action: lambda:InvokeFunction
Principal: connect.amazonaws.com
SourceAccount:
Ref: AWS::AccountId
Outputs:
# 問い合わせフローに設定するLambdaのARN
LambdaARN:
Description: ARN of the Lambda function
Value:
Fn::GetAtt:
- LambdaFunction
- Arn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment