From d03556174cde819dae1cd8a293c1f09f239fa3d2 Mon Sep 17 00:00:00 2001 From: Amanuel Engeda <74629455+engedaam@users.noreply.github.com> Date: Mon, 7 Aug 2023 15:00:55 -0700 Subject: [PATCH] ci: Tag OIDC using cluster name for clean-up (#4387) --- .github/actions/e2e/create-cluster/action.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/actions/e2e/create-cluster/action.yaml b/.github/actions/e2e/create-cluster/action.yaml index ef9841ff5369..8c799e7687d6 100644 --- a/.github/actions/e2e/create-cluster/action.yaml +++ b/.github/actions/e2e/create-cluster/action.yaml @@ -129,14 +129,10 @@ runs: if: always() shell: bash run: | - for arn in $(aws iam list-open-id-connect-providers --query "OpenIDConnectProviderList[*].{ARN:Arn}" --output text); do - tags=$(aws iam list-open-id-connect-provider-tags --open-id-connect-provider-arn $arn --output json) - if [[ $(echo $tags | jq -r '.Tags[] | select(.Key == "alpha.eksctl.io/cluster-name") | .Value') == "${{ inputs.cluster_name }}" ]]; then - aws iam tag-open-id-connect-provider --open-id-connect-provider-arn $arn \ - --tags Key=testing.karpenter.sh/type,Value=e2e Key=github.com/run-url,Value=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - break - fi - done + oidc_id=$(aws eks describe-cluster --name ${{ inputs.cluster_name }} --query "cluster.identity.oidc.issuer" --output text | cut -d '/' -f 3,4,5) + arn="arn:aws:iam::${{ inputs.account_id }}:oidc-provider/${oidc_id}" + aws iam tag-open-id-connect-provider --open-id-connect-provider-arn $arn \ + --tags Key=testing.karpenter.sh/type,Value=e2e Key=github.com/run-url,Value=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }} - name: give KarpenterNodeRole permission to bootstrap shell: bash run: |