-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecr.tf
34 lines (30 loc) · 1.27 KB
/
ecr.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
resource aws_ecr_repository "repository" {
name = "${local.resource_prefix.value}-repository"
image_tag_mutability = "MUTABLE"
tags = merge({
Name = "${local.resource_prefix.value}-repository"
}, {
git_commit = "d68d2897add9bc2203a5ed0632a5cdd8ff8cefb0"
git_file = "terraform/aws/ecr.tf"
git_last_modified_at = "2020-06-16 14:46:24"
git_last_modified_by = "[email protected]"
git_modifiers = "nimrodkor"
git_org = "bridgecrewio"
git_repo = "terragoat"
yor_trace = "7a3ec657-fa54-4aa2-8467-5d08d6c90bc2"
})
}
locals {
docker_image = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com/${aws_ecr_repository.repository.name}"
}
resource null_resource "push_image" {
provisioner "local-exec" {
working_dir = "${path.module}/resources"
command = <<BASH
aws ecr get-login-password --region ${var.region} | docker login --username AWS --password-stdin ${data.aws_caller_identity.current.account_id}.dkr.ecr.${var.region}.amazonaws.com
docker build -t ${aws_ecr_repository.repository.name} .
docker tag ${aws_ecr_repository.repository.name} ${local.docker_image}
docker push ${local.docker_image}
BASH
}
}