https://github.com/telekom-mms/terratest-action
Github Action for Terratest
https://github.com/telekom-mms/terratest-action
Last synced: 2 months ago
JSON representation
Github Action for Terratest
- Host: GitHub
- URL: https://github.com/telekom-mms/terratest-action
- Owner: telekom-mms
- License: mpl-2.0
- Created: 2022-12-12T13:06:23.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T16:25:39.000Z (2 months ago)
- Last Synced: 2025-04-08T17:31:20.829Z (2 months ago)
- Language: Go
- Size: 136 KB
- Stars: 0
- Watchers: 4
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# terraform-action
A GitHub action to run terratest test cases against your repository.
## Usage
### Prepare Repository
Create the following in your repository where the action should run.
First setup a `tests` directory and create the following files.
`tests/main.tf`
* terraform configuration to test with this action
`tests/terratest.yaml`
* configuration what tests should be run with terratest
### Setup Workflow
To use this GitHub Action, add the following parts to your YAML workflow file, e.g. `.github/workflows/terratest.yml`.
``` yaml
...jobs:
...
steps:
...- name: Setup Go
uses: actions/setup-go@v3
with:
go-version: 1.19
check-latest: true- name: Checkout Github Action
uses: actions/checkout@v3
with:
repository: telekom-mms/terratest-action
ref: main
path: ./terratest-action
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}...
- name: Run Test for ${{ matrix.example }} Setup
uses: ./terratest-action
with:
test: azure
test_type: plan
azure_client_id: ${{ secrets.AZURE_CLIENT_ID }}
azure_client_secret: ${{ secrets.AZURE_CLIENT_SECRET }}
azure_subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
azure_tenant_id: ${{ secrets.AZURE_TENANT_ID }}
```## Configuration
### Workflow
#### Inputs
| name | description | required |
| --------------------- | ---------------------------------------------| -------- |
| test | name of the test to run (e.g. azure) | true |
| test_type | which test case should be run, plan or apply | true |
| azure_client_id | application id of azure ad application | false |
| azure_client_secret | application password of azure ad application | false |
| azure_subscription_id | azure subscription id | false |
| azure_tenant_id | azure tenant id | false |### Terratest
| name | description | `terratest.yaml` |
| ----------| ------------------------------------------------------------------------------ | ---------------- |
| functions | functions that should be testet bases on the test (e.g. azure) that should run | `functions: []` |
| options | key: value pair that should be proved against the build | `options: {}` |#### azure
test case
* *Exists
* description: check if the terraformresource was created. Returns true or false* *Show
* description: runs a terraform show on the created resource and checks if the results matches the test-conditions defined in `options`Actually the following test cases are supported:
* ContainerRegistryExists
* ContainerRegistryShow
* VirtualNetworkExists
* SubnetExists
* PublicAddressExists
* PublicAddressShow
* NetworkInterfaceExists## Examples
* [Workflow configuration](examples/workflow.yml)
* [Terratest configuration](examples/terratest.yaml)