From d742b89289c7c521bc3d63e25582fd1b2c8525b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Beauchamp?= Date: Thu, 13 Jun 2019 16:23:14 -0400 Subject: [PATCH 1/5] strip '_' from title to avoid illegal character in IAM role policy --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 29bfd9a..19a341e 100644 --- a/variables.tf +++ b/variables.tf @@ -12,5 +12,5 @@ locals { name = "${var.name}" region = "${data.aws_region.current.name}" project = "${var.project}" - title = "${title(replace(replace(local.name, "-", "" ), " ", ""))}" + title = "${title(replace(replace(replace(local.name, "-", "" ), " ", "")), "_", "")}" } \ No newline at end of file From 423da1b99417e20fc7fba0b29ccf955c410198d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Beauchamp?= Date: Thu, 13 Jun 2019 16:31:05 -0400 Subject: [PATCH 2/5] fix misplaced paren --- variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/variables.tf b/variables.tf index 19a341e..c946d37 100644 --- a/variables.tf +++ b/variables.tf @@ -12,5 +12,5 @@ locals { name = "${var.name}" region = "${data.aws_region.current.name}" project = "${var.project}" - title = "${title(replace(replace(replace(local.name, "-", "" ), " ", "")), "_", "")}" + title = "${title(replace(replace(replace(local.name, "-", "" ), " ", ""), "_", ""))}" } \ No newline at end of file From d10e86cd17dc95ef88d94b9a39927bb98b573eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Beauchamp?= Date: Tue, 18 Jun 2019 08:53:39 -0400 Subject: [PATCH 3/5] add lifecycle retention policy to registry --- ecr.tf | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/ecr.tf b/ecr.tf index 6ec9643..eaa3a1b 100644 --- a/ecr.tf +++ b/ecr.tf @@ -5,3 +5,26 @@ resource "aws_ecr_repository" "image" { Project = "${local.project}" } } + +# Only keep last 30 images +resource "aws_ecr_lifecycle_policy" "cleanup" { + repository = "${aws_ecr_repository.image.name}" + policy = << END_OF_POLICY +{ + "rules": [ + { + "rulePriority": 1, + "description": "Keep last 30 images", + "selection": { + "tagStatus": "any", + "countType": "imageCountMoreThan", + "countNumber": 30 + }, + "action": { + "type": "expire" + } + } + ] +} +END_OF_POLICY +} \ No newline at end of file From 2f75aab2496b276c893bb9f2425090492e4fa9cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Beauchamp?= Date: Tue, 18 Jun 2019 09:02:08 -0400 Subject: [PATCH 4/5] fix syntax --- ecr.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ecr.tf b/ecr.tf index eaa3a1b..fac9e52 100644 --- a/ecr.tf +++ b/ecr.tf @@ -9,9 +9,10 @@ resource "aws_ecr_repository" "image" { # Only keep last 30 images resource "aws_ecr_lifecycle_policy" "cleanup" { repository = "${aws_ecr_repository.image.name}" - policy = << END_OF_POLICY + + policy = < Date: Wed, 19 Jun 2019 14:24:39 -0400 Subject: [PATCH 5/5] Upgrade to Terraform 0.12 --- ecr.tf | 11 ++++++----- outputs.tf | 9 +++++---- variables.tf | 15 +++++++++------ versions.tf | 4 ++++ 4 files changed, 24 insertions(+), 15 deletions(-) create mode 100644 versions.tf diff --git a/ecr.tf b/ecr.tf index fac9e52..ecaa540 100644 --- a/ecr.tf +++ b/ecr.tf @@ -1,14 +1,14 @@ resource "aws_ecr_repository" "image" { - name = "${var.name}" + name = var.name - tags { - Project = "${local.project}" + tags = { + Project = local.project } } # Only keep last 30 images resource "aws_ecr_lifecycle_policy" "cleanup" { - repository = "${aws_ecr_repository.image.name}" + repository = aws_ecr_repository.image.name policy = <