DevOps/Terraform
[Terraform] CDKTF 개요 및 환경 구성
Michael Kim
2022. 11. 29. 10:17
OverView
기존 Terraform은 HCL 언어를 사용하여 인프라를 정의하였지만 CDKTF를 사용하면 다른 프로그래밍 언어로도 인프라 정의 및 프로비저닝이 가능하다.
지원되는 언어는 TypeScript, Python, Java, C#, Go 지원된다.
설치 주소 - https://developer.hashicorp.com/terraform/tutorials/cdktf/cdktf-install
Install CDK for Terraform and Run a Quick Start Demo | Terraform | HashiCorp Developer
Set up your CDK for Terraform (CDKTF) environment and run a local Docker demo.
developer.hashicorp.com
CDKTF를 사용하기 위해서는 Node.js 16+, npm, terraform 1.1+ 설치가 되어야 한다.
node.js를 npm을 통해 설치를 하면 16버전보다 낮은 버전이 설치되므로 16버전 이상의 저장소를 추가하여 설치를 진행한다.
Required Install ( Ubuntu )
# 테라폼 설치를 위한 저장소 추가 및 설치
wget -O- https://apt.releases.hashicorp.com/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg
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 install terraform
# npm 설치
sudo apt install npm
# npm Update
npm install -g npm@9.1.2
# Node.js 16버전 설치를 위해 저장소 추가
sudo curl -sL https://deb.nodesource.com/setup_16.x | sudo -E bash -
sudo apt install nodejs
# 설치 확인
terraform -v
npm -v
nodejs -v
Install CDKTF
npm Install
sudo npm install --global cdktf-cli@latest
Apple Mac Install
brew install cdktf