This directory contains GitHub Actions workflows for testing and publishing the Terraform module to the Terraform Registry.
Runs on push to main/develop branches and pull requests to main.
Jobs:
- test: Validates Terraform configuration and runs tests
- Terraform format check
- Terraform validation
- Terraform test suite
- tflint linting
- security: Runs security scans
- Trivy vulnerability scanner
- tfsec security scanner
- Uploads SARIF results to GitHub Security tab
- example-test: Tests the example configurations
- Validates example Terraform configurations
- Runs terraform plan (requires AWS credentials)
Runs on version tags (v*) to publish to the Terraform Registry.
Jobs:
- release: Creates a GitHub release and publishes to registry
- Validates Terraform configuration
- Generates documentation
- Creates changelog
- Creates GitHub release
- notify: Notifies team of success/failure
Runs on push to main/develop branches and pull requests to main.
Jobs:
- pre-commit: Runs pre-commit hooks and basic checks
- Pre-commit hooks
- Terraform formatting
- Syntax validation
- Trailing whitespace check
- Large file detection
For the workflows to function properly, you need to configure the following secrets in your GitHub repository:
AWS_ACCESS_KEY_ID
: AWS access key for testing example configurationsAWS_SECRET_ACCESS_KEY
: AWS secret key for testing example configurations
GITHUB_TOKEN
: Automatically provided by GitHub Actions
Before pushing, you can run the same validation locally:
# Run all CI validation
make ci-validate
# Run individual steps
make fmt
make validate
make security
make test-ci
To publish a new version to the Terraform Registry:
- Update the version in
versions.tf
if needed - Update the
CHANGELOG.md
with changes - Commit and push changes
- Create and push a version tag:
git tag v1.0.0 git push origin v1.0.0
- The GitHub Action will automatically create a release and publish to the registry
Once published, the module will be available at:
https://registry.terraform.io/modules/Contrast-Security-OSS/ecs-contrast-agent-injection/aws
And can be used in Terraform configurations like:
module "ecs_contrast_agent_injection" {
source = "Contrast-Security-OSS/ecs-contrast-agent-injection/aws"
version = "1.0.0"
# Your configuration here
enabled = true
application_name = "my-app"
# ... other variables
}
- Always test locally first using
make ci-validate
- Use semantic versioning for tags (v1.0.0, v1.0.1, etc.)
- Update CHANGELOG.md before creating releases
- Review security scan results in the GitHub Security tab
- Test with examples to ensure backward compatibility
- Terraform format check fails: Run
terraform fmt -recursive .
- Security scan failures: Review and fix security issues, or add to
.checkov.yml
if false positives - Test failures: Check test files in
tests/
directory - AWS credentials: Ensure AWS secrets are configured for example testing
To enable verbose output in workflows, you can:
- Add
ACTIONS_STEP_DEBUG=true
to repository secrets - Use the workflow dispatch manually with debug options
When contributing to this module:
- Ensure all tests pass locally
- Add tests for new features
- Update documentation
- Follow semantic versioning for releases
- Pull requests to
main
branch
Jobs:
- terraform-validate: Validates Terraform configuration and examples
- terraform-test: Runs comprehensive Terraform tests using
terraform test
- security-scan: Runs security scans using tfsec
- lint: Runs TFLint for Terraform code quality
- docs-check: Verifies documentation is up to date
Triggers:
- Git tags matching
v*.*.*
(e.g.,v1.0.0
)
Jobs:
- release: Creates GitHub release and triggers Terraform Registry publication
To create a release:
# Create and push a tag
git tag v1.0.0
git push origin v1.0.0
Triggers:
- Schedule: Every Monday at 09:00 UTC
- Manual trigger via workflow dispatch
Jobs:
- update-terraform-providers: Updates Terraform provider dependencies and creates PR if changes are available
Triggers:
- Push to
main
branch when Terraform files change - Manual trigger via workflow dispatch
Jobs:
- update-docs: Automatically updates documentation using terraform-docs
Triggers:
- Manual trigger via workflow dispatch
Jobs:
- make-command: Runs specified Make commands with proper tooling setup
Available commands:
help
- Show available Make targetsvalidate
- Validate Terraform configurationfmt
- Format Terraform codesecurity
- Run security scansdocs
- Generate documentationclean
- Clean up generated files
No additional secrets are required for basic functionality. The workflows use:
GITHUB_TOKEN
- Automatically provided by GitHub Actions
For automatic publication to the Terraform Registry:
- Ensure your repository is public
- Register your module at registry.terraform.io
- Configure the registry to monitor your repository
- Create releases using semantic versioning tags
The workflows include:
- tfsec: Terraform static analysis security scanner
- TFLint: Terraform linting tool
- SARIF upload: Security findings are uploaded to GitHub Security tab
Before pushing changes, run tests locally:
# Run all validation checks
make ci-validate
# Run specific checks
make validate
make security
make test-ci
- Update
CHANGELOG.md
with your changes - Create and push a version tag:
git tag v1.0.0 git push origin v1.0.0
- The release workflow will automatically create a GitHub release
- The Terraform Registry will detect the new release within minutes
Some workflows can be triggered manually:
- Go to the Actions tab in your repository
- Select the workflow you want to run
- Click Run workflow
- Choose the branch and any required inputs
All workflows include:
- β Proper error handling and status reporting
- π Artifact upload for test results and reports
- π Security scanning with SARIF upload
- π± Clear status checks for pull requests
- Always test locally before pushing changes
- Keep workflows simple and focused on specific tasks
- Use semantic versioning for releases
- Update documentation when making changes
- Monitor workflow runs and fix any failures promptly
Workflow fails with "terraform not found"
- The
setup-terraform
action handles Terraform installation - Check if the specified version is available
Security scan failures
- Review the security findings in the workflow output
- Update your Terraform code to address security issues
- Consider using
.tfsec
ignore comments for false positives
Test failures
- Run
terraform test
locally to reproduce issues - Check the test artifacts uploaded by the workflow
- Review the test output in the workflow logs
- Check the Actions tab for workflow run details
- Review the Issues page for known problems
- Create a new issue if you encounter problems