/terraform-gitlab-aws

IAC to automate GitLab Omnibus installations with Praefect, Gitaly, and runners on AWS

Primary LanguageHCLMIT LicenseMIT

Terraform GitLab on AWS

1. Installations

1.1 Windows

Terraform Guide

  • Installation Link
  • Click the "Chocolatey on Windows" tab. Manual installation did not work for me
  • Make sure to run as Administrator using Command Prompt

Chocolaty install

Install terraform-docs

  • Use Chocolaty to install. Run on Command Prompt. Link

    choco install terraform-docs

2. Instructions

  1. Run terraform init in each environment's folder
  2. Run terraform get in the environment's folder to register the local modules
  3. Run terraform validate to check for syntax errors. Run terraform fmt to format code
  4. Run terraform plan to understand the changes made
  5. Run terraform apply -var-file="terraform.tfvars" to run with the variables file (Create this file based on terraform.template.tfvars provided) Note: If we want to skip the prompt do terraform apply -var-file="terraform.tfvars" -auto-approve Note: If we want to target only certain resources, we can do terraform apply -var-file="terraform.tfvars" -target module.eks
  6. Run terraform destroy after deployment if used for testing

3. Directory Structure and best practices

The following links were used to provide guidance on the Directory Structure

Best practices for naming conventions

Code Styling

Using modules

4. Interesting bash tips

Getting part of the output of a command in bash

Refer to this link

Example: This command refers to the first output of the second line

kubectl get secrets | awk 'NR==2{print $1}'

Storing the output of a command in bash in a variable to be referenced elsewhere in a bash file

Refer to this link

Example

token_name=$(kubectl get secrets | awk 'NR==2{print $1}')