|
17 | 17 | ) |
18 | 18 | from constructs import Construct |
19 | 19 | from fastapi import FastAPI, Request |
20 | | -from fastapi.responses import JSONResponse |
21 | 20 |
|
22 | 21 | from scripts.build_aws_lambda_layer import DIST_PATH, build_packaged_zip |
23 | | -from sentry_sdk.integrations.aws_lambda.consts import LAMBDA_METADATA_PATH |
24 | 22 |
|
25 | 23 | LAMBDA_FUNCTION_DIR = "./tests/integrations/aws_lambda/lambda_functions/" |
26 | 24 | LAMBDA_FUNCTION_WITH_EMBEDDED_SDK_DIR = ( |
27 | 25 | "./tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/" |
28 | 26 | ) |
29 | 27 | LAMBDA_FUNCTION_TIMEOUT = 10 |
30 | | -LAMBDA_METADATA_TOKEN = "test-token" |
31 | 28 | SAM_PORT = 3001 |
32 | 29 |
|
33 | 30 | # functions invoked through a published version or an alias instead of `$LATEST`: |
@@ -176,20 +173,6 @@ def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None: |
176 | 173 | ) |
177 | 174 |
|
178 | 175 | environment = {"SENTRY_DSN": dsn} |
179 | | - if lambda_dir == "BasicOkSpanStreamingDataCollection": |
180 | | - # AWS exposes these env. vars when the metadata endpoint |
181 | | - # (`2026-01-15/metadata/execution-environment`) is available. |
182 | | - # We set et them only on the function that exercises `cloud.availability_zone`. |
183 | | - environment.update( |
184 | | - { |
185 | | - "SENTRY_TEST_AWS_LAMBDA_METADATA_API": ( |
186 | | - f"{get_host_ip()}:9999" |
187 | | - ), |
188 | | - "SENTRY_TEST_AWS_LAMBDA_METADATA_TOKEN": ( |
189 | | - LAMBDA_METADATA_TOKEN |
190 | | - ), |
191 | | - } |
192 | | - ) |
193 | 176 | if lambda_dir in QUALIFIED_FUNCTIONS: |
194 | 177 | qualifier, function_version = QUALIFIED_FUNCTIONS[lambda_dir] |
195 | 178 | # SAM builds the invoked ARN from `AWS_LAMBDA_FUNCTION_NAME`, |
@@ -258,7 +241,6 @@ class SentryServerForTesting: |
258 | 241 | def __init__(self, host="0.0.0.0", port=9999, log_level="warning"): |
259 | 242 | self.envelopes = [] |
260 | 243 | self.span_items = [] |
261 | | - self.lambda_metadata_requests = 0 |
262 | 244 | self.host = host |
263 | 245 | self.port = port |
264 | 246 | self.log_level = log_level |
@@ -306,26 +288,6 @@ async def envelope(request: Request): |
306 | 288 |
|
307 | 289 | return {"status": "ok"} |
308 | 290 |
|
309 | | - @self.app.get(LAMBDA_METADATA_PATH) |
310 | | - async def lambda_metadata(request: Request): |
311 | | - """ |
312 | | - Mirrors the Lambda execution-environment metadata endpoint |
313 | | - (`2026-01-15/metadata/execution-environment`) used to collect |
314 | | - `AvailabilityZoneID`, including its cache lifetime. |
315 | | - https://docs.aws.amazon.com/lambda/latest/dg/configuration-metadata-endpoint.html |
316 | | - """ |
317 | | - self.lambda_metadata_requests += 1 |
318 | | - |
319 | | - if request.headers.get("Authorization") != ( |
320 | | - f"Bearer {LAMBDA_METADATA_TOKEN}" |
321 | | - ): |
322 | | - return JSONResponse({"message": "Unauthorized"}, status_code=401) |
323 | | - |
324 | | - return JSONResponse( |
325 | | - {"AvailabilityZoneID": "use1-az1"}, |
326 | | - headers={"Cache-Control": "private, max-age=43200, immutable"}, |
327 | | - ) |
328 | | - |
329 | 291 | def run_server(self): |
330 | 292 | uvicorn.run(self.app, host=self.host, port=self.port, log_level=self.log_level) |
331 | 293 |
|
|
0 commit comments