LoginSignup
0
1

More than 1 year has passed since last update.

0から始めるterraform生活

Last updated at Posted at 2021-03-21

概要

terraformの知識はほとんどなく、初めて触るレベルの人間がterraformでAWSでインフラを構築するまでの手順を記し残す

githubリポジトリ

terraformをinstall

HashiCorpのチュートリアルに沿ってインストール

  1. https://www.terraform.io/docs#get-started
  2. https://learn.hashicorp.com/terraform?utm_source=terraform_io&utm_content=terraform_io_hero AWS
  3. https://learn.hashicorp.com/collections/terraform/aws-get-started
  4. https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started

install

$ brew tap hashicorp/tap
$ brew install hashicorp/tap/terraform
$ brew upgrade hashicorp/tap/terraform

autocomplete

$ terraform -install-autocomplete
main.tf
terraform {
  required_providers {
    docker = {
      source = "terraform-providers/docker"
    }
  }
}

provider "docker" {}

resource "docker_image" "nginx" {
  name         = "nginx:latest"
  keep_locally = false
}

resource "docker_container" "nginx" {
  image = docker_image.nginx.latest
  name  = "tutorial"
  ports {
    internal = 80
    external = 8000
  }
}

docker起動

$ terraform init
$ terraform apply

http://localhost:8000/
これでアクセスできない場合、ESETなどのセキュリティソフトが起因していることがあります。

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1