diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b2937e1..a526095 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -10,7 +10,29 @@ permissions: id-token: write jobs: + # A repo with no audit role yet (like the template repo) runs this job instead + # of the benchmark, and it says what to set up. Once AWS_AUDIT_ROLE_ARN is set, it skips. + benchmark-not-set-up: + name: "Benchmark skipped: set up AWS first" + if: vars.AWS_AUDIT_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Benchmark skipped: set up AWS first::Set the AWS_AUDIT_ROLE_ARN variable to run the CIS benchmark. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Benchmark skipped: this repo has no audit role yet + + The weekly Prowler CIS benchmark signs in to AWS as a read-only `security-audit` role: + + 1. Create the `security-audit` role with `reference/security-audit-trust.json` (Security section, Unit 1). + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_AUDIT_ROLE_ARN`, set to that role's ARN. + + Then run it from **Actions → Benchmark → Run workflow**, or wait for Monday's run. + EOF + prowler: + if: vars.AWS_AUDIT_ROLE_ARN != '' runs-on: ubuntu-latest steps: # Pinned to a full commit SHA, not a version tag. Unit 3 explains why. diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f7041fa..860491f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -97,11 +97,33 @@ jobs: name: security-reports path: reports/ + # A repo with no AWS role yet (like the template repo) runs this job instead + # of deploy, and it says what to set up. Once AWS_DEPLOY_ROLE_ARN is set, it skips. + deploy-not-set-up: + name: "Deploy skipped: set up AWS first" + needs: build + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN == '' + runs-on: ubuntu-latest + steps: + - name: Say what to set up + run: | + echo "::notice title=Deploy skipped: set up AWS first::Every gate passed. Set the AWS_DEPLOY_ROLE_ARN variable to deploy. The run summary lists the steps." + cat >> "$GITHUB_STEP_SUMMARY" <<'EOF' + ## Deploy skipped: this repo has no AWS role yet + + Every gate in the build job passed. To let the deploy job sign in to AWS: + + 1. Make the `github-deploy` role, if you have not already (CI/CD section, Phase 4). + 2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_DEPLOY_ROLE_ARN`, set to that role's ARN. + + Then re-run this workflow. + EOF + # Deploying is the last stage of the lifecycle, so it only happens for main. - # A pull request never gets to sign in to AWS. + # A pull request never gets to sign in to AWS. And it needs a role to sign in as. deploy: needs: build - if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' + if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN != '' runs-on: ubuntu-latest permissions: id-token: write