Skip to content

Commit 4272dcd

Browse files
committed
docs: Explain how to provide ECR credentials in environment variables
1 parent 49f92be commit 4272dcd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ The following examples show how to set up the plugin for some popular registry p
2424
### Docker Hub
2525

2626
> Don't use your Docker Hub account password to push and pull images.
27-
> Create a Personal Access Token, which has restricted privileges, for each integration you use.
27+
> Create a Personal Access Token, which has restricted privileges, for each integration you use.
2828
> By using separate tokens, you can monitor them independently and revoke one at any time.
2929
To create a `.netrc` entry for Docker Hub:
3030

@@ -69,6 +69,32 @@ machine ghcr.io
6969
>
7070
> 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)
7171
72+
#### Using environment variables
73+
74+
Environment variables are a convenient way to store short-lived credentials.
75+
76+
1. **Remove any existing ECR credentials from your `.netrc` file.** If any entries in `.netrc` match your ECR registry hostname, these will be used in preference to the credentials in environment variables.
77+
78+
2. Set the ECR username.
79+
80+
**The login name must be `AWS`**.
81+
82+
```
83+
export CONTAINERTOOL_DEFAULT_USERNAME=AWS
84+
```
85+
86+
3. Use the `aws` CLI tool to [generate an authentication token](https://docs.aws.amazon.com/AmazonECR/latest/userguide/registry_auth.html#registry-auth-token).
87+
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.
88+
Registries in different AWS regions are separate and require different authentication tokens.
89+
90+
For example, the following command generates a token for ECR in the `us-west-2` region:
91+
92+
```
93+
export CONTAINERTOOL_DEFAULT_PASSWORD=$(aws ecr get-login-password --region us-west-2)
94+
```
95+
96+
#### Using the netrc file
97+
7298
To create a `.netrc` entry for Amazon Elastic Container Registry:
7399
74100
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).

0 commit comments

Comments
 (0)