You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置AWS OIDC策略以支持多个GitHub Actions仓库?

支持多个GitHub仓库通过OIDC访问AWS的IAM策略修改方法

在IAM角色的信任策略中,不能重复使用同一个条件键(比如token.actions.githubusercontent.com:sub),正确的做法是将多个仓库的匹配规则放在数组中。

修改后的策略示例如下:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Federated": "arn:aws:iam::<id>:oidc-provider/token.actions.githubusercontent.com"
            },
            "Action": "sts:AssumeRoleWithWebIdentity",
            "Condition": {
                "StringEquals": {
                    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com"
                },
                "StringLike": {
                    "token.actions.githubusercontent.com:sub": [
                        "repo:username/myrepo:*",
                        "repo:username/myrepo2:*",
                        "repo:another-user/their-repo:*"
                    ]
                }
            }
        }
    ]
}

关键说明:

  • 将原有的单个字符串值替换为数组,每个元素对应一个仓库的匹配规则
  • 数组中的每个条目格式保持和原规则一致:repo:<GitHub用户名>/<仓库名>:*
  • 可以添加任意数量的仓库条目,只要符合格式要求

内容的提问来源于stack exchange,提问作者Ymi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 12:32:08