Getting Started with tfaction.
In this getting started, you create a repository from the template repository and set up tfaction and manage GitHub Issue Label with Terraform.
You would know how to set up tfaction and how tfaction works.
Set up.
- Create a repository from this template repository
- Create required resources with Terraform
- Create Personal Access Token
- Fix the template and tfaction-root.yaml
Let's tfaction.
- Scaffold a working directory
- Create a pull request
Create the following resources.
- IAM OpenID Connect provider
- S3 Buckets
- IAM Roles
$ cd aws/github-terraform-ci
$ vi main.tf # Change local values
$ terraform init
$ terraform plan
$ terraform apply
After this getting started, clean up resources.
$ terraform destroy
We recommend using GitHub App instead of Personal Access Token, but in this getting started let's use a personal access token. Create a Personal Access Token and set it as GitHub Actions Secret.
https://github.com/settings/tokens/new
Secret Name: GH_PERSONAL_ACCESS_TOKEN
https://docs.github.com/en/actions/security-guides/encrypted-secrets
Required permission: https://suzuki-shunsuke.github.io/tfaction/docs/config/github-token
$ vi tfaction-root.yaml
$ vi templates/github/main.tf
$ git add tfaction-root.yaml templates/github
$ git checkout -b update-template
$ git commit -m "update template"
$ git push origin update-template
$ gh pr create -t "update template" -b "update template"
Please merge the pull request.
Please run GitHub Actions Workflow scaffold-working-directory
.
$ gh workflow run scaffold-working-directory.yaml -f target=github/foo
Then a pull request would be created.
Please merge the pull request.
The working directory github/foo
was created.
Let's add an issue request label with Terraform.
$ git fetch origin main
$ git checkout -b add-issue-label origin/main
$ vi github/foo/label.tf
label.tf
resource "github_issue_label" "bar" {
repository = "tfaction-getting-started" # CHANGE
name = "bar"
color = "FF0000"
description = "bar"
}
$ git add github/foo/label.tf
$ git commit -m "add an issue label"
$ git push origin add-issue-label
$ gh pr create -t "add an issue label" -b "add an issue label"
Please confirm the result of terraform plan
and merge the pull request.
Then terraform apply
would be run in the main branch.