From 76859320951780f16345db16ce421e5ad44a52aa Mon Sep 17 00:00:00 2001 From: caiohasouza Date: Wed, 22 Apr 2026 19:32:13 -0300 Subject: [PATCH] fix: upgrade python requests to urllib --- README.md | 4 ++-- functions/app.py | 15 +++++++++------ variables.tf | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 56e85ec..2cb4a5d 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ | [lambda\_function\_tags](#input\_lambda\_function\_tags) | Additional tags for the Lambda function | `map(string)` | `{}` | no | | [lambda\_function\_vpc\_security\_group\_ids](#input\_lambda\_function\_vpc\_security\_group\_ids) | List of security group ids when Lambda Function should run in the VPC. | `list(string)` | `null` | no | | [lambda\_function\_vpc\_subnet\_ids](#input\_lambda\_function\_vpc\_subnet\_ids) | List of subnet ids when Lambda Function should run in the VPC. Usually private or intra subnets. | `list(string)` | `null` | no | -| [lambda\_layers](#input\_lambda\_layers) | (Optional) List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function | `list(string)` |
[
"arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python-AWS-SDK:4"
]
| no | +| [lambda\_layers](#input\_lambda\_layers) | (Optional) List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function | `list(string)` | `[]` | no | | [lambda\_role](#input\_lambda\_role) | IAM role attached to the Lambda Function. If this is set then a role will not be created for you. | `string` | `""` | no | | [messenger](#input\_messenger) | The name of the channel in Slack for notifications | `string` | n/a | yes | | [recreate\_missing\_package](#input\_recreate\_missing\_package) | Whether to recreate missing Lambda package if it is missing locally or not | `bool` | `false` | no | @@ -75,4 +75,4 @@ | [lambda\_iam\_role\_arn](#output\_lambda\_iam\_role\_arn) | The ARN of the IAM role used by Lambda function | | [lambda\_iam\_role\_name](#output\_lambda\_iam\_role\_name) | The name of the IAM role used by Lambda function | | [sns\_topic\_arn](#output\_sns\_topic\_arn) | The ARN of the SNS topic from which messages will be sent to Slack | - \ No newline at end of file + diff --git a/functions/app.py b/functions/app.py index b5b899e..22cc403 100644 --- a/functions/app.py +++ b/functions/app.py @@ -1,9 +1,8 @@ import os import json import logging -#import requests -import urllib -from botocore.vendored import requests +import urllib.parse +import urllib.request # --------------------------------------------------------------------------------------------------------------------- # ENVIRONMENT VARIABLES @@ -646,9 +645,13 @@ def ecs_events_parser_title(detail_type, detail): def post(WEBHOOK_URL, message): log.debug(f'Sending message: {json.dumps(message, indent=4)}') headers = {'Content-type': 'application/json'} - response = requests.post(WEBHOOK_URL, json.dumps(message), headers=headers) - log.debug('Response: {}, message: {}'.format(response.status_code, response.text)) - return response.status_code + payload = json.dumps(message).encode("utf-8") + request = urllib.request.Request(WEBHOOK_URL, data=payload, headers=headers, method="POST") + with urllib.request.urlopen(request) as response: + body = response.read().decode("utf-8") + status_code = response.getcode() + log.debug('Response: {}, message: {}'.format(status_code, body)) + return status_code # Lambda handler def lambda_handler(event, context): diff --git a/variables.tf b/variables.tf index ef0fcd5..fb53c12 100644 --- a/variables.tf +++ b/variables.tf @@ -30,7 +30,7 @@ variable "lambda_description" { variable "lambda_layers" { description = "(Optional) List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function" type = list(string) - default = ["arn:aws:lambda:us-east-1:668099181075:layer:AWSLambda-Python-AWS-SDK:4"] + default = [] } variable "sns_topic_name" {