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,


select user who has Administrator Access-Security Credentials tab

Generate access key


export key to csv file

now open 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

I copied ami from portal


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: Logo

You are commenting using your 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