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_ssis - support Elastic Pool #18696

Merged
merged 5 commits into from
Oct 12, 2022
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 @@ -11,6 +11,7 @@ import (
"github.com/hashicorp/terraform-provider-azurerm/internal/clients"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/parse"
"github.com/hashicorp/terraform-provider-azurerm/internal/services/datafactory/validate"
sqlValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/mssql/validate"
networkValidate "github.com/hashicorp/terraform-provider-azurerm/internal/services/network/validate"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk"
"github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation"
Expand Down Expand Up @@ -229,6 +230,13 @@ func resourceDataFactoryIntegrationRuntimeAzureSsis() *pluginsdk.Resource {
"BC_Gen5_2", "BC_Gen5_4", "BC_Gen5_6", "BC_Gen5_8", "BC_Gen5_10", "BC_Gen5_12", "BC_Gen5_14", "BC_Gen5_16", "BC_Gen5_18", "BC_Gen5_20", "BC_Gen5_24", "BC_Gen5_32", "BC_Gen5_40", "BC_Gen5_80",
"HS_Gen5_2", "HS_Gen5_4", "HS_Gen5_6", "HS_Gen5_8", "HS_Gen5_10", "HS_Gen5_12", "HS_Gen5_14", "HS_Gen5_16", "HS_Gen5_18", "HS_Gen5_20", "HS_Gen5_24", "HS_Gen5_32", "HS_Gen5_40", "HS_Gen5_80",
}, false),
ConflictsWith: []string{"catalog_info.0.elastic_pool_name"},
},
"elastic_pool_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: sqlValidate.ValidateMsSqlElasticPoolName,
ConflictsWith: []string{"catalog_info.0.pricing_tier"},
},
ziyeqf marked this conversation as resolved.
Show resolved Hide resolved
"dual_standby_pair_name": {
Type: pluginsdk.TypeString,
Expand Down Expand Up @@ -638,9 +646,17 @@ func expandDataFactoryIntegrationRuntimeAzureSsisProperties(d *pluginsdk.Resourc
if catalogInfos, ok := d.GetOk("catalog_info"); ok && len(catalogInfos.([]interface{})) > 0 {
catalogInfo := catalogInfos.([]interface{})[0].(map[string]interface{})

// the property `elastic_pool_name` and `pricing_tier` share the same prop `CatalogPricingTier` in request and response.
var pricingTier datafactory.IntegrationRuntimeSsisCatalogPricingTier
ziyeqf marked this conversation as resolved.
Show resolved Hide resolved
if elasticPoolName := catalogInfo["elastic_pool_name"]; elasticPoolName != nil && elasticPoolName.(string) != "" {
pricingTier = datafactory.IntegrationRuntimeSsisCatalogPricingTier(formatDataFactoryIntegrationRuntimeElasticPool(elasticPoolName.(string)))
} else {
pricingTier = datafactory.IntegrationRuntimeSsisCatalogPricingTier(catalogInfo["pricing_tier"].(string))
}

ssisProperties.CatalogInfo = &datafactory.IntegrationRuntimeSsisCatalogInfo{
CatalogServerEndpoint: utils.String(catalogInfo["server_endpoint"].(string)),
CatalogPricingTier: datafactory.IntegrationRuntimeSsisCatalogPricingTier(catalogInfo["pricing_tier"].(string)),
CatalogPricingTier: pricingTier,
}

if adminUserName := catalogInfo["administrator_login"]; adminUserName.(string) != "" {
Expand Down Expand Up @@ -869,6 +885,12 @@ func flattenDataFactoryIntegrationRuntimeAzureSsisCatalogInfo(ssisProperties *da
dualStandbyPairName = *ssisProperties.DualStandbyPairName
}

var pricingTier, elasticPoolName string
elasticPoolName, elasticPoolNameMatched := parseDataFactoryIntegrationRuntimeElasticPool(string(ssisProperties.CatalogPricingTier))
if !elasticPoolNameMatched {
pricingTier = string(ssisProperties.CatalogPricingTier)
}

// read back
if adminPassword, ok := d.GetOk("catalog_info.0.administrator_password"); ok {
administratorPassword = adminPassword.(string)
Expand All @@ -877,7 +899,8 @@ func flattenDataFactoryIntegrationRuntimeAzureSsisCatalogInfo(ssisProperties *da
return []interface{}{
map[string]interface{}{
"server_endpoint": serverEndpoint,
"pricing_tier": string(ssisProperties.CatalogPricingTier),
"pricing_tier": pricingTier,
"elastic_pool_name": elasticPoolName,
"administrator_login": catalogAdminUserName,
"administrator_password": administratorPassword,
"dual_standby_pair_name": dualStandbyPairName,
Expand Down Expand Up @@ -1111,3 +1134,15 @@ func readBackSensitiveValue(input []interface{}, propertyName string, filters ma
}
return ""
}

func formatDataFactoryIntegrationRuntimeElasticPool(input string) string {
return fmt.Sprintf(`ELASTIC_POOL(name="%s")`, input)
}

func parseDataFactoryIntegrationRuntimeElasticPool(input string) (string, bool) {
matches := regexp.MustCompile(`^ELASTIC_POOL\(name="(.+)"\)$`).FindStringSubmatch(input)
if len(matches) != 2 {
return "", false
}
return matches[1], true
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,21 @@ func TestAccDataFactoryIntegrationRuntimeManagedSsis_expressVnetInjection(t *tes
})
}

func TestAccDataFactoryIntegrationRuntimeManagedSsis_withElasticPool(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.withElasticPool(data),
Check: acceptance.ComposeTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
),
},
data.ImportStep("catalog_info.0.administrator_password"),
})
}

func (IntegrationRuntimeManagedSsisResource) basic(data acceptance.TestData) string {
return fmt.Sprintf(`
provider "azurerm" {
Expand Down Expand Up @@ -766,6 +781,68 @@ resource "azurerm_data_factory_integration_runtime_azure_ssis" "test" {
`, data.RandomInteger, data.Locations.Primary)
}

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

resource "azurerm_resource_group" "test" {
name = "acctestRG-%[1]d"
location = "%[2]s"
}

resource "azurerm_mssql_server" "test" {
name = "acctest%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
version = "12.0"
administrator_login = "4dm1n157r470r"
administrator_login_password = "4-v3ry-53cr37-p455w0rd"
}

resource "azurerm_mssql_elasticpool" "test" {
name = "acctest-ssis-%[1]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
server_name = azurerm_mssql_server.test.name
max_size_gb = 4.8828125

sku {
name = "BasicPool"
tier = "Basic"
capacity = 50
}

per_database_settings {
min_capacity = 0
max_capacity = 5
}
}

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 = "managed-integration-runtime"
data_factory_id = azurerm_data_factory.test.id
location = azurerm_resource_group.test.location
node_size = "Standard_D8_v3"

catalog_info {
server_endpoint = "${azurerm_mssql_server.test.fully_qualified_domain_name}"
administrator_login = "ssis_catalog_admin"
administrator_password = "my-s3cret-p4ssword!"
elastic_pool_name = "${azurerm_mssql_elasticpool.test.name}"
dual_standby_pair_name = "dual_name"
}
}
`, data.RandomInteger, data.Locations.Primary, data.RandomString)
}

func (t IntegrationRuntimeManagedSsisResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) {
id, err := parse.IntegrationRuntimeID(state.ID)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ A `catalog_info` block supports the following:

* `administrator_password` - (Optional) Administrator login password for the SQL Server.

* `pricing_tier` - (Optional) Pricing tier for the database that will be created for the SSIS catalog. Valid values are: `Basic`, `S0`, `S1`, `S2`, `S3`, `S4`, `S6`, `S7`, `S9`, `S12`, `P1`, `P2`, `P4`, `P6`, `P11`, `P15`, `GP_S_Gen5_1`, `GP_S_Gen5_2`, `GP_S_Gen5_4`, `GP_S_Gen5_6`, `GP_S_Gen5_8`, `GP_S_Gen5_10`, `GP_S_Gen5_12`, `GP_S_Gen5_14`, `GP_S_Gen5_16`, `GP_S_Gen5_18`, `GP_S_Gen5_20`, `GP_S_Gen5_24`, `GP_S_Gen5_32`, `GP_S_Gen5_40`, `GP_Gen5_2`, `GP_Gen5_4`, `GP_Gen5_6`, `GP_Gen5_8`, `GP_Gen5_10`, `GP_Gen5_12`, `GP_Gen5_14`, `GP_Gen5_16`, `GP_Gen5_18`, `GP_Gen5_20`, `GP_Gen5_24`, `GP_Gen5_32`, `GP_Gen5_40`, `GP_Gen5_80`, `BC_Gen5_2`, `BC_Gen5_4`, `BC_Gen5_6`, `BC_Gen5_8`, `BC_Gen5_10`, `BC_Gen5_12`, `BC_Gen5_14`, `BC_Gen5_16`, `BC_Gen5_18`, `BC_Gen5_20`, `BC_Gen5_24`, `BC_Gen5_32`, `BC_Gen5_40`, `BC_Gen5_80`, `HS_Gen5_2`, `HS_Gen5_4`, `HS_Gen5_6`, `HS_Gen5_8`, `HS_Gen5_10`, `HS_Gen5_12`, `HS_Gen5_14`, `HS_Gen5_16`, `HS_Gen5_18`, `HS_Gen5_20`, `HS_Gen5_24`, `HS_Gen5_32`, `HS_Gen5_40` and `HS_Gen5_80`.
* `pricing_tier` - (Optional) Pricing tier for the database that will be created for the SSIS catalog. Valid values are: `Basic`, `S0`, `S1`, `S2`, `S3`, `S4`, `S6`, `S7`, `S9`, `S12`, `P1`, `P2`, `P4`, `P6`, `P11`, `P15`, `GP_S_Gen5_1`, `GP_S_Gen5_2`, `GP_S_Gen5_4`, `GP_S_Gen5_6`, `GP_S_Gen5_8`, `GP_S_Gen5_10`, `GP_S_Gen5_12`, `GP_S_Gen5_14`, `GP_S_Gen5_16`, `GP_S_Gen5_18`, `GP_S_Gen5_20`, `GP_S_Gen5_24`, `GP_S_Gen5_32`, `GP_S_Gen5_40`, `GP_Gen5_2`, `GP_Gen5_4`, `GP_Gen5_6`, `GP_Gen5_8`, `GP_Gen5_10`, `GP_Gen5_12`, `GP_Gen5_14`, `GP_Gen5_16`, `GP_Gen5_18`, `GP_Gen5_20`, `GP_Gen5_24`, `GP_Gen5_32`, `GP_Gen5_40`, `GP_Gen5_80`, `BC_Gen5_2`, `BC_Gen5_4`, `BC_Gen5_6`, `BC_Gen5_8`, `BC_Gen5_10`, `BC_Gen5_12`, `BC_Gen5_14`, `BC_Gen5_16`, `BC_Gen5_18`, `BC_Gen5_20`, `BC_Gen5_24`, `BC_Gen5_32`, `BC_Gen5_40`, `BC_Gen5_80`, `HS_Gen5_2`, `HS_Gen5_4`, `HS_Gen5_6`, `HS_Gen5_8`, `HS_Gen5_10`, `HS_Gen5_12`, `HS_Gen5_14`, `HS_Gen5_16`, `HS_Gen5_18`, `HS_Gen5_20`, `HS_Gen5_24`, `HS_Gen5_32`, `HS_Gen5_40` and `HS_Gen5_80`. Mutually exclusive with `elastic_pool_name`.

* `elastic_pool_name` - (Optional) The name of SQL elastic pool where the database will be created for the SSIS catalog. Mutually exclusive with `pricing_tier`.

* `dual_standby_pair_name` - (Optional) The dual standby Azure-SSIS Integration Runtime pair with SSISDB failover.

Expand Down