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) => {
1111 try {
1212 if ( ! apiUrl )
1313 {
14- throw error ;
14+ throw new error ( 'API URL is missing' ) ;
1515 }
16- // Make the HTTP request using Axios
16+
1717 const response = await axios . post ( apiUrl , JSON . stringify ( data ) , {
1818 headers : headers ,
1919 } ) ;
2020
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 } ` ) ;
2323 } else {
2424 console . error ( `Failed to send alert to API. Status code: ${ response . status } , Response: ${ response . data } ` ) ;
2525 }
Original file line number Diff line number Diff line change @@ -101,3 +101,12 @@ resource "aws_cloudwatch_log_group" "log_group" {
101101 name = " /aws/lambda/${ aws_lambda_function . lambda . function_name } "
102102 retention_in_days = 14
103103}
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