Demonstrate how GitHub OIDC token getting should be included in boto3

Overview

boto3 should add direct support for AssumeRoleWithWebIdentity for GitHub Actions

There is a aws-actions/configure-aws-credentials action that will get AWS credentials for you based on STS.AssumeRoleWithWebIdentity, and put the credentials in environment variables. I see two problems with this:

  • You need to put a whole step in your job definition. Why can't it just be environment variables? Or a config file in the repo, just like the ~/.aws/config file you use elsewhere?
  • You can't use more than one role at a time. At best, you would need to serialize your use of multiple roles, separated by steps to assume those different roles.

This repo demonstrates how we can solve both problems in botocore. botocore would add a new CredentialProvider. See the demo action and the demo code, the changes for botocore, and the logs for a run.

This implementation would give you two options:

Environment variables

This is the simplest method. You would set AWS_ROLE_ARN=arn:aws:iam::123456789012:role/MyRole (using your role ARN, of course) and AWS_WEB_IDENTITY_TOKEN_SERVER=GitHub in the environment, and it would get picked up. You can optionally set AWS_ROLE_SESSION_NAME as well.

Note you can do this today for web identity, except that it only works with token files and the AWS_WEB_IDENTITY_TOKEN_FILE environment variable. Indeed, Aidan Steele used this method a blog post to make GitHub actions work, before the AWS-created action was available.

Config file

An alternative, which would also support multiple roles, is a config file. The format for profiles would look like this:

[default]
role_arn = arn:aws:iam::123456789012:role/MyRole
web_identity_token_server = GitHub
region = us-east-2

(Note: role_session_name is optional in these profiles, but I set it in the config file to help differentiate which profile is being used).

Unfortunately, this requires one additional piece of configuration. The root of the checked-out repository is /home/runner/work/github-actions-boto3-demo/github-actions-boto3-demo while ~/.aws/config resolves to /home/runner/.aws/config. This means you need to set AWS_CONFIG_FILE=.github/workflows/aws_config (or whatever the path for the config file in the repo is) in the environment.

See the config file for examples.

Audience

The default audience for the OIDC token is the repo URL, which is a little weird. The audience is who should be receiving the token, which for us is the role(s) we're assuming. On the AWS side, the OIDC provider can have a list of audiences it will accept.

It should be something like the application on the destination side of the role assumption, ideally like the CloudFormation stack name that the role is in. But absent that I'd say it should be the STS service principal, sts.amazonaws.com.

But as far as I can tell, any value provided to the GitHub OIDC token vendor other than sigstore (no idea what that's for) returns an error, including the default audience value of the repo URL.

But I've provided the ability to set the audience manually, by adding a comma-separated value at the end of the token server config value (either web_identity_token_server in the config file or AWS_WEB_IDENTITY_TOKEN_SERVER in the enviornment). See the config file for examples of this (using sigstore).

Manual config

AWS might object to baking in knowledge of a 3rd party provider, so I also allowed for this to be generic. Instead of a convenient "GitHub" value for web_identity_token_server, you provide a comma-separated list of the environment variables for the URL and for the token. The code then parses the configuration from this, rather than storing direct knowledge of GitHub in the code. It's then generic, rather than GitHub-specific, but requires basically a magic incantation that people would have to copy and paste. You could even take that further and make it a base64-encoded JSON object if it needed to be more complicated, a proper opaque config value.

See the config file for examples of the manual configuration.

Owner
Ben Kehoe
Cloud Robotics Research Scientist at iRobot | AWS Serverless Hero
Ben Kehoe
A Very Simple Telegram Files Rename Bot by @AbirHasan2005

Rename-Bot This is a very simple Telegram Files Rename Bot by @AbirHasan2005. Features Rename Videos, Files or Audios. Permanent Custom Thumbnail Supp

Abir Hasan 124 Dec 25, 2022
Widevine CDM API

wvproxy Widevine CDM API Setup Install Python 3.6 or newer and Poetry Install Python package dependencies using poetry install Activate the virtual en

24 Dec 09, 2022
twtxt is a decentralised, minimalist microblogging service for hackers.

twtxt twtxt is a decentralised, minimalist microblogging service for hackers. So you want to get some thoughts out on the internet in a convenient and

buckket 1.8k Jan 09, 2023
A anti-repostbot script for reddit, runs u/ThisIsARepostBotBot

ThisIsARepostBotBot So you found a repost bot, now what? This is a bot to reply to all posts of a repost bot with a message urging users to report and

3 May 23, 2022
An advanced Filter Bot with nearly unlimitted filters

Telegram MTProto API Framework for Python Documentation • Releases • Community Pyrogram from pyrogram import Client, filters app = Client("my_account

Pyrogram 3.2k Jan 05, 2023
How to make a QR Code of your own in python

QR CODE Bilgilendirme! " pip install qrcode pillow " kurmalısınız.

Aktali 1 Dec 24, 2021
Python script to decode the EU Covid-19 vaccine certificate

vacdec Python script to decode the EU Covid-19 vaccine certificate This script takes an image with a QR code of a vaccine certificate as the parameter

Hanno Böck 244 Nov 30, 2022
DeFi wallet on Chia Network.

DeFi wallet on Chia Network.

GobyWallet 21 Aug 12, 2022
Creates Spotify playlists from Spinitron playlists.

spin2spot Creates Spotify playlists from Spinitron playlists. Quick Start You can use spin2spot as a command-line tool: Erik Didriksen 1 Aug 28, 2021

Discord Mafia Game Bot using nextcord

Mafia-Bot Discord Mafia Game Bot using nextcord Features Mafia Game Game Replays Installation Run the following command to install required modules: p

Nian 6 Nov 19, 2022
hydrotoolbox is a Python script for hydrologic calculations and analysis or by function calls within Python.

hydrotoolbox is a Python script for hydrologic calculations and analysis or by function calls within Python.

Tim Cera 4 Aug 20, 2022
🎄 JustaGrabber - A discord token grabber written in python3

🎄 JustaGrabber - A discord token grabber written in python3 🎇 Made by kldiscord https://github.com/kldiscord 🌟 Please leave a star if you liked Jus

1 Dec 19, 2022
Discord Online Account Forever

💠 Discord-Online-Account-Forever Discord Online Account Forever 📸 Tutorial Token Discord NEVER SHARE YOUR TOKEN Installation Replit 🧿 Replit : Here

nimaisox 2 Nov 28, 2021
MemeBot - A discord bot that tracks how good people's memes are

MemeBot A discord Meme "Karma" Tracking bot Dependancies Make sure you have pymongo installed and a mongodb cluster setup with two collections. pip in

Uday Sharma 3 Aug 10, 2022
A module to complement discord.py that has Music, Paginator and Levelling.

discord-super-utils A modern python module including many useful features that make discord bot programming extremely easy. Features Modern leveling m

Yash 106 Dec 19, 2022
SC4.0 - BEST EXPERIENCE · HEX EDITOR · Discord Nuker · Plugin Adder · Cheat Engine

smilecreator4 This site is for people who want to hack or want to learn it! Furthermore, this program does not work without turning off Antivirus or W

1 Jan 04, 2022
Python SDK for IEX Cloud

iexfinance Python SDK for IEX Cloud. Architecture mirrors that of the IEX Cloud API (and its documentation). An easy-to-use toolkit to obtain data for

Addison Lynch 640 Jan 07, 2023
AuthGG is a Python library for dealing with Auth.gg apis

AuthGG AuthGG is a Python library for dealing with Auth.gg apis Installation Use the package manager pip to install requests Add the auth.py file in y

ExtremeDev 1 Dec 20, 2021
SEP Finder Bot

SEP Finder Bot This is a Telegram bot that will help you find the correct SEP and Baseband files to use for your device with futurerestore. Usage A ho

6 Dec 03, 2022
A modular Telegram group management bot running with Python based on Pyrogram.

A modular Telegram group management bot running with Python based on Pyrogram.

Jefanya Efandchris 1 Nov 14, 2022