Skip to main content

Scaffold working directory by GitHub Actions workflow_dispatch event

When you add a new working directory, you can scaffold the directory by GitHub Actions. tfaction provides a workflow for it.

  1. Prepare template directories to scaffold working directories.

example

  1. Configure tfaction-root.yaml's target_groups to use the template.

example

target_groups:
- template_dir: templates/aws
# ...
  1. Set up the workflow

example

  1. Execute GitHub Actions Workflow manually.

image

Then a pull request would be created.

image

Compared with executing commands at the localhost, GitHub Actions has the following merits.

  • GitHub Actions doesn't depend on you local environment
    • You don't have to install tools at local
    • You can avoid the trouble due to the difference of local environment
    • GitHub Actions log is useful for trouble shooting

Placeholdersโ€‹

The following placeholders in templates are replaced.

  • %%TARGET%%: target
  • %%S3_BUCKET_NAME_TFMIGRATE_HISTORY%%: S3 Bucket Name for tfmigrate history files
  • %%GCS_BUCKET_NAME_TFMIGRATE_HISTORY%%: GCS Bucket Name for tfmigrate history files

e.g.

terraform {
required_version = ">= 1.0"
backend "s3" {
bucket = "S3 Bucket Name"
key = "%%TARGET%%/v1/terraform.tfstate" # Placeholder
region = "us-east-1"
}
}

๐Ÿ’ก Skip creating pull requestsโ€‹

If you don't want to create pull requests by GitHub App, please see Support skipping creating pull requests.

๐Ÿ’ก Skip creating aqua.yaml and adding packagesโ€‹

tfaction >= v0.5.25

#910

By default scaffold-working-directory creates aqua.yaml and add some packages.

aqua init
aqua g -i open-policy-agent/conftest terraform-linters/tflint aquasecurity/tfsec hashicorp/terraform

You can skip this.

tfaction-root.yaml

scaffold_working_directory:
skip_adding_aqua_packages: true

By skipping this, you can configure packages and their versions in your template or you can also manage them in repository root's aqua.yaml.