Skip to content

Commit e44e2b7

Browse files
authored
Fix livecycle (#26)
* Fix livecycle * Fix livecycle * Fix policy * Fix policy * Fix policy * Fix policy * Update main.tf * Update main.tf * Update variables.tf * Fix readmed * Fix readmed * Fix readmed
1 parent 4eb32d0 commit e44e2b7

File tree

4 files changed

+32
-14
lines changed

4 files changed

+32
-14
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ We literally have [*hundreds of terraform modules*][terraform_modules] that are
4242

4343
## Usage
4444

45+
46+
**IMPORTANT:** The `master` branch is used in `source` just as an example. In your code, do not pin to `master` because there may be breaking changes between releases.
47+
Instead pin to the release tag (e.g. `?ref=tags/x.y.z`) of one of our [latest releases](https://github.com/cloudposse/terraform-aws-ecr/releases).
48+
49+
4550
The module works in two distinct modes:
4651

4752
1. If you provide the existing IAM Role names in the `roles` attribute, the Roles will be granted permissions to work with the created registry.
@@ -119,7 +124,7 @@ Available targets:
119124
| attributes | Additional attributes (e.g. `policy` or `role`) | list | `<list>` | no |
120125
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
121126
| enabled | Set to false to prevent the module from creating any resources | string | `true` | no |
122-
| max_image_count | How many Docker Image versions AWS ECR will store | string | `7` | no |
127+
| max_image_count | How many Docker Image versions AWS ECR will store | string | `500` | no |
123128
| name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | - | yes |
124129
| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes |
125130
| principals_full_access | Principal ARN to provide with full access to the ECR | list | `<list>` | no |

docs/terraform.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| attributes | Additional attributes (e.g. `policy` or `role`) | list | `<list>` | no |
66
| delimiter | Delimiter to be used between `name`, `namespace`, `stage`, etc. | string | `-` | no |
77
| enabled | Set to false to prevent the module from creating any resources | string | `true` | no |
8-
| max_image_count | How many Docker Image versions AWS ECR will store | string | `7` | no |
8+
| max_image_count | How many Docker Image versions AWS ECR will store | string | `500` | no |
99
| name | The Name of the application or solution (e.g. `bastion` or `portal`) | string | - | yes |
1010
| namespace | Namespace (e.g. `cp` or `cloudposse`) | string | - | yes |
1111
| principals_full_access | Principal ARN to provide with full access to the ECR | list | `<list>` | no |

main.tf

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,32 @@ resource "aws_ecr_lifecycle_policy" "default" {
2727

2828
policy = <<EOF
2929
{
30-
"rules": [{
31-
"rulePriority": 1,
32-
"description": "Rotate images when reach ${var.max_image_count} images stored",
33-
"selection": {
34-
"tagStatus": "tagged",
35-
"tagPrefixList": ["${var.stage}"],
36-
"countType": "imageCountMoreThan",
37-
"countNumber": ${var.max_image_count}
30+
"rules": [
31+
{
32+
"rulePriority": 1,
33+
"description": "Remove untagged images",
34+
"selection": {
35+
"tagStatus": "untagged",
36+
"countType": "imageCountMoreThan",
37+
"countNumber": 1
38+
},
39+
"action": {
40+
"type": "expire"
41+
}
3842
},
39-
"action": {
40-
"type": "expire"
43+
{
44+
"rulePriority": 2,
45+
"description": "Rotate images when reach ${var.max_image_count} images stored",
46+
"selection": {
47+
"tagStatus": "any",
48+
"countType": "imageCountMoreThan",
49+
"countNumber": ${var.max_image_count}
50+
},
51+
"action": {
52+
"type": "expire"
53+
}
4154
}
42-
}]
55+
]
4356
}
4457
EOF
4558
}

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ variable "tags" {
5454
variable "max_image_count" {
5555
type = "string"
5656
description = "How many Docker Image versions AWS ECR will store"
57-
default = "7"
57+
default = "500"
5858
}

0 commit comments

Comments
 (0)