File tree Expand file tree Collapse file tree 17 files changed +150
-137
lines changed
oidc-github-actions-iam-role
oidc-github-actions-provider Expand file tree Collapse file tree 17 files changed +150
-137
lines changed Original file line number Diff line number Diff line change 1+ # OIDC GitHub IAM Role
2+
3+ ## About
4+
5+ This module allows you to setup an IAM role for GitHub OIDC:
6+
7+ - IAM role with trust policy
8+
9+ ## Assumptions
10+
11+ ## Usage
12+
13+ See ` variables.tf ` for the full argument reference.
Original file line number Diff line number Diff line change 1+ data "aws_iam_openid_connect_provider" "github" {
2+ url = " https://token.actions.githubusercontent.com"
3+ provider = aws. default
4+ }
5+
6+ data "aws_iam_policy_document" "assume_role_policy" {
7+ statement {
8+ effect = " Allow"
9+
10+ actions = [" sts:AssumeRoleWithWebIdentity" ]
11+
12+ principals {
13+ type = " Federated"
14+ identifiers = [data . aws_iam_openid_connect_provider . github . arn ]
15+ }
16+
17+ condition {
18+ test = " StringEquals"
19+ variable = " token.actions.githubusercontent.com:aud"
20+ values = [" sts.amazonaws.com" ]
21+ }
22+
23+ condition {
24+ test = " StringLike"
25+ variable = " token.actions.githubusercontent.com:sub"
26+ values = [" repo:${ var . repo } " ]
27+ }
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ resource "aws_iam_role" "role" {
2+ name = var. role_name
3+ assume_role_policy = data. aws_iam_policy_document . assume_role_policy . json
4+ tags = var. tags
5+ provider = aws. default
6+ }
7+
8+ resource "aws_iam_role_policy" "policy" {
9+ name = var. policy_name
10+ role = aws_iam_role. role . id
11+ policy = var. policy
12+ provider = aws. default
13+ }
Original file line number Diff line number Diff line change 1+ output "role" {
2+ value = {
3+ id = aws_iam_role.role.id
4+ arn = aws_iam_role.role.arn
5+ name = aws_iam_role.role.name
6+ }
7+ }
8+
9+ output "policy" {
10+ value = {
11+ id = aws_iam_role_policy.policy.id
12+ arn = aws_iam_role_policy.policy.name
13+ }
14+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ aws = {
4+ source = " hashicorp/aws"
5+ configuration_aliases = [
6+ aws.default,
7+ ]
8+ }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ variable "role_name" {
2+ type = string
3+ description = " The IAM role name"
4+ default = null
5+ }
6+
7+ variable "policy_name" {
8+ type = string
9+ description = " The IAM role policy name"
10+ default = null
11+ }
12+
13+ variable "policy" {
14+ type = string
15+ description = " The IAM role policy in JSON format"
16+ }
17+
18+ variable "repo" {
19+ type = string
20+ description = " The GitHub repository path (e.g. org/repo:ref:refs/heads/master)"
21+ }
22+
23+ variable "tags" {
24+ type = map (string )
25+ description = " The tags to apply to all resources created"
26+ default = {}
27+ }
Original file line number Diff line number Diff line change 1+ resource "aws_iam_openid_connect_provider" "github" {
2+ url = " https://token.actions.githubusercontent.com"
3+ client_id_list = [" sts.amazonaws.com" ]
4+ thumbprint_list = var. thumbprints
5+ tags = var. tags
6+ provider = aws. default
7+ }
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_providers {
3+ aws = {
4+ source = " hashicorp/aws"
5+ configuration_aliases = [
6+ aws.default,
7+ ]
8+ }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ variable "thumbprints" {
2+ type = list (string )
3+ description = " An optional thumbprint list."
4+ default = []
5+ }
6+
7+ variable "tags" {
8+ type = map (string )
9+ description = " The tags to apply to all resources created"
10+ default = {}
11+ }
Original file line number Diff line number Diff line change 1- # Static Site Module
1+ # Static Site
22
33## About
44
@@ -9,15 +9,9 @@ This module allows you to setup a static site with the following features:
99 - Automatic DNS validation for ACM via Route 53
1010 - Optional creation of Route 53 Hosted Zone (or reuse an existing one)
1111 - Multi-domain support
12- - CI/CD deploy IAM role via OIDC (optional)
1312- Fallback support for SPA (` 403 → 200 /index.html ` and ` 404 → 200 /index.html ` )
1413- Resource tagging for manageable resources
1514
16- ## Assumptions
17-
18- This module assumes you have GitHub OIDC setup to use the CD features provided by the module. You can use the ` setup_cd `
19- toggle to disable this.
20-
2115## Usage
2216
2317See ` variables.tf ` for the full argument reference.
@@ -29,9 +23,6 @@ module "static_site" {
2923 domains = ["example.org"]
3024 bucket_name = "example.org"
3125 hosted_zone = "my-hosted_zone"
32- role_name = "deploy-example-org"
33- repo = "example-org/repo:ref:refs/heads/master"
34- setup_cd = false
3526
3627 restriction = {
3728 type = "none"
You can’t perform that action at this time.
0 commit comments