From b4ef4e45e9f3dafb774ccf62d9473b338de68f3f Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Mon, 22 Apr 2024 11:31:35 -0400 Subject: [PATCH] feat: Update Python lambda runtime from `3.8` to `3.11` (#225) * feat: Update Python lambda runtime from `3.8` to `3.11` * fix: Update CI versions to support 3.11 --- .github/workflows/unit-test.yml | 8 ++++---- README.md | 9 ++++----- functions/.pyproject.toml | 2 +- functions/Pipfile | 6 +++--- main.tf | 2 +- 5 files changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index a1e76f4f..e300cca5 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -20,12 +20,12 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: 3.8 + python-version: 3.11 - name: Install pipenv run: | diff --git a/README.md b/README.md index 7a3b0a14..b08169f3 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Doing serverless with Terraform? Check out [serverless.tf framework](https://ser ## Supported Features -- AWS Lambda runtime Python 3.8 +- AWS Lambda runtime Python 3.11 - Create new SNS topic or use existing one - Support plaintext and encrypted version of Slack webhook URL - Most of Slack message options are customizable @@ -18,7 +18,6 @@ Doing serverless with Terraform? Check out [serverless.tf framework](https://ser - AWS CloudWatch LogMetrics Alarms - AWS GuardDuty Findings - ## Usage ```hcl @@ -38,11 +37,11 @@ module "notify_slack" { [Terraform Cloud Agents](https://www.terraform.io/docs/cloud/workspaces/agent.html) are a paid feature, available as part of the Terraform Cloud for Business upgrade package. -This module requires Python 3.8. You can customize [tfc-agent](https://hub.docker.com/r/hashicorp/tfc-agent) to include Python using this sample `Dockerfile`: +This module requires Python 3.11. You can customize [tfc-agent](https://hub.docker.com/r/hashicorp/tfc-agent) to include Python using this sample `Dockerfile`: -``` +```Dockerfile FROM hashicorp/tfc-agent:latest -RUN apt-get -y update && apt-get -y install python3.8 python3-pip +RUN apt-get -y update && apt-get -y install python3.11 python3-pip ENTRYPOINT ["/bin/tfc-agent"] ``` diff --git a/functions/.pyproject.toml b/functions/.pyproject.toml index c0374cea..1b28df83 100644 --- a/functions/.pyproject.toml +++ b/functions/.pyproject.toml @@ -1,6 +1,6 @@ [tool.black] line-length = 120 -target-version = ['py38'] +target-version = ['py311'] include = '\.pyi?$' verbose = true exclude = ''' diff --git a/functions/Pipfile b/functions/Pipfile index af8ac944..7c2a6f9a 100644 --- a/functions/Pipfile +++ b/functions/Pipfile @@ -6,8 +6,8 @@ name = "pypi" [packages] [dev-packages] -boto3 = "~=1.20" -botocore = "~=1.23" +boto3 = "~=1.34" +botocore = "~=1.34" black = "*" flake8 = "*" isort = "*" @@ -18,7 +18,7 @@ radon = "*" snapshottest = "~=0.6" [requires] -python_version = "3.8" +python_version = "3.11" [scripts] test = "python3 -m pytest --cov --cov-report=term" diff --git a/main.tf b/main.tf index 90022fd1..c8587fad 100644 --- a/main.tf +++ b/main.tf @@ -91,7 +91,7 @@ module "lambda" { handler = "${local.lambda_handler}.lambda_handler" source_path = var.lambda_source_path != null ? "${path.root}/${var.lambda_source_path}" : "${path.module}/functions/notify_slack.py" recreate_missing_package = var.recreate_missing_package - runtime = "python3.8" + runtime = "python3.11" architectures = var.architectures timeout = 30 kms_key_arn = var.kms_key_arn