1
1
#
2
- # Private repositories are created by the following policy .
2
+ # Each private repositories will be pushed the following image tags .
3
3
#
4
- # * us-west-1:
5
- # * pushed tags formatted commit-hash
6
- # * following lifecycle policies
7
- # * against untagged image, expired 30 days after it was pushed
8
- # * against tagged image, no policy
4
+ # * us-west-2:
5
+ # * pushed tags formatted commit-hash & branch-name
6
+ # * ap-northeast-1:
7
+ # * pushed tags formatted commit-hash & semver format
9
8
#
10
9
11
10
locals {
12
- repositories = [
13
- " dreamkast-ecs" ,
14
- " dreamkast-ui" ,
15
- " dreamkast-weaver" ,
16
- " dreamkast-external-scaler" ,
17
- " emtec-ecu/emtectl" ,
18
- " emtec-ecu/server" ,
19
- " seaman" ,
20
- ]
11
+ repositories = {
12
+ " us-west-2" : [
13
+ " dreamkast-ecs" ,
14
+ " dreamkast-ui" ,
15
+ " dreamkast-weaver" ,
16
+ " dreamkast-external-scaler" ,
17
+ " emtec-ecu/emtectl" ,
18
+ " emtec-ecu/server" ,
19
+ " seaman" ,
20
+ ],
21
+ " ap-northeast-1" : [
22
+ " dreamkast-ecs" ,
23
+ " dreamkast-ui" ,
24
+ " dreamkast-weaver" ,
25
+ " seaman" ,
26
+ ],
27
+ }
21
28
}
22
29
30
+ #
31
+ # us-west-2
32
+ #
33
+
23
34
resource "aws_ecr_repository" "us_west_2" {
24
- for_each = toset (local. repositories )
35
+ provider = aws
36
+ for_each = toset (local. repositories . us-west-2 )
25
37
26
38
name = each. key
27
39
image_tag_mutability = " MUTABLE"
@@ -32,7 +44,8 @@ resource "aws_ecr_repository" "us_west_2" {
32
44
}
33
45
34
46
resource "aws_ecr_lifecycle_policy" "us_west_2" {
35
- for_each = toset (local. repositories )
47
+ provider = aws
48
+ for_each = toset (local. repositories . us-west-2 )
36
49
37
50
repository = aws_ecr_repository. us_west_2 [each . key ]. name
38
51
policy = << EOF
@@ -70,7 +83,70 @@ resource "aws_ecr_lifecycle_policy" "us_west_2" {
70
83
EOF
71
84
}
72
85
73
- resource "aws_ecr_pull_through_cache_rule" "ecr_public" {
86
+ resource "aws_ecr_pull_through_cache_rule" "us_west_2" {
87
+ provider = aws
88
+ ecr_repository_prefix = " ecr-public"
89
+ upstream_registry_url = " public.ecr.aws"
90
+ }
91
+
92
+ #
93
+ # asia-northeast-1
94
+ #
95
+
96
+ resource "aws_ecr_repository" "ap_northeast_1" {
97
+ provider = aws. ap-northeast-1
98
+ for_each = toset (local. repositories . ap-northeast-1 )
99
+
100
+ name = each. key
101
+ image_tag_mutability = " MUTABLE"
102
+
103
+ image_scanning_configuration {
104
+ scan_on_push = true
105
+ }
106
+ }
107
+
108
+ resource "aws_ecr_lifecycle_policy" "ap_northeast_1" {
109
+ provider = aws. ap-northeast-1
110
+ for_each = toset (local. repositories . ap-northeast-1 )
111
+
112
+ repository = aws_ecr_repository. ap_northeast_1 [each . key ]. name
113
+ policy = << EOF
114
+ {
115
+ "rules": [
116
+ {
117
+ "rulePriority": 1,
118
+ "description": "Expire untagged images older than 3 days",
119
+ "selection": {
120
+ "tagStatus": "untagged",
121
+ "countType": "sinceImagePushed",
122
+ "countUnit": "days",
123
+ "countNumber": 3
124
+ },
125
+ "action": {
126
+ "type": "expire"
127
+ }
128
+ },
129
+ {
130
+ "rulePriority": 2,
131
+ "description": "Expire images older than 30 days",
132
+ "selection": {
133
+ "tagStatus": "tagged",
134
+ "tagPrefixList": ["commit-"],
135
+ "countType": "sinceImagePushed",
136
+ "countUnit": "days",
137
+ "countNumber": 30
138
+ },
139
+ "action": {
140
+ "type": "expire"
141
+ }
142
+ }
143
+ ]
144
+ }
145
+ EOF
146
+ }
147
+
148
+ resource "aws_ecr_pull_through_cache_rule" "ap_northeast_1" {
149
+ provider = aws. ap-northeast-1
74
150
ecr_repository_prefix = " ecr-public"
75
151
upstream_registry_url = " public.ecr.aws"
76
152
}
0 commit comments