项目作者: GlennChia

项目描述 :
IAC to automate GitLab Omnibus installations with Praefect, Gitaly and runners on AWS
高级语言: HCL
项目地址: git://github.com/GlennChia/terraform-gitlab-aws.git
创建时间: 2020-07-15T09:09:10Z
项目社区:https://github.com/GlennChia/terraform-gitlab-aws

开源协议:MIT License

下载


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

    1. 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

  • @brikis98?source=post_page-----25526d65f73d----------------------">How to create reusable infrastructure with Terraform 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

  1. 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

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