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

New Resources: azurerm_(resource_group|subscription)_template_deployment #8672

Merged
merged 16 commits into from
Oct 1, 2020

Conversation

tombuildsstuff
Copy link
Contributor

@tombuildsstuff tombuildsstuff commented Sep 29, 2020

This PR introduces two new resources:

  • azurerm_resource_group_template_deployment
  • azurerm_subscription_template_deployment

Which allow deploying an ARM Template Deployment at both the Resource Group and Subscription level. Whilst we currently have a Template Deployment resource in the form of the azurerm_template_deployment field - there's several limitations to this:

  • we don't track external changes to the Template Body, we instead rely on the local template content
  • we don't support import
  • we don't support parameters or outputs of non-string values
  • we don't clean up the resources deployed by this Template Deployment during the deletion of this resource

As such, whilst this Template Deployment resource is usable, it's not ideal - and ultimately this leads to us recommending users deploy an ARM Template into it's own Resource Group, to allow the Resource Group deletion to clear up items which have been deployed.


Instead this PR introduces two new resources azurerm_resource_group_template_deployment and azurerm_subscription_template_deployment - which can be used to deploy an ARM Template at either a Resource Group or a Subscription level.

These new resources support specifying Parameters (and retrieving Outputs) as JSON blobs - so we support all of the available types returned from Azure (Strings, Ints, Bools, Objects etc) via the jsondecode interpolation function.

In addition the Resource Group Template Deployment now attempts to delete the resources provisioned by this Template Deployment when it's being deleted (there's a feature-toggle for this in the provider block). It's worth noting this is best-effort for the moment and likely requires further tweaking - but seems to work with a nested deployment.

Unfortunately we're unable to do the same thing for Subscription Template Deployments due to a lack of support in the Azure API for a generic delete method at this level.

Whilst the existing azurerm_template_deployment resource won't be going away anytime soon - we can supersede it in this release, deprecate it in 3.0 and then remove it in the future once there's been sufficient time to switch-over.

This PR also updates the Resources package to 2020-06-01, so that we can gain this new functionality.

Fixes #3408
Fixes #5706
Fixes #6561

@tombuildsstuff tombuildsstuff force-pushed the f/template-deployment-resources branch from 65375f6 to 6c31b5d Compare September 30, 2020 08:31
Copy link
Member

@jackofallops jackofallops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tombuildsstuff - one question and one minor typo(?), but otherwise LGTM 👍

@tombuildsstuff
Copy link
Contributor Author

Tests pass:

Screenshot 2020-10-01 at 09 31 13

@tombuildsstuff tombuildsstuff merged commit 64af43f into master Oct 1, 2020
@tombuildsstuff tombuildsstuff deleted the f/template-deployment-resources branch October 1, 2020 15:36
tombuildsstuff added a commit that referenced this pull request Oct 1, 2020
@ghost
Copy link

ghost commented Oct 1, 2020

This has been released in version 2.30.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 = "~> 2.30.0"
}
# ... other configuration ...

@ghost
Copy link

ghost commented Nov 1, 2020

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 👉 [email protected]. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Nov 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.