Skip to content

Instantly share code, notes, and snippets.

@sk-t3ch
Last active May 5, 2020 19:26
Show Gist options
  • Save sk-t3ch/331aa9a98ef94bf7d85e519a6d9312f6 to your computer and use it in GitHub Desktop.
Save sk-t3ch/331aa9a98ef94bf7d85e519a6d9312f6 to your computer and use it in GitHub Desktop.
Hello World API CloudFormation - Python Lambda
Lambda:
Type: AWS::Lambda::Function
Properties:
Code:
ZipFile: |
def handler(event, context):
response = {
'isBase64Encoded': False,
'statusCode': 200,
'body': 'HELLO WORLD!'
}
return response
Handler: lambda_function.handler
Role: !GetAtt LambdaRole.Arn
Runtime: python3.7
LambdaRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Statement:
- Action: ['sts:AssumeRole']
Effect: Allow
Principal:
Service: ['lambda.amazonaws.com']
Path: /
ManagedPolicyArns:
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
LambdaFunctionPermission:
Type: AWS::Lambda::Permission
Properties:
FunctionName: !GetAtt Lambda.Arn
Action: 'lambda:InvokeFunction'
Principal: elasticloadbalancing.amazonaws.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment