Skip to content

Commit d5f72d3

Browse files
committed
feat: Allow specifying 'scan' and 'mutability' options
1 parent 33f6360 commit d5f72d3

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,39 @@ Terraform module to create AWS ECR repository.
44

55
## Usage
66

7+
Minimal params:
8+
```hcl
9+
module "my_registry" {
10+
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.2.1"
11+
name = "blinchik"
12+
tags = {
13+
Owner = "Don John",
14+
Project = "Alice"
15+
Customer = "Umbrella Corp."
16+
}
17+
}
718
```
19+
20+
All options with default values:
21+
```hcl
822
module "my_registry" {
9-
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.1.0"
23+
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.2.1"
1024
name = "blinchik"
11-
project = "FooBar"
25+
scan = false
26+
mutable = true
27+
tags = {
28+
Owner = "Don John",
29+
Project = "Alice"
30+
Customer = "Umbrella Corp."
31+
}
1232
}
1333
```
1434

35+
1536
## Outputs
1637

1738
* `ecr_host` - The hostname of the repository (in the form *aws_account_id.dkr.ecr.region.amazonaws.com*)
1839
* `ecr_repo` - The name of the repository.
1940
* `ecr_repository_url` - The URL of the repository (in the form *aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName*)
2041
* `ecr_repo_rw_policy` - IAM policy in JSON format that grant of rights to manage images.
2142
* `ecr_repo_ro_policy` - IAM policy in JSON format that grant of rights to fetch images.
22-
23-
Example:
24-
```
25-
${module.my_registry.ecr_host}/${module.my_registry.ecr_repo}
26-
```

ecr.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
resource "aws_ecr_repository" "image" {
2-
name = var.name
3-
tags = local.tags
2+
name = var.name
3+
tags = local.tags
4+
image_tag_mutability = local.mutability
5+
image_scanning_configuration {
6+
scan_on_push = local.scan
7+
}
48
}

variables.tf

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,24 @@ variable "tags" {
55
description = "Tags."
66
type = map(string)
77
}
8+
variable "mutable" {
9+
default = true
10+
}
11+
variable "scan" {
12+
default = false
13+
}
814
data "aws_region" "current" {}
915

1016
locals {
11-
name = var.name
12-
region = data.aws_region.current.name
13-
title = title(replace(replace(local.name, "-", ""), " ", ""))
14-
tags = merge({
17+
name = var.name
18+
region = data.aws_region.current.name
19+
title = title(replace(replace(local.name, "-", ""), " ", ""))
20+
mutability = var.mutable ? "MUTABLE" : "IMMUTABLE"
21+
scan = var.scan
22+
tags = merge({
1523
Name = local.name
1624
Module = "ECR Repository"
17-
ModuleVersion = "v0.2.0"
18-
ModuleSrc = "https://github.com/jetbrains-infra/terraform-aws-ecr/"
25+
ModuleVersion = "v0.2.1"
26+
ModuleSource = "https://github.com/jetbrains-infra/terraform-aws-ecr/"
1927
}, var.tags)
2028
}

0 commit comments

Comments
 (0)