diff --git a/2-modules/README.md b/2-modules/README.md index ea2c140..703ef4c 100644 --- a/2-modules/README.md +++ b/2-modules/README.md @@ -54,6 +54,7 @@ In the first lab, we bootstrapped Terraform and got familiar with the very basic module "lambda_function" { source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "hello-world" handler = "helloworld.handler" @@ -75,6 +76,8 @@ The good part is, that we can write our own modules or use third-party modules. The Terraform community is very vibrant and you can find thousands of modules. Before reinventing the wheel, check out the [Terraform Registry](https://registry.terraform.io). +For third-party modules, it's [good practice](https://www.terraform.io/language/expressions/version-constraints#module-versions) to add the version attribute and define a specific version. That ensures you don't accidentally upgrade third-party modules. + That's it for the Lambda function. Let's go to the API Gateway. ## API Gateway @@ -118,7 +121,8 @@ That's it for the Lambda function. Let's go to the API Gateway. } module "lambda_function" { - source = "terraform-aws-modules/lambda/aws" + source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "hello-world" handler = "helloworld.handler" diff --git a/2-modules/main.tf b/2-modules/main.tf index f67fc73..488db05 100644 --- a/2-modules/main.tf +++ b/2-modules/main.tf @@ -35,7 +35,8 @@ resource "aws_s3_bucket_website_configuration" "website" { } module "lambda_function" { - source = "terraform-aws-modules/lambda/aws" + source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "hello-world" handler = "helloworld.handler" diff --git a/3-composition/README.md b/3-composition/README.md index 8e0103e..7541f8c 100644 --- a/3-composition/README.md +++ b/3-composition/README.md @@ -30,7 +30,8 @@ The previous lab introduced a third-party module to easily deploy a Lambda funct } module "lambda_function" { - source = "terraform-aws-modules/lambda/aws" + source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "${local.project_name}-${var.environment}" handler = "helloworld.handler" diff --git a/3-composition/modules/api/main.tf b/3-composition/modules/api/main.tf index f867964..6fba30f 100644 --- a/3-composition/modules/api/main.tf +++ b/3-composition/modules/api/main.tf @@ -3,7 +3,8 @@ locals { } module "lambda_function" { - source = "terraform-aws-modules/lambda/aws" + source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "${local.project_name}-${var.environment}" handler = "helloworld.handler" diff --git a/4-parameterization/README.md b/4-parameterization/README.md index 836fa76..ee7a83b 100644 --- a/4-parameterization/README.md +++ b/4-parameterization/README.md @@ -24,7 +24,8 @@ The API becomes more powerful in this lab, but we want to be careful and only ro } module "lambda_function" { - source = "terraform-aws-modules/lambda/aws" + source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "${local.project_name}-${var.environment}" handler = "helloworld.handler" diff --git a/4-parameterization/modules/api/main.tf b/4-parameterization/modules/api/main.tf index b5860c4..90e35ca 100644 --- a/4-parameterization/modules/api/main.tf +++ b/4-parameterization/modules/api/main.tf @@ -4,6 +4,7 @@ locals { module "lambda_function" { source = "terraform-aws-modules/lambda/aws" + version = "3.2.0" function_name = "${local.project_name}-${var.environment}" handler = "helloworld.handler"