diff --git a/modules/docker-build/README.md b/modules/docker-build/README.md index 07da548f..eafd6871 100644 --- a/modules/docker-build/README.md +++ b/modules/docker-build/README.md @@ -53,14 +53,14 @@ module "docker_image" { | Name | Version | |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.1 | -| [aws](#requirement\_aws) | >= 3.35 | +| [aws](#requirement\_aws) | >= 4.22 | | [docker](#requirement\_docker) | >= 2.12 | ## Providers | Name | Version | |------|---------| -| [aws](#provider\_aws) | >= 3.35 | +| [aws](#provider\_aws) | >= 4.22 | | [docker](#provider\_docker) | >= 2.12 | ## Modules @@ -85,6 +85,7 @@ No modules. | [create\_ecr\_repo](#input\_create\_ecr\_repo) | Controls whether ECR repository for Lambda image should be created | `bool` | `false` | no | | [docker\_file\_path](#input\_docker\_file\_path) | Path to Dockerfile in source package | `string` | `"Dockerfile"` | no | | [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 | +| [ecr\_force\_delete](#input\_ecr\_force\_delete) | If true, will delete the repository even if it contains images. | `bool` | `true` | no | | [ecr\_repo](#input\_ecr\_repo) | Name of ECR repository to use or to create | `string` | `null` | no | | [ecr\_repo\_lifecycle\_policy](#input\_ecr\_repo\_lifecycle\_policy) | A JSON formatted ECR lifecycle policy to automate the cleaning up of unused images. | `string` | `null` | no | | [ecr\_repo\_tags](#input\_ecr\_repo\_tags) | A map of tags to assign to ECR repository | `map(string)` | `{}` | no | diff --git a/modules/docker-build/main.tf b/modules/docker-build/main.tf index 6dd15cc4..9ff74152 100644 --- a/modules/docker-build/main.tf +++ b/modules/docker-build/main.tf @@ -24,6 +24,7 @@ resource "docker_registry_image" "this" { resource "aws_ecr_repository" "this" { count = var.create_ecr_repo ? 1 : 0 + force_delete = var.ecr_force_delete name = var.ecr_repo image_tag_mutability = var.image_tag_mutability diff --git a/modules/docker-build/variables.tf b/modules/docker-build/variables.tf index f029958a..4fadbff1 100644 --- a/modules/docker-build/variables.tf +++ b/modules/docker-build/variables.tf @@ -47,6 +47,12 @@ variable "scan_on_push" { default = false } +variable "ecr_force_delete" { + description = "If true, will delete the repository even if it contains images." + default = true + type = bool +} + variable "ecr_repo_tags" { description = "A map of tags to assign to ECR repository" type = map(string) diff --git a/modules/docker-build/versions.tf b/modules/docker-build/versions.tf index 87ea2d45..9885459d 100644 --- a/modules/docker-build/versions.tf +++ b/modules/docker-build/versions.tf @@ -4,7 +4,7 @@ terraform { required_providers { aws = { source = "hashicorp/aws" - version = ">= 3.35" + version = ">= 4.22" } docker = { source = "kreuzwerker/docker"