Skip to content

Commit f11b827

Browse files
asciimikejmarlena
andauthored
Codespaces makes ECR much easier to access (#23675)
* Adding docs for ECR access * Adding debugging info * Adding note on naming * swapping order on docker login command * Update content/codespaces/codespaces-reference/allowing-your-codespace-to-access-a-private-image-registry.md Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com> * Update content/codespaces/codespaces-reference/allowing-your-codespace-to-access-a-private-image-registry.md Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: jmarlena <6732600+jmarlena@users.noreply.github.com>
1 parent 602fd9a commit f11b827

1 file changed

Lines changed: 29 additions & 3 deletions

File tree

content/codespaces/codespaces-reference/allowing-your-codespace-to-access-a-private-image-registry.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,38 @@ ACR_CONTAINER_REGISTRY_USER = acr-user-here
7474
ACR_CONTAINER_REGISTRY_PASSWORD = <PAT>
7575
```
7676

77-
For information on common image registries, see "[Common image registry servers](#common-image-registry-servers)."
77+
For information on common image registries, see "[Common image registry servers](#common-image-registry-servers)." Note that accessing AWS Elastic Container Registry (ECR) is different.
7878

7979
![Image registry secret example](/assets/images/help/settings/codespaces-image-registry-secret-example.png)
8080

8181
Once you've added the secrets, you may need to stop and then start the codespace you are in for the new environment variables to be passed into the container. For more information, see "[Suspending or stopping a codespace](/codespaces/codespaces-reference/using-the-command-palette-in-codespaces#suspending-or-stopping-a-codespace)."
8282

83+
#### Accessing AWS Elastic Container Registry
84+
85+
To access AWS Elastic Container Registry (ECR), you can provide an AWS access key ID and secret key, and {% data variables.product.prodname_dotcom %} can retrieve an access token for you and log in on your behalf.
86+
87+
```
88+
*_CONTAINER_REGISTRY_SERVER = <ECR_URL>
89+
*_CONTAINER_REGISTRY_USER = <AWS_ACCESS_KEY_ID>
90+
*_container_REGISTRY_PASSWORD = <AWS_SECRET_KEY>
91+
```
92+
93+
You must also ensure you have the appropriate AWS IAM permissions to perform the credential swap (e.g. `sts:GetServiceBearerToken`) as well as the ECR read operation (either `AmazonEC2ContainerRegistryFullAccess` or `ReadOnlyAccess`).
94+
95+
Alternatively, if you don't want GitHub to perform the credential swap on your behalf, you can provide an authorization token fetched via AWS's APIs or CLI.
96+
97+
```
98+
*_CONTAINER_REGISTRY_SERVER = <ECR_URL>
99+
*_CONTAINER_REGISTRY_USER = AWS
100+
*_container_REGISTRY_PASSWORD = <TOKEN>
101+
```
102+
103+
Since these tokens are short lived and need to be refreshed periodically, we recommend providing an access key ID and secret.
104+
105+
While these secrets can have any name, so long as the `*_CONTAINER_REGISTRY_SERVER` is an ECR URL, we recommend using `ECR_CONTAINER_REGISTRY_*` unless you are dealing with multiple ECR registries.
106+
107+
For more information, see AWS ECR's "[Private registry authentication documentation](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html)."
108+
83109
### Common image registry servers
84110

85111
Some of the common image registry servers are listed below:
@@ -90,6 +116,6 @@ Some of the common image registry servers are listed below:
90116
- [AWS Elastic Container Registry](https://docs.aws.amazon.com/AmazonECR/latest/userguide/Registries.html) - `<aws_account_id>.dkr.ecr.<region>.amazonaws.com`
91117
- [Google Cloud Container Registry](https://cloud.google.com/container-registry/docs/overview#registries) - `gcr.io` (US), `eu.gcr.io` (EU), `asia.gcr.io` (Asia)
92118

93-
#### Accessing AWS Elastic Container Registry
119+
## Debugging private image registry access
94120

95-
If you want to access AWS Elastic Container Registry (ECR), you must provide an AWS authorization token in the `ECR_CONTAINER_REGISTRY_PASSWORD`. This authorization token is not the same as your secret key. You can obtain an AWS authorization token by using AWS's APIs or CLI. These tokens are short lived and will need to be refreshed periodically. For more information, see AWS ECR's "[Private registry authentication documentation](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html)."
121+
If you are having trouble pulling an image from a private image registry, make sure you are able to run `docker login -u <user> -p <password> <server>`, using the values of the secrets defined above. If login fails, ensure that the login credentials are valid and that you have the apprioriate permissions on the server to fetch a container image. If login succeeds, make sure that these values are copied appropriately into the right {% data variables.product.prodname_codespaces %} secrets, either at the user, repository, or organization level and try again.

0 commit comments

Comments
 (0)