Skip to content

Commit e9d3156

Browse files
committed
DRIVERS-2945 AWS EKS Pod Identity
1 parent f4c0bbd commit e9d3156

File tree

2 files changed

+42
-5
lines changed

2 files changed

+42
-5
lines changed

source/auth/auth.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,8 @@ The order in which Drivers MUST search for credentials is:
10091009
2. Environment variables
10101010
3. A custom AWS credential provider if the driver supports it.
10111011
4. Using `AssumeRoleWithWebIdentity` if `AWS_WEB_IDENTITY_TOKEN_FILE` and `AWS_ROLE_ARN` are set.
1012-
5. The ECS endpoint if `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` is set. Otherwise, the EC2 endpoint.
1012+
5. The EKS endpoint if `AWS_CONTAINER_CREDENTIALS_FULL_URI` and `AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE` are set.
1013+
6. The ECS endpoint if `AWS_CONTAINER_CREDENTIALS_RELATIVE_URI` is set. Otherwise, the EC2 endpoint.
10131014

10141015
> [!NOTE]
10151016
> See *Should drivers support accessing Amazon EC2 instance metadata in Amazon ECS* in [Q & A](#q-and-a)
@@ -1099,6 +1100,33 @@ The JSON response from the STS endpoint will contain credentials in this format:
10991100

11001101
Note that the token is called `SessionToken` and not `Token` as it would be with other credential responses.
11011102

1103+
##### EKS endpoint
1104+
1105+
If a username and password are not provided and the aforementioned environment variables are not set and
1106+
`AWS_CONTAINER_CREDENTIALS_FULL_URI` and `AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE` are set, then drivers MUST use the
1107+
Amazon EKS Pod Identity endpoint to get the credentials. Drivers SHOULD enforce a 10 second read timeout while waiting
1108+
for incoming content.
1109+
1110+
The "Authorization" header value for the request is obtained by reading the contents of the file given by
1111+
`AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE`.
1112+
1113+
Querying the URI will return the JSON response:
1114+
1115+
```javascript
1116+
{
1117+
"AccessKeyId": <access_key>,
1118+
"Expiration": <date>,
1119+
"SecretAccessKey": <secret_access_key>,
1120+
"Token": <security_token>
1121+
"AccountId": <aws_account_id>
1122+
}
1123+
```
1124+
1125+
```bash
1126+
$ TOKEN=$(cat $AWS_CONTAINER_AUTHORIZATION_TOKEN_FILE)
1127+
$ curl -H Authorization:$TOKEN $AWS_CONTAINER_CREDENTIALS_FULL_URI
1128+
```
1129+
11021130
##### ECS endpoint
11031131

11041132
If a username and password are not provided and the aforementioned environment variables are not set, drivers MUST query

source/auth/tests/mongodb-aws.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ Drivers MUST test the following scenarios:
55
1. `Regular Credentials`: Auth via an `ACCESS_KEY_ID` and `SECRET_ACCESS_KEY` pair
66
2. `EC2 Credentials`: Auth from an EC2 instance via temporary credentials assigned to the machine
77
3. `ECS Credentials`: Auth from an ECS instance via temporary credentials assigned to the task
8-
4. `Assume Role`: Auth via temporary credentials obtained from an STS AssumeRole request
9-
5. `Assume Role with Web Identity`: Auth via temporary credentials obtained from an STS AssumeRoleWithWebIdentity
8+
4. `EKS Credentials`: Auth from an EKS instance via temporary credentials assigned to the pod
9+
5. `Assume Role`: Auth via temporary credentials obtained from an STS AssumeRole request
10+
6. `Assume Role with Web Identity`: Auth via temporary credentials obtained from an STS AssumeRoleWithWebIdentity
1011
request
11-
6. `AWS Lambda`: Auth via environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`.
12-
7. Caching of AWS credentials fetched by the driver.
12+
7. `AWS Lambda`: Auth via environment variables `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN`.
13+
8. Caching of AWS credentials fetched by the driver.
1314

1415
For brevity, this section gives the values `<AccessKeyId>`, `<SecretAccessKey>` and `<Token>` in place of a valid access
1516
key ID, secret access key and session token (also known as a security token). Note that if these values are passed into
@@ -66,6 +67,14 @@ mongodb://localhost/?authMechanism=MONGODB-AWS
6667
> No username, password or session token is passed into the URI. Drivers MUST query the ECS container endpoint to obtain
6768
> these credentials.
6869
70+
## EKS Credentials
71+
72+
Drivers MUST be able to authenticate from an EKS pod via temporary credentials. A sample URI in an EKS pod would be:
73+
74+
```text
75+
mongodb://mongodb-1234:27017/?authMechanism=MONGODB-AWS
76+
```
77+
6978
## AssumeRole
7079

7180
Drivers MUST be able to authenticate using temporary credentials returned from an assume role request. These temporary

0 commit comments

Comments
 (0)