@@ -38,10 +38,6 @@ set -o xtrace
3838# doesn't allow you to create registry service accounts.
3939: ${VEN_API_KEY_PULL?}
4040
41- # The Venafi Cloud team which will be the owner of the generated Venafi service
42- # accounts.
43- : ${VEN_OWNING_TEAM?}
44-
4541# The Venafi Cloud zone (application/issuing_template) which will be used by the
4642# issuer an policy.
4743: ${VEN_ZONE?}
@@ -87,12 +83,16 @@ if ! gcloud container clusters get-credentials "${CLUSTER_NAME}"; then
8783fi
8884kubectl create ns venafi || true
8985
86+ # Let's pick the first team as the owning team as it doesn't matter for this
87+ # test.
88+ owningTeamID=$( curl --fail-with-body -sS https://api.venafi.cloud/v1/teams -H " tppl-api-key: $VEN_API_KEY " | jq ' .teams[0].id' -r)
89+
9090# Pull secret for Venafi OCI registry
9191if ! kubectl get secret venafi-image-pull-secret -n venafi; then
9292 venctl iam service-accounts registry create \
9393 --api-key " ${VEN_API_KEY_PULL} " \
9494 --no-prompts \
95- --owning-team " ${VEN_OWNING_TEAM } " \
95+ --owning-team " ${owningTeamID } " \
9696 --name " venafi-kubernetes-agent-e2e-registry-${RANDOM} " \
9797 --scopes enterprise-cert-manager,enterprise-venafi-issuer,enterprise-approver-policy \
9898 | jq ' {
@@ -129,12 +129,14 @@ venctl components kubernetes apply \
129129
130130kubectl apply -n venafi -f venafi-components.yaml
131131
132+
132133subject=" system:serviceaccount:venafi:venafi-components"
133134audience=" https://${VEN_API_HOST} "
134135issuerURL=" $( kubectl create token -n venafi venafi-components | step crypto jwt inspect --insecure | jq -r ' .payload.iss' ) "
135136openidDiscoveryURL=" ${issuerURL} /.well-known/openid-configuration"
136137jwksURI=$( curl --fail-with-body -sSL ${openidDiscoveryURL} | jq -r ' .jwks_uri' )
137138
139+
138140# Create the Venafi agent service account if one does not already exist
139141while true ; do
140142 tenantID=$( curl --fail-with-body -sSL -H " tppl-api-key: $VEN_API_KEY " https://${VEN_API_HOST} /v1/serviceaccounts \
@@ -155,15 +157,14 @@ while true; do
155157 "issuerURL": $issuerURL,
156158 "jwksURI": $jwksURI,
157159 "applications": [$applications.applications[].id],
158- "owner": $teams.teams[] | select(.name==$teamName) | .id
160+ "owner": $owningTeamID
159161 }' \
160162 --arg random " ${RANDOM} " \
161- --arg teamName " ${VEN_OWNING_TEAM} " \
162163 --arg subject " ${subject} " \
163164 --arg audience " ${audience} " \
164165 --arg issuerURL " ${issuerURL} " \
165166 --arg jwksURI " ${jwksURI} " \
166- --argjson teams " $( curl https:// ${VEN_API_HOST} /v1/teams --fail-with-body -sSL -H tppl-api-key: \ ${VEN_API_KEY} ) " \
167+ --arg owningTeamID " { $owningTeamID } " \
167168 --argjson applications " $( curl https://${VEN_API_HOST} /outagedetection/v1/applications --fail-with-body -sSL -H tppl-api-key:\ ${VEN_API_KEY} ) " \
168169 | curl https://${VEN_API_HOST} /v1/serviceaccounts \
169170 -H " tppl-api-key: $VEN_API_KEY " \
0 commit comments