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

"azurerm_data_factory_integration_runtime_azure" - supports property "virtual_network_enabled" #12619

Merged
merged 1 commit into from
Jul 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,19 @@ func resourceDataFactoryIntegrationRuntimeAzure() *pluginsdk.Resource {
Optional: true,
Default: 0,
},

"virtual_network_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
ForceNew: true,
},
},
}
}

func resourceDataFactoryIntegrationRuntimeAzureCreateUpdate(d *pluginsdk.ResourceData, meta interface{}) error {
client := meta.(*clients.Client).DataFactory.IntegrationRuntimesClient
managedVirtualNetworksClient := meta.(*clients.Client).DataFactory.ManagedVirtualNetworksClient
ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d)
defer cancel()

Expand Down Expand Up @@ -121,6 +128,20 @@ func resourceDataFactoryIntegrationRuntimeAzureCreateUpdate(d *pluginsdk.Resourc
},
}

if d.Get("virtual_network_enabled").(bool) {
virtualNetworkName, err := getManagedVirtualNetworkName(ctx, managedVirtualNetworksClient, resourceGroup, factoryName)
if err != nil {
return err
}
if virtualNetworkName == nil {
return fmt.Errorf("virtual network feature for azure integration runtime is only available after managed virtual network for this data factory is enabled")
}
managedIntegrationRuntime.ManagedVirtualNetwork = &datafactory.ManagedVirtualNetworkReference{
Type: utils.String("ManagedVirtualNetworkReference"),
ReferenceName: virtualNetworkName,
}
}

basicIntegrationRuntime, _ := managedIntegrationRuntime.AsBasicIntegrationRuntime()

integrationRuntime := datafactory.IntegrationRuntimeResource{
Expand Down Expand Up @@ -183,6 +204,12 @@ func resourceDataFactoryIntegrationRuntimeAzureRead(d *pluginsdk.ResourceData, m
d.Set("description", managedIntegrationRuntime.Description)
}

virtualNetworkEnabled := false
if managedIntegrationRuntime.ManagedVirtualNetwork != nil && managedIntegrationRuntime.ManagedVirtualNetwork.ReferenceName != nil {
virtualNetworkEnabled = true
}
d.Set("virtual_network_enabled", virtualNetworkEnabled)

if computeProps := managedIntegrationRuntime.ComputeProperties; computeProps != nil {
if location := computeProps.Location; location != nil {
d.Set("location", location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ func TestAccDataFactoryIntegrationRuntimeAzure_timeToLive(t *testing.T) {
})
}

func TestAccDataFactoryIntegrationRuntimeAzure_virtualNetwork(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_integration_runtime_azure", "test")
r := IntegrationRuntimeAzureResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.virtualNetwork(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
})
}

func (IntegrationRuntimeAzureResource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -189,6 +204,34 @@ resource "azurerm_data_factory_integration_runtime_azure" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IntegrationRuntimeAzureResource) virtualNetwork(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}

resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
}

resource "azurerm_data_factory" "test" {
name = "acctestdf%d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
managed_virtual_network_enabled = true
}

resource "azurerm_data_factory_integration_runtime_azure" "test" {
name = "azure-integration-runtime"
data_factory_name = azurerm_data_factory.test.name
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
virtual_network_enabled = true
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (t IntegrationRuntimeAzureResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := azure.ParseAzureResourceID(state.ID)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ The following arguments are supported:

* `time_to_live_min` - (Optional) Time to live (in minutes) setting of the cluster which will execute data flow job. Defaults to `0`.

* `virtual_network_enabled` - (Optional) Is Integration Runtime compute provisioned within Managed Virtual Network? Changing this forces a new resource to be created.

---

## Import
Expand Down