Skip to content

Commit 2070895

Browse files
committed
docs: Add Amazon ECR authentication example
1 parent bd09b46 commit 2070895

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Sources/swift-container-plugin/Documentation.docc/authentication.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,40 @@ machine ghcr.io
5454
login mygithubusername
5555
password ghp_fAOsWl...
5656
```
57+
58+
### Amazon Elastic Container Registry
59+
60+
> Amazon Elastic Container Registry uses [short-lived authorization tokens](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html#registry-auth-token) which expire after 12 hours.
61+
>
62+
> To generate an ECR authentication token, you must [first install the AWS CLI tools.](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
63+
64+
1. Use the `aws` CLI tool to [generate an authentication token](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html#registry-auth-token).
65+
You'll need to know the name of the [AWS region](https://docs.aws.amazon.com/global-infrastructure/latest/regions/aws-regions.html) in which your registry is hosted.
66+
Registries in different AWS regions are separate and require different authentication tokens.
67+
68+
The following command generates a token which can be used with ECR in the `us-west-2` region:
69+
```
70+
aws ecr get-login-password --region us-west-2
71+
```
72+
73+
2. Copy the token and add it to your `.netrc` file.
74+
* The format of the machine name is:
75+
76+
```
77+
<aws_account_id>.dkr.ecr.<region>.amazonaws.com
78+
```
79+
80+
You can [find your AWS account ID](https://docs.aws.amazon.com/accounts/latest/reference/manage-acct-identifiers.html) in the AWS Management Console or by running the following command:
81+
```
82+
aws sts get-caller-identity \
83+
--query Account \
84+
--output text
85+
```
86+
* **The login name must be `AWS`**.
87+
* The token is a large encoded string which is not shown in full in the example.
88+
89+
```
90+
machine 123456789012.dkr.ecr.us-west-2.amazonaws.com
91+
login AWS
92+
password eyJwYXlsb2FkIj...
93+
```

0 commit comments

Comments
 (0)