Skip to content

Commit 9a8579c

Browse files
committed
feat: add aws s3 compatible backend
1 parent 3529235 commit 9a8579c

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

.env.tmpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1+
# S3 backend configuration
2+
AWS_ENDPOINT_URL_S3="https://path.to.your.s3.endpoint"
3+
AWS_ACCESS_KEY_ID="access-key-id"
4+
AWS_SECRET_ACCESS_KEY="secret-access-key"
5+
6+
# GitHub App configuration
7+
GITHUB_OWNER="your-organization"
18
GITHUB_APP_ID=1234567
29
GITHUB_APP_INSTALLATION_ID=123456789
310
GITHUB_APP_PEM_FILE_PATH=./github-app.private-key.pem
411

12+
# Terraform configuration
513
TF_VAR_config="../test.yaml"

.envrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
dotenv_if_exists
22

33
export GITHUB_APP_PEM_FILE=$(cat "$GITHUB_APP_PEM_FILE_PATH")
4+
5+
TF_WORKSPACE="$GITHUB_OWNER"

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,19 @@ GitHub organization managed as code.
55
## Features
66

77
- **Automated GitHub Organization management** - Define repositories using simple YAML file.
8+
- **GitOps Workflow** - Manage configurations using pull requests and automate updates using GitHub Actions.
89
- **Terraform** - Uses Terraform under the hood to apply changes efficiently.
10+
- **Terraform State Management** - Stores Terraform state securely in AWS S3.
911
- **GitHub App Integration** - Uses a GitHub App for authentication and API interactions.
1012

11-
## Setup
13+
## Installation and Configuration
14+
15+
- Configure an AWS S3 bucket to store Terraform state files.
16+
- Set up a GitHub App and its installation to handle authentication and authorization for your GitHub Organization.
17+
- Implement GitOps by setting up a GitHub repository with:
18+
- YAML-based configuration
19+
- GitHub workflows
20+
- Repository variables and secrets
1221

1322
### GitHub App
1423

@@ -33,6 +42,18 @@ To create a GitHub App and a GitHub App Installation:
3342
- Install App
3443
- _your organization_: **Install**
3544

45+
### GitHub Organization as Code
46+
47+
Create GitHub organization YAML configuration file. See [GitHub Organization YAML](#github-organization-yaml) below.
48+
49+
For example:
50+
51+
```yaml
52+
---
53+
repositories:
54+
- name: .github
55+
```
56+
3657
## Usage
3758
3859
### GitHub Organization Configuration YAML
@@ -59,7 +80,7 @@ Export variables `GITHUB_APP_ID`, `GITHUB_APP_INSTALLATION_ID`, and `GITHUB_APP_
5980
```shell
6081
direnv allow
6182
# direnv: loading ~/bruzit/github-organization-as-code/.envrc
62-
# direnv: export +GH_OWNER +GITHUB_APP_ID +GITHUB_APP_INSTALLATION_ID +GITHUB_APP_PEM_FILE
83+
# direnv: export +AWS_ACCESS_KEY_ID +AWS_ENDPOINT_URL_S3 +AWS_SECRET_ACCESS_KEY +GITHUB_APP_ID +GITHUB_APP_INSTALLATION_ID +GITHUB_APP_PEM_FILE +GITHUB_APP_PEM_FILE_PATH +GITHUB_OWNER +TF_VAR_config
6384

6485
# Use Terraform as you need
6586
terraform -chdir=terraform init

terraform/config.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@ terraform {
55
version = "~> 6.0"
66
}
77
}
8+
9+
backend "s3" {
10+
bucket = "bruzit-terraform-github"
11+
workspace_key_prefix = ""
12+
key = "terraform.tfstate"
13+
use_lockfile = true # Set to false only for non-AWS S3 compatible APIs without "conditional object PUTs" capability
14+
region = "us-east-1"
15+
16+
# Only for non-AWS S3 compatible APIs
17+
skip_credentials_validation = true
18+
skip_requesting_account_id = true
19+
}
820
}
921

1022
provider "github" {

0 commit comments

Comments
 (0)