Skip to content

Commit

Permalink
fix: add version attr to third-party modules (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikFricke authored May 20, 2022
1 parent db322d8 commit 354cec3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
6 changes: 5 additions & 1 deletion 2-modules/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion 2-modules/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion 3-composition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion 3-composition/modules/api/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion 4-parameterization/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions 4-parameterization/modules/api/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 354cec3

Please sign in to comment.