Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add license_type to linux_virtual_machine #10776

Merged
merged 11 commits into from
Mar 4, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ func resourceLinuxVirtualMachine() *schema.Resource {

"identity": virtualMachineIdentitySchema(),

"license_type": {
Type: schema.TypeString,
Optional: true,
Computed: true,
favoretti marked this conversation as resolved.
Show resolved Hide resolved
DiffSuppressFunc: suppress.CaseDifference,
favoretti marked this conversation as resolved.
Show resolved Hide resolved
ValidateFunc: validation.StringInSlice([]string{
"RHEL_BYOS",
"SUSE_BYOS",
}, true),
favoretti marked this conversation as resolved.
Show resolved Hide resolved
},

"max_bid_price": {
Type: schema.TypeFloat,
Optional: true,
Expand Down Expand Up @@ -401,6 +412,11 @@ func resourceLinuxVirtualMachineCreate(d *schema.ResourceData, meta interface{})
Tags: tags.Expand(t),
}

if v, ok := d.GetOk("license_type"); ok {
license := v.(string)
params.VirtualMachineProperties.LicenseType = &license
favoretti marked this conversation as resolved.
Show resolved Hide resolved
}

if encryptionAtHostEnabled, ok := d.GetOk("encryption_at_host_enabled"); ok {
params.VirtualMachineProperties.SecurityProfile = &compute.SecurityProfile{
EncryptionAtHost: utils.Bool(encryptionAtHostEnabled.(bool)),
Expand Down Expand Up @@ -556,6 +572,12 @@ func resourceLinuxVirtualMachineRead(d *schema.ResourceData, meta interface{}) e
}
d.Set("availability_set_id", availabilitySetId)

licenseType := ""
if props.LicenseType != nil {
licenseType = *props.LicenseType
}
d.Set("license_type", licenseType)

if err := d.Set("boot_diagnostics", flattenBootDiagnostics(props.DiagnosticsProfile)); err != nil {
return fmt.Errorf("setting `boot_diagnostics`: %+v", err)
}
Expand Down
8 changes: 8 additions & 0 deletions azurerm/internal/services/compute/virtual_machine_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ func resourceVirtualMachine() *schema.Resource {
ValidateFunc: validation.StringInSlice([]string{
"Windows_Client",
"Windows_Server",
"RHEL_BYOS",
"SUSE_BYOS",
}, true),
},

Expand Down Expand Up @@ -833,6 +835,12 @@ func resourceVirtualMachineRead(d *schema.ResourceData, meta interface{}) error
d.Set("availability_set_id", strings.ToLower(*availabilitySet.ID))
}

licenseType := ""
if props.LicenseType != nil {
licenseType = *props.LicenseType
}
d.Set("license_type", licenseType)
favoretti marked this conversation as resolved.
Show resolved Hide resolved

if proximityPlacementGroup := props.ProximityPlacementGroup; proximityPlacementGroup != nil {
d.Set("proximity_placement_group_id", proximityPlacementGroup.ID)
}
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/linux_virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ The following arguments are supported:

* `location` - (Required) The Azure location where the Linux Virtual Machine should exist. Changing this forces a new resource to be created.

* `license_type` - (Optional) Specifies the BYOL Type for this Virtual Machine. Possible values are `RHEL_BYOS` and `SUSE_BYOS`.

* `name` - (Required) The name of the Linux Virtual Machine. Changing this forces a new resource to be created.

* `network_interface_ids` - (Required). A list of Network Interface ID's which should be attached to this Virtual Machine. The first Network Interface ID in this list will be the Primary Network Interface on the Virtual Machine.
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/virtual_machine.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ The following arguments are supported:

* `identity` - (Optional) A `identity` block.

* `license_type` - (Optional) Specifies the BYOL Type for this Virtual Machine. This is only applicable to Windows Virtual Machines. Possible values are `Windows_Client` and `Windows_Server`.
* `license_type` - (Optional) Specifies the BYOL Type for this Virtual Machine. Possible values for Windows Virtual Machines are `Windows_Client` and `Windows_Server`. Possible values for Linux Virtual Machines are `RHEL_BYOS` and `SUSE_BYOS`.

* `os_profile` - (Optional) An `os_profile` block. Required when `create_option` in the `storage_os_disk` block is set to `FromImage`.

Expand Down