hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.53k stars 4.6k forks source link

When provisioning VMs which require legal terms to be accepted, provide an option to accept that. #1283

Closed JonTheNiceGuy closed 5 years ago

JonTheNiceGuy commented 6 years ago

Community Note

Description

When provisioning a FortiGate BYOL 6.0.0 machine using a template (I can supply the template, if required), I received the following message:

User failed validation to purchase resources. Error message: 'Legal terms have not been accepted for this item on this subscription. To accept legal terms using PowerShell, please use Get-AzureRmMarketplaceTerms and Set-AzureRmMarketplaceTerms API (https://go.microsoft.com/fwlink/?linkid=862451) or deploy via the Azure portal to accept the terms'

It would be convenient to indicate that the legal terms have been accepted on this item. There is a potential work-around which is to run this command first: az vm image accept-terms --urn ${azurerm_virtual_machine.fw01.storage_image_reference.publisher}:${azurerm_virtual_machine.fw01.storage_image_reference.offer}:${azurerm_virtual_machine.fw01.storage_image_reference.sku}:${azurerm_virtual_machine.fw01.storage_image_reference.version} however, this can't be specified as a depends_on action as a null_resource.*.local-exec command, as there is a cycle here which prevents it from running.

New or Affected Resource(s)

Potential Terraform Configuration

https://gist.github.com/JonTheNiceGuy/4f009c4e92f11dee42e4b5abba3e972e

References

tombuildsstuff commented 6 years ago

hey @JonTheNiceGuy

Thanks for opening this issue :)

Taking a brief look into this - support for this is available in the Go SDK and there's an example API call available in this Swagger example.

It's possible this could make sense as a separate resource (since it could also belong on the VMSS resource) - but it may make sense as an independent resource (this needs some experimentation to determine if it makes sense on the VM/VMSS resources or as an independent resource [since it's not possible to revoke licence acceptance, this may not make sense]).

Thanks!

tombuildsstuff commented 6 years ago

Talking some more about this internally the other day - our initial suggestion is this is a separate resource; but we need to experiment to see if licence revocation is possible as outlined above.

khushil commented 6 years ago

Ran into this while trying to create BYOL on PaloAlto's as well.

TechyMatt commented 6 years ago

@tombuildsstuff through powershell it is possible to reject marketplace items after you've accepted them https://docs.microsoft.com/en-us/powershell/module/azurerm.marketplaceordering/set-azurermmarketplaceterms?view=azurermps-6.2.0

acobaugh commented 6 years ago

I added a reaction to the OP, but also wanted to state that are use case is also accepting the BYOL t&c with the PaloAlto images. Would be really good if we could eliminate this one manual step.

bostrowski13 commented 5 years ago

Just found out this issue the hard way. Be really nice to see some action on this.

dikadali-MSFT commented 5 years ago

@tombuildsstuff through powershell it is possible to reject marketplace items after you've accepted them https://docs.microsoft.com/en-us/powershell/module/azurerm.marketplaceordering/set-azurermmarketplaceterms?view=azurermps-6.2.0

quick PowerShell command to fix this error Set-AzureRmMarketplaceTerms -Publisher "microsoft-ads" -Product "windows-data-science-vm" -Name "windows2016" -Terms $agreementTerms -Accept | Set-AzureRmMarketplaceTerms -Accept

richeney commented 5 years ago

Example az cli command to accept marketplace terms for a Cisco CSR:

for urn in $(az vm image list --all --publisher cisco --offer cisco-csr-1000v --sku 16_6 --query '[].urn' --output tsv)
do az vm image accept-terms --urn $urn
done

Could be useful in a local-exec as a workaround?

tombuildsstuff commented 5 years ago

This'll be fixed via #4305

ghost commented 5 years ago

This has been released in version 1.34.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 1.34.0"
}
# ... other configuration ...
ghost commented 4 years ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!