{"id":1166,"date":"2024-08-22T18:37:46","date_gmt":"2024-08-22T18:37:46","guid":{"rendered":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2024\/08\/22\/terraform-azurerm-provider-4-0-adds-provider-defined-functions\/"},"modified":"2024-08-22T18:37:46","modified_gmt":"2024-08-22T18:37:46","slug":"terraform-azurerm-provider-4-0-adds-provider-defined-functions","status":"publish","type":"post","link":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/2024\/08\/22\/terraform-azurerm-provider-4-0-adds-provider-defined-functions\/","title":{"rendered":"Terraform AzureRM provider 4.0 adds provider-defined functions"},"content":{"rendered":"<p>Today, we are announcing the general availability of the HashiCorp <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\">Terraform AzureRM provider 4.0<\/a>. This version includes new capabilities to improve the extensibility and flexibility of the provider: provider-defined functions and improved resource provider registration. Initially launched in <a href=\"https:\/\/www.hashicorp.com\/blog\/terraform-1-8-improves-extensibility-with-provider-defined-functions\">April 2024<\/a>, provider-defined functions allow anyone in the Terraform community to build custom functions within providers to extend the capabilities of Terraform. <\/p>\n<p>This post reviews the details and benefits of this new major version of the provider and also covers a handful of new features released this year.<\/p>\n<h2>2024 AzureRM provider highlights<\/h2>\n<p>Since the provider\u2019s last major release in March 2022, we\u2019ve added support for some 340 resources and 120 data sources, bringing the totals to more than 1,101 resources and almost 360 data sources as of mid-August, 2024. As the Terraform AzureRM provide<a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/aws\/latest\/docs\">r<\/a> download count tops 660 million, Microsoft and HashiCorp continue to develop new, innovative integrations that further ease the cloud adoption journey for enterprise organizations. This year we focused on improving the user experience for practitioners by adding new services to the AzureRM provider including:<\/p>\n<p><a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#provider-functions\">Provider-defined functions<\/a><br \/>\n<a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#improved-resource-provider-registration\">Improved resource provider registration<\/a><br \/>\n<a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#additional-properties-for-subnets-in-the-virtual-network-resource\">Additional properties for subnets in the virtual network resource<\/a><\/p>\n<h2>Provider-defined functions<\/h2>\n<p>With the release of <a href=\"https:\/\/www.hashicorp.com\/blog\/terraform-1-8-improves-extensibility-with-provider-defined-functions\">Terraform 1.8<\/a> in April, providers can implement custom functions that you can call from the Terraform configuration. The latest release of the Terraform AzureRM provider adds two Azure-specific provider functions to let users correct the casing of their resource IDs, or to access the individual components of it.<\/p>\n<p>The normalise_resource_id function attempts to normalize the case-sensitive system segments of a resource ID as required by the Azure APIs:.<\/p>\n<p>output &#8220;test&#8221; {<br \/>\n value = provider::azurerm::normalise_resource_id(&#8220;\/Subscriptions\/12345678-1234-9876-4563-123456789012\/ResourceGroups\/resGroup1\/PROVIDERS\/microsoft.apimanagement\/service\/service1\/gateWays\/gateway1\/hostnameconfigurations\/config1&#8221;)<br \/>\n}<\/p>\n<p># Result: \/subscriptions\/12345678-1234-9876-4563-123456789012\/resourceGroups\/resGroup1\/providers\/Microsoft.ApiManagement\/service\/service1\/gateways\/gateway1\/hostnameConfigurations\/config1<\/p>\n<p>The parse_resource_id function takes an Azure resource ID and splits it into its component parts:<\/p>\n<p>locals {<br \/>\n parsed_id = provider::azurerm::parse_resource_id(&#8220;\/subscriptions\/12345678-1234-9876-4563-123456789012\/resourceGroups\/resGroup1\/providers\/Microsoft.ApiManagement\/service\/service1\/gateways\/gateway1\/hostnameConfigurations\/config1&#8221;)<br \/>\n}<\/p>\n<p>output &#8220;resource_group_name&#8221; {<br \/>\n value = local.parsed_id[&#8220;resource_group_name&#8221;]<br \/>\n}<\/p>\n<p>output &#8220;resource_name&#8221; {<br \/>\n value = local.parsed_id[&#8220;resource_name&#8221;]<br \/>\n}<\/p>\n<p># Result:<br \/>\n# Outputs:<br \/>\n#<br \/>\n# resource_group_name = &#8220;resGroup1&#8221;<br \/>\n# resource_name = &#8220;config1&#8221;<\/p>\n<h2>Improved resource provider registration<\/h2>\n<p>Previously, the AzureRM provider took an all-or-nothing approach to Azure resource provider registration, where the Terraform provider would either attempt to register a fixed set of 68 providers upon initialization or registration could be skipped entirely by setting skip_provider_registration = true in the provider block. This limitation didn\u2019t match Microsoft\u2019s recommendations, which is to register resource providers only as needed to enable the services you\u2019re actively using. With the addition of two new feature flags, <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#resource_provider_registrations\">resource<em>provider<\/em>registrations<\/a> and <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#resource_providers_to_register\">resource<em>providers<\/em>to_register<\/a>, users now have more control over which providers to automatically register or whether to continue managing a subscription\u2019s resource provider registrations outside of Terraform.<\/p>\n<h2>Changes and deprecations<\/h2>\n<p>Since the last major release, the AzureRM provider has accumulated resources and properties that have been deprecated, renamed, or are no longer supported by Azure. As version 4.0 is a major release, we have removed a number of <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#behaviour-changes-and-removed-properties-in-resources\">resources<\/a> and <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#behaviour-changes-and-removed-properties-in-data-sources\">data sources<\/a> that have been deprecated over the course of the provider\u2019s lifetime. A complete list of behavior changes and removed properties can be found in the <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide#behaviour-changes-and-removed-properties-in-resources\">AzureRM provider 4.0 upgrade guide<\/a>.<\/p>\n<h2>Learn more about Microsoft and HashiCorp<\/h2>\n<p>The latest version of the AzureRM provider is available today. These features and enhancements will help simplify configurations and improve the overall experience of using the provider. Because this release introduces breaking changes, we recommend pinning your provider version to protect against unexpected results. For a complete list of the changes in 4.0, please review the <a href=\"https:\/\/registry.terraform.io\/providers\/hashicorp\/azurerm\/latest\/docs\/guides\/4.0-upgrade-guide\">AzureRM provider upgrade guide<\/a>. <\/p>\n<p>Please share any bugs or enhancement requests with us via <a href=\"https:\/\/github.com\/hashicorp\/terraform-provider-azurerm\/issues\">GitHub issues<\/a>. We are thankful to our partners and community members for their valuable contributions to the HashiCorp Terraform ecosystem.<\/p>","protected":false},"excerpt":{"rendered":"<p>Today, we are announcing the general availability of the HashiCorp Terraform AzureRM provider 4.0. This version includes new capabilities to [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[6],"tags":[],"class_list":["post-1166","post","type-post","status-publish","format-standard","hentry","category-terraform"],"_links":{"self":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/1166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/comments?post=1166"}],"version-history":[{"count":0,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/posts\/1166\/revisions"}],"wp:attachment":[{"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/media?parent=1166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/categories?post=1166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rssfeedtelegrambot.bnaya.co.il\/index.php\/wp-json\/wp\/v2\/tags?post=1166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}