User Tools

Site Tools


aws:aws-cloudformation-lambda

lambda yaml cloudformation

AWSTemplateFormatVersion: 2010-09-09
Parameters:
  var1:
    Type: CommaDelimitedList
    Description: general variable
Resources:
  LambdaRole:
    Type: 'AWS::IAM::Role'
    Properties:
      AssumeRolePolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service:
                - lambda.amazonaws.com
            Action:
              - 'sts:AssumeRole'
  LambdaPolicy:
    Type: 'AWS::IAM::Policy'
    Properties:
      PolicyName: LambdaPolicy
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Action:
              - 'logs:CreateLogGroup'
              - 'logs:CreateLogStream'
              - 'logs:PutLogEvents'
            Resource: '*'
      Roles:
        - !Ref LambdaRole
        - 
  Lambda1:
    Type: 'AWS::Lambda::Function'
    DeletionPolicy: Delete
    Properties:
      Code:
        ZipFile: !Sub |
          import cfnresponse
          import json
          import boto3
          def lambda_handler(event, context):
            print('REQUEST RECEIVED:\n' + json.dumps(event))
            return
            
      FunctionName: Lambda1
      Tags:
        - Key: "RepoName"
          Value: "Lambda1_repo"
        - Key: "CreatedBy"
          Value: "CloudFormation"

      Handler: index.lambda_handler
      Role: !GetAtt 
        - LambdaRole
        - Arn
      Runtime: python3.10
      Timeout: 10
aws/aws-cloudformation-lambda.txt · Last modified: by andrew

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki