본문 바로가기
AEWS2기

[실습] Terraform - EC2 환경 구축

by yeongki0944 2024. 4. 26.

 

 

1. EC2 생성 

  • OS : Amazon Linux2 

 

2-1. terraform 설치

# YUM 패키지 관리자의 유틸리티 설치
sudo yum install -y yum-utils

 

# yum-config-manager를 이용하여 공식 HashiCorp Linux repository를 추가
sudo yum-config-manager --add-repo <https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo>

 

# terraform 설치
sudo yum install -y terraform

 

 

2-2. terraform 설치 확인

# terraform 설치 확인
which terraform

 

 

# terraform 설치 확인
terraform version

 

 

3. AWS CLI 설치

아래 링크를 참고하여, AWS CLI v1 > v2로 업데이트 진행

https://dev.classmethod.jp/articles/lim-awscli-version-up/

 

AWS CLI v1 에서 v2로 업그레이드 해봅시다 | DevelopersIO

안녕하세요, 임채정입니다. ec2 인스턴스에서 AWS 관련 작업을 할 때는 AWS CLI가 필요합니다. 그런데 새로운 리눅스 인스턴스를 세우면 AWS CLI v1이 설치되어 있는거 아시나요? 지금은 …

dev.classmethod.jp

 

 

4. EKSCTL 설치

https://docs.aws.amazon.com/ko_kr/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-eksctl.html

 

# eksctl의 최신 릴리스를 다운로드, 압축 해제
curl --silent --location "https://github.com/weaveworks/eksctl/releases/latest/download/eksctl_$(uname -s)_amd64.tar.gz" | tar xz -C /tmp

 

# 추출된 바이너리를 /usr/local/bin으로 이동
sudo mv /tmp/eksctl /usr/local/bin

 

 

# 0.34.0 버전 이상 설치되었는지 확인
eksctl version

 

5. KUBECTL 설치

https://docs.aws.amazon.com/ko_kr/eks/latest/userguide/install-kubectl.html

# kubectl 설치 확인
kubectl version --client

 

# Kubernetes 1.29
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.29.0/2024-01-04/bin/linux/amd64/kubectl

 

 

 

# SHA-256 체크섬 다운로드
curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.29.0/2024-01-04/bin/linux/amd64/kubectl.sha256

 

# SHA-256 체크섬 확인
sha256sum -c kubectl.sha256

 

 

# kubectl 바이너리파일에 실행권한 적용
chmod +x ./kubectl

 

# kubectl 바이너리파일 이동
mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc

 

# kubectl 설치 확인
kubectl version --client

 

6. HELM 설치

https://helm.sh/docs/intro/install/

 

# helm 설치파일 다운로드
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3

 

# helm 설치파일 스크립트 실행
chmod 700 get_helm.sh
./get_helm.sh

 

 

# helm 설치 확인
helm version

 

7.  기타 툴(jq, tree) 설치 

# jq, tree 설치
sudo yum install -y jq tree