Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
59a2ab2
Update documentation
cmd-ntrf Mar 18, 2025
91ecc0d
Replace list of specific subdomains by *
cmd-ntrf Mar 26, 2025
9ee5fb0
Merge pull request #347 from ComputeCanada/wildcard_record
cmd-ntrf Mar 27, 2025
f9e2713
Update changelog
cmd-ntrf Mar 27, 2025
f909189
Add docs on prometheus
cmd-ntrf Mar 27, 2025
77855c9
Fix typo in docs
cmd-ntrf Apr 7, 2025
5073654
Make sure ssh keys do not have whitespace prefix or suffix
cmd-ntrf Apr 10, 2025
8126d82
Merge pull request #350 from ComputeCanada/sshkey_triming
cmd-ntrf Apr 10, 2025
e898422
Reduce choices of availablity zones in AWS
cmd-ntrf Apr 10, 2025
3e52c06
Merge pull request #351 from ComputeCanada/aws_av-zone_improv
cmd-ntrf Apr 11, 2025
64b67bc
Enable puppet prometheus reporting
cmd-ntrf Apr 3, 2025
d8f1743
Fix typo in changelog
cmd-ntrf Apr 22, 2025
4471777
Fix codespell check
cmd-ntrf Apr 22, 2025
a4da6de
Move definition of minimum instance root disk size in design module
cmd-ntrf Apr 17, 2025
be04440
Add warnings on low disk size per tags and cloud provider
cmd-ntrf Apr 17, 2025
3dbdb1c
Bump terraform version to 1.5.7
cmd-ntrf Apr 17, 2025
c45ded6
Update docs
cmd-ntrf Apr 17, 2025
03281a5
Merge pull request #353 from ComputeCanada/mgmt1_disk_size
cmd-ntrf Apr 22, 2025
54a89f4
Make mkdocs display warning for invalid anchor links
cmd-ntrf Apr 25, 2025
6604eb5
Fix anchor link in docs
cmd-ntrf Apr 25, 2025
5ab29de
Fix developer doc anchor link
cmd-ntrf Apr 25, 2025
363c61c
Add Trivy misconfiguration scan github workflow
Scirelgar Mar 28, 2025
6d5ba7e
Add examples to scanning (excluding advanced)
cmd-ntrf Apr 23, 2025
e7338fa
Change trivy workflow name
cmd-ntrf Apr 23, 2025
31b42be
Add .trivyignore file
cmd-ntrf Apr 23, 2025
f2098c0
Filter sarif duplicated results
cmd-ntrf Apr 23, 2025
0204d5a
Improve sarif filtering
cmd-ntrf Apr 23, 2025
c2abdc2
Change output format
cmd-ntrf Apr 24, 2025
7c6874f
Change highlight language in security summary
cmd-ntrf Apr 23, 2025
ad44406
Add on push any branch to trivy scan
cmd-ntrf Apr 23, 2025
a39becb
Change output format for trivy in action
cmd-ntrf Apr 24, 2025
bff0017
Add trivy command
cmd-ntrf Apr 24, 2025
de698ae
Add documentation on trivy
cmd-ntrf Apr 24, 2025
e363331
Merge pull request #355 from ComputeCanada/codescan
cmd-ntrf Apr 25, 2025
32a17b3
Replace steps by strategy matrix in terraform CI/CD
cmd-ntrf Apr 25, 2025
9865403
Add missing terraform setup to dns test
cmd-ntrf Apr 25, 2025
6c0116b
Remove shell bash from trivy run
cmd-ntrf Apr 25, 2025
4d2e4fb
Merge trivy and terraform testing job
cmd-ntrf Apr 25, 2025
65da305
Normalize checkout version
cmd-ntrf Apr 25, 2025
e5ae1c2
Remove usage of test_provider
cmd-ntrf Apr 25, 2025
90f72b4
Remove action test_provider no longer used
cmd-ntrf Apr 25, 2025
b051f17
Fix example name
cmd-ntrf Apr 25, 2025
7476285
Fix sed
cmd-ntrf Apr 25, 2025
52a05b1
Remove advanced example for now
cmd-ntrf Apr 25, 2025
18caf39
Disable fail-fast in github action
cmd-ntrf Apr 25, 2025
df27d7e
Limit execution of workflows on paths for docs and terraform
cmd-ntrf Apr 25, 2025
89eaeba
Drop usage of github-action-markdown-link-check
cmd-ntrf Apr 25, 2025
b69968d
Update action versions
cmd-ntrf Apr 29, 2025
fd2627c
Run trivy action only if provider and example code is valid
cmd-ntrf Apr 29, 2025
1256be6
Replace for loop by single sed call
cmd-ntrf Apr 29, 2025
a99968f
Merge pull request #356 from ComputeCanada/workflow-paths
cmd-ntrf Apr 29, 2025
8a10392
Make count optional in validation
cmd-ntrf Apr 29, 2025
35c3496
Merge pull request #357 from ComputeCanada/fix_validate_prefix
cmd-ntrf Apr 29, 2025
e431789
Add advanced examples to validation in CI/CD
cmd-ntrf Apr 29, 2025
91ecbc1
Add main branch push
cmd-ntrf Apr 30, 2025
6c7ef37
Merge pull request #358 from ComputeCanada/advanced_cicd
cmd-ntrf May 8, 2025
cca5be0
Remove aws_key_pair
cmd-ntrf May 5, 2025
4837d4c
Merge pull request #359 from ComputeCanada/aws-no-key
cmd-ntrf May 8, 2025
6201f8a
Merge pull request #349 from ComputeCanada/puppet_prom_report
cmd-ntrf May 20, 2025
27a2be4
Move puppet server inclusion etc/hosts to earlier steps
cmd-ntrf May 22, 2025
569363a
Update changelog
cmd-ntrf May 22, 2025
c1f2fda
Add release date to 14.3.0
cmd-ntrf May 22, 2025
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
29 changes: 0 additions & 29 deletions .github/actions/test_provider/action.yaml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/docs.yaml

This file was deleted.

9 changes: 8 additions & 1 deletion .github/workflows/mkdocs_test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions
name: build documentation
on: [push, pull_request]
on:
push:
paths:
- docs/*
pull_request:
paths:
- docs/*

# Declare default permissions as read only.
permissions: read-all
jobs:
Expand Down
14 changes: 0 additions & 14 deletions .github/workflows/mlc_config.json

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
uses: actions/checkout@v4

- name: Retrieve tag name
id: tag_name
run: |
echo ::set-output name=SOURCE_TAG::${GITHUB_REF#refs/tags/}

- uses: hashicorp/setup-terraform@v1
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.4.0
terraform_version: 1.5.7

- name: Create tarballs and zips
if: startsWith(github.ref, 'refs/tags/')
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/spelling.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
codespell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: codespell-project/actions-codespell@master
- uses: actions/checkout@v4
- uses: codespell-project/actions-codespell@v2.1
with:
check_filenames: true
ignore_words_list: keypair
ignore_words_list: keypair, te
only_warn: 1
185 changes: 132 additions & 53 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,78 +3,157 @@ name: Validate Terraform code
on:
push:
branches:
- '*'
- main
paths:
- aws/*
- azure/*
- common/*
- dns/*
- examples/*
- openstack/*
- ovh/*
- .github/workflows/test.yaml
pull_request:
branches:
- main
paths:
- aws/*
- azure/*
- common/*
- dns/*
- examples/*
- openstack/*
- ovh/*
- .github/workflows/test.yaml

jobs:
test:
env:
TF_VERSION: 1.4.0

validate_cloud_providers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
provider: ['aws', 'azure', 'gcp', 'openstack', 'ovh']
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: "1.5.7"
- run: terraform -chdir=${{ matrix.provider }} init
- run: terraform -chdir=${{ matrix.provider }} validate

validate_dns_providers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
provider: ['cloudflare', 'gcloud', 'txt']
steps:
- name: Checkout code
uses: actions/checkout@main

- name: Cache Terraform
id: cache-terraform
uses: actions/cache@v4
uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
path: ~/bin
key: terraform-${{ env.TF_VERSION }}
terraform_version: "1.5.7"
- run: terraform -chdir=dns/${{ matrix.provider }} init
- run: terraform -chdir=dns/${{ matrix.provider }} validate

- name: Download terraform
if: steps.cache-terraform.outputs.cache-hit != 'true'
run: |
mkdir -p "${HOME}/bin"
curl -sSL -o terraform.zip "https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip"
unzip terraform.zip
mv -v terraform "${HOME}/bin/terraform"
~/bin/terraform version

- name: Create SSH keys
run: |
ssh-keygen -b 2048 -t rsa -q -N "" -f ~/.ssh/id_rsa

- name: Test AWS
uses: ./.github/actions/test_provider
validate_examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- aws
- azure
- gcp
- openstack
- ovh
# - advanced/spot_instances/aws
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
path: ~/bin
provider: 'aws'
terraform_version: "1.5.7"
- name: Generate an SSH key
run: ssh-keygen -b 2048 -t rsa -q -N "" -f ~/.ssh/id_rsa
- run: sed -i "s;git::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git//;../../;g" examples/${{ matrix.example }}/main.tf;
- run: terraform -chdir=examples/${{ matrix.example }} init
- run: terraform -chdir=examples/${{ matrix.example }} validate

- name: Test Azure
uses: ./.github/actions/test_provider
validate_advanced_examples:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
example:
- spot_instances/aws
- spot_instances/azure
- spot_instances/gcp
- basic_puppet/openstack
- elk/openstack
- k8s/openstack
- lustre/openstack
- spark/openstack
steps:
- uses: actions/checkout@v4
- uses: hashicorp/setup-terraform@v3
with:
path: ~/bin
provider: 'azure'
terraform_version: "1.5.7"
- name: Generate an SSH key
run: ssh-keygen -b 2048 -t rsa -q -N "" -f ~/.ssh/id_rsa
- run: sed -i "s;git::${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git//;../../../../;g" examples/advanced/${{ matrix.example }}/main.tf;
- run: terraform -chdir=examples/advanced/${{ matrix.example }} init
- run: terraform -chdir=examples/advanced/${{ matrix.example }} validate

- name: Test GCP
uses: ./.github/actions/test_provider
with:
path: ~/bin
provider: 'gcp'
trivy-vuln-scan:
name: Running Trivy Scan
runs-on: ubuntu-latest
needs: [validate_cloud_providers, validate_examples]
steps:
- uses: actions/checkout@v4

- name: Test OpenStack
uses: ./.github/actions/test_provider
with:
path: ~/bin
provider: 'openstack'
- name: Resolve symbolic links and fix source
run: |
rm {aws,azure,gcp,openstack}/{outputs.tf,variables.tf}
for cloud in aws azure gcp openstack; do
cp common/outputs.tf common/variables.tf $cloud/;
done
sed -i 's;git::https://github.com/ComputeCanada/magic_castle.git//;../../;g' examples/*/*.tf

- name: Test OVH
uses: ./.github/actions/test_provider
- name: Manual Trivy Setup
uses: aquasecurity/setup-trivy@v0.2.2
with:
path: ~/bin
provider: 'ovh'
version: v0.61.1
cache: true

- name: Run Trivy on providers
run: trivy config --misconfig-scanners terraform --tf-exclude-downloaded-modules --skip-dirs examples/advanced --format json -o trivy-results.json .

- name: Test CloudFlare DNS
- name: Convert Trivy JSON output to SARIF and filter duplicated results
run: |
~/bin/terraform -chdir=dns/cloudflare init
~/bin/terraform -chdir=dns/cloudflare validate
trivy convert --format sarif trivy-results.json --output trivy-results.sarif
# When converting from JSON to SARIF, some information, like origin of the misconfiguration, is lost.
# The lost information results in duplicated issues. We filter these issues with jq and create a new
# sarif file that will be uploaded to the security tab.
jq 'reduce .runs[0].results[] as $a ([]; if IN(.[]; $a) then . else . += [$a] end)' trivy-results.sarif > trivy-results-filtered.sarif
jq ".runs[0].results |= $(cat trivy-results-filtered.sarif)" trivy-results.sarif > trivy-results-final.sarif
mv trivy-results-final.sarif trivy-results.sarif

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: "trivy-results.sarif"

- name: Test Google Cloud DNS
- name: Publish Trivy Output to Summary
run: |
~/bin/terraform -chdir=dns/gcloud init
~/bin/terraform -chdir=dns/gcloud validate
if [[ -s trivy-results.json ]]; then
{
echo "### Trivy Misconfiguration Scan Output"
echo "<details><summary>Click to expand</summary>"
echo ""
echo '```console'
echo '$ trivy config --misconfig-scanners terraform --tf-exclude-downloaded-modules --skip-dirs examples/advanced .'
trivy convert --format table trivy-results.json
echo '```'
echo "</details>"
} >> $GITHUB_STEP_SUMMARY
fi
6 changes: 6 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Some instance should have public ip addresses
AVD-GCP-0031

# Magic Castle does not handle VPC flow logs
AVD-GCP-0029
AVD-AWS-0178
25 changes: 24 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,29 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [14.3.0] 2025-05-22

### Added
- [github] Added Trivy misconfiguration scan of Terraform code (PR #355)
- [github] Added advanced examples to validation in CI/CD (PR #358)

### Changed

- [dns] The default list of vhost subdomains has been replaced by a `["*"]`.
This simplifies configuration of new virtual hosts in the reverse proxy. (PR #347)
- [common] Made sure ssh keys do not have whitespace prefix or suffix (PR #350)
- [aws] Reduced choices of availablity zones in AWS (PR #351)
- [common] Bumped terraform minimum version to 1.5.7
- [common] Improved instance root disk size computation and warnings (PR #353)
- [github] Modernized github workflows (PR #356)
- [common] Made `count` optional in validation (PR #357)
- [cloud-init] Enabled puppet prometheus reporting (PR #349)
- [cloud-init] Moved puppet server inclusion in /etc/hosts to earlier steps

### Removed

- [aws] Removed key pair resource (PR #359)

## [14.2.1] 2025-02-21

No changes to infrastructure code.
Expand All @@ -19,7 +42,7 @@ Refer to [puppet-magic_castle changelog](https://github.com/ComputeCanada/puppet

- Generalized definition of instance's specs (PR #341)
- Made tf user a system user (PR #343)
- Splited sshd config so that Match directives are in their own files (PR #345)
- Split sshd config so that Match directives are in their own files (PR #345)

## [14.1.3] 2025-01-29

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ From these new possibilities emerged an open-source software project named Magic

## Setup

- Install [Terraform](https://releases.hashicorp.com/terraform/) (>= 1.4.0)
- Install [Terraform](https://releases.hashicorp.com/terraform/) (>= 1.5.7)
- Download the [latest release of Magic Castle](https://github.com/ComputeCanada/magic_castle/releases) for the cloud provider you wish to use.
- Uncompress the release
- Follow the instructions
Expand Down
Loading