Terraform (설치 및 인스턴스 배포)
실습
AWS 사용자 생성
7가지 정책 포함!!
Terraform 설치
1. Terraform 다운
https://www.terraform.io/downloads.html
Downloads | Terraform by HashiCorp
Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.
www.terraform.io
2. 본인 데스크탑 - 윈도우 검색 – 고급 시스템 설정 보기 – 시스템 속성 – 환경 변수 – Path 환경 변수에
다운로드받은 terraform.exe 파일의 디렉터리를 추가한다.
3. 아래 명령을 이용하여 실습 예제파일을 다운로드 한다. (terraform_example 폴더에)
git clone https://github.com/moonjukhim/terraform_up_and_running.git
GitHub - moonjukhim/terraform_up_and_running
Contribute to moonjukhim/terraform_up_and_running development by creating an account on GitHub.
github.com
4. aws configure 를 통해 생성한 계정을 등록한다.
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
시작
1. main.tf 작성
간단한 AWS를 공급자로 사용하여 ap-northeast-2 리전안에 배포한다는 의미
cloudformation처럼 문서에서 원하는 것을 확인 가능
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
리소스 추가 및 terraform init으로 초기화!!!
간단한 테라폼 명령어
해본 것
- terraform init 으로 플러그인 설치
- terraform validate로 문법 오류있는지 확인
- terraform plan 으로 설치되는 것 확인
- terraform apply --auto-approve로 인스턴스 시작
- terraform destroy --auto-approve로 인스턴스 종료
ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ
우분투 리눅스를 생성하고 Hello World 출력하기
1.우분투 ami 복사하고 인스턴스 생성
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance
참조
2. 보안 그룹 생성
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group
참조
3. 보안 그룹 부착
4. 결과
전체 코드