Terraform External Provider and Datasource
Step-01: Introduction¶
- Terraform External Provider and Datasource
- We understoon about external provider and datasource in previous demo.
- Here we will integrate it with Azure Virtual machine Terraform Resource
Step-02: Review Terraform Configs¶
- Files were copied from
11-01-Terraform-Azure-Linux-Virtual-Machine - c1-versions.tf
- c2-resource-group.tf
- c3-virtual-network.tf
- c4-linux-virtual-machine.tf
- c5-external-datasource.tf
- app-scripts/app1-cloud-init.txt
- shell-scripts/ssh_key_generator.sh
Step-03: c4-linux-virtual-machine.tf¶
public_keyargument will be changed with External Datasource Value.
Step-04: Execute Terraform Commands¶
# Terraform Initialize
terraform init
# Terraform Validate
terraform validate
# Terraform Plan
terraform plan
# Observation
1. Its just datasource, so either we execute terraform plan or apply, shell script "ssh_key_generator.sh" will be triggered and Public and Private Keys are generated
# Terraform Apply
terraform apply -auto-approve
# Connect to VM (should be successful)
chmod 400 shell-scripts/terraformdemo-dev
ssh -i shell-scripts/terraformdemo-dev azureuser@<PUBLIC-IP-OF-VM>
# Access Sample App
http://<PUBLIC-IP-OF-VM>
Step-05: Clean-Up¶
# Destroy Resources
terraform destroy -auto-approve
# Delete Files
rm -rf .terraform*
rm -rf terraform.tfstate*
🎉 New Course
Ultimate DevOps Real-World Project Implementation on AWS
$15.99
$84.99
81% OFF
MARCH2026
Enroll Now on Udemy →
🎉 Offer