Skip to content

feat: Remove AWS key and use ECR passwords for docker login [Ubuntu 24] - #171

Merged
sangamcse merged 4 commits into
ProblemSetters:2404from
dhairya-hackerrank:2404-ecr
Aug 31, 2026
Merged

feat: Remove AWS key and use ECR passwords for docker login [Ubuntu 24]#171
sangamcse merged 4 commits into
ProblemSetters:2404from
dhairya-hackerrank:2404-ecr

Conversation

@dhairya-hackerrank

@dhairya-hackerrank dhairya-hackerrank commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Removes the embedded AWS access key/secret from Blackbox’s ECR login flow.

ECR passwords are now supplied by the host through a read-only token handoff directory, instead of being generated inside Blackbox with static AWS credentials.

Changes

  • Adds BLACKBOX_ECR_TOKEN_DIR (default: /run/hackerrank/devops-ecr).
  • Adds shared helpers to:
    • read non-empty private-password / public-password files;
    • log Docker in as both root and BLACKBOX_USER_NAME.
  • Uses the host-provided private ECR password as a required dependency: provisioning fails clearly if it is unavailable.
  • Keeps public ECR login best-effort for backward compatibility; a failure only warns because some existing questions still pull public images.
  • Mounts the token directory read-only into spawned check containers across the abstract, AWS, Ansible AWS, and Terraform AWS flows, so nested Docker/Kubernetes provisioning can authenticate too.
  • Retains awscli provisioning temporarily because AWS-related modules still rely on its LocalStack shim and placeholder environment setup; it is no longer used to obtain ECR credentials.
  • Documents the new token helper behavior and failure modes.

Reviewer notes

The host must publish complete token files atomically in the configured directory. Blackbox reads the token before logging out any baked Docker credential, avoiding a misleading expired-token pull failure when the host handoff is missing.

Signed-off-by: DhairyaMajmudar <dhairya.opensource@gmail.com>
@sangamcse
sangamcse requested review from sangamcse and ya-developer and removed request for sangamcse August 28, 2026 10:29

@sangamcse sangamcse left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dhairya-hackerrank, can you check these comments? Rest looks good

Comment thread framework/inventory.framework Outdated
Comment thread framework/inventory.framework Outdated
Comment thread framework/inventory.framework Outdated
Comment thread framework/inventory.framework Outdated
Signed-off-by: dhairya-majmudar <dhairya.majmudar@hackerrank.com>
Signed-off-by: dhairya-majmudar <dhairya.majmudar@hackerrank.com>
Comment thread framework/inventory.framework Outdated
Comment on lines +271 to +281
while true; do
if token=$(cat "${BLACKBOX_ECR_TOKEN_DIR}/${name}" 2>/dev/null) && [ -n "$token" ]; then
printf "%s" "$token"
return 0
fi

(( waited < wait_seconds )) || break

sleep "$interval_seconds"
waited=$(( waited + interval_seconds ))
done

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry is also not required after our internal service change. We can keep a PR ready, and once the internal service is released, we can check it in sanity. then remove it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, done removed retry logic

@sangamcse

Copy link
Copy Markdown
Contributor

@ya-developer, we are changing the way we are currently using AWS secrets for Docker login. Instead of hardcoding the Secrets in this repo, we will be creating ECR passwords from our internal service and handing off the workspace. Blackbox will use those ECR passwords for Docker login from here. Can you please review this?

Signed-off-by: dhairya-majmudar <dhairya.majmudar@hackerrank.com>
@dhairya-hackerrank dhairya-hackerrank changed the title feat: Remove AWS key and use ECR passwords for docker login feat: Remove AWS key and use ECR passwords for docker login [Ubuntu 24] Aug 31, 2026

@ya-developer ya-developer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants