Oci login rotated credentials test - #1780
Conversation
|
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement Learn more about why HashiCorp requires a CLA and what the CLA includes 1 out of 2 committers have signed the CLA.
Have you signed the CLA already but the status is still pending? Recheck it. |
|
This issue is also encountered in a CI/CD pipeline using separate plan and apply jobs (GitLab CI with OpenTofu 1.11), authenticating to Azure Container Registry via workload identity to pull Helm charts from a private OCI registry. Every available workaround has been attempted:
Observed behavior
ImpactThis is blocking the migration from static long-lived credentials to short-lived identity-based tokens. Any update on when this fix might be merged and released would be appreciated. |
|
@rigalGit — Could this PR get a review? It addresses a critical bug affecting multiple open issues (#1493, #1645, #1660) where OCI registry authentication fails during The PR has been open for over 2 months with no review activity. It may need a rebase — happy to help if the author is unavailable. |
|
I have signed the CLA multiple times but this #1780 (comment) doesn't get updated. This should be the one that counts: #1780 (comment) |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
No. This PR restores correct handling of user-supplied registry credentials on the
helm_releaseUpdate path and adds a test that exercisesit; it does not introduce or modify access controls, encryption, or logging.
Description
Fixes a regression introduced in the 3.0.0 plugin-framework rewrite where
helm_release.Updatepassesrepository_username/repository_passwordfrom the prior state toOCIRegistryLogininstead of from the current plan.For registries that issue short-lived tokens (AWS Public ECR via
data.aws_ecrpublic_authorization_token, Azure ACR, etc.), thestate-stored token has typically expired by the next
terraform apply. The login call then fails with401/403even though the user'sconfiguration already contains a fresh token — the fresh token simply never reaches the login call. Create, ModifyPlan, and the
helm_templatedata source were already reading from plan/config and were not affected.Changes:
helm/resource_helm_release.go— inUpdate, passplan.Repository/plan.Chart/plan.RepositoryUsername/plan.RepositoryPasswordtoOCIRegistryLogininstead of thestate.*equivalents. One-line behavioral fix, cherry-picked from Fix repository authentication when updating a helm_release with temporary credentials #1687 withKevin Frommelt as author.
helm/resource_helm_release_test.go— new acceptance testTestAccResourceRelease_OCI_login_rotated_credentialsthat reproduces theregression end-to-end. It starts the existing Docker-based OCI registry with auth, applies a release with one set of credentials, swaps the
registry's htpasswd between steps to simulate token rotation, then applies an Update with the new credentials and a changed
setvalue.Also adds a small
rotateOCIRegistryCredentialshelper (usesdocker cp; the distribution registry re-reads htpasswd per request so norestart is needed) and extends
setupOCIRegistryto return the container name.helm/testdata/oci_registry/auth2.htpasswd— new fixture (hashicorp2:terraform2, bcrypt) used by the rotation step of the test.Verified: without the Update-path fix the new test fails at Step 2 with an OCI login error; with the fix it passes.
go vet ./helm/...andgofmtare clean.Acceptance tests
Release Note