feat(ecr): migrate IAM to infrastructure/aws/iam/ecr module#372
Merged
Conversation
Cross-account ECR pull is now managed as a first-class IAM role in infrastructure/aws/iam/ecr, following the same pattern as external_dns and agent IAM modules. This decouples AWS permission management from nullplatform_provider_config.ecr, avoiding the ignore_changes drift issue. The nullplatform/asset/ecr module no longer embeds repository policies in provider config attributes — enable_cross_account_pull and repository_policy_pull_accounts variables are removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Remove unused aws_caller_identity data source from nullplatform/asset/ecr - Delete empty locals.tf from nullplatform/asset/ecr - Add enable_cross_account_pull bool (default false) to infrastructure/aws/iam/ecr - Make pull_account_ids optional (default []) - Gate all IAM resources behind enable_cross_account_pull with count Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… is enabled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Move all IAM resources (application role, ECR manager policy, build workflow user and access key) from nullplatform/asset/ecr/iam.tf to infrastructure/aws/iam/ecr, following the same layer separation as external_dns and agent modules. nullplatform/asset/ecr now receives IAM values as input variables and only manages the nullplatform_provider_config resource. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
davidf-null
approved these changes
May 28, 2026
Replaces aws_iam_user_policy_attachment with an IAM group + group policy attachment + user group membership, satisfying Trivy AWS-0143. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Comment on lines
+60
to
+62
| resource "aws_iam_group" "nullplatform_ecr_managers" { | ||
| name = "nullplatform-${var.cluster_name}-ecr-managers" | ||
| } |
Collaborator
Author
There was a problem hiding this comment.
Won't fix / acknowledged. This group is exclusively for a CI/CD build workflow user that authenticates via programmatic access keys (no console login). MFA enforcement at the group level would require the access key to call sts:GetSessionToken with an MFA token on every CI run, which is not compatible with standard CI/CD pipelines. The attack surface is already minimized: the user has a scoped policy limited to ECR operations only.
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.
Summary
infrastructure/aws/iam/ecrmodule following the same layer separation asexternal_dnsandagentIAM modulesnullplatform/asset/ecr/iam.tfinto the new IAM moduleenable_cross_account_pull+pull_account_idsvariablesnullplatform/asset/ecrnow only managesnullplatform_provider_configand receives IAM values as input variablesWhy
IAM resources (AWS layer) were mixed inside a NullPlatform-layer module. This blocked tracking
repository_policy_pull_accountschanges becausenullplatform_provider_config.ecrrequiresignore_changes = [attributes]to prevent drift from agent mutations. By owning IAM in the infrastructure layer, Terraform tracks all AWS permission changes correctly without workarounds.Migration notes
Existing deployments require
tofu state mvfor the 6 IAM resources before applying:Test plan
tofu planshows 0 destroy afterstate mvtofu applycreates only new cross-account IAM resourcestofu planshows no drift onnullplatform_provider_config.ecr🤖 Generated with Claude Code