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

[service_fabric] Don't pass the reverse proxy port if not set #2747

Merged
merged 4 commits into from
Jan 28, 2019
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
11 changes: 7 additions & 4 deletions azurerm/resource_arm_service_fabric_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/helper/validation"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/response"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

Expand Down Expand Up @@ -249,8 +250,9 @@ func resourceArmServiceFabricCluster() *schema.Resource {
ForceNew: true,
},
"reverse_proxy_endpoint_port": {
Type: schema.TypeInt,
Optional: true,
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validate.PortNumber,
},
"durability_level": {
Type: schema.TypeString,
Expand Down Expand Up @@ -890,7 +892,6 @@ func expandServiceFabricClusterNodeTypes(input []interface{}) *[]servicefabric.N
instanceCount := node["instance_count"].(int)
clientEndpointPort := node["client_endpoint_port"].(int)
httpEndpointPort := node["http_endpoint_port"].(int)
reverseProxyEndpointPort := node["reverse_proxy_endpoint_port"].(int)
isPrimary := node["is_primary"].(bool)
durabilityLevel := node["durability_level"].(string)

Expand All @@ -900,9 +901,11 @@ func expandServiceFabricClusterNodeTypes(input []interface{}) *[]servicefabric.N
IsPrimary: utils.Bool(isPrimary),
ClientConnectionEndpointPort: utils.Int32(int32(clientEndpointPort)),
HTTPGatewayEndpointPort: utils.Int32(int32(httpEndpointPort)),
ReverseProxyEndpointPort: utils.Int32(int32(reverseProxyEndpointPort)),
DurabilityLevel: servicefabric.DurabilityLevel(durabilityLevel),
}
if v := int32(node["reverse_proxy_endpoint_port"].(int)); v != 0 {
result.ReverseProxyEndpointPort = utils.Int32(v)
}

applicationPortsRaw := node["application_ports"].([]interface{})
if len(applicationPortsRaw) > 0 {
Expand Down
103 changes: 103 additions & 0 deletions azurerm/resource_arm_service_fabric_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ func TestAccAzureRMServiceFabricCluster_reverseProxyCertificate(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"),
resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"),
resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.reverse_proxy_endpoint_port", "19081"),
),
},
{
Expand All @@ -201,6 +202,108 @@ func TestAccAzureRMServiceFabricCluster_reverseProxyCertificate(t *testing.T) {
})
}

func TestAccAzureRMServiceFabricCluster_reverseProxyNotSet(t *testing.T) {
resourceName := "azurerm_service_fabric_cluster.test"
ri := tf.AccRandTimeInt()
location := testLocation()
config := testAccAzureRMServiceFabricCluster_basic(ri, location, 3)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceFabricClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "management_endpoint", "http://example:80"),
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "0"),
resource.TestCheckResourceAttr(resourceName, "certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "0"),
resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "0"),
resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.reverse_proxy_endpoint_port", "0"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMServiceFabricCluster_reverseProxyUpdate(t *testing.T) {
resourceName := "azurerm_service_fabric_cluster.test"
ri := tf.AccRandTimeInt()
location := testLocation()
configBasic := testAccAzureRMServiceFabricCluster_basic(ri, location, 3)
configProxy := testAccAzureRMServiceFabricCluster_reverseProxyCertificates(ri, location)

resource.ParallelTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMServiceFabricClusterDestroy,
Steps: []resource.TestStep{
{
Config: configBasic,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceFabricClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "management_endpoint", "http://example:80"),
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "0"),
resource.TestCheckResourceAttr(resourceName, "certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "0"),
resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "0"),
resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
{
Config: configProxy,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceFabricClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "certificate.#", "1"),
resource.TestCheckResourceAttr(resourceName, "certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"),
resource.TestCheckResourceAttr(resourceName, "certificate.0.x509_store_name", "My"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.#", "1"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.0.thumbprint", "33:41:DB:6C:F2:AF:72:C6:11:DF:3B:E3:72:1A:65:3A:F1:D4:3E:CD:50:F5:84:F8:28:79:3D:BE:91:03:C3:EE"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.0.x509_store_name", "My"),
resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.name", "Security"),
resource.TestCheckResourceAttr(resourceName, "fabric_settings.0.parameters.ClusterProtectionLevel", "EncryptAndSign"),
resource.TestCheckResourceAttr(resourceName, "management_endpoint", "https://example:80"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.reverse_proxy_endpoint_port", "19081"),
),
},
{
Config: configBasic,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMServiceFabricClusterExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "management_endpoint", "http://example:80"),
resource.TestCheckResourceAttr(resourceName, "add_on_features.#", "0"),
resource.TestCheckResourceAttr(resourceName, "certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "reverse_proxy_certificate.#", "0"),
resource.TestCheckResourceAttr(resourceName, "client_certificate_thumbprint.#", "0"),
resource.TestCheckResourceAttr(resourceName, "azure_active_directory.#", "0"),
resource.TestCheckResourceAttr(resourceName, "diagnostics_config.#", "0"),
resource.TestCheckResourceAttr(resourceName, "node_type.#", "1"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.instance_count", "3"),
resource.TestCheckResourceAttr(resourceName, "node_type.0.reverse_proxy_endpoint_port", "0"),
resource.TestCheckResourceAttr(resourceName, "tags.%", "0"),
),
},
},
})
}

func TestAccAzureRMServiceFabricCluster_clientCertificateThumbprint(t *testing.T) {
resourceName := "azurerm_service_fabric_cluster.test"
ri := tf.AccRandTimeInt()
Expand Down