Skip to content

Commit 3132475

Browse files
authored
Merge pull request #89134 from dfitzmau/OCPBUGS-45919-16
[enterprise-4.16] OCPBUGS-45919: Updated the service account in STS
2 parents 7f19ce8 + 36bf5a6 commit 3132475

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

modules/aws-installing-an-aws-load-balancer-operator.adoc

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ endif::openshift-rosa[]
3636
CLI (`rosa`).
3737
* You have installed the Amazon Web Services (AWS) CLI.
3838
* You have installed the OpenShift CLI (oc).
39-
* You are using OpenShift Container Platform (OCP) 4.13 or later.
39+
* You are using {product-title} 4.13 or later.
4040
4141
[IMPORTANT]
4242
====
@@ -103,14 +103,21 @@ cluster as a user with the `dedicated-admin` role and create a new project using
103103
----
104104
$ oc new-project aws-load-balancer-operator
105105
----
106-
107106
+
108107
.. Assign the following trust policy to the newly-created AWS IAM role:
109108
+
110109
[source,terminal]
111110
----
112111
$ IDP='{Cluster_OIDC_Endpoint}'
113112
$ IDP_ARN="arn:aws:iam::{AWS_AccountNo}:oidc-provider/${IDP}" <1>
113+
----
114+
<1> Replace `{AWS_AccountNo}` with your AWS account number and `{Cluster_OIDC_Endpoint}` with the OIDC DNS identified earlier in this procedure.
115+
+
116+
.. Verify that the trust policy was assigned to the AWS IAM role.
117+
+
118+
.Example output
119+
[source,terminal,subs="quotes,verbatim"]
120+
----
114121
$ cat <<EOF > albo-operator-trusted-policy.json
115122
{
116123
"Version": "2012-10-17",
@@ -131,20 +138,28 @@ $ cat <<EOF > albo-operator-trusted-policy.json
131138
}
132139
EOF
133140
----
134-
<1> Replace '{AWS_AccountNo}' with your AWS account number and '{Cluster_OIDC_Endpoint}' with the OIDC DNS identified earlier in this procedure.
135141
+
136142
[IMPORTANT]
137143
====
138144
Do not include the `https` portion of the OIDC DNS URL when replacing `{Cluster_OIDC_Endpoint}` with the OIDC DNS you identified earlier. Only the alphanumeric information that follows the `/` within the URL is needed.
139145
====
140146
+
141147
For more information on assigning trust policies to AWS IAM roles, see link:https://aws.amazon.com/blogs/security/how-to-use-trust-policies-with-iam-roles/[How to use trust policies with IAM roles].
148+
+
142149
.. Create and verify the role by using the generated trust policy:
143150
+
144151
[source, terminal]
145152
----
146153
$ aws iam create-role --role-name albo-operator --assume-role-policy-document file://albo-operator-trusted-policy.json
154+
----
155+
+
156+
[source, terminal]
157+
----
147158
$ OPERATOR_ROLE_ARN=$(aws iam get-role --role-name albo-operator --output json | jq -r '.Role.Arn')
159+
----
160+
+
161+
[source, terminal]
162+
----
148163
$ echo $OPERATOR_ROLE_ARN
149164
----
150165
+
@@ -155,6 +170,10 @@ For more information on creating AWS IAM roles, see link:https://docs.aws.amazon
155170
[source, terminal]
156171
----
157172
$ curl -o albo-operator-permission-policy.json https://raw.githubusercontent.com/openshift/aws-load-balancer-operator/release-1.1/hack/operator-permission-policy.json
173+
----
174+
+
175+
[source, terminal]
176+
----
158177
$ aws iam put-role-policy --role-name albo-operator --policy-name perms-policy-albo-operator --policy-document file://albo-operator-permission-policy.json
159178
----
160179
+
@@ -200,7 +219,7 @@ $ cat <<EOF > albo-controller-trusted-policy.json
200219
"Action": "sts:AssumeRoleWithWebIdentity",
201220
"Condition": {
202221
"StringEquals": {
203-
"${IDP}:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-controller-cluster"
222+
"${IDP}:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-operator-controller-manager"
204223
}
205224
}
206225
}
@@ -214,7 +233,15 @@ EOF
214233
[source, terminal]
215234
----
216235
$ aws iam create-role --role-name albo-controller --assume-role-policy-document file://albo-controller-trusted-policy.json
236+
----
237+
+
238+
[source,terminal]
239+
----
217240
$ CONTROLLER_ROLE_ARN=$(aws iam get-role --role-name albo-controller --output json | jq -r '.Role.Arn')
241+
----
242+
+
243+
[source,terminal]
244+
----
218245
$ echo $CONTROLLER_ROLE_ARN
219246
----
220247
+
@@ -223,6 +250,10 @@ $ echo $CONTROLLER_ROLE_ARN
223250
[source,terminal]
224251
----
225252
$ curl -o albo-controller-permission-policy.json https://raw.githubusercontent.com/kubernetes-sigs/aws-load-balancer-controller/v2.4.7/docs/install/iam_policy.json
253+
----
254+
+
255+
[source,terminal]
256+
----
226257
$ aws iam put-role-policy --role-name albo-controller --policy-name perms-policy-albo-controller --policy-document file://albo-controller-permission-policy.json
227258
----
228259
+

modules/using-aws-cli-create-iam-role-alb-controller.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ cat <<EOF > albo-controller-trust-policy.json
3030
"Action": "sts:AssumeRoleWithWebIdentity",
3131
"Condition": {
3232
"StringEquals": {
33-
"<cluster_oidc_endpoint>:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-controller-cluster" <2>
33+
"<cluster_oidc_endpoint>:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-operator-controller-manager" <2>
3434
}
3535
}
3636
}
@@ -54,7 +54,7 @@ $ aws iam create-role --role-name albo-controller --assume-role-policy-document
5454
ROLE arn:aws:iam::<aws_account_number>:role/albo-controller 2023-08-02T12:13:22Z <1>
5555
ASSUMEROLEPOLICYDOCUMENT 2012-10-17
5656
STATEMENT sts:AssumeRoleWithWebIdentity Allow
57-
STRINGEQUALS system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-controller-cluster
57+
STRINGEQUALS system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-operator-controller-manager
5858
PRINCIPAL arn:aws:iam:<aws_account_number>:oidc-provider/<cluster_oidc_endpoint>
5959
----
6060
<1> Note the ARN of an {aws-short} IAM role for the {aws-short} Load Balancer Controller, such as `arn:aws:iam::777777777777:role/albo-controller`.

modules/using-aws-cli-create-iam-role-alb-operator.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ cat <<EOF > albo-operator-trust-policy.json
3030
"Action": "sts:AssumeRoleWithWebIdentity",
3131
"Condition": {
3232
"StringEquals": {
33-
"<cluster_oidc_endpoint>:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-controller-cluster" <2>
33+
"<cluster_oidc_endpoint>:sub": "system:serviceaccount:aws-load-balancer-operator:aws-load-balancer-operator-controller-manager" <2>
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)