Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 the trust policy from the Security section (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.
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,33 @@ jobs:
path: image.tar.gz
retention-days: 1

# 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 and create the production environment 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. The deploy job runs once AWS is set up:

1. **Stage 2:** `terraform -chdir=infra apply` builds the `capstone-deploy` role.
2. **Settings → Secrets and variables → Actions → Variables:** add `AWS_DEPLOY_ROLE_ARN`, set to the output of `terraform -chdir=infra output -raw deploy_role_arn`.
3. **Stage 3, Settings → Environments:** create `production`, with yourself as a required reviewer.

Then re-run this workflow. The deploy waits for your approval, pushes the scanned image to ECR and deploys it with Systems Manager.
EOF

deploy:
needs: build
# Only main, and never for a pull request.
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
# Only main, never for a pull request, and only once AWS is set up.
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && vars.AWS_DEPLOY_ROLE_ARN != ''
runs-on: ubuntu-latest
# Waits here for your approval. The AWS role only trusts this environment.
environment:
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@
| **Cost** | About **$0.12 an hour** while it is up. `terraform -chdir=infra destroy` when you stop |
| **Deliverable** | A live HTTPS app that only your pipeline can change, a README that explains every security decision, the evidence that it holds up, then an account with nothing running |

> [!WARNING]
> **GitHub Actions is switched off on this template repo.** There is no AWS account or `production` environment behind it. In **your** repo every push runs the gates, and every deploy waits for you.
> [!NOTE]
> [![CI/CD Pipeline](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions/workflows/pipeline.yml/badge.svg)](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions/workflows/pipeline.yml)
>
> **The pipeline runs on this template repo.** Open the [Actions tab](https://github.com/wjpearce-github/TechTwoForty-Capstone/actions) to see every gate run against this code and read the logs. There is no AWS account behind it, so instead of deploying, each run ends with a job called **Deploy skipped: set up AWS first** that lists what to set. In **your** repo, once `AWS_DEPLOY_ROLE_ARN` and the `production` environment are set up, every push runs the gates and every deploy waits for you.

## The big picture

Expand Down
Loading