1
- # Managing GitHub organization with Terraform
1
+ # Managing GitHub organization with OpenTofu
2
2
3
3
This setup is based on
4
4
[ hashicorp/learn-terraform-github-actions] ( https://github.com/hashicorp/learn-terraform-github-actions ) ,
5
5
but relies exclusively on GitHub Actions without communicating with Terraform
6
6
Cloud.
7
7
8
- # 1. Cloning Terraform repository
8
+ # 1. Cloning OpenTofu repository
9
9
10
10
Clone this repository to your GitHub organization and adjust variables to your
11
11
liking.
12
12
13
13
# 2. GitHub App configuration
14
14
15
- Github App will be used by Terraform to provision organization.
15
+ GitHub App will be used by OpenTofu to provision organization.
16
16
17
17
## Creating new GitHub App
18
18
19
- It can created by following [ this guide] ( https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app ) .
19
+ It can be created by following [ this guide] ( https://docs.github.com/en/developers/apps/building-github-apps/creating-a-github-app ) .
20
20
Application should be limited to only one account. Permissions depend on what
21
- resources you plan to manage with Terraform , but sensible base is:
21
+ resources you plan to manage with OpenTofu , but a sensible base is:
22
22
23
23
- Repository/Administration - Read and write
24
24
- Repository/Contents - Read and write
@@ -30,11 +30,11 @@ resources you plan to manage with Terraform, but sensible base is:
30
30
- Organization/Members - Read and write
31
31
- Organization/Projects - Admin
32
32
33
- After creating App you may need to [ install it in
33
+ After creating the App, you may need to [ install it in
34
34
organization] ( https://docs.github.com/en/developers/apps/managing-github-apps/installing-github-apps ) .
35
35
36
- Github App will use [ private key] ( https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps )
37
- for authentication. In order to properly authenticate with Terraform GitHub
36
+ GitHub App will use [ private key] ( https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps )
37
+ for authentication. In order to properly authenticate with OpenTofu GitHub
38
38
provider you will need:
39
39
40
40
- GitHub App ID (GitHub Action secret ` GH_APP_ID ` )
@@ -43,22 +43,22 @@ provider you will need:
43
43
44
44
## Getting GitHub App node ID
45
45
46
- Node ID is used in GraphQL API. Some Terraform resources like
47
- [ github_branch_protection] ( https://registry.terraform.io/providers/integrations /github/latest/docs/resources/branch_protection )
48
- may require node IDs for access control lists. Knowing you App node ID will be
49
- handy, when you want to allow some actions only to it. While there maybe some
50
- better way of getting node ID, you can use your newly created App to query
51
- itself for node ID. First generate [ JWT token] ( https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app )
46
+ Node ID is used in GraphQL API. Some OpenTofu resources like
47
+ [ github_branch_protection] ( https://search.opentofu.org/provider/hashicorp /github/latest/docs/resources/branch_protection )
48
+ may require node IDs for access control lists. Knowing your App node ID will be
49
+ handy, when you want to allow some actions only to it. While there may be some
50
+ better way of getting the node ID, you can use your newly created App to query
51
+ itself for node ID. First, generate [ JWT token] ( https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app )
52
52
and then [ query /app endpoint] ( https://docs.github.com/en/rest/reference/apps ) .
53
53
54
54
# 3. Configuring state backend
55
55
56
- Terraform requires backend to store configuration state. This example repository
57
- uses OpenStack Swift. Consult [ Terraform documentation] ( https://www.terraform.io/ language/settings/backends )
56
+ OpenTofu requires a backend to store configuration state. This example repository
57
+ uses OpenStack Swift. Consult [ OpenTofu documentation] ( https://opentofu.org/docs/ language/settings/backends/configuration/ )
58
58
and choose your preferred backend. Keep in mind that you will also have to pass
59
59
access credentials as GitHub secrets in order to use it.
60
60
61
- # 4. Configuring Terraform repository secrets
61
+ # 4. Configuring OpenTofu repository secrets
62
62
63
63
Visit ` Repository ` -> ` Settings ` -> ` Secrets ` -> ` Actions ` and ensure that at
64
64
least the following variables are configured:
@@ -76,12 +76,12 @@ least the following variables are configured:
76
76
77
77
Workflows are divided into 3 files:
78
78
79
- - ` .github/workflows/terraform -checks.yml ` - Validates pull request without
79
+ - ` .github/workflows/tofu -checks.yml ` - Validates pull request without
80
80
accessing repository secrets.
81
- - ` .github/workflows/terraform -plan.yml ` - Generates Terraform plan. This
82
- workflow is launched only after user whitelisted in file comments pull request
83
- with _ /plan_ message. It ensures that untrusted code from pull request won't
81
+ - ` .github/workflows/tofu -plan.yml ` - Generates OpenTofu plan. This
82
+ workflow is launched only after a user whitelists in file comments pull request
83
+ with the _ /plan_ message. It ensures that untrusted code from pull requests won't
84
84
be run automatically with repository secrets. See [ this article] ( https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ )
85
85
for more details.
86
- - ` .github/workflows/terraform -apply.yml ` - Enforces state after pushing code to
87
- main branch.
86
+ - ` .github/workflows/tofu -apply.yml ` - Enforces state after pushing code to
87
+ the main branch.
0 commit comments