- Now that we have learned how to write our first Go Lambda function, let's create a new IAM role from Identity and Access Management (https://console.aws.amazon.com/iam/home) to grant the function access to AWS CloudWatch Logs:
![](https://static.packt-cdn.com/products/9781789134612/graphics/assets/fed0ecb8-e57c-4f10-bd5e-2c97d6399375.png)
- In the permissions page, you can either choose an existing AWS managed policy called CloudWatchFullAccess or (as shown in Step 3) create a least-privilege IAM role (the second option is recommended by AWS; a chapter dedicated to this will discuss security best practices for Lambda functions in depth):
![](https://static.packt-cdn.com/products/9781789134612/graphics/assets/54765997-c910-430a-9ad0-1951e03e8c4e.png)
- Go ahead and click on the Create policy button, and create a policy by selecting the appropriate service (CloudWatch) from the visual editor:
![](https://static.packt-cdn.com/products/9781789134612/graphics/assets/6eb0c424-cde0-40b7-8aa8-7e519a3478d4.png)
- For readers familiar with the JSON format, a JSON policy document can be used instead in the JSON tab. The document must have one statement that grants permissions to create log groups and...