-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 [email protected] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
29 changes: 29 additions & 0 deletions
29
environments/demo-azure-vm/production/east-us/variables.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} |