From 048f60d7f3f93b7c5dcaace2ff66f9ada9f025db Mon Sep 17 00:00:00 2001 From: QBY-MarkusMaring <106068259+QBY-MarkusMaring@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:52:44 +0200 Subject: [PATCH 1/9] added plan passthrough variable --- main.tf | 1 + variables.tf | 2 ++ 2 files changed, 3 insertions(+) diff --git a/main.tf b/main.tf index 36f5e0e..8dee282 100644 --- a/main.tf +++ b/main.tf @@ -43,6 +43,7 @@ resource "azurerm_linux_virtual_machine" "this" { location = var.virtual_machine_config.location resource_group_name = var.resource_group_name size = var.virtual_machine_config.size + plan = var.virtual_machine_config.os_plan admin_username = var.admin_username admin_password = var.admin_credential.admin_password disable_password_authentication = var.admin_credential.admin_password == null diff --git a/variables.tf b/variables.tf index 9f2f58c..61001f9 100644 --- a/variables.tf +++ b/variables.tf @@ -90,6 +90,7 @@ variable "virtual_machine_config" { os_offer = string os_version = string os_publisher = string + os_plan = optional(string) os_disk_caching = optional(string, "ReadWrite") os_disk_size_gb = optional(number) os_disk_storage_type = optional(string, "Premium_LRS") @@ -132,6 +133,7 @@ variable "virtual_machine_config" { os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created. os_version: (Required) Optionally specify an os version for the chosen sku. os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created. + os_plan: When using marketplace images passing this plan information is required. Otherwise optional. os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite. os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image. os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS. From 92a6386b01f3f7fe93335de2d75de20617a49e6b Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Sep 2024 09:55:58 +0000 Subject: [PATCH 2/9] terraform-docs: automated action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4baf811..0bc6b16 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ resource "azurerm_subnet" "this" { | [admin\_credential](#input\_admin\_credential) |
Specify either admin_password or public_key:
admin_password: Password of the local administrator.
public_key: SSH public key file (e.g. file(id_rsa.pub))
|
object({
admin_password = optional(string)
public_key = optional(string)
})
| n/a | yes | | [resource\_group\_name](#input\_resource\_group\_name) | Name of the resource group where the resources will be created. | `string` | n/a | yes | | [subnet](#input\_subnet) | The variable takes the subnet as input and takes the id and the address prefix for further configuration. |
object({
id = string
address_prefixes = list(string)
})
| n/a | yes | -| [virtual\_machine\_config](#input\_virtual\_machine\_config) |
hostname: Name of system hostname.
size: The size of the vm. Possible values can be seen here: https://learn.microsoft.com/en-us/azure/virtual-machines/sizes
location: The location of the virtual machine.
os_sku: (Required) The os that will be running on the vm.
os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created.
os_version: (Required) Optionally specify an os version for the chosen sku.
os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created.
os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite.
os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image.
os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS.
zone: Optionally specify an availibility zone for the vm. Values 1, 2 or 3.
availability_set_id: Optionally specify an availibility set for the vm. Not compatible with zone.
os_disk_write_accelerator_enabled: Optionally activate write accelaration for the os disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
proximity_placement_group_id: (Optional) The ID of the Proximity Placement Group which the Virtual Machine should be assigned to.
severity_group: (Required) Sets tag 'Severity Group Monthly' to a specific time and date when an update will be done automatically.
update_allowed: Sets tag 'Update allowed' to yes or no to specify if this VM should currently receive updates.
|
object({
hostname = string
size = string
location = string
os_sku = string
os_offer = string
os_version = string
os_publisher = string
os_disk_caching = optional(string, "ReadWrite")
os_disk_size_gb = optional(number)
os_disk_storage_type = optional(string, "Premium_LRS")
os_disk_write_accelerator_enabled = optional(bool, false)
zone = optional(number)
availability_set_id = optional(string)
proximity_placement_group_id = optional(string)
severity_group = string
update_allowed = optional(bool, true)
})
| n/a | yes | +| [virtual\_machine\_config](#input\_virtual\_machine\_config) |
hostname: Name of system hostname.
size: The size of the vm. Possible values can be seen here: https://learn.microsoft.com/en-us/azure/virtual-machines/sizes
location: The location of the virtual machine.
os_sku: (Required) The os that will be running on the vm.
os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created.
os_version: (Required) Optionally specify an os version for the chosen sku.
os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created.
os_plan: When using marketplace images passing this plan information is required. Otherwise optional.
os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite.
os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image.
os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS.
zone: Optionally specify an availibility zone for the vm. Values 1, 2 or 3.
availability_set_id: Optionally specify an availibility set for the vm. Not compatible with zone.
os_disk_write_accelerator_enabled: Optionally activate write accelaration for the os disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
proximity_placement_group_id: (Optional) The ID of the Proximity Placement Group which the Virtual Machine should be assigned to.
severity_group: (Required) Sets tag 'Severity Group Monthly' to a specific time and date when an update will be done automatically.
update_allowed: Sets tag 'Update allowed' to yes or no to specify if this VM should currently receive updates.
|
object({
hostname = string
size = string
location = string
os_sku = string
os_offer = string
os_version = string
os_publisher = string
os_plan = optional(string)
os_disk_caching = optional(string, "ReadWrite")
os_disk_size_gb = optional(number)
os_disk_storage_type = optional(string, "Premium_LRS")
os_disk_write_accelerator_enabled = optional(bool, false)
zone = optional(number)
availability_set_id = optional(string)
proximity_placement_group_id = optional(string)
severity_group = string
update_allowed = optional(bool, true)
})
| n/a | yes | | [additional\_network\_interface\_ids](#input\_additional\_network\_interface\_ids) | List of ids for additional azurerm\_network\_interface. | `list(string)` | `[]` | no | | [admin\_username](#input\_admin\_username) | Optionally choose the admin\_username of the vm. Defaults to loc\_sysadmin. | `string` | `"loc_sysadmin"` | no | | [data\_disks](#input\_data\_disks) |
 = {
lun: Number of the lun.
disk_size_gb: The size of the data disk.
storage_account_type: Optionally change the storage_account_type. Defaults to StandardSSD_LRS.
caching: Optionally activate disk caching. Defaults to None.
create_option: Optionally change the create option. Defaults to Empty disk.
source_resource_id: (Optional) The ID of an existing Managed Disk or Snapshot to copy when create_option is Copy or
the recovery point to restore when create_option is Restore. Changing this forces a new resource to be created.
write_accelerator_enabled: Optionally activate write accelaration for the data disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
on_demand_bursting_enabled: Optionally activate disk bursting. Only for Premium disk. Default false.
}
|
map(object({
lun = number
disk_size_gb = number
caching = optional(string, "ReadWrite")
create_option = optional(string, "Empty")
source_resource_id = optional(string)
storage_account_type = optional(string, "Premium_LRS")
write_accelerator_enabled = optional(bool, false)
on_demand_bursting_enabled = optional(bool, false)
}))
| `{}` | no | From 91b94ed3a643586d71d7d12a7cbe5b401ff696cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4risch?= Date: Mon, 16 Sep 2024 13:39:24 +0200 Subject: [PATCH 3/9] feat: improving support for marketplace images accept marketplace agreement and provide image plan by setting enable_plan to true --- CHANGELOG.md | 3 +++ main.tf | 19 ++++++++++++++++++- variables.tf | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2deb9f3..d202d95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.4.0] - 2024-09-16 + - Added enable_plan option for marketplace images. + ## [1.3.0] - 2024-08-20 ### Added diff --git a/main.tf b/main.tf index 8dee282..d43a28b 100644 --- a/main.tf +++ b/main.tf @@ -37,13 +37,20 @@ check "no_nsg_on_nic" { } } +resource "azurerm_marketplace_agreement" "default" { + count = var.virtual_machine_config.enable_plan == true ? 1 : 0 + + publisher = var.virtual_machine_config.os_publisher + offer = var.virtual_machine_config.os_offer + plan = var.source_image_reference.os_sku +} + resource "azurerm_linux_virtual_machine" "this" { name = local.virtual_machine.name computer_name = var.virtual_machine_config.hostname location = var.virtual_machine_config.location resource_group_name = var.resource_group_name size = var.virtual_machine_config.size - plan = var.virtual_machine_config.os_plan admin_username = var.admin_username admin_password = var.admin_credential.admin_password disable_password_authentication = var.admin_credential.admin_password == null @@ -72,6 +79,16 @@ resource "azurerm_linux_virtual_machine" "this" { version = var.virtual_machine_config.os_version } + dynamic "plan" { + for_each = var.virtual_machine_config.enable_plan ? ["one"] : [] + + content { + name = var.virtual_machine_config.sku + product = var.virtual_machine_config.offer + publisher = var.virtual_machine_config.publisher + } + } + proximity_placement_group_id = var.virtual_machine_config.proximity_placement_group_id network_interface_ids = concat([azurerm_network_interface.this.id], var.additional_network_interface_ids) availability_set_id = var.virtual_machine_config.availability_set_id diff --git a/variables.tf b/variables.tf index 61001f9..713f6ba 100644 --- a/variables.tf +++ b/variables.tf @@ -90,7 +90,6 @@ variable "virtual_machine_config" { os_offer = string os_version = string os_publisher = string - os_plan = optional(string) os_disk_caching = optional(string, "ReadWrite") os_disk_size_gb = optional(number) os_disk_storage_type = optional(string, "Premium_LRS") @@ -100,6 +99,7 @@ variable "virtual_machine_config" { proximity_placement_group_id = optional(string) severity_group = string update_allowed = optional(bool, true) + enable_plan = optional(bool, false) }) validation { condition = contains(["None", "ReadOnly", "ReadWrite"], var.virtual_machine_config.os_disk_caching) @@ -133,7 +133,6 @@ variable "virtual_machine_config" { os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created. os_version: (Required) Optionally specify an os version for the chosen sku. os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created. - os_plan: When using marketplace images passing this plan information is required. Otherwise optional. os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite. os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image. os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS. @@ -144,6 +143,7 @@ variable "virtual_machine_config" { proximity_placement_group_id: (Optional) The ID of the Proximity Placement Group which the Virtual Machine should be assigned to. severity_group: (Required) Sets tag 'Severity Group Monthly' to a specific time and date when an update will be done automatically. update_allowed: Sets tag 'Update allowed' to yes or no to specify if this VM should currently receive updates. + enable_plan: When using marketplace images, sending plan information might be required. Also accepts the terms of the marketplace product. ``` DOC } From e494d53dd3fca3c535f233eb1fcc3d4daae02130 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 16 Sep 2024 11:40:49 +0000 Subject: [PATCH 4/9] terraform-docs: automated action --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0bc6b16..663293a 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ resource "azurerm_subnet" "this" { | [admin\_credential](#input\_admin\_credential) |
Specify either admin_password or public_key:
admin_password: Password of the local administrator.
public_key: SSH public key file (e.g. file(id_rsa.pub))
|
object({
admin_password = optional(string)
public_key = optional(string)
})
| n/a | yes | | [resource\_group\_name](#input\_resource\_group\_name) | Name of the resource group where the resources will be created. | `string` | n/a | yes | | [subnet](#input\_subnet) | The variable takes the subnet as input and takes the id and the address prefix for further configuration. |
object({
id = string
address_prefixes = list(string)
})
| n/a | yes | -| [virtual\_machine\_config](#input\_virtual\_machine\_config) |
hostname: Name of system hostname.
size: The size of the vm. Possible values can be seen here: https://learn.microsoft.com/en-us/azure/virtual-machines/sizes
location: The location of the virtual machine.
os_sku: (Required) The os that will be running on the vm.
os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created.
os_version: (Required) Optionally specify an os version for the chosen sku.
os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created.
os_plan: When using marketplace images passing this plan information is required. Otherwise optional.
os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite.
os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image.
os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS.
zone: Optionally specify an availibility zone for the vm. Values 1, 2 or 3.
availability_set_id: Optionally specify an availibility set for the vm. Not compatible with zone.
os_disk_write_accelerator_enabled: Optionally activate write accelaration for the os disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
proximity_placement_group_id: (Optional) The ID of the Proximity Placement Group which the Virtual Machine should be assigned to.
severity_group: (Required) Sets tag 'Severity Group Monthly' to a specific time and date when an update will be done automatically.
update_allowed: Sets tag 'Update allowed' to yes or no to specify if this VM should currently receive updates.
|
object({
hostname = string
size = string
location = string
os_sku = string
os_offer = string
os_version = string
os_publisher = string
os_plan = optional(string)
os_disk_caching = optional(string, "ReadWrite")
os_disk_size_gb = optional(number)
os_disk_storage_type = optional(string, "Premium_LRS")
os_disk_write_accelerator_enabled = optional(bool, false)
zone = optional(number)
availability_set_id = optional(string)
proximity_placement_group_id = optional(string)
severity_group = string
update_allowed = optional(bool, true)
})
| n/a | yes | +| [virtual\_machine\_config](#input\_virtual\_machine\_config) |
hostname: Name of system hostname.
size: The size of the vm. Possible values can be seen here: https://learn.microsoft.com/en-us/azure/virtual-machines/sizes
location: The location of the virtual machine.
os_sku: (Required) The os that will be running on the vm.
os_offer: (Required) Specifies the offer of the image used to create the virtual machines. Changing this forces a new resource to be created.
os_version: (Required) Optionally specify an os version for the chosen sku.
os_publisher: (Required) Specifies the Publisher of the Marketplace Image this Virtual Machine should be created from. Changing this forces a new resource to be created.
os_disk_caching: Optionally change the caching option of the os disk. Defaults to ReadWrite.
os_disk_size_gb: Optionally change the size of the os disk. Defaults to be specified by image.
os_disk_storage_type: Optionally change the os_disk_storage_type. Defaults to StandardSSD_LRS.
zone: Optionally specify an availibility zone for the vm. Values 1, 2 or 3.
availability_set_id: Optionally specify an availibility set for the vm. Not compatible with zone.
os_disk_write_accelerator_enabled: Optionally activate write accelaration for the os disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
proximity_placement_group_id: (Optional) The ID of the Proximity Placement Group which the Virtual Machine should be assigned to.
severity_group: (Required) Sets tag 'Severity Group Monthly' to a specific time and date when an update will be done automatically.
update_allowed: Sets tag 'Update allowed' to yes or no to specify if this VM should currently receive updates.
enable_plan: When using marketplace images, sending plan information might be required. Also accepts the terms of the marketplace product.
|
object({
hostname = string
size = string
location = string
os_sku = string
os_offer = string
os_version = string
os_publisher = string
os_disk_caching = optional(string, "ReadWrite")
os_disk_size_gb = optional(number)
os_disk_storage_type = optional(string, "Premium_LRS")
os_disk_write_accelerator_enabled = optional(bool, false)
zone = optional(number)
availability_set_id = optional(string)
proximity_placement_group_id = optional(string)
severity_group = string
update_allowed = optional(bool, true)
enable_plan = optional(bool, false)
})
| n/a | yes | | [additional\_network\_interface\_ids](#input\_additional\_network\_interface\_ids) | List of ids for additional azurerm\_network\_interface. | `list(string)` | `[]` | no | | [admin\_username](#input\_admin\_username) | Optionally choose the admin\_username of the vm. Defaults to loc\_sysadmin. | `string` | `"loc_sysadmin"` | no | | [data\_disks](#input\_data\_disks) |
 = {
lun: Number of the lun.
disk_size_gb: The size of the data disk.
storage_account_type: Optionally change the storage_account_type. Defaults to StandardSSD_LRS.
caching: Optionally activate disk caching. Defaults to None.
create_option: Optionally change the create option. Defaults to Empty disk.
source_resource_id: (Optional) The ID of an existing Managed Disk or Snapshot to copy when create_option is Copy or
the recovery point to restore when create_option is Restore. Changing this forces a new resource to be created.
write_accelerator_enabled: Optionally activate write accelaration for the data disk. Can only
be activated on Premium disks and caching deactivated. Defaults to false.
on_demand_bursting_enabled: Optionally activate disk bursting. Only for Premium disk. Default false.
}
|
map(object({
lun = number
disk_size_gb = number
caching = optional(string, "ReadWrite")
create_option = optional(string, "Empty")
source_resource_id = optional(string)
storage_account_type = optional(string, "Premium_LRS")
write_accelerator_enabled = optional(bool, false)
on_demand_bursting_enabled = optional(bool, false)
}))
| `{}` | no | @@ -93,6 +93,7 @@ resource "azurerm_subnet" "this" { |------|-------| | [azurerm_linux_virtual_machine](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine) | 1 | | [azurerm_managed_disk](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/managed_disk) | 1 | + | [azurerm_marketplace_agreement](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/marketplace_agreement) | 1 | | [azurerm_network_interface](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface) | 1 | | [azurerm_network_interface_security_group_association](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface_security_group_association) | 1 | | [azurerm_public_ip](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | 1 | @@ -118,6 +119,7 @@ No modules. | Name | Type | |------|------| | [azurerm_linux_virtual_machine.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/linux_virtual_machine) | resource | + | [azurerm_marketplace_agreement.default](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/marketplace_agreement) | resource | | [azurerm_network_interface.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface) | resource | | [azurerm_network_interface_security_group_association.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface_security_group_association) | resource | | [azurerm_public_ip.this](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) | resource | From 5cdfae1d4cde79047ce44cc93bb5b63d852f7571 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4risch?= Date: Mon, 16 Sep 2024 14:38:55 +0200 Subject: [PATCH 5/9] fix: copy-paste issue --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index d43a28b..58759e2 100644 --- a/main.tf +++ b/main.tf @@ -42,7 +42,7 @@ resource "azurerm_marketplace_agreement" "default" { publisher = var.virtual_machine_config.os_publisher offer = var.virtual_machine_config.os_offer - plan = var.source_image_reference.os_sku + plan = var.virtual_machine_config.os_sku } resource "azurerm_linux_virtual_machine" "this" { From f6539b95c8d08a3ac47a8845e91b1db56ff4018e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4risch?= Date: Mon, 16 Sep 2024 14:56:36 +0200 Subject: [PATCH 6/9] added marketplace example --- .../marketplace_image/.terraform.lock.hcl | 22 +++++++++ examples/marketplace_image/main.tf | 46 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 examples/marketplace_image/.terraform.lock.hcl create mode 100644 examples/marketplace_image/main.tf diff --git a/examples/marketplace_image/.terraform.lock.hcl b/examples/marketplace_image/.terraform.lock.hcl new file mode 100644 index 0000000..1be1e35 --- /dev/null +++ b/examples/marketplace_image/.terraform.lock.hcl @@ -0,0 +1,22 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/azurerm" { + version = "4.2.0" + constraints = ">= 3.7.0" + hashes = [ + "h1:Yghh9LVa0QHAOvVir9pgAW/GxHSYY+Z4JMujm1/tG8o=", + "zh:44d84b8a5f2bc6a71a32d85b706200d4dbb2b6a2a9babb25193a852fbbdb9e23", + "zh:57633b586c7b73b169d047a25dd2aa8931ba86bfea22f8e54228b849525708d6", + "zh:58f4e6a80cbc3ad5c92b9c6352f8b1fce6fa0b8a3231e1317bc9b3efba605355", + "zh:a2e2cc82b0d018abe8a9535dcbc173f55b36354fe9778941bdd71c975999fb52", + "zh:a7040aac14e384137f263f1d31a6183556a5acedcc19679647f0deda3c42ba1b", + "zh:c476526f7d54766b627758134a9340984888bacd41954dd11239cbe9b592fc46", + "zh:d001651de98256162c6dc351f4a22d446b6a77d65c487a59bd987d6783a93e71", + "zh:d7bffe913c2fb2a2b7abcf7d747c707a03182a2dc0dbd60a7b5da7a8c7705c3d", + "zh:e2b04f060c72050e7b53582edaaae10d1ed41d07a07babc933c04e9f600a4542", + "zh:eed6694ca700dae58f4a1aa12e02c58d2bfb0a2f09be72f43608bb1ffe709b6b", + "zh:f29200bafe66af9700dc3eb23aa2430a68d5e3dfdd3fc41ad7ceab743c10e164", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/examples/marketplace_image/main.tf b/examples/marketplace_image/main.tf new file mode 100644 index 0000000..7311528 --- /dev/null +++ b/examples/marketplace_image/main.tf @@ -0,0 +1,46 @@ +provider "azurerm" { + subscription_id = "fadc80bd-751e-4fe8-b2da-9d6e16bc4b52" + features {} +} + +module "virtual_machine" { + source = "../.." + + virtual_machine_config = { + hostname = "CUSTAPP001" + location = azurerm_resource_group.this.location + size = "Standard_B1ms" + os_sku = "smvm12" + os_offer = "seppmailvirtualmachine" + os_version = "12.0.5" + os_publisher = "seppmailag" + severity_group = "01-second-monday-0300-XCSUFEDTG-reboot" + enable_plan = true + } + admin_username = "local_admin" + admin_credential = { + admin_password = "H3ll0W0rld!" + } + + resource_group_name = azurerm_resource_group.this.name + subnet = azurerm_subnet.this +} + +resource "azurerm_resource_group" "this" { + name = "rg-TestLinuxBasic-tst-01" + location = "westeurope" +} + +resource "azurerm_virtual_network" "this" { + name = "vnet-10-0-0-0-24-${azurerm_resource_group.this.location}" + address_space = ["10.0.0.0/24"] + location = azurerm_resource_group.this.location + resource_group_name = azurerm_resource_group.this.name +} + +resource "azurerm_subnet" "this" { + name = "snet-10-0-0-0-24-Test" + resource_group_name = azurerm_resource_group.this.name + virtual_network_name = azurerm_virtual_network.this.name + address_prefixes = ["10.0.0.0/24"] +} \ No newline at end of file From b8aacc520b1bb4ce023ecf15d3ad847dcbf14ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4risch?= Date: Mon, 16 Sep 2024 14:59:38 +0200 Subject: [PATCH 7/9] fix: fixed copy/paste issues --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 58759e2..da25398 100644 --- a/main.tf +++ b/main.tf @@ -83,9 +83,9 @@ resource "azurerm_linux_virtual_machine" "this" { for_each = var.virtual_machine_config.enable_plan ? ["one"] : [] content { - name = var.virtual_machine_config.sku - product = var.virtual_machine_config.offer - publisher = var.virtual_machine_config.publisher + name = var.virtual_machine_config.os_sku + product = var.virtual_machine_config.os_offer + publisher = var.virtual_machine_config.os_publisher } } From 940a59300e7531292fb8335da0c3fe7398586f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A4risch?= Date: Mon, 16 Sep 2024 15:27:46 +0200 Subject: [PATCH 8/9] fix: example works for marketplace image --- .../marketplace_image/.terraform.lock.hcl | 22 ------------------- examples/marketplace_image/main.tf | 1 - 2 files changed, 23 deletions(-) delete mode 100644 examples/marketplace_image/.terraform.lock.hcl diff --git a/examples/marketplace_image/.terraform.lock.hcl b/examples/marketplace_image/.terraform.lock.hcl deleted file mode 100644 index 1be1e35..0000000 --- a/examples/marketplace_image/.terraform.lock.hcl +++ /dev/null @@ -1,22 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/azurerm" { - version = "4.2.0" - constraints = ">= 3.7.0" - hashes = [ - "h1:Yghh9LVa0QHAOvVir9pgAW/GxHSYY+Z4JMujm1/tG8o=", - "zh:44d84b8a5f2bc6a71a32d85b706200d4dbb2b6a2a9babb25193a852fbbdb9e23", - "zh:57633b586c7b73b169d047a25dd2aa8931ba86bfea22f8e54228b849525708d6", - "zh:58f4e6a80cbc3ad5c92b9c6352f8b1fce6fa0b8a3231e1317bc9b3efba605355", - "zh:a2e2cc82b0d018abe8a9535dcbc173f55b36354fe9778941bdd71c975999fb52", - "zh:a7040aac14e384137f263f1d31a6183556a5acedcc19679647f0deda3c42ba1b", - "zh:c476526f7d54766b627758134a9340984888bacd41954dd11239cbe9b592fc46", - "zh:d001651de98256162c6dc351f4a22d446b6a77d65c487a59bd987d6783a93e71", - "zh:d7bffe913c2fb2a2b7abcf7d747c707a03182a2dc0dbd60a7b5da7a8c7705c3d", - "zh:e2b04f060c72050e7b53582edaaae10d1ed41d07a07babc933c04e9f600a4542", - "zh:eed6694ca700dae58f4a1aa12e02c58d2bfb0a2f09be72f43608bb1ffe709b6b", - "zh:f29200bafe66af9700dc3eb23aa2430a68d5e3dfdd3fc41ad7ceab743c10e164", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - ] -} diff --git a/examples/marketplace_image/main.tf b/examples/marketplace_image/main.tf index 7311528..9127eed 100644 --- a/examples/marketplace_image/main.tf +++ b/examples/marketplace_image/main.tf @@ -1,5 +1,4 @@ provider "azurerm" { - subscription_id = "fadc80bd-751e-4fe8-b2da-9d6e16bc4b52" features {} } From 7e78127b89a18a54dc70d886b436f1dfe7902df2 Mon Sep 17 00:00:00 2001 From: QBY-MauriceBaerisch Date: Mon, 16 Sep 2024 15:36:07 +0200 Subject: [PATCH 9/9] fix: better rg name for marketplace example Co-authored-by: QBY-MarkusMaring <106068259+QBY-MarkusMaring@users.noreply.github.com> --- examples/marketplace_image/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/marketplace_image/main.tf b/examples/marketplace_image/main.tf index 9127eed..006dbb5 100644 --- a/examples/marketplace_image/main.tf +++ b/examples/marketplace_image/main.tf @@ -26,7 +26,7 @@ module "virtual_machine" { } resource "azurerm_resource_group" "this" { - name = "rg-TestLinuxBasic-tst-01" + name = "rg-TestLinuxMarketplace-tst-01" location = "westeurope" }