Skip to content

Commit

Permalink
Merge pull request #2514 from terraform-providers/b/arm-template-depl…
Browse files Browse the repository at this point in the history
…oyment

r/template_deployment: fixing support for nested template deployments
  • Loading branch information
katbyte authored Dec 17, 2018
2 parents aeb761d + 759762e commit 152cdb8
Show file tree
Hide file tree
Showing 17 changed files with 6,354 additions and 10 deletions.
14 changes: 8 additions & 6 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"time"

"github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
resourcesprofile "github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
appinsights "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights"
"github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation"
"github.com/Azure/azure-sdk-for-go/services/batch/mgmt/2017-09-01/batch"
Expand Down Expand Up @@ -57,6 +57,7 @@ import (
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-06-01/subscriptions"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2016-09-01/locks"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/policy"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler"
"github.com/Azure/azure-sdk-for-go/services/search/mgmt/2015-08-19/search"
"github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus"
Expand Down Expand Up @@ -274,7 +275,7 @@ type ArmClient struct {
// Resources
managementLocksClient locks.ManagementLocksClient
deploymentsClient resources.DeploymentsClient
providersClient resources.ProvidersClient
providersClient resourcesprofile.ProvidersClient
resourcesClient resources.Client
resourceGroupsClient resources.GroupsClient
subscriptionsClient subscriptions.Client
Expand Down Expand Up @@ -1042,13 +1043,14 @@ func (c *ArmClient) registerResourcesClients(endpoint, subscriptionId string, au
c.configureClient(&resourceGroupsClient.Client, auth)
c.resourceGroupsClient = resourceGroupsClient

providersClient := resources.NewProvidersClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&providersClient.Client, auth)
c.providersClient = providersClient

subscriptionsClient := subscriptions.NewClientWithBaseURI(endpoint)
c.configureClient(&subscriptionsClient.Client, auth)
c.subscriptionsClient = subscriptionsClient

// this has to come from the Profile since this is shared with Stack
providersClient := resourcesprofile.NewProvidersClientWithBaseURI(endpoint, subscriptionId)
c.configureClient(&providersClient.Client, auth)
c.providersClient = providersClient
}

func (c *ArmClient) registerSchedulerClients(endpoint, subscriptionId string, auth autorest.Authorizer) {
Expand Down
2 changes: 1 addition & 1 deletion azurerm/data_source_dns_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"fmt"

"github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
"github.com/Azure/azure-sdk-for-go/services/preview/dns/mgmt/2018-03-01-preview/dns"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_container_registry_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"reflect"
"testing"

"github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2017-10-01/storage"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/terraform"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_resource_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
Expand Down
2 changes: 1 addition & 1 deletion azurerm/resource_arm_template_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"time"

"github.com/Azure/azure-sdk-for-go/profiles/2017-03-09/resources/mgmt/resources"
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
Expand Down
77 changes: 77 additions & 0 deletions azurerm/resource_arm_template_deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ func TestAccAzureRMTemplateDeployment_disappears(t *testing.T) {
})
}

func TestAccAzureRMTemplateDeployment_nestedTemplate(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMTemplateDeployment_nestedTemplate(ri, testLocation())
resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMTemplateDeploymentDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMTemplateDeploymentExists("azurerm_template_deployment.test"),
),
},
},
})
}

func TestAccAzureRMTemplateDeployment_withParams(t *testing.T) {
ri := acctest.RandInt()
config := testAccAzureRMTemplateDeployment_withParams(ri, testLocation())
Expand Down Expand Up @@ -324,6 +342,65 @@ DEPLOY
`, rInt, location, rInt)
}

func testAccAzureRMTemplateDeployment_nestedTemplate(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "%s"
}
resource "azurerm_template_deployment" "test" {
name = "acctesttemplate-%d"
resource_group_name = "${azurerm_resource_group.test.name}"
template_body = <<DEPLOY
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
"location": "[resourceGroup().location]",
"resourceGroupName": "[resourceGroup().name]"
},
"resources": [
{
"apiVersion": "2017-05-10",
"name": "nested-template-deployment",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "[variables('resourceGroupName')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {
"location": "[variables('location')]",
"resourceGroupName": "[variables('resourceGroupName')]"
},
"resources": [
{
"type": "Microsoft.Network/publicIPAddresses",
"apiVersion": "2015-06-15",
"name": "acctest-pip",
"location": "[variables('location')]",
"properties": {
"publicIPAllocationMethod": "Dynamic"
}
}
]
}
}
}
]
}
DEPLOY
deployment_mode = "Complete"
}
`, rInt, location, rInt)
}

func testaccAzureRMTemplateDeployment_withParamsBody(rInt int, location string) string {
return fmt.Sprintf(`
resource "azurerm_resource_group" "test" {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 152cdb8

Please sign in to comment.