Code Monkey home page Code Monkey logo

tf-demo's Introduction

Infrastructure as code(IaC)

  • Manage infrastructure on multiple cloud platforms
  • Human-readable
  • Track resource changes

Standardize workflow

~~~graph-easy --as=boxart
[ Dev ] -> [ IaC ] -> [Plan] -> [Apply] -> [AWS]
[Apply] -> [Azure]
[Apply] -> [K8s]
~~~

To deploy infrastructure with Terraform:

  • Scope - Identify the infrastructure for your project.
  • Author - Write the configuration for your infrastructure.
  • Initialize - Install the plugins Terraform needs to manage the infrastructure.
  • Plan - Preview the changes Terraform will make to match your configuration.
  • Apply - Make the planned changes.

Basic Usage

resource "local_file" "foo" {
  content  = "foo!"
  filename = "${path.module}/foo.txt"
}

resource "random_string" "password" {
  length  = 18
  upper   = true
  lower   = true
  number  = true
  special = false
}

output "password" {
  value = random_string.password.result
}

Data VS Variable

  • Data sources provide dynamic information about entities that are not managed by the current Terraform and configuration.
  • Variables provide static information.
  • Data sources allow data to be fetched or computed for use elsewhere in Terraform configuration.
data "aws_ami" "free" {
  most_recent = true
  owners      = ["amazon"]

  filter {
    name   = "name"
    values = ["amzn2-ami-hvm-2.0.????????.?-x86_64-gp2"]
  }
}

variable "instance_name" {
  description = "Value of the Name tag for the EC2 instance"
  type        = string
  default     = "TerraformDemo"
}

Command

  • terraform init
  • terraform validate
  • terraform plan
  • terraform apply
  • terraform show

Dependence

  • terraform-cli
  • aws-cli
  • graph-easy

Reference

tf-demo's People

Contributors

xuanyu-h avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.