Skip to content

americano212/terraform-usage

Repository files navigation

πŸ–₯ Terraform Usage Repository

πŸ“Œ Case-by-case Teraform Usage Repository

🧿 Case

Case Link Note
S3+CDN 정적 μ›ΉνŽ˜μ΄μ§€ 배포 s3-cloudfront-deploy --------
슀팟 μΈμŠ€ν„΄μŠ€ 호좜(μΌνšŒμ„±) spot-instance --------
MySQL DB 생성 rds-mysql-database --------
Lambda+API Gateway(REST API) 생성 rest-api-lambda-api-gateway --------
파일 μ—…λ‘œλ“œμš© S3 버킷 생성 file-upload-s3 --------

πŸ”¨ Guide

ν™˜κ²½λ³€μˆ˜ μ„ΈνŒ…

# Unix/Linux
export AWS_ACCESS_KEY_ID=""
export AWS_SECRET_ACCESS_KEY=""
export AWS_REGION=""

# Windows
SET AWS_ACCESS_KEY_ID=
SET AWS_SECRET_ACCESS_KEY=
SET AWS_REGION=

provider.tf 생성

terraform {
  backend "s3" {
    bucket         = "<s3-bucket-name>" # s3 버킷λͺ…
    key            = "<service-key>/terraform.tfstate" # tfstate μ €μž₯ 경둜
    region         = "ap-northeast-2"
    dynamodb_table = "terraform-tfstate-lock" # dynamodb table 이름
  }
}

provider "aws" {}

provider "aws" {
  alias   = "virginia"
  region  = "us-east-1"
}

Terraform CLI

terraform init

terraform plan
terraform apply

terraform destroy

About

Source code for studying terraform usage

Resources

Stars

Watchers

Forks

Languages