Terraform: Difference between revisions
Content added Content deleted
Line 39: | Line 39: | ||
<pre> |
<pre> |
||
provider "aws" { |
provider "aws" { |
||
access_key = " |
access_key = "AKIAJTS6BwYereLDFVNWA" |
||
secret_key = " |
secret_key = "lWjjHcTnadsEAmgh/fFYpQmSFUCUsy9Twvdd5122vY" |
||
region = "us-west-2" |
region = "us-west-2" |
||
} |
} |
||
resource "aws_instance" " |
resource "aws_instance" "ubuntu-instance" { |
||
ami = "ami-23b34343" |
ami = "ami-23b34343" |
||
instance_type = "t2.micro" |
instance_type = "t2.micro" |
||
tags { |
tags { |
||
Name = " |
Name = "my-terraform-ubuntu-instance" |
||
} |
} |
||
} |
} |
Revision as of 11:59, 5 October 2018
Installation
Install unzip
sudo apt-get install unzip
Download latest version of the terraform
wget https://releases.hashicorp.com/terraform/0.11.8/terraform_0.11.8_linux_amd64.zip
Extract the downloaded file archive
unzip terraform_0.11.8_linux_amd64.zip
Move the executable into a directory searched for executables
sudo mv terraform /usr/local/bin/
Run it
terraform --version
Provision AWS EC2 Cloud Instance
Source: linoxide.com
Create EC2 user under:
IAM > Users > Add User click only "Programmatic access". Create Group: filter by keyword AmazonEC2, Select AmazonEC2FullAccess. Download .csv file
Initialise Terraform:
mkdir terraform cd terraform/ terraform init nano aws.tf
provider "aws" { access_key = "AKIAJTS6BwYereLDFVNWA" secret_key = "lWjjHcTnadsEAmgh/fFYpQmSFUCUsy9Twvdd5122vY" region = "us-west-2" } resource "aws_instance" "ubuntu-instance" { ami = "ami-23b34343" instance_type = "t2.micro" tags { Name = "my-terraform-ubuntu-instance" } }
terraform plan terraform apply
terraform show
- References
{{#widget:DISQUS
|id=networkm
|uniqid=Terraform
|url=https://aman.awiki.org/wiki/Terraform
}}