Explore Courses Blog Tutorials Interview Questions
0 votes
in AWS by (19.1k points)

I am looking for a Cloudformation template to push cloud watch logs to elasticsearch in another account. Even to the same account would be ok and I can update that.

Seems like a standard problem but haven't seen any template which automates the steps described in

1 Answer

0 votes
by (44.4k points)

Use this, hope it's useful:






              - Action: ['sts:AssumeRole']

                Effect: Allow


                  Service: []

              Version: '2012-10-17'


            - PolicyDocument:


                - Action: ['es:ESHttpPost']

                  Effect: Allow

                  Resource: "*"

                - Action: ['logs:CreateLogGroup', 'logs:CreateLogStream', 'logs:PutLogEvents']

                  Effect: Allow

                  Resource: "arn:aws:logs:*:*:*"

                - Action: ['lambda:InvokeFunction']

                  Effect: Allow

                  Resource: "arn:aws:logs:*:*:*"

                Version: '2012-10-17'

              PolicyName: lambdaRoleElasticSearchStreaming

          Type: AWS::IAM::Role


         Type: AWS::Lambda::Function

         DependsOn: LambdaElasticSearchExecutionRole


           Handler: index.handler


             Fn::GetAtt: [LambdaElasticSearchExecutionRole, Arn]


             S3Bucket: {'Fn::Sub': 'do-not-delete-cw-es-log-streaming-lamda-${AWS::Region}'}


           Runtime: nodejs4.3


         DependsOn: ESStreamingLambda

         Type: AWS::Lambda::Permission


          Action: lambda:InvokeFunction


            Fn::GetAtt: [ESStreamingLambda, Arn]

          Principal: {'Fn::Sub': 'logs.${AWS::Region}'}


    Type: AWS::Logs::SubscriptionFilter

    DependsOn: [ESStreamingLambda, LambdaPermissionForCWInvokation]



        Fn::GetAtt: [ESStreamingLambda, Arn]

      FilterPattern: ''

      LogGroupName: {Ref: LambdaLogGroup}


Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Apr 2, 2020 in AWS by Amenda (1.4k points)

Browse Categories