File tree Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Expand file tree Collapse file tree 3 files changed +22
-0
lines changed Original file line number Diff line number Diff line change 4
4
from os import environ
5
5
6
6
import boto3
7
+ import sentry_sdk
8
+ from sentry_sdk .integrations .aws_lambda import AwsLambdaIntegration
7
9
8
10
9
11
class LambdaError (RuntimeError ):
@@ -25,6 +27,10 @@ class InstanceRefreshInProgress(LambdaError):
25
27
REFRESH_INSTANCE_WARMUP = int (environ ['REFRESH_INSTANCE_WARMUP' ])
26
28
REFRESH_MIN_HEALTHY_PERCENTAGE = int (environ ['REFRESH_MIN_HEALTHY_PERCENTAGE' ])
27
29
SSM_PARAMETER_NAME = environ ['SSM_PARAMETER_NAME' ]
30
+ SENTRY_DSN = environ .get ('SENTRY_DSN' )
31
+
32
+ if SENTRY_DSN :
33
+ sentry_sdk .init (SENTRY_DSN , integrations = [AwsLambdaIntegration ()])
28
34
29
35
logging .config .dictConfig ({
30
36
'version' : 1 ,
Original file line number Diff line number Diff line change @@ -10,12 +10,18 @@ resource "aws_lambda_function" "refresh" {
10
10
11
11
description = var. lambda_description
12
12
13
+ layers = [
14
+ " arn:aws:lambda:${ data . aws_region . current . name } :943013980633:layer:SentryPythonServerlessSDK:7" ,
15
+ ]
16
+
13
17
environment {
14
18
variables = {
15
19
AUTO_SCALING_GROUP_NAME = var.autoscaling_group_name
16
20
DESCRIBE_INSTANCE_REFRESHES_MAX_RECORDS = var.describe_instance_refreshes_max_records
17
21
REFRESH_INSTANCE_WARMUP = var.instance_refresh_instance_warmup
18
22
REFRESH_MIN_HEALTHY_PERCENTAGE = var.instance_refresh_min_healthy_percentage
23
+ SENTRY_DSN = var.sentry_dsn
24
+ SENTRY_ENVIRONMENT = var.sentry_environment
19
25
SSM_PARAMETER_NAME = var.ami_ssm_parameter
20
26
}
21
27
}
Original file line number Diff line number Diff line change @@ -85,3 +85,13 @@ variable "launch_template_source_version" {
85
85
default = " $Default"
86
86
type = string
87
87
}
88
+
89
+ variable "sentry_dsn" {
90
+ default = null
91
+ type = string
92
+ }
93
+
94
+ variable "sentry_environment" {
95
+ default = null
96
+ type = string
97
+ }
You can’t perform that action at this time.
0 commit comments