-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker_images.tf
83 lines (74 loc) · 2.09 KB
/
docker_images.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
data "aws_ecr_authorization_token" "token" {}
provider "docker" {
registry_auth {
address = format("%v.dkr.ecr.%v.amazonaws.com", data.aws_caller_identity.this.account_id, var.region)
username = data.aws_ecr_authorization_token.token.user_name
password = data.aws_ecr_authorization_token.token.password
}
}
#
# analytics lambda container
#
data "external" "analytics_lambda_source_hash" {
program = ["python", "./lambda/analytics/docker_prep.py"]
working_dir = path.module
}
module "docker_image_analytics_lambda" {
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
create_ecr_repo = true
ecr_repo = "sbeacon-analytics-lambda-containers"
ecr_repo_lifecycle_policy = jsonencode({
"rules" : [
{
"rulePriority" : 1,
"description" : "Keep only the last 1 images",
"selection" : {
"tagStatus" : "any",
"countType" : "imageCountMoreThan",
"countNumber" : 1
},
"action" : {
"type" : "expire"
}
}
]
})
use_image_tag = false
source_path = "${path.module}/lambda/analytics"
triggers = {
dir_sha = data.external.analytics_lambda_source_hash.result.hash
}
}
#
# askbeacon lambda container
#
data "external" "askbeacon_lambda_source_hash" {
program = ["python", "./lambda/askbeacon/docker_prep.py"]
working_dir = path.module
}
module "docker_image_askbeacon_lambda" {
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
create_ecr_repo = true
ecr_repo = "sbeacon-askbeacon-lambda-containers"
ecr_repo_lifecycle_policy = jsonencode({
"rules" : [
{
"rulePriority" : 1,
"description" : "Keep only the last 1 images",
"selection" : {
"tagStatus" : "any",
"countType" : "imageCountMoreThan",
"countNumber" : 1
},
"action" : {
"type" : "expire"
}
}
]
})
use_image_tag = false
source_path = "${path.module}/lambda/askbeacon"
triggers = {
dir_sha = data.external.askbeacon_lambda_source_hash.result.hash
}
}