Skip to content

Commit

Permalink
Adding production for Azure VM demo
Browse files Browse the repository at this point in the history
  • Loading branch information
tungbq committed Oct 5, 2024
1 parent 8dba5a5 commit f70228e
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
35 changes: 35 additions & 0 deletions environments/demo-azure-vm/production/east-us/README.md
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]
```
8 changes: 8 additions & 0 deletions environments/demo-azure-vm/production/east-us/main.tf
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
}
15 changes: 15 additions & 0 deletions environments/demo-azure-vm/production/east-us/output.tf
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 environments/demo-azure-vm/production/east-us/variables.tf
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"
}

0 comments on commit f70228e

Please sign in to comment.