File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -11,15 +11,15 @@ const handler: Handler = async (payload: Payload) => {
11
11
try {
12
12
if ( ! apiUrl )
13
13
{
14
- throw error ;
14
+ throw new error ( 'API URL is missing' ) ;
15
15
}
16
- // Make the HTTP request using Axios
16
+
17
17
const response = await axios . post ( apiUrl , JSON . stringify ( data ) , {
18
18
headers : headers ,
19
19
} ) ;
20
20
21
- if ( response . status === 200 ) {
22
- console . log ( ' Alert sent to API successfully' ) ;
21
+ if ( response . status === 200 || response . status === 202 ) {
22
+ console . log ( ` Alert sent to API successfully with status ${ response . status } ` ) ;
23
23
} else {
24
24
console . error ( `Failed to send alert to API. Status code: ${ response . status } , Response: ${ response . data } ` ) ;
25
25
}
Original file line number Diff line number Diff line change @@ -101,3 +101,12 @@ resource "aws_cloudwatch_log_group" "log_group" {
101
101
name = " /aws/lambda/${ aws_lambda_function . lambda . function_name } "
102
102
retention_in_days = 14
103
103
}
104
+
105
+ data "aws_iam_policy" "write_logs_access" {
106
+ arn = " arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
107
+ }
108
+
109
+ resource "aws_iam_role_policy_attachment" "write_logs_access" {
110
+ role = aws_iam_role. lambda_execution_role . id
111
+ policy_arn = data. aws_iam_policy . write_logs_access . arn
112
+ }
You can’t perform that action at this time.
0 commit comments