GithubHelp home page GithubHelp logo

saidsef / terraform-aws-github-oidc Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 1.0 56 KB

Terraform module to configure GitHub Actions as an IAM OIDC identity provider in AWS

License: Apache License 2.0

HCL 100.00%
aws aws-iam-policies aws-iam-roles federated-identity github github-actions oidc openid openid-connect terraform github-action

terraform-aws-github-oidc's Introduction

Terraform AWS GitHub OIDC Provider

CI GitHub issues License FOSSA Status

This Terraform module enables you to configure GitHub Actions as an AWS IAM OIDC identity provider in AWS, which enables GitHub Actions to access resources within an AWS account(s) without requiring long-lived credentials to be stored as GitHub secrets.

Prerequisites

  • AWS Account(s) and credentials
  • GitHub repository
  • Terraform >= 1.x
  • ...
  • Profit?

Deployment / Usage

provider "aws" {
  region = var.region
}

module "github_oidc" {
  source  = "saidsef/github-oidc/aws"
  version = "~> 2"

  attach_read_only_policy = true
  github_organisation     = "saidsef"
  github_repositories     = [{
    name = "terraform-aws-github-oidc",
    branches = ["main", "pr-*", "*pull*", "*"]
  }]
  tags                    = var.tags
}

Provider Specifications and Requirements

Please see TERRAFORM.md

GitHub Actions

Retrieve temporary credentials:

caller-identity-check:
if: contains(github.event_name, 'pull_request')
name: Return the IAM user
needs: [validate, tfsec]
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
aws-region: ${{ secrets.AWS_REGION }}
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions
role-session-name: ${{ github.event.repository.name }}-${{ github.ref_type }}
- run: |
aws sts get-caller-identity

Source

Our latest and greatest source of terraform-aws-github-oidc can be found on GitHub. Fork us!

Contributing

We would ❤️ you to contribute by making a pull request.

Please read the official Contribution Guide for more information on how you can contribute.

License

FOSSA Status

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.