Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Make compatible_runtimes optional, added sam metadata control #493

Merged
merged 8 commits into from
Oct 27, 2023
1 change: 0 additions & 1 deletion examples/alias/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

data "aws_organizations_organization" "this" {}
Expand Down
1 change: 0 additions & 1 deletion examples/async/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
1 change: 0 additions & 1 deletion examples/build-package/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
1 change: 0 additions & 1 deletion examples/code-signing/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

################################################################################
Expand Down
1 change: 0 additions & 1 deletion examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

data "aws_caller_identity" "current" {}
Expand Down
1 change: 0 additions & 1 deletion examples/container-image/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

provider "docker" {
Expand Down
1 change: 0 additions & 1 deletion examples/deploy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
1 change: 0 additions & 1 deletion examples/event-source-mapping/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

data "aws_availability_zones" "available" {}
Expand Down
2 changes: 0 additions & 2 deletions examples/multiple-regions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

provider "aws" {
Expand All @@ -16,7 +15,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

################################
Expand Down
1 change: 0 additions & 1 deletion examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
1 change: 0 additions & 1 deletion examples/triggers/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

##########################################
Expand Down
1 change: 0 additions & 1 deletion examples/with-efs/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
1 change: 0 additions & 1 deletion examples/with-vpc-s3-endpoint/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

data "aws_region" "current" {}
Expand Down
1 change: 0 additions & 1 deletion examples/with-vpc/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ provider "aws" {
skip_metadata_api_check = true
skip_region_validation = true
skip_credentials_validation = true
skip_requesting_account_id = true
}

resource "random_pet" "this" {
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ resource "aws_lambda_layer_version" "this" {
description = var.description
license_info = var.license_info

compatible_runtimes = length(var.compatible_runtimes) > 0 ? var.compatible_runtimes : [var.runtime]
compatible_runtimes = length(var.compatible_runtimes) > 0 ? var.compatible_runtimes : (var.runtime == "" ? null : [var.runtime])
compatible_architectures = var.compatible_architectures
skip_destroy = var.layer_skip_destroy

Expand Down
1 change: 1 addition & 0 deletions modules/docker-build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ No modules.
|------|-------------|------|---------|:--------:|
| <a name="input_build_args"></a> [build\_args](#input\_build\_args) | A map of Docker build arguments. | `map(string)` | `{}` | no |
| <a name="input_create_ecr_repo"></a> [create\_ecr\_repo](#input\_create\_ecr\_repo) | Controls whether ECR repository for Lambda image should be created | `bool` | `false` | no |
| <a name="input_create_sam_metadata"></a> [create\_sam\_metadata](#input\_create\_sam\_metadata) | Controls whether the SAM metadata null resource should be created | `bool` | `false` | no |
| <a name="input_docker_file_path"></a> [docker\_file\_path](#input\_docker\_file\_path) | Path to Dockerfile in source package | `string` | `"Dockerfile"` | no |
| <a name="input_ecr_address"></a> [ecr\_address](#input\_ecr\_address) | Address of ECR repository for cross-account container image pulling (optional). Option `create_ecr_repo` must be `false` | `string` | `null` | no |
| <a name="input_ecr_force_delete"></a> [ecr\_force\_delete](#input\_ecr\_force\_delete) | If true, will delete the repository even if it contains images. | `bool` | `true` | no |
Expand Down
2 changes: 2 additions & 0 deletions modules/docker-build/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ resource "aws_ecr_lifecycle_policy" "this" {
# to the TF application. This resource will maintain the metadata information about the image type lambda
# functions. It will contain the information required to build the docker image locally.
resource "null_resource" "sam_metadata_docker_registry_image" {
count = var.create_sam_metadata ? 1 : 0

triggers = {
resource_type = "IMAGE_LAMBDA_FUNCTION"
docker_context = var.source_path
Expand Down
6 changes: 6 additions & 0 deletions modules/docker-build/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ variable "create_ecr_repo" {
default = false
}

variable "create_sam_metadata" {
description = "Controls whether the SAM metadata null resource should be created"
type = bool
default = false
}

variable "ecr_address" {
description = "Address of ECR repository for cross-account container image pulling (optional). Option `create_ecr_repo` must be `false`"
type = string
Expand Down
1 change: 1 addition & 0 deletions wrappers/docker-build/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module "wrapper" {
for_each = var.items

create_ecr_repo = try(each.value.create_ecr_repo, var.defaults.create_ecr_repo, false)
create_sam_metadata = try(each.value.create_sam_metadata, var.defaults.create_sam_metadata, false)
ecr_address = try(each.value.ecr_address, var.defaults.ecr_address, null)
ecr_repo = try(each.value.ecr_repo, var.defaults.ecr_repo, null)
image_tag = try(each.value.image_tag, var.defaults.image_tag, null)
Expand Down