File tree Expand file tree Collapse file tree 5 files changed +58
-4
lines changed Expand file tree Collapse file tree 5 files changed +58
-4
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,9 @@ aws-assumed-role/
3636** /.module /
3737** /.helmfile /
3838
39+ # We pull account-map from a remote repository in Github Actions
40+ # However, we want to locally to validate tflint
41+ account-map /
3942
4043# Draft or auto-saved version
4144# Note that the leading "**/" appears necessary for Docker even if not for Git
Original file line number Diff line number Diff line change 1+ locals {
2+ enabled = module. this . enabled
3+ }
4+
15module "full_access" {
26 source = " ../account-map/modules/roles-to-principals"
37
@@ -15,7 +19,7 @@ module "readonly_access" {
1519}
1620
1721locals {
18- ecr_user_arn = join (" " , aws_iam_user. ecr . * . arn )
22+ ecr_user_arn = join (" " , aws_iam_user. ecr [ * ] . arn )
1923}
2024
2125module "ecr" {
@@ -35,3 +39,21 @@ module "ecr" {
3539
3640 context = module. this . context
3741}
42+
43+ data "aws_secretsmanager_secret" "cache_credentials" {
44+ for_each = local. enabled ? {
45+ for key , rule in var . pull_through_cache_rules :
46+ key = > rule.secret
47+ if length (rule. secret ) > 0
48+ } : {}
49+
50+ name = each. value
51+ }
52+
53+ resource "aws_ecr_pull_through_cache_rule" "this" {
54+ for_each = local. enabled ? var. pull_through_cache_rules : {}
55+
56+ ecr_repository_prefix = each. key
57+ upstream_registry_url = each. value . registry
58+ credential_arn = length (each. value . secret ) > 0 ? data. aws_secretsmanager_secret . cache_credentials [each . key ]. arn : null
59+ }
Original file line number Diff line number Diff line change @@ -14,16 +14,16 @@ output "ecr_repo_url_map" {
1414}
1515
1616output "ecr_user_name" {
17- value = join (" " , aws_iam_user. ecr . * . name )
17+ value = join (" " , aws_iam_user. ecr [ * ] . name )
1818 description = " ECR user name"
1919}
2020
2121output "ecr_user_arn" {
22- value = join (" " , aws_iam_user. ecr . * . arn )
22+ value = join (" " , aws_iam_user. ecr [ * ] . arn )
2323 description = " ECR user ARN"
2424}
2525
2626output "ecr_user_unique_id" {
27- value = join (" " , aws_iam_user. ecr . * . unique_id )
27+ value = join (" " , aws_iam_user. ecr [ * ] . unique_id )
2828 description = " ECR user unique ID assigned by AWS"
2929}
Original file line number Diff line number Diff line change @@ -58,3 +58,12 @@ variable "principals_lambda" {
5858 description = " Principal account IDs of Lambdas allowed to consume ECR"
5959 default = []
6060}
61+
62+ variable "pull_through_cache_rules" {
63+ type = map (object ({
64+ registry = string
65+ secret = optional (string , " " )
66+ }))
67+ description = " Map of pull through cache rules to configure"
68+ default = {}
69+ }
You can’t perform that action at this time.
0 commit comments