?? Cloud-Init, User Data, Custom Script Extensions, & Run Command: Azure & AWS Unified Guide ??
Venkata Pavan Vishnu Rachapudi
?? AWS Community Builder – Security | ????AWStronaut (12x AWS) | AWS Golden Jacket ?? |Works on Cloud and DevOps | Certified in Azure & HashiCorp | passionate about Gen AI & Cloud Security | blogger at Techno Diary.
Hey, #CloudCommunity! When it comes to automating VM/EC2 setup and management, AWS and Azure both offer powerful tools. Here’s a rundown of Cloud-Init, User Data, Custom Script Extensions, and Run Command across both platforms — with examples for installing Nginx on Linux! ???
1. Cloud-Init (AWS & Azure) ??
#cloud-config
package_update: true
packages:
- nginx
runcmd:
- systemctl start nginx
- systemctl enable nginx
2. User Data (AWS) & Custom Script Extension (Azure) ???
#!/bin/bash
sudo apt update -y
sudo apt install nginx -y
sudo systemctl start nginx
sudo systemctl enable nginx
领英推荐
az vm extension set \
--resource-group myResourceGroup \
--vm-name myVM \
--name CustomScript \
--publisher Microsoft.Azure.Extensions \
--settings '{"fileUris": [], "commandToExecute": "sudo apt update -y && sudo apt install nginx -y && sudo systemctl start nginx && sudo systemctl enable nginx"}'
3. Run Command (AWS & Azure) ??
aws ssm send-command \
--document-name "AWS-RunShellScript" \
--targets "Key=instanceIds,Values=i-0123456789abcdef0" \
--parameters 'commands=["sudo apt update -y", "sudo apt install nginx -y", "sudo systemctl start nginx", "sudo systemctl enable nginx"]'
az vm run-command invoke \
--resource-group myResourceGroup \
--name myVM \
--command-id RunShellScript \
--scripts "sudo apt update -y && sudo apt install nginx -y && sudo systemctl start nginx && sudo systemctl enable nginx"
Quick Recap
Which method do you use most often? Share your thoughts below!