-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathecr.tf
38 lines (31 loc) · 1018 Bytes
/
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
35
36
37
38
### ------------------------------
### Create ECR repo
### ------------------------------
resource "aws_ecr_repository" "repo" {
name = "${var.prefix}-ecr-demo"
image_tag_mutability = "MUTABLE"
image_scanning_configuration {
scan_on_push = true
}
force_delete = true
}
### -------------------------------------------
### Push sample container image
### - This runs in local machine environment.
### - Therefore, this demo won't work in TFC
### --------------------------------------------
resource "null_resource" "frontend" {
triggers = {
file_content_md5 = md5(file("${path.module}/dockerbuild.sh"))
}
provisioner "local-exec" {
command = "sh ${path.module}/dockerbuild.sh"
environment = {
AWS_REGION = local.region
AWS_ACCOUNT_ID = data.aws_caller_identity.current.account_id
REPO_URL = aws_ecr_repository.repo.repository_url
CONTAINER_NAME = "${var.prefix}-hello-world"
}
}
depends_on = [aws_ecr_repository.repo]
}