Skip to content

Commit 5f40461

Browse files
authored
Merge pull request #1631 from naveenpaul1/sts-minikube-doc
STS | Update doc for AWS STS minikube set up
2 parents eba832e + a57e6e7 commit 5f40461

File tree

1 file changed

+46
-34
lines changed

1 file changed

+46
-34
lines changed

doc/dev_guide/create_aws_sts_setup_on_minikube.md

Lines changed: 46 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -81,36 +81,10 @@ ls -al
8181

8282
Note: every time you do `minikube delete` and `minikube start` you will need to create this new file (and the 2 files that are described in next steps).
8383

84-
### Creating AWS resources manually - Using the Amazon web console:
85-
7. Create s3 bucket (you already did it in the step Initial Setup - Create S3 Bucket).
86-
87-
8. Create Identity Provider: IAM → Identity providers → Add provider → Provider type: choose OpenID Connect → Provider URL: paste the value of OPENID_BUCKET_URL → click on `Get thumbprint`` → Audience: api (type api in the field) → Click on add provider.
88-
89-
9. Create role: IAM &rarr; Roles &rarr; Create Role &rarr; Trusted entity type: Web Identity &rarr; Identity Provider should be the name of the provider that we added (with structure: https://<oidc_bucket_name>.s3.<aws_region>.amazonaws.com ) &rarr; Add the permission: `AmazonS3FullAccess`.
90-
91-
When you finish, check in the Trusted entities that you see:
92-
93-
```json
94-
"Principal": {
95-
"Federated": "arn:aws:iam::<account-id>:oidc-provider/<oidc-bucket-name>.s3.<region>.amazonaws.com"
96-
},
97-
"Action": "sts:AssumeRoleWithWebIdentity",
98-
"Condition": {
99-
"StringEquals": {
100-
"<oidc-bucket-name>.s3.<region>.amazonaws.com:aud": "api"
101-
}
102-
```
103-
104-
10. In later steps you will need to provide the ARN of the role (you can easily copy it from AWS console, it looks like `arn:aws:iam::<id-account>:role/<role-name>` you can create a variable in the terminal:
105-
106-
```bash
107-
OIDC_ROLE_ARN='<paste here you role ARN>'
108-
```
109-
11084
### Build an OIDC configuration
11185
Note: those steps were taken from [OCP 4.7 doc](https://docs.openshift.com/container-platform/4.7/authentication/managing_cloud_provider_credentials/cco-mode-sts.html#sts-mode-installing-manual-config_cco-mode-sts), there you can read the full explanations for each command).
11286

113-
11. Create a file named `keys.json` that contains the following information:
87+
7. Create a file named `keys.json` that contains the following information:
11488

11589
```json
11690
{
@@ -148,7 +122,7 @@ printf "%016x" $(openssl rsa -pubin -in sa-signer.pub -noout -text | grep Expone
148122

149123
Note: in the commands above were piping to `base64 -w0``, since I don't have this flag on MAC I removed it.
150124

151-
12. Create a file named `openid-configuration` that contains the following information:
125+
8. Create a file named `openid-configuration` that contains the following information:
152126

153127
```json
154128
{
@@ -177,7 +151,7 @@ Note: in the commands above were piping to `base64 -w0``, since I don't have thi
177151
**Where:**
178152
- You need the paste the value of `${OPENID_BUCKET_URL}`.
179153

180-
13. Upload the OIDC configuration:
154+
9. Upload the OIDC configuration:
181155

182156
```bash
183157
aws s3api put-object --bucket ${OPENID_BUCKET_NAME} --key keys.json --body ./keys.json
@@ -187,7 +161,7 @@ aws s3api put-object --bucket ${OPENID_BUCKET_NAME} --key keys.json --body ./key
187161
aws s3api put-object --bucket ${OPENID_BUCKET_NAME} --key '.well-known/openid-configuration' --body ./openid-configuration
188162
```
189163

190-
14. Allow the AWS IAM OIDC identity provider to read these files:
164+
10. Allow the AWS IAM OIDC identity provider to read these files:
191165

192166
```bash
193167
aws s3api put-object-acl --bucket ${OPENID_BUCKET_NAME} --key keys.json --acl public-read
@@ -197,14 +171,40 @@ aws s3api put-object-acl --bucket ${OPENID_BUCKET_NAME} --key keys.json --acl pu
197171
aws s3api put-object-acl --bucket ${OPENID_BUCKET_NAME} --key '.well-known/openid-configuration' --acl public-read
198172
```
199173

200-
15. You can verify that the configuration are public available by using your browser (Chrome, Firefox, etc.) and enter the URL of:
174+
11. You can verify that the configuration are public available by using your browser (Chrome, Firefox, etc.) and enter the URL of:
201175
https://<oidc-bucket-name>.s3.<region>.amazonaws.com/keys.json
202176
https://<oidc-bucket-name>.s3.<region>.amazonaws.com/.well-known/openid-configuration
203177

178+
### Creating AWS resources manually - Using the Amazon web console:
179+
12. Create s3 bucket (you already did it in the step Initial Setup - Create S3 Bucket).
180+
181+
13. Create Identity Provider: IAM &rarr; Identity providers &rarr; Add provider &rarr; Provider type: choose OpenID Connect &rarr; Provider URL: paste the value of OPENID_BUCKET_URL &rarr; click on `Get thumbprint`` &rarr; Audience: api (type api in the field) &rarr; Click on add provider.
182+
183+
14. Create role: IAM &rarr; Roles &rarr; Create Role &rarr; Trusted entity type: Web Identity &rarr; Identity Provider should be the name of the provider that we added (with structure: https://<oidc_bucket_name>.s3.<aws_region>.amazonaws.com ) &rarr; Add the permission: `AmazonS3FullAccess`.
184+
185+
When you finish, check in the Trusted entities that you see:
186+
187+
```json
188+
"Principal": {
189+
"Federated": "arn:aws:iam::<account-id>:oidc-provider/<oidc-bucket-name>.s3.<region>.amazonaws.com"
190+
},
191+
"Action": "sts:AssumeRoleWithWebIdentity",
192+
"Condition": {
193+
"StringEquals": {
194+
"<oidc-bucket-name>.s3.<region>.amazonaws.com:aud": "api"
195+
}
196+
```
197+
198+
15. In later steps you will need to provide the ARN of the role (you can easily copy it from AWS console, it looks like `arn:aws:iam::<id-account>:role/<role-name>` you can create a variable in the terminal:
199+
200+
```bash
201+
OIDC_ROLE_ARN='<paste here you role ARN>'
202+
```
203+
204204
### Test:
205205
We would create an nginx pod and fetch the Service Account token from it and then run `assume-role-with-web-identity` and see that we can get the credentials.
206206

207-
15. Create a nginx pod
207+
16. Create a nginx pod
208208

209209
```bash
210210
kubectl apply -f - <<EOF
@@ -230,13 +230,13 @@ spec:
230230
EOF
231231
```
232232

233-
16. Fetch the Projected service account token and save it in `WEB_IDENTITY_TOKEN`.
233+
17. Fetch the Projected service account token and save it in `WEB_IDENTITY_TOKEN`.
234234

235235
```bash
236236
WEB_IDENTITY_TOKEN=$(kubectl exec nginx -- cat /var/run/secrets/tokens/oidc-token)
237237
```
238238

239-
17. Use assume-role-with-web-identity
239+
18. Use assume-role-with-web-identity
240240

241241
```bash
242242
aws sts assume-role-with-web-identity --role-arn ${OIDC_ROLE_ARN} --role-session-name "test" --web-identity-token ${WEB_IDENTITY_TOKEN}
@@ -261,3 +261,15 @@ You should see in the output the credentials (which includes the `AccessKeyId`,
261261
"Audience": "api"
262262
}
263263
```
264+
265+
#### Create backing store using STS
266+
267+
Noobaa WEB_IDENTITY_TOKEN Audience value is `openshift` because of that You shouls update the Audience in Identity Provider to opeshift.
268+
269+
```bash
270+
TARGET_BUCKET='<target bucket name>'
271+
```
272+
273+
```
274+
nb backingstore create aws-sts-s3 {backing-store} --target-bucket ${TARGET_BUCKET} --aws-sts-arn ${OIDC_ROLE_ARN}
275+
```

0 commit comments

Comments
 (0)