Workaround to get AWS ECR working in Coder / example of scripting with the Coder REST API.
Run this script (in a cron operation) to update your registry in Coder with the latest ECR password. It also edits the registry name to include the date, so it is easy to debug if/when the script failed. Comment/edit that line to keep your existing registry name.
Coder currently only supports password-based authentication to registries. AWS ECR can generate a password token but it only lasts 12 hours. This script, if ran in a cron operation, will update the Coder registry with the latest password. (username should remain as AWS
).
-
Coder API Token (create one here)
-
AWS CLI authenticated on this machine/runner (it uses the
aws ecr get-login-password
command) -
These values. Set inside the script or as env vars:
CODER_URL
(ex. "https://coder.yoursite.com")
CODER_API_TOKEN
(get it with coder-cli):
$ coder tokens create ecr-sync
CODER_ORG_ID
(visit this coder when you are logged in):
https://coder.yoursite.com/api/v0/orgs
CODER_REGISTRY_ID
(visit this coder when you are logged in):
https://coder.yoursite.com/api/v0/registries?org={orgid}