Terraform code to spin up an Azure vm with:
- an open security group (all TCP traffic allowed on port 22).
- One user.
N.B.
This is purely a test to gain knowledge of Azure services. Close security group for alternative use.
Authenticate Azure via the CLI as documented here.
$ terraform init
$ terraform plan
$ terraform apply
As I haven't used Azure before, I have highlighted parts of the process to spin up the Azure Virtual Machine that are interesting or differ from AWS.
- Powershell is used to configure advanced Azure features e.g. Resource Manager cmdlets.
-
Authenticated Azure via CLI instead of using a Service Principal.
-
Azure CLI authentication is smoother than AWS but potentially less easy to configure?
-
Env
SUBSCRIPTION_ID
doesn't need to be set as using only the default subscription.
- Assigning
os_profile_linux_config
ssh_key
. In AWS I did this viauser data
with AWS parameter store and base64 decryption. Perhaps there was a better option.
Do you have to provision the public key and then go to the console to download the private key for the Virtual Machine?
Can you assign your own public key? Does it format it correctly to path?
Here are some of the results of running terraform apply
in the Azure console.
Here is the result of ssh
to the Azure Virtual Machine.