Skip to content

Commit

Permalink
data factory integration runtime supports cleanup_enabled, subnet_id
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-henglu committed Sep 3, 2021
1 parent e11a0fa commit d74f3e8
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ func resourceDataFactoryIntegrationRuntimeAzure() *pluginsdk.Resource {

"location": azure.SchemaLocation(),

"cleanup_enabled": {
Type: pluginsdk.TypeBool,
Optional: true,
Computed: true, // Defaults to true
},

"compute_type": {
Type: pluginsdk.TypeString,
Optional: true,
Expand Down Expand Up @@ -227,6 +233,8 @@ func resourceDataFactoryIntegrationRuntimeAzureRead(d *pluginsdk.ResourceData, m
if timeToLive := dataFlowProps.TimeToLive; timeToLive != nil {
d.Set("time_to_live_min", timeToLive)
}

d.Set("cleanup_enabled", dataFlowProps.Cleanup)
}
}

Expand Down Expand Up @@ -263,13 +271,18 @@ func expandDataFactoryIntegrationRuntimeAzureComputeProperties(d *pluginsdk.Reso
location := azure.NormalizeLocation(d.Get("location").(string))
coreCount := int32(d.Get("core_count").(int))
timeToLiveMin := int32(d.Get("time_to_live_min").(int))

cleanup := true
// nolint staticcheck
if v, ok := d.GetOkExists("cleanup_enabled"); ok {
cleanup = v.(bool)
}
return &datafactory.IntegrationRuntimeComputeProperties{
Location: &location,
DataFlowProperties: &datafactory.IntegrationRuntimeDataFlowProperties{
ComputeType: datafactory.DataFlowComputeType(d.Get("compute_type").(string)),
CoreCount: &coreCount,
TimeToLive: &timeToLiveMin,
Cleanup: utils.Bool(cleanup),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,35 @@ func TestAccDataFactoryIntegrationRuntimeAzure_virtualNetwork(t *testing.T) {
})
}

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

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.cleanup(data, false),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.cleanup(data, true),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(),
{
Config: r.cleanup(data, false),
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 @@ -204,6 +233,33 @@ resource "azurerm_data_factory_integration_runtime_azure" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger)
}

func (IntegrationRuntimeAzureResource) cleanup(data acceptance.TestData, enabled bool) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%d"
location = "%s"
}
resource "azurerm_data_factory" "test" {
name = "acctestdfirm%d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
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
cleanup_enabled = %t
}
`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, enabled)
}

func (IntegrationRuntimeAzureResource) virtualNetwork(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,20 @@ func resourceDataFactoryIntegrationRuntimeAzureSsis() *pluginsdk.Resource {
Schema: map[string]*pluginsdk.Schema{
"vnet_id": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
ExactlyOneOf: []string{"vnet_integration.0.vnet_id", "vnet_integration.0.subnet_id"},
ValidateFunc: azure.ValidateResourceID,
},
"subnet_id": {
Type: pluginsdk.TypeString,
Optional: true,
ExactlyOneOf: []string{"vnet_integration.0.vnet_id", "vnet_integration.0.subnet_id"},
ValidateFunc: networkValidate.SubnetID,
},
"subnet_name": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
RequiredWith: []string{"vnet_integration.0.vnet_id"},
ValidateFunc: validation.StringIsNotEmpty,
},
"public_ips": {
Expand Down Expand Up @@ -584,9 +592,16 @@ func expandDataFactoryIntegrationRuntimeAzureSsisComputeProperties(d *pluginsdk.

if vnetIntegrations, ok := d.GetOk("vnet_integration"); ok && len(vnetIntegrations.([]interface{})) > 0 {
vnetProps := vnetIntegrations.([]interface{})[0].(map[string]interface{})
computeProperties.VNetProperties = &datafactory.IntegrationRuntimeVNetProperties{
VNetID: utils.String(vnetProps["vnet_id"].(string)),
Subnet: utils.String(vnetProps["subnet_name"].(string)),
if vnetId := vnetProps["vnet_id"].(string); len(vnetId) > 0 {
computeProperties.VNetProperties = &datafactory.IntegrationRuntimeVNetProperties{
VNetID: utils.String(vnetId),
Subnet: utils.String(vnetProps["subnet_name"].(string)),
}
}
if subnetId := vnetProps["subnet_id"].(string); len(subnetId) > 0 {
computeProperties.VNetProperties = &datafactory.IntegrationRuntimeVNetProperties{
SubnetID: utils.String(subnetId),
}
}

if publicIPs := vnetProps["public_ips"].([]interface{}); len(publicIPs) > 0 {
Expand Down Expand Up @@ -793,17 +808,21 @@ func flattenDataFactoryIntegrationRuntimeAzureSsisVnetIntegration(vnetProperties
return []interface{}{}
}

var vnetId, subnetName string
var vnetId, subnetName, subnetId string
if vnetProperties.VNetID != nil {
vnetId = *vnetProperties.VNetID
}
if vnetProperties.Subnet != nil {
subnetName = *vnetProperties.Subnet
}
if vnetProperties.SubnetID != nil {
subnetId = *vnetProperties.SubnetID
}

return []interface{}{
map[string]interface{}{
"vnet_id": vnetId,
"subnet_id": subnetId,
"subnet_name": subnetName,
"public_ips": utils.FlattenStringSlice(vnetProperties.PublicIPs),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,26 @@ func TestAccDataFactoryIntegrationRuntimeManagedSsis_complete(t *testing.T) {
})
}

func TestAccDataFactoryIntegrationRuntimeManagedSsis_vnetIntegration(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_integration_runtime_azure_ssis", "test")
r := IntegrationRuntimeManagedSsisResource{}

data.ResourceTest(t, r, []acceptance.TestStep{
{
Config: r.vnetIntegration(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep(
"catalog_info.0.administrator_password",
"custom_setup_script.0.sas_token",
"express_custom_setup.0.component.0.license",
"express_custom_setup.0.command_key.0.password",
),
})
}

func TestAccDataFactoryIntegrationRuntimeManagedSsis_keyVaultSecretReference(t *testing.T) {
data := acceptance.BuildTestData(t, "azurerm_data_factory_integration_runtime_azure_ssis", "test")
r := IntegrationRuntimeManagedSsisResource{}
Expand Down Expand Up @@ -314,6 +334,53 @@ resource "azurerm_data_factory_integration_runtime_azure_ssis" "test" {
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (IntegrationRuntimeManagedSsisResource) vnetIntegration(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
features {}
}
resource "azurerm_resource_group" "test" {
name = "acctestRG-df-%[1]d"
location = "%[2]s"
}
resource "azurerm_virtual_network" "test" {
name = "acctestvnet%[1]d"
address_space = ["10.0.0.0/16"]
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_subnet" "test" {
name = "acctestsubnet%[1]d"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_data_factory" "test" {
name = "acctestdfirm%[1]d"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_data_factory_integration_runtime_azure_ssis" "test" {
name = "acctestiras%[1]d"
description = "acctest"
data_factory_name = azurerm_data_factory.test.name
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
node_size = "Standard_D8_v3"
vnet_integration {
subnet_id = "${azurerm_subnet.test.id}"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (IntegrationRuntimeManagedSsisResource) keyVaultSecretReference(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ The following arguments are supported:

* `description` - (Optional) Integration runtime description.

* `cleanup_enabled` - (Optional) Cluster will not be recycled and it will be used in next data flow activity run until TTL (time to live) is reached if this is set as false. Default is true.

* `compute_type` - (Optional) Compute type of the cluster which will execute data flow job. Valid values are `General`, `ComputeOptimized` and `MemoryOptimized`. Defaults to `General`.

* `core_count` - (Optional) Core count of the cluster which will execute data flow job. Valid values are `8`, `16`, `32`, `48`, `80`, `144` and `272`. Defaults to `8`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ A `proxy` block supports the following:

A `vnet_integration` block supports the following:

* `vnet_id` - (Required) ID of the virtual network to which the nodes of the Azure-SSIS Integration Runtime will be added.
* `vnet_id` - (Optional) ID of the virtual network to which the nodes of the Azure-SSIS Integration Runtime will be added.

* `subnet_name` - (Required) Name of the subnet to which the nodes of the Azure-SSIS Integration Runtime will be added.
* `subnet_name` - (Optional) Name of the subnet to which the nodes of the Azure-SSIS Integration Runtime will be added.

* `subnet_id` - (Optional) id of the subnet to which the nodes of the Azure-SSIS Integration Runtime will be added.

-> **NOTE** Only one of `subnet_id` and `subnet_name` can be specified. If `subnet_name` is specified, `vnet_id` must be provided.

* `public_ips` - (Optional) Static public IP addresses for the Azure-SSIS Integration Runtime. The size must be 2.

Expand Down

0 comments on commit d74f3e8

Please sign in to comment.