Terraform

To create a new assignment in Terraform, click into one of your courses, and then click Add assignment. Choose Terraform from the drop-down list of available DevOps tools and set the the rest of your assignment's parameters (deadline, etc.). Once the assignment is created, a new folder will be created in the private GitHub/GitLab template repository for the course in which you are added this assignment. This folder will contain a standard Terraform project structure.

Automated test-suite setup

If you would like to add tests that are automatically run by AssignmentOS against each student's solution to your assignment, you can add these to the existing foo_test.go file in the template repository. It would be best if you also renamed this foo_test.go file to something more relevant to your assignment.

We use the Terratest Go library to run automated tests against the resources that are created when we run & deploy the student's Terraform code.

For custom assignments, the student's Terraform code must be deployed to an AWS or GCP account that belongs to you.

For us to have the permission to deploy to your AWS account, you must create an IAM user has all the required permissions to create the resources needed to pass your assignment successfully. The AWS Access Key and Secret Key for this user needs to be then added to the existing credentials file in the template repo. Likewise, for GCP, a service account with all the required permissions must be created in your GCP account, and the service account's key .json file must be added to the template repo (replacing the existing foo.json file).

You can add more than one unit test files. All unit test file names must end with _test.go, and all unit test classes with names that end with _hidden_test.go will not be visible to the student. These hidden unit tests allow you to test candidate's solutions against edge cases etc.

If you want to add files that your hidden unit tests use and hence are also not visible to the student, the names of these files must begin with hidden (case-insensitive), e.g., hiddenFoo.json, hiddenFoo.csv, hidden_foo.go, etc.

The existing dependencies and versions in the go.mod file must not be modified.

GitHub Action & GitLab CI/CD

AssignmentOS uses either GitHub Actions or GitLab CI/CD (depending on whether you use with GitHub or GitLab) to run automated unit tests. We provide the following GitHub Action & GitLab CI/CD file for Terraform assignments. Note that this file is added dynamically to the repo of each student taking your assignment, so please do not include it in your template repo. This file also cannot be changed.

GitHub Action .yml fileGitLab CI/CD .yml file
name: Terraform CI

on: [push]

jobs:

  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3

    - name: Set up Terraform
      uses: hashicorp/setup-terraform@v2
      with:
        terraform_version: 1.3.7
        terraform_wrapper: false

    - name: Set up Go
      uses: actions/setup-go@v4
      with:
        go-version: 1.19

    - name: Download dependencies
      run: go mod download

    - name: Tidy depedencies
      run: go mod tidy

    - name: Test
      run: go test -v

Coming soon!

Last updated