From 7e61bfc4be238adab2edad9845b33495ea83da6d Mon Sep 17 00:00:00 2001 From: Robert Fairburn <8029478+rfairburn@users.noreply.github.com> Date: Tue, 1 Apr 2025 09:51:43 -0500 Subject: [PATCH] tfvalidate per file change on PR and fmt example (#21) --- .github/workflows/tfvalidate.yml | 12 ++++++++++-- example/main.tf | 12 ++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tfvalidate.yml b/.github/workflows/tfvalidate.yml index f7c5331..f4a94f2 100644 --- a/.github/workflows/tfvalidate.yml +++ b/.github/workflows/tfvalidate.yml @@ -35,9 +35,17 @@ jobs: uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 with: egress-policy: audit - - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + - name: Clone repo + uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b + with: + fetch-depth: 0 - id: matrix - run: echo "value=$(find ./ -type f -name '*.tf' | awk -F/ 'BEGIN { OFS="/" } ; {$NF=""; print }' | sort -u | jq -c -s -R 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + run: | + if [[ "${{ github.event_name }}" = "pull_request" ]]; then + echo "value=$(git diff --name-only origin/${{ github.base_ref }} | awk -F/ 'BEGIN { OFS="/" }; { if ( $NF ~ "\.tf$") { $NF=""; print "./" $0 } }' | sort -u | jq -c -s -R 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + else + echo "value=$(find ./ -type f -name '*.tf' | awk -F/ 'BEGIN { OFS="/" } ; {$NF=""; print }' | sort -u | jq -c -s -R 'split("\n")[:-1]')" >> ${GITHUB_OUTPUT} + fi tfvalidate: name: terraform validate runs-on: ubuntu-latest diff --git a/example/main.tf b/example/main.tf index be165c6..8a295c2 100644 --- a/example/main.tf +++ b/example/main.tf @@ -74,8 +74,8 @@ module "fleet" { max_capacity = 5 } # 4GB Required for vulnerability scanning. 512MB works without. - mem = 4096 - cpu = 512 + mem = 4096 + cpu = 512 extra_environment_variables = merge( local.fleet_environment_variables, # uncomment if using a3 carves @@ -87,10 +87,10 @@ module "fleet" { # extra_secrets = module.mdm.extra_secrets # extra_execution_iam_policies = module.mdm.extra_execution_iam_policies # extra_iam_policies = concat( - # uncomment if using a3 carves - # module.osquery-carve.fleet_extra_iam_policies, - # uncomment if using firehose - # module.firehose-logging.fleet_extra_iam_policies, + # uncomment if using a3 carves + # module.osquery-carve.fleet_extra_iam_policies, + # uncomment if using firehose + # module.firehose-logging.fleet_extra_iam_policies, # ) } rds_config = {