6. 前述のポリシーでは、特定の**トリガー**を持つ**組織**の**リポジトリ**の**ブランチ**のみが許可されていることに注意してください。
7. Githubアクションが**なりすます**ことができる**ロール**の**ARN**は、Githubアクションが知る必要がある"秘密"になるので、**環境**内の**シークレット**に**保存**してください。
8. 最後に、ワークフローで使用されるAWSクレデンシャルを設定するためにgithubアクションを使用します。
```yaml
name: 'test AWS Access'
# The workflow should only trigger on pull requests to the main branch
on:
pull_request:
branches:
- main
# Required to get the ID Token that will be used for OIDC
permissions:
id-token: write
contents: read # needed for private repos to checkout
jobs:
aws:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-region: eu-west-1
role-to-assume: ${{ secrets.READ_ROLE }}
role-session-name: OIDCSession
- run: aws sts get-caller-identity
shell: bash
OIDC - EKS の悪用
# Crate an EKS cluster (~10min)eksctlcreatecluster--namedemo--fargate
# Create an Identity Provider for an EKS clustereksctlutilsassociate-iam-oidc-provider--clusterTesting--approve
EKSクラスターでは、クラスターのOIDC URLを新しいOpen ID Identity providerとして設定することで、OIDC providersを生成することが可能です。これは一般的なデフォルトポリシーです: