Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow targetGroups to be omitted in tfaction-root.yaml #1498

Closed
florianmutter opened this issue Feb 2, 2024 · 4 comments
Closed

Allow targetGroups to be omitted in tfaction-root.yaml #1498

florianmutter opened this issue Feb 2, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@florianmutter
Copy link
Contributor

Feature Overview

We would like to add working directories without needing to add them to tfaction-root.yaml. We would like to only add the tfaction.yaml in the working directory with all settings including target to add a working directory.

Why is the feature needed?

No need to manually maintain a list of working directories in a global config

Example Code

GitHub Actions

tfaction-root.yaml

---
plan_workflow_name: test

draft_pr: true # default is false. If `draft_pr` is true, tfaction creates pull requests as draft
base_working_directory: "" # default is empty, which means the current directory
working_directory_file: tfaction.yaml # default is "tfaction.yaml"
renovate_login: 'renovate[bot]' # default is "renovate[bot]"
label_prefixes:
  target: "target:" # default is "target:"
  tfmigrate: "tfmigrate:" # default is "tfmigrate:"
  skip: "skip:" # default is "skip:"

aqua:
  update_checksum:
    # Update aqua-checksums.json in `setup` action
    enabled: true # default is false
    skip_push: false # default is false
    prune: true # default is false

# https://github.com/suzuki-shunsuke/tfaction/pull/1106
# tfsec:
#   enabled: true
# tflint:
#   enabled: true
# trivy:
#   enabled: false

# We don't recommend disabling this feature.
# update_related_pull_requests:
#   enabled: false

# tfaction >= v0.5.25
# https://github.com/suzuki-shunsuke/tfaction/pull/910
# scaffold_working_directory:
#   skip_adding_aqua_packages: true

# tfaction >= v0.6.0
drift_detection:
  enabled: false
  issue_repo_owner: suzuki-shunsuke
  issue_repo_name: tfaction-example
  num_of_issues: 1
  minimum_detection_interval: 1

tfaction.yaml

target: aws/
aws_region: ap-northeast-1
s3_bucket_name_tfmigrate_history: '<S3 Bucket Name for tfmigrate history files>'
template_dir: templates/aws # This is used by `scaffold-working-dir` action
drift_detection:
  enabled: true
terraform_plan_config:
  aws_assume_role_arn: arn:aws:iam::000000000000:role/GitHubActions_Terraform_AWS_terraform_plan
tfmigrate_plan_config:
  aws_assume_role_arn: arn:aws:iam::000000000000:role/GitHubActions_Terraform_AWS_tfmigrate_plan
terraform_apply_config:
  aws_assume_role_arn: arn:aws:iam::000000000000:role/GitHubActions_Terraform_AWS_terraform_apply
tfmigrate_apply_config:
  aws_assume_role_arn: arn:aws:iam::000000000000:role/GitHubActions_Terraform_AWS_tfmigrate_apply

Note

No response

@florianmutter florianmutter added the enhancement New feature or request label Feb 2, 2024
@suzuki-shunsuke
Copy link
Owner

suzuki-shunsuke commented Feb 2, 2024

Thank you for your feedback!

I understand your proposal. It makes sense.

  1. template_dir should be set in tfaction-root.yaml as this is used for scaffolding.

e.g. tfaction-root.yaml

plan_workflow_name: test
template_dir: templates/aws

No need to manually maintain a list of working directories in a global config

If you create working directories in some subdirectories, you don't need to maintain the list of working directories in tfaction-root.yaml.

e.g.

terraform/
  foo/
    tfaction.yaml
  bar/
    tfaction.yaml
  ...
target_groups:
  - working_directory: terraform/
    target: terraform/
  1. If you create working directories on the repository root directory, maybe you can make working_directory and target empty.
target_groups:
  - working_directory: ""
    target: ""

Maybe this target group matches with all working directories, though I'm not sure if it works well.
I'll test if it works well.

@suzuki-shunsuke
Copy link
Owner

  1. If you create working directories on the repository root directory, maybe you can make working_directory and target empty.
target_groups:
  - working_directory: ""
    target: ""

Maybe this target group matches with all working directories, though I'm not sure if it works well.
I'll test if it works well.

I tried a little. It seems to work well.

@florianmutter
Copy link
Contributor Author

If you create working directories in some subdirectories, you don't need to maintain the list of working directories in tfaction-root.yaml.

This is actually enough for us! We have a top level terraform/ folder that contains all our states.

If you want you can close this issue in favor of #1502

Thank you very much.

@suzuki-shunsuke
Copy link
Owner

Sounds good!
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants