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 property to document required providers when using azurerm_resource_group_template_deployment #9714

Closed
sharebear opened this issue Dec 7, 2020 · 4 comments

Comments

@sharebear
Copy link
Contributor

sharebear commented Dec 7, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

When using azurerm_resource_group_template_deployment there is no way for terraform to know which providers are necessary to successfully apply the deployment. This means that when running terraform in a locked-down production environment with the skip_provider_registration feature enabled terraform has no way to identify which providers could be needed within the template, potentially resulting in an error message such as the following.

Error: waiting for creation of Template Deployment "eventgrid-deployment" (Resource Group "<redacted>"): Code="DeploymentFailed" Message="At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details." Details=[{"code":"Conflict","message":"{\r\n  \"error\": {\r\n    \"code\": \"MissingSubscriptionRegistration\",\r\n    \"message\": \"The subscription is not registered to use namespace 'Microsoft.EventGrid'. See https://aka.ms/rps-not-found for how to register subscriptions.\",\r\n    \"details\": [\r\n      {\r\n        \"code\": \"MissingSubscriptionRegistration\",\r\n        \"target\": \"Microsoft.EventGrid\",\r\n        \"message\": \"The subscription is not registered to use namespace 'Microsoft.EventGrid'. See https://aka.ms/rps-not-found for how to register subscriptions.\"\r\n      }\r\n    ]\r\n  }\r\n}"}]

Would it be an idea to add a required_providers list to the resource that the azurerm provider could use to identify dependent providers?

Alternatively could this be an explicit resource type?

New or Affected Resource(s)

  • azurerm_resource_group_template_deployment
  • azurerm_subscription_template_deployment

Potential Terraform Configuration

resource "azurerm_resource_group_template_deployment" "main" {
  name                = "eventgrid-deployment"
  resource_group_name = var.resource_group_name
  deployment_mode     = "Incremental"
  required_providers  = ["Microsoft.EventGrid"]   # <--- NEW ARGUMENT HERE
  template_content    = <<TEMPLATE
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {},
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.EventGrid/systemTopics",
            "apiVersion": "2020-04-01-preview",
            "name": "mytopic",
            "location": "${var.location}",
            "properties": {
                "source": "${azurerm_storage_account.mysa.id}",
                "topicType": "Microsoft.Storage.StorageAccounts"
            }
        },
        {
            "type": "Microsoft.EventGrid/systemTopics/eventSubscriptions",
            "apiVersion": "2020-04-01-preview",
            "name": "[concat('mytopic', '/mysubscription')]",
            "dependsOn": [
                "[resourceId('Microsoft.EventGrid/systemTopics', 'mytopic')]"
            ],
            "properties": {
                "destination": {
                    "properties": {
                        "resourceId": "[concat('${azurerm_function_app.myfunction.id}', '/functions/my-trigger')]",
                        "maxEventsPerBatch": 1,
                        "preferredBatchSizeInKilobytes": 64
                    },
                    "endpointType": "AzureFunction"
                },
                "filter": {
                    "includedEventTypes": ["Microsoft.Storage.BlobCreated"],
                    "subjectBeginsWith": "/blobServices/default/containers/mycontainer/"
                },
                "labels": [],
                "eventDeliverySchema": "EventGridSchema",
                "retryPolicy": {
                    "maxDeliveryAttempts": 30,
                    "eventTimeToLiveInMinutes": 1440
                }
            }
        }
    ]
}
TEMPLATE
}

References

@sharebear
Copy link
Contributor Author

Additional notes:

@sharebear
Copy link
Contributor Author

I just saw in the release notes that azurerm_resource_provider_registration was merged, coupled with a depends_on to ensure the correct ordering, that could solve this use-case.

Leaving the issue open for now in case someone else sees why this might not work as I expect.

@katbyte
Copy link
Collaborator

katbyte commented Jun 24, 2021

closing as this appears to have been fixed

@katbyte katbyte closed this as completed Jun 24, 2021
@github-actions
Copy link

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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants