Adam Matan
Adam Matan

Reputation: 136191

Granting CloudWatch access to a lambda function deployed using the Serverless framework

My problem

I am writing a Lambda function using the Serverless framework.

The function is invoked by an HTTP request. It parses the request parameters, fetches some logs from a CloudWatch group and stream according to the parameters and replies with a summary of the logs.

I would like to grant CloudWatch read access to the Lambda function using the serverless configuration file.

Code

The function definition (serverless.yml) is pretty basic:

service: adam-test-sls
provider:
  name: aws
  runtime: nodejs6.10
  region: eu-central-1
functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get

What have I tried

My question

How do I grant read (and/or write) permissions that will enable this Lambda function to access Specific CloudWatch logs?

Upvotes: 1

Views: 1245

Answers (1)

Pierre
Pierre

Reputation: 6172

Serverless allows you to define a default IAM role for all functions (which should have CloudWatch access by default)

Also by default, your Lambda functions have permission to create and write to CloudWatch logs.

You can also fine tune the IAM role for all functions, or even provide fine-grained permissions for each function using the role attribute.

The reference is here

Upvotes: 2

Related Questions