AWSTemplateFormatVersion: "2010-09-09"
Description: "An example template with an IAM role for a Lambda function."
Resources:

  LambdaRole:
    Type: AWS::IAM::Role
    Properties:
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
        - Effect: Allow
          Principal:
            Service:
            - lambda.amazonaws.com
          Action:
          - sts:AssumeRole
      Path: "/"
      Policies:
      - PolicyName: root
        PolicyDocument:
          Version: '2012-10-17'
          Statement:
          - Effect: Allow
            Action:
            - logs:*
            Resource: arn:aws:logs:*:*:*

  LambdaFunction:
    Type: "AWS::Lambda::Function"
    Properties:
      Handler: "index.handler"
      Role: !GetAtt [ LambdaRole, Arn ]
      Code:
        ZipFile: |
          def handler(event, context):
            timeOfDay = event['timeOfDay']
            name = event['name']
            return [
                "Good {tod}, {name}!".format(tod=timeOfDay, name=name)
            ]
      Runtime: "python3.6"
      Timeout: "25"
