aws terraform start an instance code example

Example 1: aws instance creation using terraform

resource "aws_instance" "myec2" {
  ami                    = ""
  instance_type          = "t2.micro"
  vpc_security_group_ids = ["SECURITY-GROUP-ID"]
  key_name               = ""
  subnet_id              = ""
  iam_instance_profile = ""

  tags = {
    Name = ""
  }
}

Example 2: terraform script to launch aws instance launch

provider "aws" { access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "${var.aws_region}" } resource "aws_instance" "web_server" { ami = "ami-061392db613a6357b" instance_type = "t2.small" tags { Name = "my_server" } }

Tags:

Misc Example