Compare commits

...

6 Commits

Author SHA1 Message Date
Oleh Motrunych d6683593ed
Merge ede3038bbe into 5c5ed195f5 2024-02-10 12:57:14 +00:00
R Tyler Croy 5c5ed195f5
Merge pull request #135 from scribd/dependabot/bundler/nokogiri-1.16.2
Bump nokogiri from 1.14.3 to 1.16.2
2024-02-07 09:46:35 -08:00
dependabot[bot] 3fb64427ff
Bump nokogiri from 1.14.3 to 1.16.2
Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.3 to 1.16.2.
- [Release notes](https://github.com/sparklemotion/nokogiri/releases)
- [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md)
- [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.14.3...v1.16.2)

---
updated-dependencies:
- dependency-name: nokogiri
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-06 03:31:41 +00:00
Oleh Motrunych ede3038bbe fixed URL 2022-09-02 10:44:40 +02:00
Oleh Motrunych 2e6ec2a899 fixed URL links, typos 2022-09-02 10:42:46 +02:00
Oleh Motrunych c1023b758b terraform-oidc-module post 2022-09-02 10:21:19 +02:00
2 changed files with 50 additions and 2 deletions

View File

@ -231,7 +231,7 @@ GEM
jekyll-seo-tag (~> 2.1)
minitest (5.17.0)
multipart-post (2.1.1)
nokogiri (1.14.3-x86_64-linux)
nokogiri (1.16.2-x86_64-linux)
racc (~> 1.4)
octokit (4.22.0)
faraday (>= 0.9)
@ -239,7 +239,7 @@ GEM
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (4.0.7)
racc (1.6.2)
racc (1.7.3)
rb-fsevent (0.11.1)
rb-inotify (0.10.1)
ffi (~> 1.0)

View File

@ -0,0 +1,48 @@
---
layout: post
title: "Terraform OIDC module"
tags:
- Oidc
- Terraform
- GithubActions
team: Platform Infra
author: Oleh Motrunych
---
We at platform engineering, use quite a bit of GitHub actions in our repositories, and in some cases from GitHub Action we need to access AWS resources. Managing AWS API key and API token generated from AWS IAM user is kind of time-consuming. Moreover, these keys are not managed by Terraform and it's hard to track when it was rotated and if it was ever. AWS supports identity which is ideal to handle this kind of situation in a more maintainable way. IAM OIDC identity providers are entities in IAM that describe an external identity provider.
Federated GitHub Actions works by allowing GitHub to authenticate to AWS directly, specifying the repo and role to assume GitHub - aws-actions/configure-aws-credentials: Configure AWS credential environment variables for use in other GitHub Actions.
Terraform has resource aws_iam_openid_connect_provider available starting from AWS provider version 3.26.0 Using this resource and IAM role with required permissions we can access our AWS resources from GitHub action. After years of using GitHub Action we have some common cases to access AWS resources and instead of copying aws_iam_openid_connect_provider from repo to repo we decided to create Terraform module what covers our basic organisation needs:
- **access S3 bucket with read only permissions**
- **access S3 bucket with write permissions**
- **access ECR with read only permissions**
- **access ECR with write permissions**
- **access some AWS service with some specific permissions set**
[The following diagram gives an overview of how GitHub's OIDC provider integrates with your workflows and cloud provider:](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect#getting-started-with-oidc)
![img.png](https://docs.github.com/assets/cb-63262/images/help/images/oidc-architecture.png)
Based on our work in GitHub and AWS using Terraform we created Terraform module what helps us access AWS from GitHub actions https://github.com/scribd/terraform-oidc-module It cover our needs and even more it can attach any of your IAM policies what you pass as a parameter into module.
One of the usage examples:
using this code we can create IAM role and trust relations with a conditional usage and using custom_policy_arns parameter we can pass a list of our IAM policies what will be attached into IAM role.
```hcl
module "oidc" {
source = "git::https://github.com/scribd/terraform-oidc-module.git?ref=v1.0.0"
name = "example"
url = "https://token.actions.githubusercontent.com"
client_id_list = ["sts.amazonaws.com"]
thumbprint_list = ["example0000example000example"]
repo_ref = ["repo:REPO_ORG/REPO_NAME:ref:refs/heads/main"]
custom_policy_arns = [aws_iam_policy.example_policy0.arn,aws_iam_policy.example_policy1.arn ]
tags = {
Terraform = "true"
Environment = "dev"
}
}
```