Skip to content

Latest commit

 

History

History
89 lines (64 loc) · 1.87 KB

README.md

File metadata and controls

89 lines (64 loc) · 1.87 KB

Terraform AWS EC2

This project is a way to provision a basic EC2 with variables on AWS using Terraform CLI. According to Terraform documentation, it's a good practice create several ".tf" files to organize your project, when invoking any command that loads the Terraform configuration, Terraform loads all configuration files within the directory specified in alphabetical order.

Credentials on AWS

Use this article to get your credentials have crated at AWS.

Usage

  • First of all, check if your code is correct:
$ terraform fmt
  • Prepare your working directory for other commands:
$ terraform init
  • Show changes required by the current configuration:
$ terraform plan
  • Create or update infrastructure:
$ terraform apply
  • Destroy previously-created infrastructure:
$ terraform destroy

Basic Examples

  • A basic example for provider .tf:
terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.0"
    }
  }
}

provider "aws" {
  region = var.region
}

resource "aws_instance" "tutorials" {
  ami           = var.ami
  instance_type = var.instance_type
}
  • A basix example for variables .tf:
variable "region" {
  description = "define what region"
  default     = "us-east-1"
}

variable "ami" {
  description = "define what AMI"
  default     = "ami-09e67e426f25ce0d7"
}

variable "instance_type" {
  description = "value"
  default     = "t2.micro"
}    

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT