From b78ac013e8672a673a71068e812db405159d8eed Mon Sep 17 00:00:00 2001 From: Piotr Roszatycki Date: Thu, 12 Nov 2026 18:58:38 +0100 Subject: [PATCH] Examples of Lambda: the variable aws_profile of the profile of the provider of AWS Without it, the provider takes the credentials and the region of the default chain of AWS, as before. Co-Authored-By: Claude Opus 5.5 --- examples/lambda/README.md | 4 ++-- examples/lambda/variables.tf | 6 ++++++ examples/lambda/versions.tf | 7 ++++--- examples/lambda_stream/README.md | 4 ++-- examples/lambda_stream/variables.tf | 6 ++++++ examples/lambda_stream/versions.tf | 7 ++++--- examples/lambda_zip/README.md | 4 ++-- examples/lambda_zip/variables.tf | 6 ++++++ examples/lambda_zip/versions.tf | 7 ++++--- 9 files changed, 36 insertions(+), 15 deletions(-) diff --git a/examples/lambda/README.md b/examples/lambda/README.md index 10db0aca..e5a296ed 100644 --- a/examples/lambda/README.md +++ b/examples/lambda/README.md @@ -40,8 +40,8 @@ uv run --directory examples/lambda/function python app.py generate lambda-zip -- ``` OpenTofu 1.13 deploys it with the credentials and the region of the default -chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, and a new build of the same -files changes nothing: +chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, or of the profile of +`-var aws_profile=NAME`, and a new build of the same files changes nothing: ```sh tofu -chdir=examples/lambda init diff --git a/examples/lambda/variables.tf b/examples/lambda/variables.tf index cc2ae252..2efad291 100644 --- a/examples/lambda/variables.tf +++ b/examples/lambda/variables.tf @@ -10,6 +10,12 @@ variable "region" { default = null } +variable "aws_profile" { + description = "The profile of AWS of the credentials and the region, or the one of the default chain of AWS" + type = string + default = null +} + variable "runtime" { description = "The runtime of Python of the function, the one of \"generate lambda-zip --runtime\"" type = string diff --git a/examples/lambda/versions.tf b/examples/lambda/versions.tf index 3c535caf..e234120e 100644 --- a/examples/lambda/versions.tf +++ b/examples/lambda/versions.tf @@ -14,10 +14,11 @@ terraform { } } -# The credentials and the region of the default chain of AWS: the variables of the environment, the profile and the -# role of the machine +# The credentials and the region of the profile of the variable "aws_profile", or of the default chain of AWS: the +# variables of the environment, the profile and the role of the machine provider "aws" { - region = var.region + profile = var.aws_profile + region = var.region default_tags { tags = { diff --git a/examples/lambda_stream/README.md b/examples/lambda_stream/README.md index 615e631b..f6a516f2 100644 --- a/examples/lambda_stream/README.md +++ b/examples/lambda_stream/README.md @@ -51,8 +51,8 @@ uv run --directory examples/lambda_stream/function python app.py generate lambda ``` OpenTofu 1.13 deploys it with the credentials and the region of the default -chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, and a new build of the same -files changes nothing: +chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, or of the profile of +`-var aws_profile=NAME`, and a new build of the same files changes nothing: ```sh tofu -chdir=examples/lambda_stream init diff --git a/examples/lambda_stream/variables.tf b/examples/lambda_stream/variables.tf index 91e0a26f..df235f58 100644 --- a/examples/lambda_stream/variables.tf +++ b/examples/lambda_stream/variables.tf @@ -10,6 +10,12 @@ variable "region" { default = null } +variable "aws_profile" { + description = "The profile of AWS of the credentials and the region, or the one of the default chain of AWS" + type = string + default = null +} + variable "runtime" { description = "The runtime of Python of the function, the one of \"generate lambda-zip --runtime\"" type = string diff --git a/examples/lambda_stream/versions.tf b/examples/lambda_stream/versions.tf index 3c535caf..e234120e 100644 --- a/examples/lambda_stream/versions.tf +++ b/examples/lambda_stream/versions.tf @@ -14,10 +14,11 @@ terraform { } } -# The credentials and the region of the default chain of AWS: the variables of the environment, the profile and the -# role of the machine +# The credentials and the region of the profile of the variable "aws_profile", or of the default chain of AWS: the +# variables of the environment, the profile and the role of the machine provider "aws" { - region = var.region + profile = var.aws_profile + region = var.region default_tags { tags = { diff --git a/examples/lambda_zip/README.md b/examples/lambda_zip/README.md index 9d3da31f..8b58d062 100644 --- a/examples/lambda_zip/README.md +++ b/examples/lambda_zip/README.md @@ -44,8 +44,8 @@ uv run --directory examples/lambda_zip/function python app.py generate lambda-zi ``` OpenTofu 1.13 deploys it with the credentials and the region of the default -chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, and a new build of the same -files changes nothing: +chain of AWS, as `AWS_PROFILE` and `AWS_REGION`, or of the profile of +`-var aws_profile=NAME`, and a new build of the same files changes nothing: ```sh tofu -chdir=examples/lambda_zip init diff --git a/examples/lambda_zip/variables.tf b/examples/lambda_zip/variables.tf index 136f633c..6e061768 100644 --- a/examples/lambda_zip/variables.tf +++ b/examples/lambda_zip/variables.tf @@ -10,6 +10,12 @@ variable "region" { default = null } +variable "aws_profile" { + description = "The profile of AWS of the credentials and the region, or the one of the default chain of AWS" + type = string + default = null +} + variable "pyjoyment_layer" { description = "The ARN of a published layer of Pyjoyment, in the place of the public one or of function/dist/pyjoyment.zip" type = string diff --git a/examples/lambda_zip/versions.tf b/examples/lambda_zip/versions.tf index 3c535caf..e234120e 100644 --- a/examples/lambda_zip/versions.tf +++ b/examples/lambda_zip/versions.tf @@ -14,10 +14,11 @@ terraform { } } -# The credentials and the region of the default chain of AWS: the variables of the environment, the profile and the -# role of the machine +# The credentials and the region of the profile of the variable "aws_profile", or of the default chain of AWS: the +# variables of the environment, the profile and the role of the machine provider "aws" { - region = var.region + profile = var.aws_profile + region = var.region default_tags { tags = {