GithubHelp home page GithubHelp logo

iameddie / advanced-terraform Goto Github PK

View Code? Open in Web Editor NEW

This project forked from linkedinlearning/advanced-terraform-2823489

0.0 0.0 0.0 32 KB

Advanced Terraform repository

License: Other

HCL 100.00%

advanced-terraform's Introduction

Advanced Terraform

This is the repository for the LinkedIn Learning course Advanced Terraform. The full course is available from LinkedIn Learning.

Advanced Terraform Terraform simplifies and accelerates the configuration of cloud-based environments. DevOps engineers looking to use Terraform in the real world can start by learning how to work with the Terraform CLI and the HashiCorp Configuration Language (HCL). In this course, David Swersky covers these concepts and more, helping you go beyond the basics with this powerful infrastructure as code solution. Using practical use cases, David shows how to manage and automate your infrastructure with Terraform. He steps through how to analyze an existing application running in a client's data center, and design a Terraform configuration that supports the application in AWS. He also goes over advanced concepts, including how to set the values of variables in a Terraform configuration. Plus, he steps through how to develop an application infrastructure with Terraform, create an infrastructure CI/CD pipeline using GitHub and Terraform Cloud, and more.

Instructions

This repository has a folder for each of the videos in the course. The naming convention is [CHAPTER]_[NAME], e.g.: 01_05_base

Installing

  1. To use these exercise files, you must have the following installed:

    • [list of requirements for course]
    • create AWS IAM user with programatic access and keep safe of the keys
    • install AWS CLi
    • aws configure...
    • aws ec2 create-key-pair --key-name tf_key --query 'KeyMaterial' --profile demo --output text >tf_key.pem
    • aws sts get-caller-identity --profile demo
  2. Fork this repository to your own account

  3. Clone your fork to your local machine using the terminal (Mac), CMD (Windows), or a GUI tool like SourceTree.

  4. List of resources(AWS Infrastructure) to create for use case of a web application with ec2 instances and a MySQL DB

  • vpc
  • Elastic Load Balancer
  • ec2 instances
  • subnets(2 subnets)
  • Internet Gatway for internet facing application
  • security groups
  • MySQL DB
  1. Copy the created tf_key.pem into the 01_05_base folder
  2. Make a copy of the terraform.tfvars.backup file and paste it into the 01_05_base folder
  3. Rename the terraform.tfvars.backup to terraform.tfvars

.gitignore contains important files that we don't want t be commited to the public repository

  1. cd into 01_05_base folder
  2. run $ terraform init
  3. run $ terraform plan -out=s1.tfplan
  4. run $ terraform graph and cpy to paste on http://webgraphviz.com/ to see a graph 12: $ terraform show s1.tfplan #to see a plan generated by someone in the console
  5. $ terraform show -json s1.tfplan #shows macine readable json
  6. $ terraform apply s1.tfplan #to create the resources
  7. $ chmod 400 tf_key.pem
  8. $ ssh -i "tf_key.pem" [email protected]
  9. By default show command displays the state
  • $ terraform show
  1. Review the created instance #useful for scripting
  • $ aws ec2 describe-instances --query "Reservations[].Instances[].InstanceId" --output table --profile demo
  1. Clean/Destroy the created resources
  • $ terraform destroy

Commands

$ terraform plan -var deploy_environment=PROD $ terraform console #starts a repl(read, evaluate, print, look) => 5 != 5 ? "foo" : "bar" #if condition is true, it prints "foo" but if false, it prints "bar"(turnery operator)

  • aws_instance=node_instances.*.public_dns #the * asteristik is calld a sprat, to regenerate count
  • "${data.aws_iam_user.terraform.arn}" #string intrapolation to allow the injection the resources of the terraform user $ terraform plan -out=backend.tfplan

03_05-06_multi_environment commands

$ terraform init ../../manifests $ terraform plan -out=s1.tfplan ../..manifests View the resources

  1. $ export AWS_PAGER=""
  2. $ aws ec2 describe-instances
    --filters Name=tag-key,Values=Name
    --query 'Reservations[].Instances[].{Instance:InstanceId,AZ:Placement.AvailabilityZone,Name:Tags[?Key=='Name']|[0].Value,Environment:Tags[?Key=='environment']|[0].Value}'
    --output table

Terraform Cloud

  • You must have an account on app.terraform.io
  1. Navigate to the folder
  2. $ terraform login

Instructor

David Swersky

DevOps and Enterprise Architect with 20+ years of IT experience

Check out some of my other courses on LinkedIn Learning.

advanced-terraform's People

Contributors

dswersky avatar linkedin-learning-a1 avatar nichollsspencer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.