SuperAPI AI 工具集

granted-aws

部署与运维

查看项目

更新于 10-15 20:27

技能介绍

用途:通过 granted.dev 的 assume 获取短期 AWS 凭证与控制台访问,避免在磁盘上保存明文密钥。该工具虽以 SSO 为卖点,也适用于普通 IAM 用户。

主要能力:granted 将密钥存入操作系统钥匙串,仅在 ~/.aws/config 写入 credential_process 行;assume 可获取短期凭证并打开控制台;granted sso populate 可为每个账户与权限集生成 profile。

使用方式:需 granted/assume 与 aws 在 PATH 中(brew install common-fate/granted/granted awscli)。先根据登录 URL 选择流程:https://<account-id>.signin.aws.amazon.com/console 为 IAM 用户流程;https://<subdomain>.awsapps.com/start 为 SSO 流程。

IAM 用户流程:在控制台创建访问密钥(CLI),不要为 root 创建密钥,并为 IAM 用户启用 MFA。执行 granted browser set;先创建配置文件 mkdir -p ~/.aws && touch ~/.aws/config;再执行 granted credentials add 添加密钥,随后删除显示密钥的控制台标签页。用 granted credentials list 检查,granted credentials update <profile> 更新。设置区域:aws configure set region <region> --profile <profile>。验证:assume <profile>,aws sts get-caller-identity,exit。打开控制台:assume <profile> -c --browser-profile "<profile-dir>",profile 目录可在 chrome://version 的 Profile Path 末段找到,也可在 ~/.granted/config 设默认值。

SSO 流程:granted sso populate --sso-region <region> https://<subdomain>.awsapps.com/start,然后 assume 选择 profile,使用短期凭证。

从 IAM 用户升级到 SSO:执行 sso populate 后,用 granted credentials remove <profile> 移除钥匙串中的长期密钥,并在 IAM 控制台删除该访问密钥。

限制:首次运行有三类错误信息不明确;若配置文件不存在,granted credentials add 会报 open ~/.aws/config: no such file or directory;未设置区域时 assume <profile> 报 region not set;对 IAM 用户 URL 运行 sso populate 无效。