@@ -2,19 +2,11 @@ locals {
22 services = [
33 " pycon-backend" ,
44 " pycon-backend/cache" ,
5- " pycon-frontend" ,
6- " pycon-frontend/cache" ,
75 " pretix" ,
86 " pretix/cache" ,
97 ]
10- infrastructure_tools_account_id = [
11- for account in data . aws_organizations_organization . organization . non_master_accounts :
12- account . id
13- if account . name == " Infrastructure Tools"
14- ][0 ]
158}
169
17- data "aws_organizations_organization" "organization" {}
1810
1911resource "aws_ecr_repository" "service_repo" {
2012 for_each = toset (local. services )
@@ -25,35 +17,3 @@ resource "aws_ecr_repository" "service_repo" {
2517 scan_on_push = false
2618 }
2719}
28-
29- data "aws_iam_policy_document" "access_from_infrastructure_account" {
30- statement {
31- sid = " access from infrastructure account"
32- effect = " Allow"
33-
34- principals {
35- type = " AWS"
36- identifiers = [local . infrastructure_tools_account_id ]
37- }
38-
39- actions = [
40- " ecr:GetDownloadUrlForLayer" ,
41- " ecr:BatchGetImage" ,
42- " ecr:BatchCheckLayerAvailability" ,
43- " ecr:PutImage" ,
44- " ecr:InitiateLayerUpload" ,
45- " ecr:UploadLayerPart" ,
46- " ecr:CompleteLayerUpload" ,
47- " ecr:DescribeRepositories" ,
48- " ecr:GetRepositoryPolicy" ,
49- " ecr:ListImages" ,
50- " ecr:BatchDeleteImage" ,
51- ]
52- }
53- }
54-
55- resource "aws_ecr_repository_policy" "access_from_infrastructure_account" {
56- for_each = toset (local. services )
57- repository = aws_ecr_repository. service_repo [each . key ]. name
58- policy = data. aws_iam_policy_document . access_from_infrastructure_account . json
59- }
0 commit comments