Skip to content

Commit 460f74e

Browse files
author
Ben Fortuna
committed
Added examples with ECR import
1 parent 14c562b commit 460f74e

File tree

10 files changed

+76
-10
lines changed

10 files changed

+76
-10
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Created by .ignore support plugin (hsz.mobi)
22
terraform-aws-ecr-repository.iml
33
.terraform/
4+
*.tfvars
5+
*tfstate*

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
SHELL:=/bin/bash
2-
TERRAFORM_VERSION=0.12.24
3-
TERRAFORM=docker run --rm -v "${PWD}:/work" -v "${HOME}:/root" -e AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION) -e http_proxy=$(http_proxy) --net=host -w /work hashicorp/terraform:$(TERRAFORM_VERSION)
2+
TERRAFORM_VERSION=0.13.4
3+
TERRAFORM=docker run --rm -it -v "${PWD}:/work" -v "${HOME}:/root" -e AWS_DEFAULT_REGION=$(AWS_DEFAULT_REGION) -e http_proxy=$(http_proxy) --net=host -w /work hashicorp/terraform:$(TERRAFORM_VERSION)
44

55
TERRAFORM_DOCS=docker run --rm -v "${PWD}:/work" tmknom/terraform-docs
66

@@ -34,7 +34,8 @@ docs: diagram
3434

3535
format:
3636
$(TERRAFORM) fmt -list=true ./ && \
37-
$(TERRAFORM) fmt -list=true ./examples/nginx
37+
$(TERRAFORM) fmt -list=true ./examples/nginx && \
38+
$(TERRAFORM) fmt -list=true ./examples/apachesling
3839

3940
example:
4041
$(TERRAFORM) init examples/$(EXAMPLE) && $(TERRAFORM) plan examples/$(EXAMPLE)

examples/apachesling/main.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module "repository" {
2+
source = "../.."
3+
4+
name = "apache/sling"
5+
scan_on_push = var.scan_on_push
6+
untagged_image_expiry_days = var.untagged_image_expiry_days
7+
}
8+
9+
module "import" {
10+
count = length(var.source_tags)
11+
source = "figurate/docker-container/docker//modules/ecr"
12+
13+
command = ["push", "apache/sling", var.source_tags[count.index]]
14+
depends_on = [module.repository]
15+
rm = false
16+
aws_region = var.aws_region
17+
}

examples/apachesling/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "docker" {
2+
host = "tcp://127.0.0.1:2375/"
3+
}

examples/apachesling/vars.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
variable "scan_on_push" {
2+
description = "Automatically scan pushed images for vulnerabilities"
3+
default = true
4+
}
5+
6+
variable "untagged_image_expiry_days" {
7+
description = "Age (in days) of untagged images to be removed automatically"
8+
type = number
9+
default = 7
10+
}
11+
12+
variable "source_tags" {
13+
description = "A list of tags for image import from external registry"
14+
type = list(string)
15+
default = ["latest"]
16+
}
17+
18+
variable "aws_region" {
19+
description = "AWS region for running ECR commands"
20+
}

examples/apachesling/versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
docker = {
4+
source = "terraform-providers/docker"
5+
version = "~> 2.0"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}

examples/nginx/main.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ module "repository" {
44
name = "nginx"
55
scan_on_push = var.scan_on_push
66
untagged_image_expiry_days = var.untagged_image_expiry_days
7-
import_frequency = var.import_frequency
8-
source_tags = var.source_tags
7+
}
8+
9+
module "import" {
10+
count = length(var.source_tags)
11+
source = "figurate/docker-container/docker//modules/ecr"
12+
13+
command = ["push", "nginx", var.source_tags[count.index]]
14+
depends_on = [module.repository]
15+
rm = false
916
}

examples/nginx/provider.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "docker" {
2+
host = "tcp://127.0.0.1:2375/"
3+
}

examples/nginx/vars.tf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ variable "untagged_image_expiry_days" {
99
default = 7
1010
}
1111

12-
variable "import_frequency" {
13-
description = "Indicates how often to check the source registry for updates (once, weekly, daily, hourly, always)"
14-
default = "daily"
15-
}
16-
1712
variable "source_tags" {
1813
description = "A list of tags for image import from external registry"
1914
type = list(string)

examples/nginx/versions.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
required_providers {
3+
docker = {
4+
source = "terraform-providers/docker"
5+
version = "~> 2.0"
6+
}
7+
}
8+
required_version = ">= 0.13"
9+
}

0 commit comments

Comments
 (0)