Skip to content

Latest commit

 

History

History
43 lines (22 loc) · 1.24 KB

File metadata and controls

43 lines (22 loc) · 1.24 KB

Infrastructure as Code with Terraform and GitLab

This is a short example of what has to be added to repo in order to have workable terraform in GitLab ci with state kept in GitLab. Full doc is here.

Files are located in the sandbox folder.

CI variables

For AWS credentials are stored in CI variables: AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_DEFAULT_REGION (optionally).

State

This allows to maintain state in GitLab:

terraform {
  backend "http" {
  }
}

infrastructure-as-code-with-terraform-and-gitLab

Templates

The following templates do the magic (IaC security scan and gitlab's TF image to exec tf commands)

include:
  - template: Terraform/Base.gitlab-ci.yml  # https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Terraform/Base.gitlab-ci.yml
  - template: Jobs/SAST-IaC.gitlab-ci.yml   # https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Jobs/SAST-IaC.gitlab-ci.yml

That's it!