Skip to content

Commit

Permalink
feat: Allow specifying 'scan' and 'mutability' options
Browse files Browse the repository at this point in the history
  • Loading branch information
sugdyzhekov committed Jul 20, 2020
1 parent 33f6360 commit d5f72d3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 15 deletions.
30 changes: 23 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,39 @@ Terraform module to create AWS ECR repository.

## Usage

Minimal params:
```hcl
module "my_registry" {
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.2.1"
name = "blinchik"
tags = {
Owner = "Don John",
Project = "Alice"
Customer = "Umbrella Corp."
}
}
```

All options with default values:
```hcl
module "my_registry" {
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.1.0"
source = "github.com/jetbrains-infra/terraform-aws-ecr?ref=v0.2.1"
name = "blinchik"
project = "FooBar"
scan = false
mutable = true
tags = {
Owner = "Don John",
Project = "Alice"
Customer = "Umbrella Corp."
}
}
```


## Outputs

* `ecr_host` - The hostname of the repository (in the form *aws_account_id.dkr.ecr.region.amazonaws.com*)
* `ecr_repo` - The name of the repository.
* `ecr_repository_url` - The URL of the repository (in the form *aws_account_id.dkr.ecr.region.amazonaws.com/repositoryName*)
* `ecr_repo_rw_policy` - IAM policy in JSON format that grant of rights to manage images.
* `ecr_repo_ro_policy` - IAM policy in JSON format that grant of rights to fetch images.

Example:
```
${module.my_registry.ecr_host}/${module.my_registry.ecr_repo}
```
8 changes: 6 additions & 2 deletions ecr.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
resource "aws_ecr_repository" "image" {
name = var.name
tags = local.tags
name = var.name
tags = local.tags
image_tag_mutability = local.mutability
image_scanning_configuration {
scan_on_push = local.scan
}
}
20 changes: 14 additions & 6 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,24 @@ variable "tags" {
description = "Tags."
type = map(string)
}
variable "mutable" {
default = true
}
variable "scan" {
default = false
}
data "aws_region" "current" {}

locals {
name = var.name
region = data.aws_region.current.name
title = title(replace(replace(local.name, "-", ""), " ", ""))
tags = merge({
name = var.name
region = data.aws_region.current.name
title = title(replace(replace(local.name, "-", ""), " ", ""))
mutability = var.mutable ? "MUTABLE" : "IMMUTABLE"
scan = var.scan
tags = merge({
Name = local.name
Module = "ECR Repository"
ModuleVersion = "v0.2.0"
ModuleSrc = "https://github.com/jetbrains-infra/terraform-aws-ecr/"
ModuleVersion = "v0.2.1"
ModuleSource = "https://github.com/jetbrains-infra/terraform-aws-ecr/"
}, var.tags)
}

0 comments on commit d5f72d3

Please sign in to comment.