provider/azurerm: add traffic manager resources (#7826)
* provider/azurerm: vendor arm/trafficmanager package * provider/azurerm: add azurerm_traffic_manager_profile resource * provider/azurerm: add azurerm_traffic_manager_endpoint resource * provider/azurerm: document traffic manager resources * provider/azurerm: use short type argument for traffic manager endpoint The resource now takes the short type for example azureEndpoints instead of the long form Microsoft.Network/TrafficManagerProfiles/azureEndpoints. ``` TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMTrafficManagerEndpoint -timeout 120m === RUN TestAccAzureRMTrafficManagerEndpoint_basic --- PASS: TestAccAzureRMTrafficManagerEndpoint_basic (179.72s) === RUN TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal --- PASS: TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal (171.36s) === RUN TestAccAzureRMTrafficManagerEndpoint_updateWeight --- PASS: TestAccAzureRMTrafficManagerEndpoint_updateWeight (167.24s) === RUN TestAccAzureRMTrafficManagerEndpoint_updatePriority --- PASS: TestAccAzureRMTrafficManagerEndpoint_updatePriority (192.91s) === RUN TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints --- PASS: TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints (111.18s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 822.534s ``` * provider/azurerm: remove unnecesary dereferences in traffic manager resources ``` TF_ACC=1 go test ./builtin/providers/azurerm -v -run TestAccAzureRMTrafficManager -timeout 120m === RUN TestAccAzureRMTrafficManagerEndpoint_basic --- PASS: TestAccAzureRMTrafficManagerEndpoint_basic (176.08s) === RUN TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal --- PASS: TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal (172.28s) === RUN TestAccAzureRMTrafficManagerEndpoint_updateWeight --- PASS: TestAccAzureRMTrafficManagerEndpoint_updateWeight (148.97s) === RUN TestAccAzureRMTrafficManagerEndpoint_updatePriority --- PASS: TestAccAzureRMTrafficManagerEndpoint_updatePriority (101.18s) === RUN TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints --- PASS: TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints (88.33s) === RUN TestAccAzureRMTrafficManagerProfile_weighted --- PASS: TestAccAzureRMTrafficManagerProfile_weighted (80.92s) === RUN TestAccAzureRMTrafficManagerProfile_performance --- PASS: TestAccAzureRMTrafficManagerProfile_performance (82.98s) === RUN TestAccAzureRMTrafficManagerProfile_priority --- PASS: TestAccAzureRMTrafficManagerProfile_priority (81.07s) === RUN TestAccAzureRMTrafficManagerProfile_withTags --- PASS: TestAccAzureRMTrafficManagerProfile_withTags (102.50s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 1034.458s ```
This commit is contained in:
parent
802f014d60
commit
cc18e4d7ca
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
|
||||
"github.com/Azure/azure-sdk-for-go/arm/scheduler"
|
||||
"github.com/Azure/azure-sdk-for-go/arm/storage"
|
||||
"github.com/Azure/azure-sdk-for-go/arm/trafficmanager"
|
||||
mainStorage "github.com/Azure/azure-sdk-for-go/storage"
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
|
@ -61,6 +62,9 @@ type ArmClient struct {
|
|||
storageUsageClient storage.UsageOperationsClient
|
||||
|
||||
deploymentsClient resources.DeploymentsClient
|
||||
|
||||
trafficManagerProfilesClient trafficmanager.ProfilesClient
|
||||
trafficManagerEndpointsClient trafficmanager.EndpointsClient
|
||||
}
|
||||
|
||||
func withRequestLogging() autorest.SendDecorator {
|
||||
|
@ -325,6 +329,18 @@ func (c *Config) getArmClient() (*ArmClient, error) {
|
|||
dc.Sender = autorest.CreateSender(withRequestLogging())
|
||||
client.deploymentsClient = dc
|
||||
|
||||
tmpc := trafficmanager.NewProfilesClient(c.SubscriptionID)
|
||||
setUserAgent(&tmpc.Client)
|
||||
tmpc.Authorizer = spt
|
||||
tmpc.Sender = autorest.CreateSender(withRequestLogging())
|
||||
client.trafficManagerProfilesClient = tmpc
|
||||
|
||||
tmec := trafficmanager.NewEndpointsClient(c.SubscriptionID)
|
||||
setUserAgent(&tmec.Client)
|
||||
tmec.Authorizer = spt
|
||||
tmec.Sender = autorest.CreateSender(withRequestLogging())
|
||||
client.trafficManagerEndpointsClient = tmec
|
||||
|
||||
return &client, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,8 @@ func Provider() terraform.ResourceProvider {
|
|||
"azurerm_storage_table": resourceArmStorageTable(),
|
||||
"azurerm_subnet": resourceArmSubnet(),
|
||||
"azurerm_template_deployment": resourceArmTemplateDeployment(),
|
||||
"azurerm_traffic_manager_endpoint": resourceArmTrafficManagerEndpoint(),
|
||||
"azurerm_traffic_manager_profile": resourceArmTrafficManagerProfile(),
|
||||
"azurerm_virtual_machine": resourceArmVirtualMachine(),
|
||||
"azurerm_virtual_machine_scale_set": resourceArmVirtualMachineScaleSet(),
|
||||
"azurerm_virtual_network": resourceArmVirtualNetwork(),
|
||||
|
|
|
@ -0,0 +1,251 @@
|
|||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/trafficmanager"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceArmTrafficManagerEndpoint() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceArmTrafficManagerEndpointCreate,
|
||||
Read: resourceArmTrafficManagerEndpointRead,
|
||||
Update: resourceArmTrafficManagerEndpointCreate,
|
||||
Delete: resourceArmTrafficManagerEndpointDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"type": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerEndpointType,
|
||||
},
|
||||
|
||||
"profile_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"target": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
// when targeting an Azure resource the FQDN of that resource will be set as the target
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"target_resource_id": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"endpoint_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"weight": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerEndpointWeight,
|
||||
},
|
||||
|
||||
"priority": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerEndpointPriority,
|
||||
},
|
||||
|
||||
"endpoint_location": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
// when targeting an Azure resource the location of that resource will be set on the endpoint
|
||||
Computed: true,
|
||||
StateFunc: azureRMNormalizeLocation,
|
||||
},
|
||||
|
||||
"min_child_endpoints": {
|
||||
Type: schema.TypeInt,
|
||||
Optional: true,
|
||||
},
|
||||
|
||||
"resource_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerEndpointCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerEndpointsClient
|
||||
|
||||
log.Printf("[INFO] preparing arguments for ARM TrafficManager Endpoint creation.")
|
||||
|
||||
name := d.Get("name").(string)
|
||||
endpointType := d.Get("type").(string)
|
||||
fullEndpointType := fmt.Sprintf("Microsoft.Network/TrafficManagerProfiles/%s", endpointType)
|
||||
profileName := d.Get("profile_name").(string)
|
||||
resGroup := d.Get("resource_group_name").(string)
|
||||
|
||||
params := trafficmanager.Endpoint{
|
||||
Name: &name,
|
||||
Type: &fullEndpointType,
|
||||
Properties: getArmTrafficManagerEndpointProperties(d),
|
||||
}
|
||||
|
||||
_, err := client.CreateOrUpdate(resGroup, profileName, endpointType, name, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
read, err := client.Get(resGroup, profileName, endpointType, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if read.ID == nil {
|
||||
return fmt.Errorf("Cannot read TrafficManager endpoint %s (resource group %s) ID", name, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
|
||||
return resourceArmTrafficManagerEndpointRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerEndpointRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerEndpointsClient
|
||||
|
||||
id, err := parseAzureResourceID(d.Id())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resGroup := id.ResourceGroup
|
||||
endpointType := d.Get("type").(string)
|
||||
profileName := id.Path["trafficManagerProfiles"]
|
||||
|
||||
// endpoint name is keyed by endpoint type in ARM ID
|
||||
name := id.Path[endpointType]
|
||||
|
||||
resp, err := client.Get(resGroup, profileName, endpointType, name)
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error making Read request on TrafficManager Endpoint %s: %s", name, err)
|
||||
}
|
||||
endpoint := *resp.Properties
|
||||
|
||||
d.Set("name", resp.Name)
|
||||
d.Set("endpoint_status", endpoint.EndpointStatus)
|
||||
d.Set("target_resource_id", endpoint.TargetResourceID)
|
||||
d.Set("target", endpoint.Target)
|
||||
d.Set("weight", endpoint.Weight)
|
||||
d.Set("priority", endpoint.Priority)
|
||||
d.Set("endpoint_location", endpoint.EndpointLocation)
|
||||
d.Set("endpoint_monitor_status", endpoint.EndpointMonitorStatus)
|
||||
d.Set("min_child_endpoints", endpoint.MinChildEndpoints)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerEndpointDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerEndpointsClient
|
||||
|
||||
id, err := parseAzureResourceID(d.Id())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resGroup := id.ResourceGroup
|
||||
endpointType := d.Get("type").(string)
|
||||
profileName := id.Path["trafficManagerProfiles"]
|
||||
|
||||
// endpoint name is keyed by endpoint type in ARM ID
|
||||
name := id.Path[endpointType]
|
||||
|
||||
_, err = client.Delete(resGroup, profileName, endpointType, name)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func getArmTrafficManagerEndpointProperties(d *schema.ResourceData) *trafficmanager.EndpointProperties {
|
||||
var endpointProps trafficmanager.EndpointProperties
|
||||
|
||||
if targetResID := d.Get("target_resource_id").(string); targetResID != "" {
|
||||
endpointProps.TargetResourceID = &targetResID
|
||||
}
|
||||
|
||||
if target := d.Get("target").(string); target != "" {
|
||||
endpointProps.Target = &target
|
||||
}
|
||||
|
||||
if status := d.Get("endpoint_status").(string); status != "" {
|
||||
endpointProps.EndpointStatus = &status
|
||||
}
|
||||
|
||||
if weight := d.Get("weight").(int); weight != 0 {
|
||||
w64 := int64(weight)
|
||||
endpointProps.Weight = &w64
|
||||
}
|
||||
|
||||
if priority := d.Get("priority").(int); priority != 0 {
|
||||
p64 := int64(priority)
|
||||
endpointProps.Priority = &p64
|
||||
}
|
||||
|
||||
if location := d.Get("endpoint_location").(string); location != "" {
|
||||
endpointProps.EndpointLocation = &location
|
||||
}
|
||||
|
||||
if minChildEndpoints := d.Get("min_child_endpoints").(int); minChildEndpoints != 0 {
|
||||
mci64 := int64(minChildEndpoints)
|
||||
endpointProps.MinChildEndpoints = &mci64
|
||||
}
|
||||
|
||||
return &endpointProps
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerEndpointType(i interface{}, k string) (s []string, errors []error) {
|
||||
valid := map[string]struct{}{
|
||||
"azureEndpoints": struct{}{},
|
||||
"externalEndpoints": struct{}{},
|
||||
"nestedEndpoints": struct{}{},
|
||||
}
|
||||
|
||||
if _, ok := valid[i.(string)]; !ok {
|
||||
errors = append(errors, fmt.Errorf("endpoint type invalid, got %s", i.(string)))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerEndpointWeight(i interface{}, k string) (s []string, errors []error) {
|
||||
w := i.(int)
|
||||
if w < 1 || w > 1000 {
|
||||
errors = append(errors, fmt.Errorf("endpoint weight must be between 1-1000 inclusive"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerEndpointPriority(i interface{}, k string) (s []string, errors []error) {
|
||||
p := i.(int)
|
||||
if p < 1 || p > 1000 {
|
||||
errors = append(errors, fmt.Errorf("endpoint priority must be between 1-1000 inclusive"))
|
||||
}
|
||||
return
|
||||
}
|
|
@ -0,0 +1,539 @@
|
|||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/core/http"
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAzureRMTrafficManagerEndpoint_basic(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_basic, ri, ri, ri, ri, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerEndpointDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testAzure"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testAzure", "endpoint_status", "Enabled"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "endpoint_status", "Enabled"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMTrafficManagerEndpoint_basicDisableExternal(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_basic, ri, ri, ri, ri, ri, ri, ri)
|
||||
postConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_basicDisableExternal, ri, ri, ri, ri, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerEndpointDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testAzure"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testAzure", "endpoint_status", "Enabled"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "endpoint_status", "Enabled"),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testAzure"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testAzure", "endpoint_status", "Enabled"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "endpoint_status", "Disabled"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Altering weight might be used to ramp up migration traffic
|
||||
func TestAccAzureRMTrafficManagerEndpoint_updateWeight(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_weight, ri, ri, ri, ri, ri)
|
||||
postConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_updateWeight, ri, ri, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerEndpointDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternalNew"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "weight", "50"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternalNew", "weight", "50"),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternalNew"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "weight", "25"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternalNew", "weight", "75"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
// Altering priority might be used to switch failover/active roles
|
||||
func TestAccAzureRMTrafficManagerEndpoint_updatePriority(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_priority, ri, ri, ri, ri, ri)
|
||||
postConfig := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_updatePriority, ri, ri, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerEndpointDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternalNew"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "priority", "1"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternalNew", "priority", "2"),
|
||||
),
|
||||
},
|
||||
{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternal"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.testExternalNew"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternal", "priority", "3"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_endpoint.testExternalNew", "priority", "2"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMTrafficManagerEndpoint_nestedEndpoints(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMTrafficManagerEndpoint_nestedEndpoints, ri, ri, ri, ri, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerEndpointDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.nested"),
|
||||
testCheckAzureRMTrafficManagerEndpointExists("azurerm_traffic_manager_endpoint.externalChild"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testCheckAzureRMTrafficManagerEndpointExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
// Ensure we have enough information in state to look up in API
|
||||
rs, ok := s.RootModule().Resources[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
name := rs.Primary.Attributes["name"]
|
||||
endpointType := rs.Primary.Attributes["type"]
|
||||
profileName := rs.Primary.Attributes["profile_name"]
|
||||
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||
if !hasResourceGroup {
|
||||
return fmt.Errorf("Bad: no resource group found in state for Traffic Manager Profile: %s", name)
|
||||
}
|
||||
|
||||
// Ensure resource group/virtual network combination exists in API
|
||||
conn := testAccProvider.Meta().(*ArmClient).trafficManagerEndpointsClient
|
||||
|
||||
resp, err := conn.Get(resourceGroup, profileName, path.Base(endpointType), name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Bad: Get on trafficManagerEndpointsClient: %s", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return fmt.Errorf("Bad: Traffic Manager Endpoint %q (resource group: %q) does not exist", name, resourceGroup)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testCheckAzureRMTrafficManagerEndpointDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*ArmClient).trafficManagerEndpointsClient
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "azurerm_traffic_manager_endpoint" {
|
||||
continue
|
||||
}
|
||||
|
||||
name := rs.Primary.Attributes["name"]
|
||||
endpointType := rs.Primary.Attributes["type"]
|
||||
profileName := rs.Primary.Attributes["profile_name"]
|
||||
resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||
|
||||
resp, err := conn.Get(resourceGroup, profileName, path.Base(endpointType), name)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusNotFound {
|
||||
return fmt.Errorf("Traffic Manager Endpoint sitll exists:\n%#v", resp.Properties)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_basic = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "test" {
|
||||
name = "acctestpublicip-%d"
|
||||
location = "West US"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
public_ip_address_allocation = "static"
|
||||
domain_name_label = "acctestpublicip-%d"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testAzure" {
|
||||
name = "acctestend-azure%d"
|
||||
type = "azureEndpoints"
|
||||
target_resource_id = "${azurerm_public_ip.test.id}"
|
||||
weight = 3
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
weight = 3
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_basicDisableExternal = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_public_ip" "test" {
|
||||
name = "acctestpublicip-%d"
|
||||
location = "West US"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
public_ip_address_allocation = "static"
|
||||
domain_name_label = "acctestpublicip-%d"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testAzure" {
|
||||
name = "acctestend-azure%d"
|
||||
type = "azureEndpoints"
|
||||
target_resource_id = "${azurerm_public_ip.test.id}"
|
||||
weight = 3
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
endpoint_status = "Disabled"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
weight = 3
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_weight = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
weight = 50
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternalNew" {
|
||||
name = "acctestend-external%d-2"
|
||||
type = "externalEndpoints"
|
||||
target = "www.terraform.io"
|
||||
weight = 50
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_updateWeight = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
weight = 25
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternalNew" {
|
||||
name = "acctestend-external%d-2"
|
||||
type = "externalEndpoints"
|
||||
target = "www.terraform.io"
|
||||
weight = 75
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_priority = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
priority = 1
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternalNew" {
|
||||
name = "acctestend-external%d-2"
|
||||
type = "externalEndpoints"
|
||||
target = "www.terraform.io"
|
||||
priority = 2
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_updatePriority = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternal" {
|
||||
name = "acctestend-external%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
priority = 3
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "testExternalNew" {
|
||||
name = "acctestend-external%d-2"
|
||||
type = "externalEndpoints"
|
||||
target = "www.terraform.io"
|
||||
priority = 2
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerEndpoint_nestedEndpoints = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "parent" {
|
||||
name = "acctesttmpparent%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctestparent%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "child" {
|
||||
name = "acctesttmpchild%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmpchild%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "nested" {
|
||||
name = "acctestend-parent%d"
|
||||
type = "nestedEndpoints"
|
||||
target_resource_id = "${azurerm_traffic_manager_profile.child.id}"
|
||||
priority = 1
|
||||
profile_name = "${azurerm_traffic_manager_profile.parent.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
min_child_endpoints = 1
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "externalChild" {
|
||||
name = "acctestend-child%d"
|
||||
type = "externalEndpoints"
|
||||
target = "terraform.io"
|
||||
priority = 1
|
||||
profile_name = "${azurerm_traffic_manager_profile.child.name}"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
}
|
||||
`
|
|
@ -0,0 +1,323 @@
|
|||
package azurerm
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/arm/trafficmanager"
|
||||
"github.com/hashicorp/terraform/helper/hashcode"
|
||||
"github.com/hashicorp/terraform/helper/schema"
|
||||
)
|
||||
|
||||
func resourceArmTrafficManagerProfile() *schema.Resource {
|
||||
return &schema.Resource{
|
||||
Create: resourceArmTrafficManagerProfileCreate,
|
||||
Read: resourceArmTrafficManagerProfileRead,
|
||||
Update: resourceArmTrafficManagerProfileCreate,
|
||||
Delete: resourceArmTrafficManagerProfileDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
},
|
||||
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"profile_status": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
Computed: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerStatus,
|
||||
},
|
||||
|
||||
"traffic_routing_method": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerRoutingMethod,
|
||||
},
|
||||
|
||||
"dns_config": {
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"relative_name": {
|
||||
Type: schema.TypeString,
|
||||
ForceNew: true,
|
||||
Required: true,
|
||||
},
|
||||
"ttl": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerTTL,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAzureRMTrafficManagerDNSConfigHash,
|
||||
},
|
||||
|
||||
// inlined from dns_config for ease of use
|
||||
"fqdn": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
||||
"monitor_config": {
|
||||
Type: schema.TypeSet,
|
||||
Required: true,
|
||||
Elem: &schema.Resource{
|
||||
Schema: map[string]*schema.Schema{
|
||||
"protocol": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerMonitorProtocol,
|
||||
},
|
||||
"port": {
|
||||
Type: schema.TypeInt,
|
||||
Required: true,
|
||||
ValidateFunc: validateAzureRMTrafficManagerMonitorPort,
|
||||
},
|
||||
"path": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
Set: resourceAzureRMTrafficManagerMonitorConfigHash,
|
||||
},
|
||||
|
||||
"resource_group_name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
},
|
||||
|
||||
"tags": tagsSchema(),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerProfileCreate(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerProfilesClient
|
||||
|
||||
log.Printf("[INFO] preparing arguments for Azure ARM virtual network creation.")
|
||||
|
||||
name := d.Get("name").(string)
|
||||
// must be provided in request
|
||||
location := "global"
|
||||
resGroup := d.Get("resource_group_name").(string)
|
||||
tags := d.Get("tags").(map[string]interface{})
|
||||
|
||||
profile := trafficmanager.Profile{
|
||||
Name: &name,
|
||||
Location: &location,
|
||||
Properties: getArmTrafficManagerProfileProperties(d),
|
||||
Tags: expandTags(tags),
|
||||
}
|
||||
|
||||
_, err := client.CreateOrUpdate(resGroup, name, profile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
read, err := client.Get(resGroup, name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if read.ID == nil {
|
||||
return fmt.Errorf("Cannot read TrafficManager profile %s (resource group %s) ID", name, resGroup)
|
||||
}
|
||||
|
||||
d.SetId(*read.ID)
|
||||
|
||||
return resourceArmTrafficManagerProfileRead(d, meta)
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerProfileRead(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerProfilesClient
|
||||
|
||||
id, err := parseAzureResourceID(d.Id())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resGroup := id.ResourceGroup
|
||||
name := id.Path["trafficManagerProfiles"]
|
||||
|
||||
resp, err := client.Get(resGroup, name)
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
d.SetId("")
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error making Read request on Traffic Manager Profile %s: %s", name, err)
|
||||
}
|
||||
profile := *resp.Properties
|
||||
|
||||
// update appropriate values
|
||||
d.Set("name", resp.Name)
|
||||
d.Set("profile_status", profile.ProfileStatus)
|
||||
d.Set("traffic_routing_method", profile.TrafficRoutingMethod)
|
||||
|
||||
dnsFlat := flattenAzureRMTrafficManagerProfileDNSConfig(profile.DNSConfig)
|
||||
d.Set("dns_config", schema.NewSet(resourceAzureRMTrafficManagerDNSConfigHash, dnsFlat))
|
||||
|
||||
// fqdn is actually inside DNSConfig, inlined for simpler reference
|
||||
d.Set("fqdn", profile.DNSConfig.Fqdn)
|
||||
|
||||
monitorFlat := flattenAzureRMTrafficManagerProfileMonitorConfig(profile.MonitorConfig)
|
||||
d.Set("monitor_config", schema.NewSet(resourceAzureRMTrafficManagerMonitorConfigHash, monitorFlat))
|
||||
|
||||
flattenAndSetTags(d, resp.Tags)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func resourceArmTrafficManagerProfileDelete(d *schema.ResourceData, meta interface{}) error {
|
||||
client := meta.(*ArmClient).trafficManagerProfilesClient
|
||||
|
||||
id, err := parseAzureResourceID(d.Id())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
resGroup := id.ResourceGroup
|
||||
name := id.Path["trafficManagerProfiles"]
|
||||
|
||||
_, err = client.Delete(resGroup, name)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func getArmTrafficManagerProfileProperties(d *schema.ResourceData) *trafficmanager.ProfileProperties {
|
||||
routingMethod := d.Get("traffic_routing_method").(string)
|
||||
props := &trafficmanager.ProfileProperties{
|
||||
TrafficRoutingMethod: &routingMethod,
|
||||
DNSConfig: expandArmTrafficManagerDNSConfig(d),
|
||||
MonitorConfig: expandArmTrafficManagerMonitorConfig(d),
|
||||
}
|
||||
|
||||
if status, ok := d.GetOk("profile_status"); ok {
|
||||
s := status.(string)
|
||||
props.ProfileStatus = &s
|
||||
}
|
||||
|
||||
return props
|
||||
}
|
||||
|
||||
func expandArmTrafficManagerMonitorConfig(d *schema.ResourceData) *trafficmanager.MonitorConfig {
|
||||
monitorSets := d.Get("monitor_config").(*schema.Set).List()
|
||||
monitor := monitorSets[0].(map[string]interface{})
|
||||
|
||||
proto := monitor["protocol"].(string)
|
||||
port := int64(monitor["port"].(int))
|
||||
path := monitor["path"].(string)
|
||||
|
||||
return &trafficmanager.MonitorConfig{
|
||||
Protocol: &proto,
|
||||
Port: &port,
|
||||
Path: &path,
|
||||
}
|
||||
}
|
||||
|
||||
func expandArmTrafficManagerDNSConfig(d *schema.ResourceData) *trafficmanager.DNSConfig {
|
||||
dnsSets := d.Get("dns_config").(*schema.Set).List()
|
||||
dns := dnsSets[0].(map[string]interface{})
|
||||
|
||||
name := dns["relative_name"].(string)
|
||||
ttl := int64(dns["ttl"].(int))
|
||||
|
||||
return &trafficmanager.DNSConfig{
|
||||
RelativeName: &name,
|
||||
TTL: &ttl,
|
||||
}
|
||||
}
|
||||
|
||||
func flattenAzureRMTrafficManagerProfileDNSConfig(dns *trafficmanager.DNSConfig) []interface{} {
|
||||
result := make(map[string]interface{})
|
||||
|
||||
result["relative_name"] = *dns.RelativeName
|
||||
result["ttl"] = int(*dns.TTL)
|
||||
|
||||
return []interface{}{result}
|
||||
}
|
||||
|
||||
func flattenAzureRMTrafficManagerProfileMonitorConfig(cfg *trafficmanager.MonitorConfig) []interface{} {
|
||||
result := make(map[string]interface{})
|
||||
|
||||
result["protocol"] = *cfg.Protocol
|
||||
result["port"] = int(*cfg.Port)
|
||||
result["path"] = *cfg.Path
|
||||
|
||||
return []interface{}{result}
|
||||
}
|
||||
|
||||
func resourceAzureRMTrafficManagerDNSConfigHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["relative_name"].(string)))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["ttl"].(int)))
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func resourceAzureRMTrafficManagerMonitorConfigHash(v interface{}) int {
|
||||
var buf bytes.Buffer
|
||||
m := v.(map[string]interface{})
|
||||
|
||||
buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["protocol"].(string))))
|
||||
buf.WriteString(fmt.Sprintf("%d-", m["port"].(int)))
|
||||
buf.WriteString(fmt.Sprintf("%s-", m["path"].(string)))
|
||||
|
||||
return hashcode.String(buf.String())
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerStatus(i interface{}, k string) (s []string, errors []error) {
|
||||
status := strings.ToLower(i.(string))
|
||||
if status != "enabled" && status != "disabled" {
|
||||
errors = append(errors, fmt.Errorf("%s must be one of: Enabled, Disabled", k))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerRoutingMethod(i interface{}, k string) (s []string, errors []error) {
|
||||
valid := map[string]struct{}{
|
||||
"Performance": struct{}{},
|
||||
"Weighted": struct{}{},
|
||||
"Priority": struct{}{},
|
||||
}
|
||||
|
||||
if _, ok := valid[i.(string)]; !ok {
|
||||
errors = append(errors, fmt.Errorf("traffic_routing_method must be one of (Performance, Weighted, Priority), got %s", i.(string)))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerTTL(i interface{}, k string) (s []string, errors []error) {
|
||||
ttl := i.(int)
|
||||
if ttl < 30 || ttl > 999999 {
|
||||
errors = append(errors, fmt.Errorf("ttl must be between 30 and 999,999 inclusive"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerMonitorProtocol(i interface{}, k string) (s []string, errors []error) {
|
||||
p := i.(string)
|
||||
if p != "http" && p != "https" {
|
||||
errors = append(errors, fmt.Errorf("monitor_config.protocol must be one of: http, https"))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func validateAzureRMTrafficManagerMonitorPort(i interface{}, k string) (s []string, errors []error) {
|
||||
p := i.(int)
|
||||
if p < 1 || p > 65535 {
|
||||
errors = append(errors, fmt.Errorf("monitor_config.port must be between 1 - 65535 inclusive"))
|
||||
}
|
||||
return
|
||||
}
|
|
@ -0,0 +1,303 @@
|
|||
package azurerm
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
|
||||
"github.com/Azure/azure-sdk-for-go/core/http"
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
"github.com/hashicorp/terraform/helper/resource"
|
||||
"github.com/hashicorp/terraform/terraform"
|
||||
)
|
||||
|
||||
func TestAccAzureRMTrafficManagerProfile_weighted(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMTrafficManagerProfile_weighted, ri, ri, ri)
|
||||
|
||||
fqdn := fmt.Sprintf("acctesttmp%d.trafficmanager.net", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerProfileDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerProfileExists("azurerm_traffic_manager_profile.test"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "traffic_routing_method", "Weighted"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "fqdn", fqdn),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMTrafficManagerProfile_performance(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMTrafficManagerProfile_performance, ri, ri, ri)
|
||||
|
||||
fqdn := fmt.Sprintf("acctesttmp%d.trafficmanager.net", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerProfileDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerProfileExists("azurerm_traffic_manager_profile.test"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "traffic_routing_method", "Performance"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "fqdn", fqdn),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMTrafficManagerProfile_priority(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
config := fmt.Sprintf(testAccAzureRMTrafficManagerProfile_priority, ri, ri, ri)
|
||||
|
||||
fqdn := fmt.Sprintf("acctesttmp%d.trafficmanager.net", ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerProfileDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: config,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerProfileExists("azurerm_traffic_manager_profile.test"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "traffic_routing_method", "Priority"),
|
||||
resource.TestCheckResourceAttr("azurerm_traffic_manager_profile.test", "fqdn", fqdn),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func TestAccAzureRMTrafficManagerProfile_withTags(t *testing.T) {
|
||||
ri := acctest.RandInt()
|
||||
preConfig := fmt.Sprintf(testAccAzureRMTrafficManagerProfile_withTags, ri, ri, ri)
|
||||
postConfig := fmt.Sprintf(testAccAzureRMTrafficManagerProfile_withTagsUpdated, ri, ri, ri)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
Providers: testAccProviders,
|
||||
CheckDestroy: testCheckAzureRMTrafficManagerProfileDestroy,
|
||||
Steps: []resource.TestStep{
|
||||
resource.TestStep{
|
||||
Config: preConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerProfileExists("azurerm_traffic_manager_profile.test"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_traffic_manager_profile.test", "tags.%", "2"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_traffic_manager_profile.test", "tags.environment", "Production"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_traffic_manager_profile.test", "tags.cost_center", "MSFT"),
|
||||
),
|
||||
},
|
||||
|
||||
resource.TestStep{
|
||||
Config: postConfig,
|
||||
Check: resource.ComposeTestCheckFunc(
|
||||
testCheckAzureRMTrafficManagerProfileExists("azurerm_traffic_manager_profile.test"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_traffic_manager_profile.test", "tags.%", "1"),
|
||||
resource.TestCheckResourceAttr(
|
||||
"azurerm_traffic_manager_profile.test", "tags.environment", "staging"),
|
||||
),
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func testCheckAzureRMTrafficManagerProfileExists(name string) resource.TestCheckFunc {
|
||||
return func(s *terraform.State) error {
|
||||
// Ensure we have enough information in state to look up in API
|
||||
rs, ok := s.RootModule().Resources[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Not found: %s", name)
|
||||
}
|
||||
|
||||
name := rs.Primary.Attributes["name"]
|
||||
resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||
if !hasResourceGroup {
|
||||
return fmt.Errorf("Bad: no resource group found in state for Traffic Manager Profile: %s", name)
|
||||
}
|
||||
|
||||
// Ensure resource group/virtual network combination exists in API
|
||||
conn := testAccProvider.Meta().(*ArmClient).trafficManagerProfilesClient
|
||||
|
||||
resp, err := conn.Get(resourceGroup, name)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Bad: Get on trafficManagerProfilesClient: %s", err)
|
||||
}
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound {
|
||||
return fmt.Errorf("Bad: Traffic Manager %q (resource group: %q) does not exist", name, resourceGroup)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func testCheckAzureRMTrafficManagerProfileDestroy(s *terraform.State) error {
|
||||
conn := testAccProvider.Meta().(*ArmClient).trafficManagerProfilesClient
|
||||
|
||||
for _, rs := range s.RootModule().Resources {
|
||||
if rs.Type != "azurerm_traffic_manager_profile" {
|
||||
continue
|
||||
}
|
||||
|
||||
log.Printf("[TRACE] test_profile %#v", rs)
|
||||
|
||||
name := rs.Primary.Attributes["name"]
|
||||
resourceGroup := rs.Primary.Attributes["resource_group_name"]
|
||||
|
||||
resp, err := conn.Get(resourceGroup, name)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusNotFound {
|
||||
return fmt.Errorf("Traffic Manager profile sitll exists:\n%#v", resp.Properties)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var testAccAzureRMTrafficManagerProfile_weighted = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerProfile_performance = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Performance"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerProfile_priority = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerProfile_withTags = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
|
||||
tags {
|
||||
environment = "Production"
|
||||
cost_center = "MSFT"
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
var testAccAzureRMTrafficManagerProfile_withTagsUpdated = `
|
||||
resource "azurerm_resource_group" "test" {
|
||||
name = "acctestrg-%d"
|
||||
location = "West US"
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "acctesttmp%d"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
traffic_routing_method = "Priority"
|
||||
|
||||
dns_config {
|
||||
relative_name = "acctesttmp%d"
|
||||
ttl = 30
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "https"
|
||||
port = 443
|
||||
path = "/"
|
||||
}
|
||||
|
||||
tags {
|
||||
environment = "staging"
|
||||
}
|
||||
}
|
||||
`
|
52
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go
generated
vendored
Normal file
52
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/client.go
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
// Package trafficmanager implements the Azure ARM Trafficmanager service API
|
||||
// version 2015-11-01.
|
||||
//
|
||||
package trafficmanager
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
|
||||
import (
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
)
|
||||
|
||||
const (
|
||||
// APIVersion is the version of the Trafficmanager
|
||||
APIVersion = "2015-11-01"
|
||||
|
||||
// DefaultBaseURI is the default URI used for the service Trafficmanager
|
||||
DefaultBaseURI = "https://management.azure.com"
|
||||
)
|
||||
|
||||
// ManagementClient is the base client for Trafficmanager.
|
||||
type ManagementClient struct {
|
||||
autorest.Client
|
||||
BaseURI string
|
||||
APIVersion string
|
||||
SubscriptionID string
|
||||
}
|
||||
|
||||
// New creates an instance of the ManagementClient client.
|
||||
func New(subscriptionID string) ManagementClient {
|
||||
return ManagementClient{
|
||||
Client: autorest.NewClientWithUserAgent(UserAgent()),
|
||||
BaseURI: DefaultBaseURI,
|
||||
APIVersion: APIVersion,
|
||||
SubscriptionID: subscriptionID,
|
||||
}
|
||||
}
|
312
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go
generated
vendored
Normal file
312
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/endpoints.go
generated
vendored
Normal file
|
@ -0,0 +1,312 @@
|
|||
package trafficmanager
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
|
||||
import (
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// EndpointsClient is the client for the Endpoints methods of the
|
||||
// Trafficmanager service.
|
||||
type EndpointsClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewEndpointsClient creates an instance of the EndpointsClient client.
|
||||
func NewEndpointsClient(subscriptionID string) EndpointsClient {
|
||||
return EndpointsClient{New(subscriptionID)}
|
||||
}
|
||||
|
||||
// CreateOrUpdate create or update a Traffic Manager endpoint.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager endpoint to be created or updated. profileName is the name of the
|
||||
// Traffic Manager profile. endpointType is the type of the Traffic Manager
|
||||
// endpoint to be created or updated. endpointName is the name of the Traffic
|
||||
// Manager endpoint to be created or updated. parameters is the Traffic
|
||||
// Manager endpoint parameters supplied to the CreateOrUpdate operation.
|
||||
func (client EndpointsClient) CreateOrUpdate(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) {
|
||||
req, err := client.CreateOrUpdatePreparer(resourceGroupName, profileName, endpointType, endpointName, parameters)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.CreateOrUpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.CreateOrUpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||
func (client EndpointsClient) CreateOrUpdatePreparer(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"endpointName": autorest.Encode("path", endpointName),
|
||||
"endpointType": autorest.Encode("path", endpointType),
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPut(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client EndpointsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client EndpointsClient) CreateOrUpdateResponder(resp *http.Response) (result Endpoint, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete deletes a Traffic Manager endpoint.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager endpoint to be deleted. profileName is the name of the Traffic
|
||||
// Manager profile. endpointType is the type of the Traffic Manager endpoint
|
||||
// to be deleted. endpointName is the name of the Traffic Manager endpoint to
|
||||
// be deleted.
|
||||
func (client EndpointsClient) Delete(resourceGroupName string, profileName string, endpointType string, endpointName string) (result autorest.Response, err error) {
|
||||
req, err := client.DeletePreparer(resourceGroupName, profileName, endpointType, endpointName)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client EndpointsClient) DeletePreparer(resourceGroupName string, profileName string, endpointType string, endpointName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"endpointName": autorest.Encode("path", endpointName),
|
||||
"endpointType": autorest.Encode("path", endpointType),
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client EndpointsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client EndpointsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get gets a Traffic Manager endpoint.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager endpoint. profileName is the name of the Traffic Manager profile.
|
||||
// endpointType is the type of the Traffic Manager endpoint. endpointName is
|
||||
// the name of the Traffic Manager endpoint.
|
||||
func (client EndpointsClient) Get(resourceGroupName string, profileName string, endpointType string, endpointName string) (result Endpoint, err error) {
|
||||
req, err := client.GetPreparer(resourceGroupName, profileName, endpointType, endpointName)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client EndpointsClient) GetPreparer(resourceGroupName string, profileName string, endpointType string, endpointName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"endpointName": autorest.Encode("path", endpointName),
|
||||
"endpointType": autorest.Encode("path", endpointType),
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client EndpointsClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client EndpointsClient) GetResponder(resp *http.Response) (result Endpoint, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update update a Traffic Manager endpoint.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager endpoint to be updated. profileName is the name of the Traffic
|
||||
// Manager profile. endpointType is the type of the Traffic Manager endpoint
|
||||
// to be updated. endpointName is the name of the Traffic Manager endpoint to
|
||||
// be updated. parameters is the Traffic Manager endpoint parameters supplied
|
||||
// to the Update operation.
|
||||
func (client EndpointsClient) Update(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (result Endpoint, err error) {
|
||||
req, err := client.UpdatePreparer(resourceGroupName, profileName, endpointType, endpointName, parameters)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.EndpointsClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client EndpointsClient) UpdatePreparer(resourceGroupName string, profileName string, endpointType string, endpointName string, parameters Endpoint) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"endpointName": autorest.Encode("path", endpointName),
|
||||
"endpointType": autorest.Encode("path", endpointType),
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client EndpointsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client EndpointsClient) UpdateResponder(resp *http.Response) (result Endpoint, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
120
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go
generated
vendored
Normal file
120
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/models.go
generated
vendored
Normal file
|
@ -0,0 +1,120 @@
|
|||
package trafficmanager
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
|
||||
import (
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
)
|
||||
|
||||
// CheckTrafficManagerRelativeDNSNameAvailabilityParameters is parameters
|
||||
// supplied to check Traffic Manager name operation.
|
||||
type CheckTrafficManagerRelativeDNSNameAvailabilityParameters struct {
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
// DNSConfig is class containing DNS settings in a Traffic Manager profile.
|
||||
type DNSConfig struct {
|
||||
RelativeName *string `json:"relativeName,omitempty"`
|
||||
Fqdn *string `json:"fqdn,omitempty"`
|
||||
TTL *int64 `json:"ttl,omitempty"`
|
||||
}
|
||||
|
||||
// Endpoint is class respresenting a Traffic Manager endpoint.
|
||||
type Endpoint struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
Properties *EndpointProperties `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// EndpointProperties is class respresenting a Traffic Manager endpoint
|
||||
// properties.
|
||||
type EndpointProperties struct {
|
||||
TargetResourceID *string `json:"targetResourceId,omitempty"`
|
||||
Target *string `json:"target,omitempty"`
|
||||
EndpointStatus *string `json:"endpointStatus,omitempty"`
|
||||
Weight *int64 `json:"weight,omitempty"`
|
||||
Priority *int64 `json:"priority,omitempty"`
|
||||
EndpointLocation *string `json:"endpointLocation,omitempty"`
|
||||
EndpointMonitorStatus *string `json:"endpointMonitorStatus,omitempty"`
|
||||
MinChildEndpoints *int64 `json:"minChildEndpoints,omitempty"`
|
||||
}
|
||||
|
||||
// MonitorConfig is class containing endpoint monitoring settings in a Traffic
|
||||
// Manager profile.
|
||||
type MonitorConfig struct {
|
||||
ProfileMonitorStatus *string `json:"profileMonitorStatus,omitempty"`
|
||||
Protocol *string `json:"protocol,omitempty"`
|
||||
Port *int64 `json:"port,omitempty"`
|
||||
Path *string `json:"path,omitempty"`
|
||||
}
|
||||
|
||||
// NameAvailability is class representing a Traffic Manager Name Availability
|
||||
// response.
|
||||
type NameAvailability struct {
|
||||
autorest.Response `json:"-"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
NameAvailable *bool `json:"nameAvailable,omitempty"`
|
||||
Reason *string `json:"reason,omitempty"`
|
||||
Message *string `json:"message,omitempty"`
|
||||
}
|
||||
|
||||
// Profile is class representing a Traffic Manager profile.
|
||||
type Profile struct {
|
||||
autorest.Response `json:"-"`
|
||||
ID *string `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
Location *string `json:"location,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
Properties *ProfileProperties `json:"properties,omitempty"`
|
||||
}
|
||||
|
||||
// ProfileListResult is the list Traffic Manager profiles operation response.
|
||||
type ProfileListResult struct {
|
||||
autorest.Response `json:"-"`
|
||||
Value *[]Profile `json:"value,omitempty"`
|
||||
}
|
||||
|
||||
// ProfileProperties is class representing the Traffic Manager profile
|
||||
// properties.
|
||||
type ProfileProperties struct {
|
||||
ProfileStatus *string `json:"profileStatus,omitempty"`
|
||||
TrafficRoutingMethod *string `json:"trafficRoutingMethod,omitempty"`
|
||||
DNSConfig *DNSConfig `json:"dnsConfig,omitempty"`
|
||||
MonitorConfig *MonitorConfig `json:"monitorConfig,omitempty"`
|
||||
Endpoints *[]Endpoint `json:"endpoints,omitempty"`
|
||||
}
|
||||
|
||||
// Resource is
|
||||
type Resource struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Type *string `json:"type,omitempty"`
|
||||
Location *string `json:"location,omitempty"`
|
||||
Tags *map[string]*string `json:"tags,omitempty"`
|
||||
}
|
||||
|
||||
// SubResource is
|
||||
type SubResource struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
}
|
481
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go
generated
vendored
Normal file
481
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/profiles.go
generated
vendored
Normal file
|
@ -0,0 +1,481 @@
|
|||
package trafficmanager
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
|
||||
import (
|
||||
"github.com/Azure/go-autorest/autorest"
|
||||
"github.com/Azure/go-autorest/autorest/azure"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// ProfilesClient is the client for the Profiles methods of the Trafficmanager
|
||||
// service.
|
||||
type ProfilesClient struct {
|
||||
ManagementClient
|
||||
}
|
||||
|
||||
// NewProfilesClient creates an instance of the ProfilesClient client.
|
||||
func NewProfilesClient(subscriptionID string) ProfilesClient {
|
||||
return ProfilesClient{New(subscriptionID)}
|
||||
}
|
||||
|
||||
// CheckTrafficManagerRelativeDNSNameAvailability checks the availability of a
|
||||
// Traffic Manager Relative DNS name.
|
||||
//
|
||||
// parameters is the Traffic Manager name parameters supplied to the
|
||||
// CheckTrafficManagerNameAvailability operation.
|
||||
func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailability(parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters) (result NameAvailability, err error) {
|
||||
req, err := client.CheckTrafficManagerRelativeDNSNameAvailabilityPreparer(parameters)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.CheckTrafficManagerRelativeDNSNameAvailabilitySender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.CheckTrafficManagerRelativeDNSNameAvailabilityResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CheckTrafficManagerRelativeDNSNameAvailability", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CheckTrafficManagerRelativeDNSNameAvailabilityPreparer prepares the CheckTrafficManagerRelativeDNSNameAvailability request.
|
||||
func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailabilityPreparer(parameters CheckTrafficManagerRelativeDNSNameAvailabilityParameters) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPost(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/providers/Microsoft.Network/checkTrafficManagerNameAvailability", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CheckTrafficManagerRelativeDNSNameAvailabilitySender sends the CheckTrafficManagerRelativeDNSNameAvailability request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailabilitySender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CheckTrafficManagerRelativeDNSNameAvailabilityResponder handles the response to the CheckTrafficManagerRelativeDNSNameAvailability request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) CheckTrafficManagerRelativeDNSNameAvailabilityResponder(resp *http.Response) (result NameAvailability, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdate create or update a Traffic Manager profile.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager profile. profileName is the name of the Traffic Manager profile.
|
||||
// parameters is the Traffic Manager profile parameters supplied to the
|
||||
// CreateOrUpdate operation.
|
||||
func (client ProfilesClient) CreateOrUpdate(resourceGroupName string, profileName string, parameters Profile) (result Profile, err error) {
|
||||
req, err := client.CreateOrUpdatePreparer(resourceGroupName, profileName, parameters)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.CreateOrUpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.CreateOrUpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||
func (client ProfilesClient) CreateOrUpdatePreparer(resourceGroupName string, profileName string, parameters Profile) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPut(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) CreateOrUpdateResponder(resp *http.Response) (result Profile, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete deletes a Traffic Manager profile.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager profile to be deleted. profileName is the name of the Traffic
|
||||
// Manager profile to be deleted.
|
||||
func (client ProfilesClient) Delete(resourceGroupName string, profileName string) (result autorest.Response, err error) {
|
||||
req, err := client.DeletePreparer(resourceGroupName, profileName)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.DeleteSender(req)
|
||||
if err != nil {
|
||||
result.Response = resp
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.DeleteResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Delete", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// DeletePreparer prepares the Delete request.
|
||||
func (client ProfilesClient) DeletePreparer(resourceGroupName string, profileName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsDelete(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// DeleteSender sends the Delete request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// DeleteResponder handles the response to the Delete request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
|
||||
autorest.ByClosing())
|
||||
result.Response = resp
|
||||
return
|
||||
}
|
||||
|
||||
// Get gets a Traffic Manager profile.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager profile. profileName is the name of the Traffic Manager profile.
|
||||
func (client ProfilesClient) Get(resourceGroupName string, profileName string) (result Profile, err error) {
|
||||
req, err := client.GetPreparer(resourceGroupName, profileName)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.GetSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.GetResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Get", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// GetPreparer prepares the Get request.
|
||||
func (client ProfilesClient) GetPreparer(resourceGroupName string, profileName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// GetSender sends the Get request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) GetSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// GetResponder handles the response to the Get request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) GetResponder(resp *http.Response) (result Profile, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// ListAll lists all Traffic Manager profiles within a subscription.
|
||||
func (client ProfilesClient) ListAll() (result ProfileListResult, err error) {
|
||||
req, err := client.ListAllPreparer()
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.ListAllSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.ListAllResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAll", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListAllPreparer prepares the ListAll request.
|
||||
func (client ProfilesClient) ListAllPreparer() (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/trafficmanagerprofiles", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// ListAllSender sends the ListAll request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) ListAllSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// ListAllResponder handles the response to the ListAll request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) ListAllResponder(resp *http.Response) (result ProfileListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// ListAllInResourceGroup lists all Traffic Manager profiles within a resource
|
||||
// group.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager profiles to be listed.
|
||||
func (client ProfilesClient) ListAllInResourceGroup(resourceGroupName string) (result ProfileListResult, err error) {
|
||||
req, err := client.ListAllInResourceGroupPreparer(resourceGroupName)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.ListAllInResourceGroupSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.ListAllInResourceGroupResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "ListAllInResourceGroup", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// ListAllInResourceGroupPreparer prepares the ListAllInResourceGroup request.
|
||||
func (client ProfilesClient) ListAllInResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsGet(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles", pathParameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// ListAllInResourceGroupSender sends the ListAllInResourceGroup request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) ListAllInResourceGroupSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// ListAllInResourceGroupResponder handles the response to the ListAllInResourceGroup request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) ListAllInResourceGroupResponder(resp *http.Response) (result ProfileListResult, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
||||
|
||||
// Update update a Traffic Manager profile.
|
||||
//
|
||||
// resourceGroupName is the name of the resource group containing the Traffic
|
||||
// Manager profile. profileName is the name of the Traffic Manager profile.
|
||||
// parameters is the Traffic Manager profile parameters supplied to the
|
||||
// Update operation.
|
||||
func (client ProfilesClient) Update(resourceGroupName string, profileName string, parameters Profile) (result Profile, err error) {
|
||||
req, err := client.UpdatePreparer(resourceGroupName, profileName, parameters)
|
||||
if err != nil {
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", nil, "Failure preparing request")
|
||||
}
|
||||
|
||||
resp, err := client.UpdateSender(req)
|
||||
if err != nil {
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return result, autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", resp, "Failure sending request")
|
||||
}
|
||||
|
||||
result, err = client.UpdateResponder(resp)
|
||||
if err != nil {
|
||||
err = autorest.NewErrorWithError(err, "trafficmanager.ProfilesClient", "Update", resp, "Failure responding to request")
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// UpdatePreparer prepares the Update request.
|
||||
func (client ProfilesClient) UpdatePreparer(resourceGroupName string, profileName string, parameters Profile) (*http.Request, error) {
|
||||
pathParameters := map[string]interface{}{
|
||||
"profileName": autorest.Encode("path", profileName),
|
||||
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||
}
|
||||
|
||||
queryParameters := map[string]interface{}{
|
||||
"api-version": client.APIVersion,
|
||||
}
|
||||
|
||||
preparer := autorest.CreatePreparer(
|
||||
autorest.AsJSON(),
|
||||
autorest.AsPatch(),
|
||||
autorest.WithBaseURL(client.BaseURI),
|
||||
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}", pathParameters),
|
||||
autorest.WithJSON(parameters),
|
||||
autorest.WithQueryParameters(queryParameters))
|
||||
return preparer.Prepare(&http.Request{})
|
||||
}
|
||||
|
||||
// UpdateSender sends the Update request. The method will close the
|
||||
// http.Response Body if it receives an error.
|
||||
func (client ProfilesClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||
return autorest.SendWithSender(client, req)
|
||||
}
|
||||
|
||||
// UpdateResponder handles the response to the Update request. The method always
|
||||
// closes the http.Response Body.
|
||||
func (client ProfilesClient) UpdateResponder(resp *http.Response) (result Profile, err error) {
|
||||
err = autorest.Respond(
|
||||
resp,
|
||||
client.ByInspecting(),
|
||||
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||
autorest.ByUnmarshallingJSON(&result),
|
||||
autorest.ByClosing())
|
||||
result.Response = autorest.Response{Response: resp}
|
||||
return
|
||||
}
|
43
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go
generated
vendored
Normal file
43
vendor/github.com/Azure/azure-sdk-for-go/arm/trafficmanager/version.go
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
package trafficmanager
|
||||
|
||||
// Copyright (c) Microsoft and contributors. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
//
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0
|
||||
// Changes may cause incorrect behavior and will be lost if the code is
|
||||
// regenerated.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const (
|
||||
major = "3"
|
||||
minor = "0"
|
||||
patch = "0"
|
||||
// Always begin a "tag" with a dash (as per http://semver.org)
|
||||
tag = "-beta"
|
||||
semVerFormat = "%s.%s.%s%s"
|
||||
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
|
||||
)
|
||||
|
||||
// UserAgent returns the UserAgent string to use when sending http.Requests.
|
||||
func UserAgent() string {
|
||||
return fmt.Sprintf(userAgentFormat, Version(), "trafficmanager", "2015-11-01")
|
||||
}
|
||||
|
||||
// Version returns the semantic version (see http://semver.org) of the client.
|
||||
func Version() string {
|
||||
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
|
||||
}
|
|
@ -44,6 +44,12 @@
|
|||
"revision": "2cdbb8553a20830507e4178b4d0803794136dde7",
|
||||
"revisionTime": "2016-06-29T16:19:23Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "2qCsDmxUSe6LzkuC9+rTK9wEPBg=",
|
||||
"path": "github.com/Azure/azure-sdk-for-go/arm/trafficmanager",
|
||||
"revision": "2cdbb8553a20830507e4178b4d0803794136dde7",
|
||||
"revisionTime": "2016-06-29T16:19:23Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Q+0Zz0iylSKMck4JhYc8XR83i8M=",
|
||||
"comment": "v2.1.1-beta-8-gca4d906",
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
---
|
||||
layout: "azurerm"
|
||||
page_title: "Azure Resource Manager: azurerm_traffic_manager_endpoint"
|
||||
sidebar_current: "docs-azurerm-resource-network-traffic-manager-endpoint"
|
||||
description: |-
|
||||
Creates a Traffic Manager Endpoint.
|
||||
---
|
||||
|
||||
# azurerm\_traffic\_manager\_endpoint
|
||||
|
||||
Creates a Traffic Manager Endpoint.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "profile1"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
location = "West US"
|
||||
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "profile1"
|
||||
ttl = 100
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "http"
|
||||
port = 80
|
||||
path = "/"
|
||||
}
|
||||
|
||||
tags {
|
||||
environment = "Production"
|
||||
}
|
||||
}
|
||||
|
||||
resource "azurerm_traffic_manager_endpoint" "test" {
|
||||
name = "profile1"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
profile_name = "${azurerm_traffic_manager_profile.test.name}"
|
||||
target = "terraform.io"
|
||||
type = "externalEndpoints"
|
||||
weight = 100
|
||||
}
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
||||
The following arguments are supported:
|
||||
|
||||
* `name` - (Required) The name of the virtual network. Changing this forces a
|
||||
new resource to be created.
|
||||
|
||||
* `resource_group_name` - (Required) The name of the resource group in which to
|
||||
create the virtual network.
|
||||
|
||||
* `profile_name` - (Required) The name of the Traffic Manager Profile to attach
|
||||
create the virtual network.
|
||||
|
||||
* `endpoint_status` - (Optional) The status of the Endpoint, can be set to
|
||||
either `Enabled` or `Disabled`. Defaults to `Enabled`.
|
||||
|
||||
* `type` - (Required) The Endpoint type, must be one of:
|
||||
- `azureEndpoints`
|
||||
- `externalEndpoints`
|
||||
- `nestedEndpoints`
|
||||
|
||||
* `target` - (Optional) The FQDN DNS name of the target. This argument must be
|
||||
provided for an endpoint of type `externalEndpoints`, for other types it
|
||||
will be computed.
|
||||
|
||||
* `target_resource_id` - (Optional) The resource id of an Azure resource to
|
||||
target. This argument must be provided for an endpoint of type
|
||||
`azureEndpoints`.
|
||||
|
||||
* `weight` - (Optional) Specifies how much traffic should be distributed to this
|
||||
endpoint, this must be specified for Profiles using the `Weighted` traffic
|
||||
routing method. Supports values between 1 and 1000.
|
||||
|
||||
* `priority` - (Optional) Specifies the priority of this Endpoint, this must be
|
||||
specified for Profiles using the `Priority` traffic routing method. Supports
|
||||
values between 1 and 1000, with no Endpoints sharing the same value. If
|
||||
omitted the value will be computed in order of creation.
|
||||
|
||||
* `endpoint_location` - (Optional) Specifies the Azure location of the Endpoint,
|
||||
this must be specified for Profiles using the `Performance` routing method
|
||||
if the Endpoint is of either type `nestedEndpoints` or `externalEndpoints`.
|
||||
For Endpoints of type `azureEndpoints` the value will be taken from the
|
||||
location of the Azure target resource.
|
||||
|
||||
* `min_child_endpoints` - (Optional) This argument specifies the minimum number
|
||||
of endpoints that must be ‘online’ in the child profile in order for the
|
||||
parent profile to direct traffic to any of the endpoints in that child
|
||||
profile. This argument only applies to Endpoints of type `nestedEndpoints`
|
||||
and defaults to `1`.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
The following attributes are exported:
|
||||
|
||||
* `id` - The Traffic Manager Endpoint id.
|
||||
|
||||
## Import
|
||||
|
||||
Traffic Manager Endpoints can be imported using the `resource id`, e.g.
|
||||
|
||||
```
|
||||
terraform import azurerm_traffic_manager_endpoint.testEndpoints /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/trafficManagerProfiles/mytrafficmanagerprofile1/azureEndpoints/mytrafficmanagerendpoint
|
||||
```
|
|
@ -0,0 +1,104 @@
|
|||
---
|
||||
layout: "azurerm"
|
||||
page_title: "Azure Resource Manager: azurerm_traffic_manager_profile"
|
||||
sidebar_current: "docs-azurerm-resource-network-traffic-manager-profile"
|
||||
description: |-
|
||||
Creates a Traffic Manager Profile.
|
||||
---
|
||||
|
||||
# azurerm\_traffic\_manager\_profile
|
||||
|
||||
Creates a Traffic Manager Profile to which multiple endpoints can be attached.
|
||||
|
||||
## Example Usage
|
||||
|
||||
```
|
||||
resource "azurerm_traffic_manager_profile" "test" {
|
||||
name = "profile1"
|
||||
resource_group_name = "${azurerm_resource_group.test.name}"
|
||||
location = "West US"
|
||||
|
||||
traffic_routing_method = "Weighted"
|
||||
|
||||
dns_config {
|
||||
relative_name = "profile1"
|
||||
ttl = 100
|
||||
}
|
||||
|
||||
monitor_config {
|
||||
protocol = "http"
|
||||
port = 80
|
||||
path = "/"
|
||||
}
|
||||
|
||||
tags {
|
||||
environment = "Production"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Argument Reference
|
||||
|
||||
The following arguments are supported:
|
||||
|
||||
* `name` - (Required) The name of the virtual network. Changing this forces a
|
||||
new resource to be created.
|
||||
|
||||
* `resource_group_name` - (Required) The name of the resource group in which to
|
||||
create the virtual network.
|
||||
|
||||
* `profile_status` - (Optional) The status of the profile, can be set to either
|
||||
`Enabled` or `Disabled`. Defaults to `Enabled`.
|
||||
|
||||
* `traffic_routing_method` - (Required) Specifies the algorithm used to route
|
||||
traffic, possible values are:
|
||||
- `Performance`- Traffic is routed via the User's closest Endpoint
|
||||
- `Weighted` - Traffic is spread across Endpoints proportional to their
|
||||
`weight` value.
|
||||
- `Priority` - Traffic is routed to the Endpoint with the lowest
|
||||
`priority` value.
|
||||
|
||||
* `dns_config` - (Required) This block specifies the DNS configuration of the
|
||||
Profile, it supports the fields documented below.
|
||||
|
||||
* `monitor_config` - (Required) This block specifies the Endpoint monitoring
|
||||
configuration for the Profile, it supports the fields documented below.
|
||||
|
||||
* `tags` - (Optional) A mapping of tags to assign to the resource.
|
||||
|
||||
The `dns_config` block supports:
|
||||
|
||||
* `relative_name` - (Required) The relative domain name, this is combined with
|
||||
the domain name used by Traffic Manager to form the FQDN which is exported
|
||||
as documented below. Changing this forces a new resource to be created.
|
||||
|
||||
* `ttl` - (Required) The TTL value of the Profile used by Local DNS resolvers
|
||||
and clients.
|
||||
|
||||
The `monitor_config` block supports:
|
||||
|
||||
* `http` - (Required) The protocol used by the monitoring checks, supported
|
||||
values are `http` or `https`.
|
||||
|
||||
* `port` - (Required) The port number used by the monitoring checks.
|
||||
|
||||
* `path` - (Required) The path used by the monitoring checks.
|
||||
|
||||
## Attributes Reference
|
||||
|
||||
The following attributes are exported:
|
||||
|
||||
* `id` - The Traffic Manager Profile id.
|
||||
* `fqdn` - The FQDN of the created Profile.
|
||||
|
||||
## Notes
|
||||
|
||||
The Traffic Manager is created with the location `global`.
|
||||
|
||||
## Import
|
||||
|
||||
Traffic Manager Profiles can be imported using the `resource id`, e.g.
|
||||
|
||||
```
|
||||
terraform import azurerm_traffic_manager_profile.testProfile /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/trafficManagerProfiles/mytrafficmanagerprofile1
|
||||
```
|
|
@ -114,6 +114,14 @@
|
|||
<a href="/docs/providers/azurerm/r/route.html">azurerm_route</a>
|
||||
</li>
|
||||
|
||||
<li<%= sidebar_current("docs-azurerm-resource-network-traffic-manager-profile") %>>
|
||||
<a href="/docs/providers/azurerm/r/traffic_manager_profile.html">azurerm_traffic_manager_profile</a>
|
||||
</li>
|
||||
|
||||
<li<%= sidebar_current("docs-azurerm-resource-network-traffic-manager-endpoint") %>>
|
||||
<a href="/docs/providers/azurerm/r/traffic_manager_endpoint.html">azurerm_traffic_manager_endpoint</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
|
Loading…
Reference in New Issue