This repository has been archived by the owner on Nov 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from aztfmod/1912
Initial release
- Loading branch information
Showing
15 changed files
with
680 additions
and
1 deletion.
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,9 @@ | ||
# Local .terraform directories | ||
**/.terraform/* | ||
|
||
# .tfstate files | ||
*.tfstate | ||
*.tfstate.* | ||
|
||
# .tfvars files | ||
*.tfvars |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Microsoft | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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 |
---|---|---|
@@ -1 +1,54 @@ | ||
# terraform-azurerm-caf-vm | ||
# Deploys an Azure Virtual Machine | ||
Creates an Azure Virtual Machine. | ||
This virtual machine can be created from: | ||
- Azure Gallery | ||
- Azure Shared Image | ||
|
||
Reference the module to a specific version (recommended): | ||
```hcl | ||
module "vm" { | ||
source = "aztfmod/caf-container-registry/azurerm" | ||
version = "0.x.y" | ||
resource_group_name = var.rg | ||
asr_vault_name = var.name | ||
location = var.location | ||
tags = var.tags | ||
opslogs_retention_period = var.retention | ||
diagnostics_map = var.diagsmap | ||
la_workspace_id = var.laworkspace.id | ||
} | ||
``` | ||
|
||
## Inputs | ||
|
||
| Name | Type | Default | Description | | ||
| -- | -- | -- | -- | | ||
| name | string | None | Specifies the name of the VM. Changing this forces a new resource to be created. | | ||
| resource_group_name | string | None | The name of the resource group in which to create the VM. Changing this forces a new resource to be created. | | ||
| location | string | None | Specifies the supported Azure location where to create the resource. Changing this forces a new resource to be created. | | ||
| tags | map | None | Map of tags for the deployment. | | ||
| la_workspace_id | string | None | Log Analytics Repository ID. | | ||
| diagnostics_map | map | None | Map with the diagnostics repository information. | | ||
| diagnostics_settings | object | None | Map with the diagnostics settings for VM deployment. See the required structure in the following example or in the diagnostics module documentation. | | ||
| network_interface_ids | list | False | A list of Network Interface ID's which should be associated with the Virtual Machine | | ||
| primary_network_interface_id | string | None | The primary Network Interface ID's which should be associated with the Virtual Machine. Note when using multiple NICs you must set it in the nic_object configuration | | ||
| os | string | Windows |Define if the operating system is 'Linux' or 'Windows' | | ||
| os_profile | object | None | A windows or Linux profile as per documentation. To find types of images, refer to https://docs.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage | | ||
| os_profile_secrets | object | None | Specifies the settings to store OS secret as defined in https://www.terraform.io/docs/providers/azurerm/r/virtual_machine.html | | ||
| storage_image_reference | string | None | storage_image_reference | | ||
| storage_os_disk | object | null | storage_os_disk | | ||
| vm_size | string | None | Azure VM size name, to list all images available in a regionm use : "az vm list-sizes --location <region>" | | ||
|
||
|
||
## Output | ||
|
||
| Name | Type | Description | | ||
| -- | -- | -- | | ||
| network_interface_ids | list(string) | Set of all NIC identifers | | ||
| primary_network_interface_id | string | Primary NIC ID | | ||
| admin_username | string | Name of the local admin account created | | ||
| ssh_private_key_pem | string | Private Key of the VM | | ||
| msi_system_principal_id | string | Principal ID for the created VM | | ||
| id | string | Identifier of the VM | | ||
| name | string | Name of the VM | |
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,22 @@ | ||
# Azure Linux Virtual Machine test | ||
|
||
Creates a test Azure Linux VM environment. | ||
|
||
## Usage | ||
To run this example, simply execute: | ||
|
||
```hcl | ||
terraform init | ||
terraform plan | ||
terraform apply | ||
``` | ||
|
||
Once you are done, just run | ||
```hcl | ||
terraform destroy | ||
``` | ||
|
||
## Outputs | ||
| Name | Description | | ||
| -- | -- | | ||
| object | Returns the Azure Container Registry object | |
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,85 @@ | ||
module "rg_test" { | ||
source = "aztfmod/caf-resource-group/azurerm" | ||
version = "0.1.1" | ||
|
||
prefix = local.prefix | ||
resource_groups = local.resource_groups | ||
tags = local.tags | ||
} | ||
|
||
# to be enabled for vnext log analytics/diagnostics extension | ||
# module "la_test" { | ||
# source = "aztfmod/caf-log-analytics/azurerm" | ||
# version = "1.0.0" | ||
|
||
# convention = local.convention | ||
# location = local.location | ||
# name = local.name | ||
# solution_plan_map = local.solution_plan_map | ||
# prefix = local.prefix | ||
# resource_group_name = module.rg_test.names.test | ||
# tags = local.tags | ||
# } | ||
|
||
# module "diags_test" { | ||
# source = "aztfmod/caf-diagnostics-logging/azurerm" | ||
# version = "1.0.0" | ||
|
||
# convention = local.convention | ||
# name = local.name | ||
# resource_group_name = module.rg_test.names.test | ||
# prefix = local.prefix | ||
# location = local.location | ||
# tags = local.tags | ||
# enable_event_hub = false | ||
# } | ||
|
||
resource "azurerm_virtual_network" "vm_test" { | ||
name = "${local.prefix}-network" | ||
address_space = ["10.0.0.0/16"] | ||
location = local.location | ||
resource_group_name = module.rg_test.names.test | ||
} | ||
|
||
resource "azurerm_subnet" "subnet_test" { | ||
name = "internal" | ||
resource_group_name = module.rg_test.names.test | ||
virtual_network_name = azurerm_virtual_network.vm_test.name | ||
address_prefix = "10.0.2.0/24" | ||
} | ||
|
||
resource "azurerm_network_interface" "nic_test" { | ||
name = "${local.prefix}-nic" | ||
location = local.location | ||
resource_group_name = module.rg_test.names.test | ||
|
||
ip_configuration { | ||
name = "testconfiguration1" | ||
subnet_id = azurerm_subnet.subnet_test.id | ||
private_ip_address_allocation = "Dynamic" | ||
} | ||
} | ||
|
||
module "vm_test" { | ||
source = "../../" | ||
|
||
prefix = local.prefix | ||
convention = local.convention | ||
name = local.name | ||
resource_group_name = module.rg_test.names.test | ||
location = local.location | ||
tags = local.tags | ||
# to be enabled for vnext log analytics/diagnostics extension | ||
# log_analytics_workspace_id = module.la_test.id | ||
# diagnostics_map = module.diags_test.diagnostics_map | ||
# diagnostics_settings = local.diagnostics | ||
|
||
network_interface_ids = [azurerm_network_interface.nic_test.id] | ||
primary_network_interface_id= azurerm_network_interface.nic_test.id | ||
os = local.os | ||
os_profile = local.os_profile | ||
storage_image_reference = local.storage_image_reference | ||
storage_os_disk = local.storage_os_disk | ||
vm_size = local.vm_size | ||
} | ||
|
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,42 @@ | ||
locals { | ||
convention = "random" | ||
name = "caftest" | ||
location = "southeastasia" | ||
prefix = "test" | ||
resource_groups = { | ||
test = { | ||
name = "test-caf" | ||
location = "southeastasia" | ||
}, | ||
} | ||
tags = { | ||
environment = "DEV" | ||
owner = "CAF" | ||
} | ||
solution_plan_map = { | ||
NetworkMonitoring = { | ||
"publisher" = "Microsoft" | ||
"product" = "OMSGallery/NetworkMonitoring" | ||
}, | ||
} | ||
|
||
os = "Linux" | ||
os_profile = { | ||
computer_name = "testcafvm" | ||
admin_username = "testadmin" | ||
} | ||
storage_image_reference = { | ||
publisher = "Canonical" | ||
offer = "UbuntuServer" | ||
sku = "16.04-LTS" | ||
version = "latest" | ||
} | ||
storage_os_disk = { | ||
name = "myosdisk1" | ||
caching = "ReadWrite" | ||
create_option = "FromImage" | ||
managed_disk_type = "Standard_LRS" | ||
disk_size_gb = "128" | ||
} | ||
vm_size = "Standard_DS1_v2" | ||
} |
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,36 @@ | ||
output "network_interface_ids" { | ||
|
||
value = module.vm_test.network_interface_ids | ||
} | ||
|
||
output "primary_network_interface_id" { | ||
value = module.vm_test.primary_network_interface_id | ||
} | ||
|
||
output "admin_username" { | ||
depends_on = [azurerm_virtual_machine.vm] | ||
value = local.os_profile.admin_username | ||
} | ||
|
||
# TODO - get a keyvault created to insert the ssh key and share the kv secret id instead | ||
output "ssh_private_key_pem" { | ||
sensitive = true | ||
value = module.vm_test.ssh_private_key_pem | ||
} | ||
|
||
output "msi_system_principal_id" { | ||
value = module.vm_test.msi_system_principal_id | ||
} | ||
|
||
output "name" { | ||
value = module.vm_test.name | ||
} | ||
|
||
output "id" { | ||
value = module.vm_test.id | ||
} | ||
|
||
output "object" { | ||
sensitive = true | ||
value = module.vm_test | ||
} |
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,22 @@ | ||
# Azure Windows Virtual Machine test | ||
|
||
Creates a test Azure Windows VM environment. | ||
|
||
## Usage | ||
To run this example, simply execute: | ||
|
||
```hcl | ||
terraform init | ||
terraform plan | ||
terraform apply | ||
``` | ||
|
||
Once you are done, just run | ||
```hcl | ||
terraform destroy | ||
``` | ||
|
||
## Outputs | ||
| Name | Description | | ||
| -- | -- | | ||
| object | Returns the Azure Container Registry object | |
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,46 @@ | ||
locals { | ||
convention = "random" | ||
name = "caftest" | ||
location = "southeastasia" | ||
prefix = "test" | ||
resource_groups = { | ||
test = { | ||
name = "test-caf" | ||
location = "southeastasia" | ||
}, | ||
} | ||
tags = { | ||
environment = "DEV" | ||
owner = "CAF" | ||
} | ||
solution_plan_map = { | ||
NetworkMonitoring = { | ||
"publisher" = "Microsoft" | ||
"product" = "OMSGallery/NetworkMonitoring" | ||
}, | ||
} | ||
|
||
os = "Windows" | ||
os_profile = { | ||
computer_name = "testcafvm" | ||
admin_username = "testadmin" | ||
admin_password = "Password1234!" | ||
provision_vm_agent = false | ||
license_type = "Windows_Server" | ||
#Support for BYOL (HUB) - values can be "Windows_Server" or "Windows_Client" | ||
} | ||
storage_image_reference = { | ||
publisher = "MicrosoftWindowsServer" | ||
offer = "WindowsServer" | ||
sku = "2019-Datacenter-Core" | ||
version = "latest" | ||
} | ||
storage_os_disk = { | ||
name = "myosdisk1" | ||
caching = "ReadWrite" | ||
create_option = "FromImage" | ||
managed_disk_type = "Standard_LRS" | ||
disk_size_gb = "128" | ||
} | ||
vm_size = "Standard_DS1_v2" | ||
} |
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,36 @@ | ||
output "network_interface_ids" { | ||
|
||
value = module.vm_test.network_interface_ids | ||
} | ||
|
||
output "primary_network_interface_id" { | ||
value = module.vm_test.primary_network_interface_id | ||
} | ||
|
||
output "admin_username" { | ||
depends_on = [azurerm_virtual_machine.vm] | ||
value = local.os_profile.admin_username | ||
} | ||
|
||
# TODO - get a keyvault created to insert the ssh key and share the kv secret id instead | ||
output "ssh_private_key_pem" { | ||
sensitive = true | ||
value = module.vm_test.ssh_private_key_pem | ||
} | ||
|
||
output "msi_system_principal_id" { | ||
value = module.vm_test.msi_system_principal_id | ||
} | ||
|
||
output "name" { | ||
value = module.vm_test.name | ||
} | ||
|
||
output "id" { | ||
value = module.vm_test.id | ||
} | ||
|
||
output "object" { | ||
sensitive = true | ||
value = module.vm_test | ||
} |
Oops, something went wrong.