Skip to content

Commit 77ea7bc

Browse files
authored
chore: Update the examples (#85)
1 parent 3b2f620 commit 77ea7bc

File tree

13 files changed

+98
-163
lines changed

13 files changed

+98
-163
lines changed

examples/basic/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Basic example
2+
3+
The following example is the minimal configuration you can use to get started,
4+
this will create an OIDC provider with a single role called `GitHubActions`,
5+
and permissions for manage Lambda resources.

examples/basic/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
provider "aws" {}
2+
3+
module "oidc_github" {
4+
source = "../.."
5+
6+
attach_lambda_full_access_policy = true
7+
github_repositories = var.github_repositories
8+
}

examples/basic/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "github_repositories" {
2+
default = []
3+
description = "GitHub organization/repository names authorized to assume the role."
4+
type = list(string)
5+
}

examples/complete/versions.tf renamed to examples/basic/versions.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
// SPDX-License-Identifier: MIT
33

44
terraform {
5+
required_version = "~> 1.12"
6+
57
required_providers {
68
aws = {
79
source = "hashicorp/aws"
8-
version = ">= 5.0"
10+
version = "~> 6.0.0"
911
}
1012

1113
tls = {
1214
source = "hashicorp/tls"
13-
version = ">= 4.0"
15+
version = "~> 4.0.0"
1416
}
1517
}
16-
17-
required_version = "~> 1.10"
1818
}

examples/complete/main.tf

Lines changed: 0 additions & 37 deletions
This file was deleted.

examples/complete/outputs.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/complete/variables.tf

Lines changed: 0 additions & 111 deletions
This file was deleted.

examples/multiple-roles/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# OIDC provider with multiple roles
2+
3+
The following example demonstrates creating the OIDC provider along with
4+
multiple custom roles, and attaching the assume role policy document to
5+
each role.

examples/multiple-roles/main.tf

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
provider "aws" {}
2+
3+
module "label" {
4+
source = "cloudposse/label/null"
5+
version = "0.25.0"
6+
7+
namespace = "unfunco"
8+
environment = "test"
9+
name = "terraform-aws-oidc-github"
10+
}
11+
12+
module "oidc_github" {
13+
source = "../.."
14+
15+
create_iam_role = false
16+
github_repositories = var.github_repositories
17+
}
18+
19+
resource "aws_iam_role" "network" {
20+
assume_role_policy = module.oidc_github.assume_role_policy
21+
description = "Assumed by GitHub Actions to manage to network resources."
22+
name = join("-", [module.label.id, "network"])
23+
}
24+
25+
resource "aws_iam_role_policy_attachment" "vpc_full_access" {
26+
policy_arn = "arn:aws:iam::aws:policy/AmazonVPCFullAccess"
27+
role = aws_iam_role.network.name
28+
}
29+
30+
resource "aws_iam_role" "storage" {
31+
assume_role_policy = module.oidc_github.assume_role_policy
32+
description = "Assumed by GitHub Actions to manage storage resources."
33+
name = join("-", [module.label.id, "storage"])
34+
}
35+
36+
resource "aws_iam_role_policy_attachment" "s3_full_access" {
37+
policy_arn = "arn:aws:iam::aws:policy/AmazonS3FullAccess"
38+
role = aws_iam_role.storage.name
39+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
variable "github_repositories" {
2+
default = []
3+
description = "GitHub organization/repository names authorized to assume the role."
4+
type = list(string)
5+
}

0 commit comments

Comments
 (0)