Skip to content

Commit 4350ac5

Browse files
Moved AWS Lambda docs from Notion to develop docs (#15034)
<!-- Use this checklist to make sure your PR is ready for merge. You may delete any sections you don't need. --> ## DESCRIBE YOUR PR This documentation was before in Notion: https://www.notion.so/sentry/Serverless-Development-Environment-AWS-Lambda-61c4578c23784b5c9a54ab01b9b6daad To have everything in `develop` docs I move it here and the page in Notion will be deleted. Preview: - https://develop-docs-git-antonpirker-developaws-lambda.sentry.dev/sdk/platform-specifics/serverless-sdks/aws-lambda-development-environment/ - https://develop-docs-git-antonpirker-developaws-lambda.sentry.dev/sdk/platform-specifics/serverless-sdks/download-production-lambda-layer/ ## IS YOUR CHANGE URGENT? Help us prioritize incoming PRs by letting us know when the change needs to go live. - [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE --> - [ ] Other deadline: <!-- ENTER DATE HERE --> - [x] None: Not urgent, can wait up to 1 week+ ## SLA - Teamwork makes the dream work, so please add a reviewer to your PRs. - Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it. Thanks in advance for your help! ## PRE-MERGE CHECKLIST *Make sure you've checked the following before merging your changes:* - [x] Checked Vercel preview for correctness, including links - [ ] PR was reviewed and approved by any necessary SMEs (subject matter experts) - [ ] PR was reviewed and approved by a member of the [Sentry docs team](https://github.com/orgs/getsentry/teams/docs) ## LEGAL BOILERPLATE <!-- Sentry employees and contractors can delete or ignore this section. --> Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms. ## EXTRA RESOURCES - [Sentry Docs contributor guide](https://docs.sentry.io/contributing/) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > <sup>[Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) is generating a summary for commit 67678dc. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Alex Krawiec <[email protected]>
1 parent a29a039 commit 4350ac5

File tree

3 files changed

+253
-2
lines changed

3 files changed

+253
-2
lines changed
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
---
2+
title: AWS Lambda Development Environment
3+
description: How to configure AWS Lambda to send data to a development Sentry instance.
4+
sidebar_order: 200
5+
---
6+
7+
This guide will explain how you can setup a development environment to work on the [AWS Lambda Integration](https://docs.sentry.io/product/integrations/cloud-monitoring/aws-lambda/). The setup includes running a local instance of `sentry` and configuring AWS so that both environments work together.
8+
9+
<Alert level="warning" title="IMPORTANT">
10+
11+
**This guide is only if you want to send data from an AWS Lambda function to your local `sentry` instance.**
12+
13+
When working on the Sentry AWS Lambda layer from one of the SDKs, the workflow is that you have your example Lambda function in a dev account on AWS and then deploy your local layer to the dev account and attach it to your example function. How do to this in Python is described in the [contribution guide](https://github.com/getsentry/sentry-python/blob/master/CONTRIBUTING.md#contributing-to-sentry-aws-lambda-layer) of the Python SDK.
14+
15+
</Alert>
16+
17+
## Configuration of AWS
18+
19+
To emulate a Sentry integration with a project base on AWS Lambda functions you need:
20+
21+
- One AWS account representing Sentry having an IAM and a S3 Bucket containing a JSON config file.
22+
- One AWS account representing the user that has a example Lambda function.
23+
24+
### Detailed Configuration Steps
25+
26+
For the **“Sentry Account”** in AWS we assume the AWS Account ID is `1111 1111 1111` in this guide. This account can be the shared official dev AWS account of Sentry, or you can create a personal one (credit card required for this)
27+
28+
- Create an **IAM user** in the **“Sentry account”** that can create S3 buckets, and has permission to assume roles. The policy that can be directly attached to the IAM user looks like this:
29+
30+
{/* _TODO: check if we can restrict those permissions more_ */}
31+
32+
```json
33+
{
34+
"Version": "2012-10-17",
35+
"Statement": [
36+
{
37+
"Sid": "VisualEditor0",
38+
"Effect": "Allow",
39+
"Action": "sts:AssumeRole",
40+
"Resource": "*"
41+
}
42+
]
43+
}
44+
```
45+
46+
- Create an **S3 Bucket in “Sentry Account”** that is accessible by the public to host the CloudFormation configuration file. (more on this later). The S3 Bucket Policy should look like this (in this example “sentry-dev-cloudformation” is the name of the S3 bucket):
47+
48+
{/* _TODO: check if we can restrict those permissions more_ */}
49+
50+
```json
51+
{
52+
"Version": "2012-10-17",
53+
"Statement": [
54+
{
55+
"Sid": "Statement1",
56+
"Effect": "Allow",
57+
"Principal": "*",
58+
"Action": "s3:*",
59+
"Resource": [
60+
"arn:aws:s3:::sentry-dev-cloudformation",
61+
"arn:aws:s3:::sentry-dev-cloudformation/dev.json"
62+
]
63+
}
64+
]
65+
}
66+
```
67+
68+
- Place a **CloudFormation configuration file** called `dev.json` in the S3 bucket of the “Sentry account” mentioned above. The `dev.json` file is a pointer to a “Sentry account” user. The file must be readable by the customer.
69+
The dev.json must look like this. You need to replace `arn:aws:iam::111111111111:user/sentry` with the ARN of your user:
70+
71+
{/* *TODO: check if we can restrict those permissions more.* */}
72+
73+
```json
74+
{
75+
"Description": "This stack grants write access to your Lambda functions in order to add Sentry error and performance monitoring. After pressing create, wait for the stack to be created before copying your AWS account number and region into the Sentry installation modal.",
76+
"Resources": {
77+
"SentryRole": {
78+
"Type": "AWS::IAM::Role",
79+
"Properties": {
80+
"AssumeRolePolicyDocument": {
81+
"Version": "2012-10-17",
82+
"Statement": [
83+
{
84+
"Effect": "Allow",
85+
"Principal": {
86+
"AWS": "arn:aws:iam::111111111111:user/sentry"
87+
},
88+
"Action": [
89+
"sts:AssumeRole"
90+
],
91+
"Condition": {
92+
"StringEquals": {
93+
"sts:ExternalId": {
94+
"Ref": "ExternalId"
95+
}
96+
}
97+
}
98+
}
99+
]
100+
},
101+
"Path": "/",
102+
"RoleName": "SentryRole",
103+
"ManagedPolicyArns": [],
104+
"Policies": [
105+
{
106+
"PolicyName": "sentry-policy",
107+
"PolicyDocument": {
108+
"Version": "2012-10-17",
109+
"Statement": [
110+
{
111+
"Effect": "Allow",
112+
"Action": [
113+
"lambda:UpdateFunctionConfiguration",
114+
"lambda:ListFunctions",
115+
"lambda:ListLayerVersions",
116+
"lambda:GetFunction",
117+
"lambda:GetLayerVersion",
118+
"organizations:DescribeAccount"
119+
],
120+
"Resource": "*"
121+
}
122+
]
123+
}
124+
}
125+
]
126+
}
127+
}
128+
},
129+
"Parameters": {
130+
"ExternalId": {
131+
"Description": "External ID for securing the role - Do not change",
132+
"Type": "String"
133+
}
134+
}
135+
}
136+
```
137+
138+
This CloudFormation config file basically gives the user in the “Sentry account” access to assume a role in the “User account” to augment the Lambda functions (add the Sentry Lambda Layer) to instrument them for sending errors/metrics to Sentry
139+
140+
- Create one **AWS** account representing the user and where the Lambda functions of the user live. This account we will call the **User account”**.
141+
The **“Sentry account”** and the **“User account”** can also be the same account.
142+
143+
Ok, so now you have two AWS accounts and you have set up your CloudFormation config in a S3 bucket that is accessible to the world. Great!
144+
145+
## Configuration of Local Sentry Instance
146+
147+
You need just a default installation of `sentry` on your computer. Please install it following the [Development Environment Setup Guide](https://develop.sentry.dev/development-infrastructure/environment/).
148+
149+
Now you have to tell your sentry installation what AWS account to use and where it can find the CloudFormation configuration.
150+
151+
You can do this by adding the following parameter to your `~/.sentry/config.yml` file:
152+
153+
```yaml
154+
aws-lambda.access-key-id: AKIXXXXXXXXXXXXXXXXX
155+
aws-lambda.secret-access-key: IuyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX2Xoj
156+
aws-lambda.cloudformation-url: https://sentry-dev-cloudformation.s3.eu-central-1.amazonaws.com/dev.json
157+
aws-lambda.node.layer-version: "37"
158+
aws-lambda.python.layer-version: "142"
159+
```
160+
161+
Explanation:
162+
163+
- `aws-lambda.access-key-id` AWS access key id of the IAM user created in the “Sentry Account”.
164+
- `aws-lambda.secret-access-key`AWS secret access key of the IAM user created in the “Sentry Account”.
165+
- `aws-lambda.cloudformation-url` public accessible URL of the CloudFormation config file that lives in a S3 bucket in the “Sentry Account”.
166+
- `aws-lambda.node.layer-version` the version of the Lambda layer that should be used for Node Lambda functions. This version number can be found here: [https://github.com/getsentry/sentry-release-registry/tree/master/aws-lambda-layers](https://github.com/getsentry/sentry-release-registry/tree/master/aws-lambda-layers) (Hint: every region can have another version of the Layer installed.)
167+
- `aws-lambda.python.layer-version` same as above but for Python based Lambda functions.
168+
169+
## Configuration of Ngrok
170+
171+
With [Ngrok](https://ngrok.com/) you get an URL that points to your local computer. So everyone on the internet can talk to your Sentry installation on your computer.
172+
173+
This is needed so your AWS Lambda function can send its errors/tracing to your local Sentry installation.
174+
175+
Follow the instructions on the [Ngrok documentation](https://develop.sentry.dev/development/ngrok/) page to install ngrok.
176+
177+
Now start Ngrok like the following:
178+
179+
```bash
180+
ngrok http 8000
181+
```
182+
183+
If ngrok starts it outputs the URL that your computer is now available at. Copy the HTTP URL (it should look something like `http://xxxx-xxx-xxx-x-xxx.ngrok.io`).
184+
185+
If you follow the guide in the ngrok page linked above you will get access to the Sentry Ngrok account and you can create a subdomain that is custom and not always changing when you restart ngrok. This is highly recommended.
186+
187+
You now have to tell your sentry installation its new URL by adding the following line to your `~/.sentry/config.yml` :
188+
189+
```yaml
190+
system.url-prefix: "http://xxxx-xxx-xxx-x-xxx.ngrok.io"
191+
```
192+
193+
Make sure to restart all the development environment, to make sure all services know about the new URL. (with `devservices down && devservices up`)
194+
195+
## Start the Local Sentry Server
196+
197+
If you now run your local Sentry with this command, it will have all the information it needs:
198+
199+
```bash
200+
devservices serve
201+
```
202+
203+
You are now ready for serverless integration development.
204+
205+
## Add Sentry to Your Lambda Functions
206+
207+
Log into your local sentry environment at your ngrok URL and follow the [AWS Lambda Guide](https://docs.sentry.io/product/integrations/cloud-monitoring/aws-lambda/) in our documentation to add Sentry instrumentation to your demo AWS Lambda function.

develop-docs/sdk/platform-specifics/serverless-sdks/aws-lambda.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: AWS Lambda
3-
sidebar_order: 10
2+
title: AWS Lambda Primer
3+
sidebar_order: 100
44
---
55

66
Lambda functions can be written in numerous programming languages (JavaScript,
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: How to Download Production Sentry Lambda Layer
3+
description: Instructions for downloading the Sentry AWS Lambda layer.
4+
sidebar_order: 300
5+
---
6+
7+
You need to have the [AWS CLI](https://aws.amazon.com/cli/) installed and configured to have access to the production Sentry AWS account.
8+
9+
Then you can get information about the Sentry Lambda layer with this command:
10+
```bash
11+
aws lambda get-layer-version --layer-name arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK --version-number 142
12+
```
13+
Make sure you have the region (in the example `eu-central-1`) and the version number (in the example `142`) to the version of the layer you want to download. If you want to download the Javascript layer use `SentryNodeServerlessSDKvX` (replacing `X` with the version of the JS SDK is in the layer) instead of `SentryPythonServerlessSDK`.
14+
15+
Output will be something like this:
16+
17+
```bash
18+
{
19+
"Content": {
20+
"Location": "https://awslambda-eu-cent-1-layers.s3.eu-central-1.amazonaws.com/snapshots/943013980633/SentryPythonServerlessSDK-008d308b-4dc8-46c4-b7f2-48c31e187a85?versionId=xxx&X-Amz-Security-Token=xxx&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260825T072152Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=xxx&X-Amz-Signature=xxx",
21+
"CodeSha256": "L/xPQraARPazFPwChPLlzETN2emli4UIgabUOu34bZ4=",
22+
"CodeSize": 9883188
23+
},
24+
"LayerArn": "arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK",
25+
"LayerVersionArn": "arn:aws:lambda:eu-central-1:943013980633:layer:SentryPythonServerlessSDK:35",
26+
"Description": "",
27+
"CreatedDate": "2026-08-16T11:15:45.768+0000",
28+
"Version": 142,
29+
"CompatibleRuntimes": [
30+
"...",
31+
"python3.13",
32+
"python3.14"
33+
],
34+
"LicenseInfo": "MIT"
35+
}
36+
```
37+
38+
Then pick the `Location` and download the layer as zip file:
39+
40+
```bash
41+
curl -o layer.zip https://awslambda-eu-cent-1-layers.s3.eu-central-1.amazonaws.com/snapshots/943013980633/SentryPythonServerlessSDK-008d308b-4dc8-46c4-b7f2-48c31e187a85?versionId=xxx&X-Amz-Security-Token=xxx&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Date=20260825T072152Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Credential=xxx&X-Amz-Signature=xxx
42+
```
43+
44+
Now your layer is in `layer.zip`. Enjoy!

0 commit comments

Comments
 (0)