티스토리 뷰
노트북 포맷한 김에 작성하는 글.
Terraform 설치
Install Terraform | Terraform | HashiCorp Developer
Install Terraform on Mac, Linux, or Windows by downloading the binary or using a package manager (Homebrew or Chocolatey). Then create a Docker container locally by following a quick-start tutorial to check that Terraform installed correctly.
developer.hashicorp.com
$ sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
$ wget -O- https://apt.releases.hashicorp.com/gpg | \
gpg --dearmor | \
sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
$ gpg --no-default-keyring \
--keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
--fingerprint
$ echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
sudo tee /etc/apt/sources.list.d/hashicorp.list
$ sudo apt update
$ sudo apt-get install terraform
$ terraform version
Terraform v1.6.6
on linux_amd64
AWS CLI 설치
최신 버전의 AWS CLI 설치 또는 업데이트 - AWS Command Line Interface
이전 버전에서 업데이트하는 경우 unzip 명령을 실행하면 기존 파일을 덮어쓸지 묻는 메시지가 표시됩니다. 스크립트 자동화와 같은 경우에 이러한 프롬프트를 건너뛰려면 unzip에 대한 -u 업데이
docs.aws.amazon.com
$ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
$ sudo apt install unzip
$ unzip awscliv2.zip
$ sudo ./aws/install
$ aws --version
aws-cli/2.15.4 Python/3.11.6 Linux/5.15.133.1-microsoft-standard-WSL2 exe/x86_64.ubuntu.22 prompt/off
AWS CLI 로그인
IAM 사용자 생성 및 액세스 키 발급 필요
Default 계정 등록
$ aws configure
AWS Access Key ID [None]:
AWS Secret Access Key [None]:
Default region name [None]: ap-northeast-2
Default output format [None]: json
$ aws configure list
Terraform 테스트
테스트 디렉터리 생성
$ mkdir terraform_test
$ cd terraform_test/
VSCode Extensions 설치
main.tf 작성
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.31.0"
}
}
}
provider "aws" {}
resource "aws_s3_bucket" "test_bucket" {
bucket = "test-bucket-a124daszxv"
}
terraform 초기화 및 리소스 생성
$ terraform init
$ terraform apply -auto-approve
...
Plan: 1 to add, 0 to change, 0 to destroy.
aws_s3_bucket.test_bucket: Creating...
aws_s3_bucket.test_bucket: Creation complete after 2s [id=test-bucket-a124daszxv]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
$ aws s3 ls
2023-12-27 20:12:14 test-bucket-a124daszxv
리소스 제거
$ terraform destroy --auto-approve
...
Plan: 0 to add, 0 to change, 1 to destroy.
aws_s3_bucket.test_bucket: Destroying... [id=test-bucket-a124daszxv]
aws_s3_bucket.test_bucket: Destruction complete after 0s
Destroy complete! Resources: 1 destroyed.
'개발 부스러기' 카테고리의 다른 글
Hyperlane V3를 사용한 Crosschain NFT (0) | 2024.02.12 |
---|---|
mdBook을 사용해 markdown 형식의 정적 웹사이트 만들기 (0) | 2024.01.21 |
WSL에서 Github 사용하기 (0) | 2023.12.26 |
WSL에서 Go 사용하기 (0) | 2023.12.26 |
Chainlink - Data Feeds (0) | 2023.10.31 |