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.6k stars 4.65k forks source link

Support for better handling of Plan Agreements #22636

Open dstamen opened 1 year ago

dstamen commented 1 year ago

Is there an existing issue for this?

Community Note

Description

When using the marketplace agreement plans it only needs to be accepted once. However if multiple modules need to reference the plan if the agreement is always accepted it errors.

image

// accept azure marketplace agreement
resource "azurerm_marketplace_agreement" "plan" {
    publisher = data.cbs_azure_plans.azure_plans.plans[0].publisher
    offer = "pure_storage_cloud_block_store_deployment"
    plan = data.cbs_azure_plans.azure_plans.plans[0].name
}

Looking to see if there can be an update, that if the agreement is not accepted, it is accepted. If it is already accepted, then ignore and no longer require it to be manually imported.

Unfortuantely with TF 1.5.3 there is an import block that can be used but unfortunately does not accept variables to get around this.

import {
  to = azurerm_marketplace_agreement.plan
  id = "/subscriptions/${var.azure_subscription_id}/providers/Microsoft.MarketplaceOrdering/agreements/purestoragemarketplaceadmin/offers/pure_storage_cloud_block_store_deployment/plans/${azurerm_marketplace_agreement.plan.plan}"
}

New or Affected Resource(s)/Data Source(s)

azurerm_marketplace_agreement

Potential Terraform Configuration

No response

References

No response

dstamen commented 1 year ago

Has limitations on the resource block here. https://github.com/hashicorp/terraform/issues/33228

grusak commented 10 months ago

I am running into the same issue with accepting marketplace agreements. The permission to create the acceptance is fairly high level and we don't allow most authors to do it. Can the data source be used as sufficient acceptance of the agreement. This will also not destroy the agreement if it's used across multiple modules in the subscription.