Skip to content
This repository was archived by the owner on Oct 8, 2022. It is now read-only.

Commit b95b3b9

Browse files
Upgrade module to support Terraform 0.12 (#6)
* Upgrade module to support Terraform 0.12 Following the instructions outlined in the Terraform documentation, update the module's configuration to support Terraform 0.12. Despite containing minor changes, this is expected to cause a major version bump, because the changes are not backwards compatible. * Apply suggestions from code review Co-authored-by: Cole Kettler <me@colekettler.com> Co-authored-by: Cole Kettler <me@colekettler.com>
1 parent 174c9a7 commit b95b3b9

File tree

5 files changed

+36
-19
lines changed

5 files changed

+36
-19
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ module "ecr-repository" {
1616
}
1717
```
1818

19-
2019
## Variables
2120

22-
- `repository_name` - name of the repository
23-
- `attach_lifecycle_policy` - attach an [ECR lifecycle policy](https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html) (default: `false`)
24-
- `lifecycle_policy` - ECR lifecycle policy (default: the contents of `default-lifecycle-policy.json.tpl`, untagged images older than 7 days will be deleted)
21+
- `repository_name` - Name of the repository
22+
- `attach_lifecycle_policy` - If true, an [ECR lifecycle policy](https://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html) will be attached (default: `false`)
23+
- `lifecycle_policy` - Contents of the ECR lifecycle policy (default: contents of `default-lifecycle-policy.json.tpl`, untagged images older than 7 days will be deleted)
2524

2625
## Outputs
2726

28-
- `arn` - full ARN of the repository
29-
- `name` - the name of the repository
30-
- `registry_id` - the registry ID where the repository was created
31-
- `repository_url` - the URL of the repository (in the form aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName)
27+
- `arn` - Full ARN of the repository
28+
- `name` - Name of the repository
29+
- `registry_id` - Registry ID where the repository was created
30+
- `repository_url` - URL of the repository (in the form aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName)

main.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# ECR Resources
33
#
44
resource "aws_ecr_repository" "default" {
5-
name = "${var.repository_name}"
5+
name = var.repository_name
66
}
77

88
resource "aws_ecr_lifecycle_policy" "default" {
9-
count = "${var.attach_lifecycle_policy ? 1 : 0}"
9+
count = var.attach_lifecycle_policy ? 1 : 0
1010

11-
repository = "${aws_ecr_repository.default.name}"
12-
policy = "${var.lifecycle_policy != "" ? var.lifecycle_policy : file("${path.module}/templates/default-lifecycle-policy.json.tpl")}"
11+
repository = aws_ecr_repository.default.name
12+
policy = var.lifecycle_policy != "" ? var.lifecycle_policy : file("${path.module}/templates/default-lifecycle-policy.json.tpl")
1313
}

outputs.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
output "arn" {
2-
value = "${aws_ecr_repository.default.arn}"
2+
value = aws_ecr_repository.default.arn
3+
description = "Full ARN of the repository"
34
}
45

56
output "name" {
6-
value = "${aws_ecr_repository.default.name}"
7+
value = aws_ecr_repository.default.name
8+
description = "Name of the repository"
79
}
810

911
output "registry_id" {
10-
value = "${aws_ecr_repository.default.registry_id}"
12+
value = aws_ecr_repository.default.registry_id
13+
description = "Registry ID where the repository was created"
1114
}
1215

1316
output "repository_url" {
14-
value = "${aws_ecr_repository.default.repository_url}"
17+
value = aws_ecr_repository.default.repository_url
18+
description = "URL of the repository"
1519
}

variables.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
variable "repository_name" {}
1+
variable "repository_name" {
2+
type = string
3+
description = "Name of the repository"
4+
}
25

36
variable "attach_lifecycle_policy" {
4-
default = false
7+
default = false
8+
type = bool
9+
description = "If true, an ECR lifecycle policy will be attached"
510
}
611

712
variable "lifecycle_policy" {
8-
default = ""
13+
default = ""
14+
type = string
15+
description = "Contents of the ECR lifecycle policy"
916
}

versions.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
terraform {
3+
required_version = ">= 0.12"
4+
required_providers {
5+
aws = ">= 2.33.0"
6+
}
7+
}

0 commit comments

Comments
 (0)