diff --git a/environments/demo-azure-vm/production/east-us/README.md b/environments/demo-azure-vm/production/east-us/README.md new file mode 100644 index 0000000..9f7d390 --- /dev/null +++ b/environments/demo-azure-vm/production/east-us/README.md @@ -0,0 +1,35 @@ +## Deploy + +```bash +terraform init -upgrade + +terraform plan + +terraform apply +``` + +## Result + +- You can find the output information in the console + +``` +key_data = "xxxxxyyyyyzzzztttt generated-by-azure" +private_key_data = "zzzzzzzzzzzzzzzz" +public_ip_address = "x.y.z.t" +resource_group_name = "ENV-rg-some-thing" +``` + +## Connect to the VM + +```bash +# Save the private key *.pem +mkdir ssh_key +cd ssh_key +vi azure-vm-private-key.pem + +# It is required that your private key files are NOT accessible by others. +chmod 600 azure-vm-private-key.pem + +# Now SSH +ssh -i azure-vm-private-key.pem azureadmin@x.y.z.t +``` diff --git a/environments/demo-azure-vm/production/east-us/main.tf b/environments/demo-azure-vm/production/east-us/main.tf new file mode 100644 index 0000000..457b113 --- /dev/null +++ b/environments/demo-azure-vm/production/east-us/main.tf @@ -0,0 +1,8 @@ +module "demo_azure_vm" { + source = "../../../../modules/demo-azure-vm" + resource_group_location = var.resource_group_location + vm_size = var.vm_size + resource_group_name_prefix = var.resource_group_name_prefix + username = var.username + vm_hostname = var.vm_hostname +} diff --git a/environments/demo-azure-vm/production/east-us/output.tf b/environments/demo-azure-vm/production/east-us/output.tf new file mode 100644 index 0000000..18d9569 --- /dev/null +++ b/environments/demo-azure-vm/production/east-us/output.tf @@ -0,0 +1,15 @@ +output "resource_group_name" { + value = module.demo_azure_vm.resource_group_name +} + +output "public_ip_address" { + value = module.demo_azure_vm.public_ip_address +} + +output "key_data" { + value = module.demo_azure_vm.key_data +} + +output "private_key_data" { + value = module.demo_azure_vm.private_key_data +} diff --git a/environments/demo-azure-vm/production/east-us/variables.tf b/environments/demo-azure-vm/production/east-us/variables.tf new file mode 100644 index 0000000..f38e5b1 --- /dev/null +++ b/environments/demo-azure-vm/production/east-us/variables.tf @@ -0,0 +1,29 @@ +variable "resource_group_location" { + type = string + default = "eastus" + description = "Location of the resource group." +} + +variable "resource_group_name_prefix" { + type = string + default = "PROD-rg" + description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription." +} + +variable "username" { + type = string + description = "The username for the local account that will be created on the new VM." + default = "azureadmin" +} + +variable "vm_size" { + type = string + description = "vm_size" + default = "Standard_DS1_v2" +} + +variable "vm_hostname" { + type = string + description = "vm_hostname" + default = "prod-azurevm" +} \ No newline at end of file