LogoLogo
  • Project Reclass Infrastructure
  • Frequently Asked Questions
  • Cloud Basics
  • Cloud Basics
  • How to migrate to a new AWS Account
  • Setting up SSL with Bitnami
  • AWS OpsWorks
  • Docker Basics
    • Intro to Docker
    • Buddy Bot
  • Github
    • Project-Reclass/toynet-react
  • Golang
    • Hello, Project Reclass
  • HashiCorp Vault
    • Getting Started with Vault
  • Linux Basics
    • What is a command?
    • Super User
    • Creating and managing users
    • How to move around the filesystem
    • Getting started with vim
    • Running your first shell script
    • Understanding Linux Permissions
    • How to SSH
  • Terraform
  • Terraform Basics
Powered by GitBook
On this page

Was this helpful?

Export as PDF

Terraform Basics

This will be a brief overview on how to create resources in AWS with Terraform

Set Access Credentials for AWS

Configure your AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY with the following

aws configure

Refer to how to access AWS on notes for getting an Access Key and Secret

This example terraform code should give you an idea of how to create resources in this case we'll be making an EC2 Instance

main.tf
# Set your provider and region in this case AWS and Ohio 
provider "aws" {
    region = "us-east-2"
}

resource "aws_instance" "my-first-instance" { # resource first then custom name
    ami           = "123gd4df5678a" # image ID is necessary to tell AWS what to build
    instance_type = "t2.nano" # this is the size of the VM. This size is free tier
    key_name      = "My-first-key" # this will tell AWS which key to use, it must already exist
}
    
    # It's important for readability to have equal signs in a resource align
    # Not doing so may cause issues in running this code
    
    # Save and exit this file and run `terraform init` followed by `terraform apply main.tf`
    

main.tf is the main file terraform runs by default. Create the main.tf file fill it with your Terraform code. Afterwards run: terraform init followed by terraform apply to create your resources.

PreviousHow to SSH

Last updated 3 years ago

Was this helpful?