Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Resource: Autoscale Settings #135

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Terraform always thinks the following template needs changes:

https://gist.github.com/StephenWeatherford/c236ae8c3f61efcbfd153b6d58f3049a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's because the VMSS number of instances got changed by the auto-scaling.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, does the number of instances (capacity) within VMSS need to be set to computed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any mistake whatsoever in the values sent to Azure causes 400 unknown with no info on where/what the problem is. Can you check with fiddler to see if that's really all we're getting, and report an error to Azure (if it is) or go sdk (if sdk is not giving us the error info).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same on portal, when something goes wrong with autoscale settings, it just says "bad request". :(

"github.com/Azure/azure-sdk-for-go/arm/disk"
"github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/insights"
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/redis"
Expand Down Expand Up @@ -42,6 +43,8 @@ type ArmClient struct {

rivieraClient *riviera.Client

autoscaleSettingsClient insights.AutoscaleSettingsClient

availSetClient compute.AvailabilitySetsClient
usageOpsClient compute.UsageClient
vmExtensionImageClient compute.VirtualMachineExtensionImagesClient
Expand Down Expand Up @@ -194,6 +197,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {

// NOTE: these declarations should be left separate for clarity should the
// clients be wished to be configured with custom Responders/PollingModess etc...
assc := insights.NewAutoscaleSettingsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&assc.Client)
assc.Authorizer = auth
assc.Sender = autorest.CreateSender(withRequestLogging())
client.autoscaleSettingsClient = assc

asc := compute.NewAvailabilitySetsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&asc.Client)
asc.Authorizer = auth
Expand Down
80 changes: 80 additions & 0 deletions azurerm/import_arm_autoscale_setting_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMAutoscaleSetting_importBasic(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"

ri := acctest.RandInt()
config := testAccAzureRMAutoscaleSetting_basic(ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAutoscaleSettingDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMAutoscaleSetting_importRecurrence(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"

ri := acctest.RandInt()
config := testAccAzureRMAutoscaleSetting_recurrence(ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAutoscaleSettingDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMAutoscaleSetting_importFixedDate(t *testing.T) {
resourceName := "azurerm_autoscale_setting.test"

ri := acctest.RandInt()
config := testAccAzureRMAutoscaleSetting_fixedDate(ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAutoscaleSettingDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
1 change: 1 addition & 0 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func Provider() terraform.ResourceProvider {

ResourcesMap: map[string]*schema.Resource{
// These resources use the Azure ARM SDK
"azurerm_autoscale_setting": resourceArmAutoscaleSetting(),
"azurerm_availability_set": resourceArmAvailabilitySet(),
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(),
Expand Down
Loading