Misc Terrform CDK (TF CDK) codebase
- On windows:
choco install terraform
- On Mac:
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
- On Ubuntu Linux:
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
Confirm Terraform installation
terraform version
sudo npm install --global cdktf-cli@latest
- Confirm version:
cdktf --version
- Start Docker Desktop on Windows
- Ensure Docker is running:
docker info
- mkdir terraform-docker-container && cd terraform-docker-container
terraform init
(or better:terraform init --upgrade
)- Refer Terraform & Docker script as main.tf
terraform plan -out "terraform_docker_plan.out"
terraform apply "terraform_docker_plan.out"
- confirm the ngnix container running:
docker ps
curl -sL http://localhost:8080
or Visit http://localhost:8080 (User the port configured in main.tf)- Remove the stack:
terraform destroy
- Login
If not logged-in
az account show
az login az account set --subscription "azure-subscription-id"
- Create Service Principle
Save the output and run powershell e.g.
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/azure-subscription-id"
.\azure_setup.ps1
- cd terraform-azure
terraform init --upgrade```
terraform plan -out "terraform_azure_plan.out"
terraform apply "terraform_azure_plan.out"
Confirm the creation of Resource Group in Region: "West US 2"
terraform destroy
Create Typescript project
cdktf init