Last active
May 17, 2017 14:04
-
-
Save yamamoto-febc/ea42fb342e7612fa9a9739fdc3bc403e to your computer and use it in GitHub Desktop.
Terraform for さくらのクラウド スタートガイド(第1回) ref: http://qiita.com/yamamoto-febc/items/ae92cd258cf040957487
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| provider "aws" { | |
| access_key = "ACCESS_KEY_HERE" | |
| secret_key = "SECRET_KEY_HERE" | |
| region = "ap-northeast-1" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| provider "sakuracloud" { | |
| token = "先ほど取得した[ACCESS_TOKEN]" | |
| secret = "先ほど取得した[ACCESS_TOKEN_SECRET]" | |
| } | |
| resource "sakuracloud_disk" "disk"{ | |
| name = "disk01" | |
| source_archive_name = "CentOS 7.2 64bit" | |
| # 任意のパスワードを設定してください。 | |
| password = "YourPassword" | |
| } | |
| resource "sakuracloud_server" "server" { | |
| name = "server01" | |
| disks = ["${sakuracloud_disk.disk.id}"] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "sakuracloud_server" "server" { | |
| name = "server01" | |
| disks = ["${sakuracloud_disk.disk.id}"] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "sakuracloud_disk" "disk"{ | |
| name = "disk01" | |
| source_archive_name = "CentOS 7.2 64bit" | |
| # 任意のパスワードを設定してください。 | |
| password = "YourPassword" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ssh root@[確認したグローバルIP] | |
| # パスワードはsakura.tfで指定したものを入力 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ダウンロード | |
| $ curl -L https://releases.hashicorp.com/terraform/0.6.16/terraform_0.6.16_darwin_amd64.zip > ~/terraform/terraform.zip | |
| # 展開 | |
| $ unzip ~/terraform/terraform.zip | |
| # パスを通す | |
| $ export PATH=$PATH:~/terraform/ | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ terraform | |
| usage: terraform [--version] [--help] <command> [<args>] | |
| Available commands are: | |
| apply Builds or changes infrastructure | |
| destroy Destroy Terraform-managed infrastructure | |
| get Download and install modules for the configuration | |
| graph Create a visual graph of Terraform resources | |
| init Initializes Terraform configuration from a module | |
| output Read an output from a state file | |
| plan Generate and show an execution plan | |
| push Upload this Terraform module to Atlas to run | |
| refresh Update local state file against real resources | |
| remote Configure remote state storage | |
| show Inspect Terraform state or plan | |
| taint Manually mark a resource for recreation | |
| validate Validates the Terraform files | |
| version Prints the Terraform version | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 作業用ディレクトリを作る | |
| $ mkdir ~/terraform_start_guide | |
| $ cd ~/terraform_start_guide | |
| # tfファイル作成(内容は以下参照) | |
| $ vi sakura.tf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment