Repository navigation
feat(infra): an ECR repo for the buildkit layer cache - #405
Merged
Merged
Conversation
The Actions cache is a shared 10 GB budget and buildkit's type=gha,mode=max layer cache (~5 GB measured) is its largest producer — the thing rust.yml's cache-prune exists to cap. Same move sccache made: a registry backend with no shared budget. Its own repo because the image repos are IMMUTABLE (a cache ref is overwritten every push) with a last-30-of-any lifecycle that fits images, not orphan-producing cache pushes; scan_on_push off because the layers are scanned on push to their real repos. Sequence (the sccache lesson, recorded in the file): apply this, THEN point images.yml at it. Co-Authored-By: Claude Fable 5 <[email protected]>
Contributor
terraform plan
core — 2 to add, 1 to changemodule.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Read complete after 0s [id=2395007408]
data.aws_iam_policy_document.ci_tf_drift_refresh: Read complete after 0s [id=2350222434]
data.aws_iam_policy_document.sccache_read: Reading...
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
data.aws_iam_policy_document.sccache_write: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
data.aws_iam_policy_document.cur_delivery: Reading...
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.config_bucket: Reading...
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.ci_tf_drift_trust: Reading...
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_drift_trust: Read complete after 0s [id=2357770959]
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 0s [id=us-east-2]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 0s [id=b17b2500-e0b1-7046-405b-23c088cf392b]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
~ update in-place
<= read (data resources)
Terraform will perform the following actions:
# aws_ecr_lifecycle_policy.buildcache will be created
+ resource "aws_ecr_lifecycle_policy" "buildcache" {
+ id = (known after apply)
+ policy = jsonencode(
{
+ rules = [
+ {
+ action = {
+ type = "expire"
}
+ description = "Expire orphaned cache manifests after a day"
+ rulePriority = 1
+ selection = {
+ countNumber = 1
+ countType = "sinceImagePushed"
+ countUnit = "days"
+ tagStatus = "untagged"
}
},
+ {
+ action = {
+ type = "expire"
}
+ description = "Backstop: never hold more than 10 cache images"
+ rulePriority = 2
+ selection = {
+ countNumber = 10
+ countType = "imageCountMoreThan"
+ tagStatus = "any"
}
},
]
}
)
+ region = "us-east-2"
+ registry_id = (known after apply)
+ repository = "er-buildcache"
}
# aws_ecr_repository.buildcache will be created
+ resource "aws_ecr_repository" "buildcache" {
+ arn = (known after apply)
+ id = (known after apply)
+ image_tag_mutability = "MUTABLE"
+ name = "er-buildcache"
+ region = "us-east-2"
+ registry_id = (known after apply)
+ repository_url = (known after apply)
+ tags_all = {
+ "Environment" = "core"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ encryption_configuration {
+ encryption_type = "AES256"
+ kms_key = (known after apply)
}
+ image_scanning_configuration {
+ scan_on_push = false
}
}
# module.github_oidc.data.aws_iam_policy_document.push will be read during apply
# (config refers to values not yet known)
<= data "aws_iam_policy_document" "push" {
+ id = (known after apply)
+ json = (known after apply)
+ minified_json = (known after apply)
+ statement {
+ actions = [
+ "ecr:GetAuthorizationToken",
]
+ effect = "Allow"
+ resources = [
+ "*",
]
+ sid = "EcrAuth"
}
+ statement {
+ actions = [
+ "ecr:BatchCheckLayerAvailability",
+ "ecr:BatchGetImage",
+ "ecr:CompleteLayerUpload",
+ "ecr:DescribeImages",
+ "ecr:DescribeRepositories",
+ "ecr:GetDownloadUrlForLayer",
+ "ecr:InitiateLayerUpload",
+ "ecr:PutImage",
+ "ecr:UploadLayerPart",
]
+ effect = "Allow"
+ resources = [
+ "arn:aws:ecr:us-east-2:797781631727:repository/er-api",
+ "arn:aws:ecr:us-east-2:797781631727:repository/er-pipeline",
+ "arn:aws:ecr:us-east-2:797781631727:repository/er-web",
+ (known after apply),
]
+ sid = "EcrPushPull"
}
}
# module.github_oidc.aws_iam_role_policy.push will be updated in-place
~ resource "aws_iam_role_policy" "push" {
id = "er-ci-ecr-push:ecr-push"
name = "ecr-push"
~ policy = jsonencode(
{
- Statement = [
- {
- Action = "ecr:GetAuthorizationToken"
- Effect = "Allow"
- Resource = "*"
- Sid = "EcrAuth"
},
- {
- Action = [
- "ecr:UploadLayerPart",
- "ecr:PutImage",
- "ecr:InitiateLayerUpload",
- "ecr:GetDownloadUrlForLayer",
- "ecr:DescribeRepositories",
- "ecr:DescribeImages",
- "ecr:CompleteLayerUpload",
- "ecr:BatchGetImage",
- "ecr:BatchCheckLayerAvailability",
]
- Effect = "Allow"
- Resource = [
- "arn:aws:ecr:us-east-2:797781631727:repository/er-web",
- "arn:aws:ecr:us-east-2:797781631727:repository/er-pipeline",
- "arn:aws:ecr:us-east-2:797781631727:repository/er-api",
]
- Sid = "EcrPushPull"
},
]
- Version = "2012-10-17"
}
) -> (known after apply)
# (2 unchanged attributes hidden)
}
Plan: 2 to add, 1 to change, 0 to destroy.
|
athvin
added a commit
that referenced
this pull request
Nov 2, 2026
The gha backend's ~5 GB mode=max cache was the largest producer in the shared 10 GB Actions budget — the thing cache-prune exists to cap. Both image builds now cache-to er-buildcache (terraform #405), with image-manifest=true,oci-mediatypes=true because ECR rejects buildkit's default cache-manifest media type. The gha line survives as a transitional cache-FROM only, so the first registry run starts warm; cache-to stops feeding the Actions cache immediately. cache-prune's comment now records that both of its budgets are rollback insurance. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Terraform half of the buildkit-cache move build-cost.md has prescribed since the sccache migration ("the structural fix for buildkit is the same shape as sccache's"). A dedicated
er-buildcacherepo because the image repos can't host it: they're IMMUTABLE (a registry cache ref is overwritten on every push) and their last-30-of-any lifecycle fits images, not the orphaned manifests every cache push produces (here: expire-untagged-after-1-day + a count backstop).scan_on_pushoff — the layers are scanned on push to their real repos. The existinger-ci-ecr-pushrole covers it via the ARN list.Workflow half (
images.ymlcache-to: type=registry) follows in its own PR after the unattended apply creates the repo — the exact sequencing sccache.tf documents.🤖 Generated with Claude Code