Deploying Amazon EC2 instance using Terraform

Posted: January 5, 2018 in Amazon Web Services (AWS), AWS, Linux, terraform

In previous post  we installed Terraform, now we’ll use it to deploy VM to Amazon

I used Hyper-V CentOS VM on my lap-top.

Preparing Access Keys

In order to connect to Amazon we need Access key and secret access key.

From Amazon console go to Identity and Access Management (IAM)-Users,

Untitled.png

select user who has Administrator Access-Security Credentials tab

Generate access key

1-1.png

export key to csv file

now open template.tf file (created in previous post ) and add following lines

provider "aws" {
access_key = "some key"
secret_key = "secret keys"
region = "eu-west-1"
}

# Resource configuration
resource "aws_instance" "hello-instance" {
ami = "ami-1a962263"
instance_type = "t2.micro"
tags {
Name = "hello-instance"
}
}

For region list refer to https://docs.aws.amazon.com/general/latest/gr/rande.html

I copied ami from portal

2.PNG

Now type terraform init && terraform apply and new instance will be created

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s