Ce diaporama a bien été signalé.
Le téléchargement de votre SlideShare est en cours. ×

Introduction To Terraform

Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Publicité
Prochain SlideShare
Terraform introduction
Terraform introduction
Chargement dans…3
×

Consultez-les par la suite

1 sur 14 Publicité

Plus De Contenu Connexe

Diaporamas pour vous (20)

Similaire à Introduction To Terraform (20)

Publicité

Plus récents (20)

Introduction To Terraform

  1. 1. TERRAFORM 3rd October 2018 Introduction to Terraform By Sasitha Rajapaksha
  2. 2. Overview ● Terraform ● What is Terraform ● Why we use Terraform ● Terraform use cases ● Compare with Cloudformation ● Workflow of provisioning ● Hands on with Terraform ○ S3 ○ Cloudfront ○ EC2
  3. 3. Terraform ● Open source ● Mozilla public licence 2.0 ● Created by Hashicorp ● Started in 2014 ● Written in GO ● Pluggable
  4. 4. Terraform is a tool to BUILD, CHANGE and VERSION CONTROL your infrastructure. Terraform can work with multiple cloud infrastructure at the same time and ensure creation and consistency.
  5. 5. Terraform Remote State ● There is default local state Which making sure that developer doesn’t do any changes to the same infrastructure at the same time ● Remote state ○ Work same as the local state but it is useful when working with a team. This remote state will share with each other and block the concurrent changes to the same infrastructure.
  6. 6. Terraform use cases ● Apply incremental changes ● Destroy infrastructure at any time we want ● Preview changes ● Scale easily ● Version control
  7. 7. Terraform vs. Cloudformation resource "aws_s3_bucket" "bucket" { bucket = "my-tf-test-bucket" acl = "private" } { "Resources": { "my-cf-test-bucket":{ "Type": "AWS::S3::Bucket", "Properties":{ "AccessControl":"Private", }, }, } } Terraform Cloudformation
  8. 8. How Terraform works ● Terraform takes variables as a inputs ○ JSON ○ HCL ○ CLI ● Output ip address, texts and etc.. ○ JSON ○ CLI
  9. 9. Let's start
  10. 10. AWS Provider provider "aws" { access_key = "${var.aws_access_key}" secret_key = "${var.aws_secret_key}" region = "us-east-1" } Azure Provider provider "azurerm" { subscription_id = "${var.subscription_id }" client_id = "${var.client_id }" client_secret = "${var.client_secret }" tenant_id = "${var.tenant_id }" }
  11. 11. Workflow of provisioning 1. First start with “terraform init” to setup initial aws or azure providers 2. Then “terraform plan” command to see than plan of what will provision 3. Finally “terraform apply” command to provision all the infrastructure 4. Okay, then you can use “terraform apply” at any time to do any changes to the provisioned infrastructure.
  12. 12. S3 Bucket to store static website resource "aws_s3_bucket" "b" { bucket = "mybucket" acl = "private" tags { Name = "My bucket" } } locals { s3_origin_id = "myS3Origin" }
  13. 13. EC2 instance provider "aws" { region = "us-west-2" } data "aws_ami" "ubuntu" { most_recent = true filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu- trusty-14.04-amd64-server-*"] } filter { name = "virtualization-type" values = ["hvm"] } owners = ["099720109477"] # Canonical } resource "aws_instance" "web" { ami = "${data.aws_ami.ubuntu.id}" instance_type = "t2.micro" tags { Name = "HelloWorld" } }
  14. 14. Creating Cloudfront resource "aws_cloudfront_distribution" "s3_distribution" { origin { domain_name = "${aws_s3_bucket.b.bucket_regional_domain_name}" origin_id = "${local.s3_origin_id}" s3_origin_config { origin_access_identity = "origin-access-identity/cloudfront/ABCDEFG1234567" } } }

×