From bf82a07848f6c9a3b1a955021d162d728f36bcb4 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 12 Feb 2020 20:00:08 +0100 Subject: [PATCH 1/2] 2.0: removing Scheduler since this is no longer supported --- azurerm/internal/clients/client.go | 3 - .../provider/required_resource_providers.go | 1 - azurerm/internal/provider/services.go | 2 - .../resource_arm_dev_test_lab_schedule.go | 15 +- .../services/scheduler/client/client.go | 25 - .../data_source_scheduler_job_collection.go | 123 -- .../services/scheduler/registration.go | 27 - .../scheduler/resource_arm_scheduler_job.go | 1028 ----------------- .../resource_arm_scheduler_job_collection.go | 318 ----- ...ta_source_scheduler_job_collection_test.go | 63 - ...ource_arm_scheduler_job_collection_test.go | 207 ---- .../tests/resource_arm_scheduler_job_test.go | 910 --------------- .../testdata/application_gateway_test.pfx | Bin 4213 -> 0 bytes website/azurerm.erb | 17 - .../d/scheduler_job_collection.html.markdown | 64 - website/docs/r/scheduler_job.html.markdown | 280 ----- .../r/scheduler_job_collection.html.markdown | 85 -- 17 files changed, 7 insertions(+), 3161 deletions(-) delete mode 100644 azurerm/internal/services/scheduler/client/client.go delete mode 100644 azurerm/internal/services/scheduler/data_source_scheduler_job_collection.go delete mode 100644 azurerm/internal/services/scheduler/registration.go delete mode 100644 azurerm/internal/services/scheduler/resource_arm_scheduler_job.go delete mode 100644 azurerm/internal/services/scheduler/resource_arm_scheduler_job_collection.go delete mode 100644 azurerm/internal/services/scheduler/tests/data_source_scheduler_job_collection_test.go delete mode 100644 azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_collection_test.go delete mode 100644 azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_test.go delete mode 100644 azurerm/internal/services/scheduler/tests/testdata/application_gateway_test.pfx delete mode 100644 website/docs/d/scheduler_job_collection.html.markdown delete mode 100644 website/docs/r/scheduler_job.html.markdown delete mode 100644 website/docs/r/scheduler_job_collection.html.markdown diff --git a/azurerm/internal/clients/client.go b/azurerm/internal/clients/client.go index a5c93d96aa5f..d81fcca5d799 100644 --- a/azurerm/internal/clients/client.go +++ b/azurerm/internal/clients/client.go @@ -54,7 +54,6 @@ import ( redis "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/redis/client" relay "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/relay/client" resource "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/resource/client" - scheduler "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/scheduler/client" search "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/search/client" securityCenter "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/securitycenter/client" serviceBus "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus/client" @@ -124,7 +123,6 @@ type Client struct { Redis *redis.Client Relay *relay.Client Resource *resource.Client - Scheduler *scheduler.Client Search *search.Client SecurityCenter *securityCenter.Client ServiceBus *serviceBus.Client @@ -193,7 +191,6 @@ func (client *Client) Build(ctx context.Context, o *common.ClientOptions) error client.Redis = redis.NewClient(o) client.Relay = relay.NewClient(o) client.Resource = resource.NewClient(o) - client.Scheduler = scheduler.NewClient(o) client.Search = search.NewClient(o) client.SecurityCenter = securityCenter.NewClient(o) client.ServiceBus = serviceBus.NewClient(o) diff --git a/azurerm/internal/provider/required_resource_providers.go b/azurerm/internal/provider/required_resource_providers.go index 422bc71eac39..652dcb2dbd38 100644 --- a/azurerm/internal/provider/required_resource_providers.go +++ b/azurerm/internal/provider/required_resource_providers.go @@ -56,7 +56,6 @@ func RequiredResourceProviders() map[string]struct{} { "Microsoft.Relay": {}, "Microsoft.RecoveryServices": {}, "Microsoft.Resources": {}, - "Microsoft.Scheduler": {}, "Microsoft.Search": {}, "Microsoft.Security": {}, "Microsoft.ServiceBus": {}, diff --git a/azurerm/internal/provider/services.go b/azurerm/internal/provider/services.go index 4a052e204d13..70d8913b5c2f 100644 --- a/azurerm/internal/provider/services.go +++ b/azurerm/internal/provider/services.go @@ -51,7 +51,6 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/redis" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/relay" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/resource" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/scheduler" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/search" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/securitycenter" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/servicebus" @@ -116,7 +115,6 @@ func SupportedServices() []common.ServiceRegistration { redis.Registration{}, relay.Registration{}, resource.Registration{}, - scheduler.Registration{}, search.Registration{}, securitycenter.Registration{}, servicebus.Registration{}, diff --git a/azurerm/internal/services/devtestlabs/resource_arm_dev_test_lab_schedule.go b/azurerm/internal/services/devtestlabs/resource_arm_dev_test_lab_schedule.go index 4f3c3b144cce..ccd8c90b2bb0 100644 --- a/azurerm/internal/services/devtestlabs/resource_arm_dev_test_lab_schedule.go +++ b/azurerm/internal/services/devtestlabs/resource_arm_dev_test_lab_schedule.go @@ -6,7 +6,6 @@ import ( "time" "github.com/Azure/azure-sdk-for-go/services/devtestlabs/mgmt/2016-05-15/dtl" - "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" @@ -93,13 +92,13 @@ func resourceArmDevTestLabSchedules() *schema.Resource { Elem: &schema.Schema{ Type: schema.TypeString, ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.Monday), - string(scheduler.Tuesday), - string(scheduler.Wednesday), - string(scheduler.Thursday), - string(scheduler.Friday), - string(scheduler.Saturday), - string(scheduler.Sunday), + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday", }, false), }, }, diff --git a/azurerm/internal/services/scheduler/client/client.go b/azurerm/internal/services/scheduler/client/client.go deleted file mode 100644 index 24083ea69a8d..000000000000 --- a/azurerm/internal/services/scheduler/client/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package client - -import ( - "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" -) - -// TODO: remove in 2.0 -type Client struct { - JobCollectionsClient *scheduler.JobCollectionsClient //nolint: megacheck - JobsClient *scheduler.JobsClient //nolint: megacheck -} - -func NewClient(o *common.ClientOptions) *Client { - jobCollectionsClient := scheduler.NewJobCollectionsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) //nolint: megacheck - o.ConfigureClient(&jobCollectionsClient.Client, o.ResourceManagerAuthorizer) - - jobsClient := scheduler.NewJobsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) //nolint: megacheck - o.ConfigureClient(&jobsClient.Client, o.ResourceManagerAuthorizer) - - return &Client{ - JobCollectionsClient: &jobCollectionsClient, - JobsClient: &jobsClient, - } -} diff --git a/azurerm/internal/services/scheduler/data_source_scheduler_job_collection.go b/azurerm/internal/services/scheduler/data_source_scheduler_job_collection.go deleted file mode 100644 index 51235aea12c5..000000000000 --- a/azurerm/internal/services/scheduler/data_source_scheduler_job_collection.go +++ /dev/null @@ -1,123 +0,0 @@ -package scheduler - -import ( - "fmt" - "time" - - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func dataSourceArmSchedulerJobCollection() *schema.Resource { - return &schema.Resource{ - Read: dataSourceArmSchedulerJobCollectionRead, - - Timeouts: &schema.ResourceTimeout{ - Read: schema.DefaultTimeout(5 * time.Minute), - }, - - DeprecationMessage: "Scheduler Job Collection has been deprecated in favour of Logic Apps - more information can be found at https://docs.microsoft.com/en-us/azure/scheduler/migrate-from-scheduler-to-logic-apps", - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - }, - - "location": azure.SchemaLocationForDataSource(), - - "resource_group_name": azure.SchemaResourceGroupNameForDataSource(), - - "tags": tags.SchemaDataSource(), - - "sku": { - Type: schema.TypeString, - Computed: true, - }, - - "state": { - Type: schema.TypeString, - Computed: true, - }, - - "quota": { - Type: schema.TypeList, - Computed: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - - //max_job_occurrence doesn't seem to do anything and always remains empty - - "max_job_count": { - Type: schema.TypeInt, - Computed: true, - }, - - "max_recurrence_frequency": { - Type: schema.TypeString, - Computed: true, - }, - - // API documentation states the MaxRecurrence.Interval "Gets or sets the interval between retries." - // however it does appear it is the max interval allowed for recurrences - "max_retry_interval": { - Type: schema.TypeInt, - Deprecated: "Renamed to `max_recurrence_interval` to match azure", - Computed: true, - }, - - "max_recurrence_interval": { - Type: schema.TypeInt, - Computed: true, - }, - }, - }, - }, - }, - } -} - -func dataSourceArmSchedulerJobCollectionRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobCollectionsClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - resourceGroup := d.Get("resource_group_name").(string) - name := d.Get("name").(string) - - collection, err := client.Get(ctx, resourceGroup, name) //nolint: megacheck - if err != nil { - if utils.ResponseWasNotFound(collection.Response) { - return fmt.Errorf("Error: Scheduler Job Collection %q (Resource Group %q) was not found", name, resourceGroup) - } - - return fmt.Errorf("Error making Read request on Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - d.SetId(*collection.ID) - - //standard properties - d.Set("name", collection.Name) - d.Set("resource_group_name", resourceGroup) - if location := collection.Location; location != nil { - d.Set("location", azure.NormalizeLocation(*location)) - } - - //resource specific - if properties := collection.Properties; properties != nil { - if sku := properties.Sku; sku != nil { - d.Set("sku", sku.Name) - } - d.Set("state", string(properties.State)) - - if err := d.Set("quota", flattenAzureArmSchedulerJobCollectionQuota(properties.Quota)); err != nil { - return fmt.Errorf("Error setting quota for Job Collection %q (Resource Group %q): %+v", *collection.Name, resourceGroup, err) - } - } - - return tags.FlattenAndSet(d, collection.Tags) -} diff --git a/azurerm/internal/services/scheduler/registration.go b/azurerm/internal/services/scheduler/registration.go deleted file mode 100644 index 45c6f742dc79..000000000000 --- a/azurerm/internal/services/scheduler/registration.go +++ /dev/null @@ -1,27 +0,0 @@ -package scheduler - -import ( - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" -) - -type Registration struct{} - -// Name is the name of this Service -func (r Registration) Name() string { - return "Scheduler" -} - -// SupportedDataSources returns the supported Data Sources supported by this Service -func (r Registration) SupportedDataSources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "azurerm_scheduler_job_collection": dataSourceArmSchedulerJobCollection(), - } -} - -// SupportedResources returns the supported Resources supported by this Service -func (r Registration) SupportedResources() map[string]*schema.Resource { - return map[string]*schema.Resource{ - "azurerm_scheduler_job_collection": resourceArmSchedulerJobCollection(), - "azurerm_scheduler_job": resourceArmSchedulerJob(), - } -} diff --git a/azurerm/internal/services/scheduler/resource_arm_scheduler_job.go b/azurerm/internal/services/scheduler/resource_arm_scheduler_job.go deleted file mode 100644 index a4eb8c5bc689..000000000000 --- a/azurerm/internal/services/scheduler/resource_arm_scheduler_job.go +++ /dev/null @@ -1,1028 +0,0 @@ -// nolint: megacheck -// entire automation SDK has been depreciated in v21.3 in favor of logic apps, an entirely different service. -package scheduler - -import ( - "bytes" - "fmt" - "log" - "regexp" - "strings" - "time" - - "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" - "github.com/Azure/go-autorest/autorest/date" - "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/set" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/storage" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func resourceArmSchedulerJob() *schema.Resource { - return &schema.Resource{ - Create: resourceArmSchedulerJobCreateUpdate, - Read: resourceArmSchedulerJobRead, - Update: resourceArmSchedulerJobCreateUpdate, - Delete: resourceArmSchedulerJobDelete, - - DeprecationMessage: "Scheduler Job's have been deprecated in favour of Logic Apps - more information can be found at https://docs.microsoft.com/en-us/azure/scheduler/migrate-from-scheduler-to-logic-apps", - - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), - Read: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), - }, - - CustomizeDiff: resourceArmSchedulerJobCustomizeDiff, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringMatch( - regexp.MustCompile("^[a-zA-Z][-_a-zA-Z0-9].*$"), - "Job Collection Name name must start with a letter and contain only letters, numbers, hyphens and underscores.", - ), - }, - - "resource_group_name": azure.SchemaResourceGroupName(), - - "job_collection_name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - //actions - "action_web": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: resourceArmSchedulerJobActionWebSchema("action_web"), - ConflictsWith: []string{"action_storage_queue"}, - }, - - "action_storage_queue": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: resourceArmSchedulerJobActionStorageSchema(), - ConflictsWith: []string{"action_web"}, - }, - - //actions - "error_action_web": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: resourceArmSchedulerJobActionWebSchema("error_action_web"), - ConflictsWith: []string{"error_action_storage_queue"}, - }, - - "error_action_storage_queue": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: resourceArmSchedulerJobActionStorageSchema(), - ConflictsWith: []string{"error_action_web"}, - }, - - //retry policy - "retry": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - - //silently fails if the duration is not in the correct format - //todo validation - "interval": { - Type: schema.TypeString, - Optional: true, - Default: "00:00:30", - ValidateFunc: validation.StringIsNotEmpty, - }, - - "count": { - Type: schema.TypeInt, - Optional: true, - Default: 4, - ValidateFunc: validation.IntBetween(1, 20), - }, - }, - }, - }, - - //recurrences (schedule in portal, recurrence in API) - "recurrence": { - Type: schema.TypeList, - MinItems: 1, - MaxItems: 1, - Optional: true, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - - "frequency": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.Minute), - string(scheduler.Hour), - string(scheduler.Day), - string(scheduler.Week), - string(scheduler.Month), - }, true), - }, - - "interval": { - Type: schema.TypeInt, - Optional: true, - Default: 1, //defaults to 1 in the portal - - //maximum is dynamic: 1 min <= interval * frequency <= 500 days (bounded by JobCollection quotas) - ValidateFunc: validation.IntAtLeast(1), - }, - - "count": { - Type: schema.TypeInt, - Optional: true, - //silently fails/produces odd results at >2147483647 - ValidateFunc: validation.IntBetween(1, 2147483647), - }, - - "end_time": { - Type: schema.TypeString, - Optional: true, - Computed: true, - DiffSuppressFunc: suppress.RFC3339Time, - ValidateFunc: validate.RFC3339Time, - }, - - "minutes": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - ValidateFunc: validation.IntBetween(0, 59), - }, - Set: set.HashInt, - }, - - "hours": { - Type: schema.TypeSet, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeInt, - ValidateFunc: validation.IntBetween(0, 23), - }, - Set: set.HashInt, - }, - - "week_days": { //used with weekly - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"recurrence.0.month_days", "recurrence.0.monthly_occurrences"}, - // the constants are title cased but the API returns all lowercase - // so lets ignore the case - Set: set.HashStringIgnoreCase, - Elem: &schema.Schema{ - Type: schema.TypeString, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validate.DayOfTheWeek(true), - }, - }, - - "month_days": { //used with monthly, - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"recurrence.0.week_days", "recurrence.0.monthly_occurrences"}, - MinItems: 1, - Elem: &schema.Schema{ - Type: schema.TypeInt, - ValidateFunc: validation.All( - validation.IntBetween(-31, 31), - validation.IntNotInSlice([]int{0}), - ), - }, - Set: set.HashInt, - }, - - "monthly_occurrences": { - Type: schema.TypeSet, - Optional: true, - ConflictsWith: []string{"recurrence.0.week_days", "recurrence.0.month_days"}, - MinItems: 1, - Set: resourceAzureRMSchedulerJobMonthlyOccurrenceHash, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "day": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validate.DayOfTheWeek(true), - }, - - "occurrence": { - Type: schema.TypeInt, - Required: true, - ValidateFunc: validation.All( - validation.IntBetween(-5, 5), - validation.IntNotInSlice([]int{0}), - ), - }, - }, - }, - }, - }, - }, - }, - - "start_time": { - Type: schema.TypeString, - Optional: true, - Computed: true, //defaults to now in create function - DiffSuppressFunc: suppress.RFC3339Time, - ValidateFunc: validate.RFC3339Time, //times in the past just start immediately - }, - - "state": { - Type: schema.TypeString, - Optional: true, - Computed: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.JobStateEnabled), - string(scheduler.JobStateDisabled), - // JobStateFaulted & JobStateCompleted are also possible, but silly - }, true), - }, - }, - } -} - -func resourceArmSchedulerJobActionWebSchema(propertyName string) *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - // we can determine the type (HTTP/HTTPS) from the url - // but we need to make sure the url starts with http/https - // both so we can determine the type and as azure requires it - "url": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.IsURLWithScheme([]string{"http", "https"}), - }, - - "method": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringInSlice([]string{ - "Get", "Put", "Post", "Delete", - }, true), - }, - - //only valid/used when action type is put - "body": { - Type: schema.TypeString, - Optional: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "headers": { - Type: schema.TypeMap, - Optional: true, - Elem: &schema.Schema{ - Type: schema.TypeString, - }, - }, - - //authentication requires HTTPS - "authentication_basic": { - Type: schema.TypeList, - MaxItems: 1, - Optional: true, - ConflictsWith: []string{ - fmt.Sprintf("%s.0.authentication_certificate", propertyName), - fmt.Sprintf("%s.0.authentication_active_directory", propertyName), - }, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "username": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "password": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - }, - }, - }, - - "authentication_certificate": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ConflictsWith: []string{ - fmt.Sprintf("%s.0.authentication_basic", propertyName), - fmt.Sprintf("%s.0.authentication_active_directory", propertyName), - }, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "pfx": { - Type: schema.TypeString, - Required: true, - Sensitive: true, //sensitive & shortens diff - ValidateFunc: validation.StringIsNotEmpty, - }, - - "password": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "thumbprint": { - Type: schema.TypeString, - Computed: true, - }, - - "expiration": { - Type: schema.TypeString, - Computed: true, - }, - - "subject_name": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - }, - - "authentication_active_directory": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - ConflictsWith: []string{ - fmt.Sprintf("%s.0.authentication_basic", propertyName), - fmt.Sprintf("%s.0.authentication_certificate", propertyName), - }, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "tenant_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "client_id": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - "secret": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "audience": { - Type: schema.TypeString, - Optional: true, - Computed: true, //is defaulted to the ServiceManagementEndpoint in create - }, - }, - }, - }, - }, - } -} - -func resourceArmSchedulerJobActionStorageSchema() *schema.Resource { - return &schema.Resource{ - Schema: map[string]*schema.Schema{ - - "storage_account_name": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: storage.ValidateArmStorageAccountName, - }, - - "storage_queue_name": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: storage.ValidateArmStorageAccountName, - }, - - "sas_token": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - - "message": { - Type: schema.TypeString, - Required: true, - ValidateFunc: validation.StringIsNotEmpty, - }, - }, - } -} - -func resourceArmSchedulerJobCustomizeDiff(diff *schema.ResourceDiff, _ interface{}) error { - _, hasWeb := diff.GetOk("action_web") - _, hasStorage := diff.GetOk("action_storage_queue") - if !hasWeb && !hasStorage { - return fmt.Errorf("One of `action_web` or `action_storage_queue` must be set") - } - - if b, ok := diff.GetOk("recurrence"); ok { - if recurrence, ok := b.([]interface{})[0].(map[string]interface{}); ok { - //if neither count nor end time is set the API will silently fail - _, hasCount := recurrence["count"] - _, hasEnd := recurrence["end_time"] - if !hasCount && !hasEnd { - return fmt.Errorf("One of `count` or `end_time` must be set for the 'recurrence' block.") - } - } - } - - return nil -} - -func resourceArmSchedulerJobCreateUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobsClient - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - - name := d.Get("name").(string) - resourceGroup := d.Get("resource_group_name").(string) - jobCollection := d.Get("job_collection_name").(string) - - if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, jobCollection, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing Scheduler Job %q (resource group %q)", name, resourceGroup) - } - } - - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_scheduler_job", *existing.ID) - } - } - - job := scheduler.JobDefinition{ - Properties: &scheduler.JobProperties{ - Action: expandAzureArmSchedulerJobAction(d, meta), - }, - } - - log.Printf("[DEBUG] Creating/updating Scheduler Job %q (resource group %q)", name, resourceGroup) - - //schedule (recurrence) - if b, ok := d.GetOk("recurrence"); ok { - job.Properties.Recurrence = expandAzureArmSchedulerJobRecurrence(b) - } - - //start time, should be validated by schema, also defaults to now if not set - if v, ok := d.GetOk("start_time"); ok { - startTime, _ := time.Parse(time.RFC3339, v.(string)) - job.Properties.StartTime = &date.Time{Time: startTime} - } else { - job.Properties.StartTime = &date.Time{Time: time.Now()} - } - - //state - if state, ok := d.GetOk("state"); ok { - job.Properties.State = scheduler.JobState(state.(string)) - } - - resp, err := client.CreateOrUpdate(ctx, resourceGroup, jobCollection, name, job) - if err != nil { - return fmt.Errorf("Error creating/updating Scheduler Job %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - d.SetId(*resp.ID) - - return resourceArmSchedulerJobRead(d, meta) -} - -func resourceArmSchedulerJobRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobsClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - - name := id.Path["jobs"] - resourceGroup := id.ResourceGroup - jobCollection := id.Path["jobCollections"] - - log.Printf("[DEBUG] Reading Scheduler Job %q (resource group %q)", name, resourceGroup) - - job, err := client.Get(ctx, resourceGroup, jobCollection, name) - if err != nil { - if utils.ResponseWasNotFound(job.Response) { - d.SetId("") - return nil - } - - return fmt.Errorf("Error making Read request on Scheduler Job %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - //standard properties - d.Set("name", name) - d.Set("resource_group_name", resourceGroup) - d.Set("job_collection_name", jobCollection) - - //check & get properties - properties := job.Properties - if properties != nil { - //action - action := properties.Action - if action != nil { - actionType := strings.ToLower(string(action.Type)) - - if strings.EqualFold(actionType, string(scheduler.HTTP)) || strings.EqualFold(actionType, string(scheduler.HTTPS)) { - if err := d.Set("action_web", flattenAzureArmSchedulerJobActionRequest(d, "action_web", action.Request)); err != nil { - return err - } - } else if strings.EqualFold(actionType, string(scheduler.StorageQueue)) { - if err := d.Set("action_storage_queue", flattenAzureArmSchedulerJobActionQueueMessage(d, "action_storage_queue", action.QueueMessage)); err != nil { - return err - } - } - - //error action - if errorAction := action.ErrorAction; errorAction != nil { - errorActionType := strings.ToLower(string(errorAction.Type)) - - if strings.EqualFold(errorActionType, string(scheduler.HTTP)) || strings.EqualFold(errorActionType, string(scheduler.HTTPS)) { - if err := d.Set("error_action_web", flattenAzureArmSchedulerJobActionRequest(d, "error_action_web", errorAction.Request)); err != nil { - return err - } - } else if strings.EqualFold(errorActionType, string(scheduler.StorageQueue)) { - if err := d.Set("error_action_storage_queue", flattenAzureArmSchedulerJobActionQueueMessage(d, "error_action_storage_queue", errorAction.QueueMessage)); err != nil { - return err - } - } - } - - //retry - if retry := action.RetryPolicy; retry != nil { - //if its not fixed we should not have a retry block - //api returns whatever casing it gets so do a case insensitive comparison - if strings.EqualFold(string(retry.RetryType), string(scheduler.Fixed)) { - if err := d.Set("retry", flattenAzureArmSchedulerJobActionRetry(retry)); err != nil { - return err - } - } - } - } - - //schedule - if recurrence := properties.Recurrence; recurrence != nil { - if err := d.Set("recurrence", flattenAzureArmSchedulerJobSchedule(recurrence)); err != nil { - return err - } - } - - if v := properties.StartTime; v != nil { - d.Set("start_time", (*v).Format(time.RFC3339)) - } - - //status && state - d.Set("state", properties.State) - } - - return nil -} - -func resourceArmSchedulerJobDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobsClient - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - - name := id.Path["jobs"] - resourceGroup := id.ResourceGroup - jobCollection := id.Path["jobCollections"] - - log.Printf("[DEBUG] Deleting Scheduler Job %q (resource group %q)", name, resourceGroup) - - resp, err := client.Delete(ctx, resourceGroup, jobCollection, name) - if err != nil { - if !utils.ResponseWasNotFound(resp) { - return fmt.Errorf("Error issuing delete request for Scheduler Job %q (Resource Group %q): %+v", name, resourceGroup, err) - } - } - - return nil -} - -func expandAzureArmSchedulerJobAction(d *schema.ResourceData, meta interface{}) *scheduler.JobAction { - action := scheduler.JobAction{} - - //action - if b, ok := d.GetOk("action_web"); ok { - action.Request, action.Type = expandAzureArmSchedulerJobActionRequest(b, meta) - } else if b, ok := d.GetOk("action_storage_queue"); ok { - action.QueueMessage = expandAzureArmSchedulerJobActionStorage(b) - action.Type = scheduler.StorageQueue - } - - //error action - if b, ok := d.GetOk("error_action_web"); ok { - action.ErrorAction = &scheduler.JobErrorAction{} - action.ErrorAction.Request, action.ErrorAction.Type = expandAzureArmSchedulerJobActionRequest(b, meta) - } else if b, ok := d.GetOk("error_action_storage_queue"); ok { - action.ErrorAction = &scheduler.JobErrorAction{} - action.ErrorAction.QueueMessage = expandAzureArmSchedulerJobActionStorage(b) - action.ErrorAction.Type = scheduler.StorageQueue - } - - //retry policy - if b, ok := d.GetOk("retry"); ok { - action.RetryPolicy = expandAzureArmSchedulerJobActionRetry(b) - } else { - action.RetryPolicy = &scheduler.RetryPolicy{ - RetryType: scheduler.None, - } - } - - return &action -} - -func expandAzureArmSchedulerJobActionRequest(b interface{}, meta interface{}) (*scheduler.HTTPRequest, scheduler.JobActionType) { - block := b.([]interface{})[0].(map[string]interface{}) - - url := block["url"].(string) - - request := scheduler.HTTPRequest{ - URI: &url, - Method: utils.String(block["method"].(string)), - Headers: map[string]*string{}, - } - - // determine type from the url, the property validation must ensure this - // otherwise we need to worry about what happens if neither is true - var jobType scheduler.JobActionType - if strings.HasPrefix(strings.ToLower(url), "https://") { - jobType = scheduler.HTTPS - } else { - jobType = scheduler.HTTP - } - - //load headers - for k, v := range block["headers"].(map[string]interface{}) { - request.Headers[k] = utils.String(v.(string)) - } - - //only valid for a set - if v, ok := block["body"].(string); ok && v != "" { - request.Body = utils.String(block["body"].(string)) - } - - //authentications - if v, ok := block["authentication_basic"].([]interface{}); ok && len(v) > 0 { - b := v[0].(map[string]interface{}) - request.Authentication = &scheduler.BasicAuthentication{ - Type: scheduler.TypeBasic, - Username: utils.String(b["username"].(string)), - Password: utils.String(b["password"].(string)), - } - } - - if v, ok := block["authentication_certificate"].([]interface{}); ok && len(v) > 0 { - b := v[0].(map[string]interface{}) - request.Authentication = &scheduler.ClientCertAuthentication{ - Type: scheduler.TypeClientCertificate, - Pfx: utils.String(b["pfx"].(string)), - Password: utils.String(b["password"].(string)), - } - } - - if v, ok := block["authentication_active_directory"].([]interface{}); ok && len(v) > 0 { - b := v[0].(map[string]interface{}) - oauth := &scheduler.OAuthAuthentication{ - Type: scheduler.TypeActiveDirectoryOAuth, - Tenant: utils.String(b["tenant_id"].(string)), - ClientID: utils.String(b["client_id"].(string)), - Secret: utils.String(b["secret"].(string)), - } - - //default to the service Management Endpoint - if v, ok := b["audience"].(string); ok { - oauth.Audience = utils.String(v) - } else { - oauth.Audience = utils.String(meta.(*clients.Client).Account.Environment.ServiceManagementEndpoint) - } - - request.Authentication = oauth - } - - return &request, jobType -} - -func expandAzureArmSchedulerJobActionStorage(b interface{}) *scheduler.StorageQueueMessage { - block := b.([]interface{})[0].(map[string]interface{}) - - message := scheduler.StorageQueueMessage{ - StorageAccount: utils.String(block["storage_account_name"].(string)), - QueueName: utils.String(block["storage_queue_name"].(string)), - SasToken: utils.String(block["sas_token"].(string)), - Message: utils.String(block["message"].(string)), - } - - return &message -} - -func expandAzureArmSchedulerJobActionRetry(b interface{}) *scheduler.RetryPolicy { - block := b.([]interface{})[0].(map[string]interface{}) - retry := scheduler.RetryPolicy{ - RetryType: scheduler.Fixed, - } - - if v, ok := block["interval"].(string); ok && v != "" { - retry.RetryInterval = utils.String(v) - } - if v, ok := block["count"].(int); ok { - retry.RetryCount = utils.Int32(int32(v)) - } - - return &retry -} - -func expandAzureArmSchedulerJobRecurrence(b interface{}) *scheduler.JobRecurrence { - block := b.([]interface{})[0].(map[string]interface{}) - - recurrence := scheduler.JobRecurrence{ - Frequency: scheduler.RecurrenceFrequency(block["frequency"].(string)), - Interval: utils.Int32(int32(block["interval"].(int))), - } - if v, ok := block["count"].(int); ok { - recurrence.Count = utils.Int32(int32(v)) - } - if v, ok := block["end_time"].(string); ok && v != "" { - endTime, _ := time.Parse(time.RFC3339, v) //validated by schema - recurrence.EndTime = &date.Time{Time: endTime} - } - - schedule := scheduler.JobRecurrenceSchedule{} - if s, ok := block["minutes"].(*schema.Set); ok && s.Len() > 0 { - schedule.Minutes = set.ToSliceInt32P(s) - } - if s, ok := block["hours"].(*schema.Set); ok && s.Len() > 0 { - schedule.Hours = set.ToSliceInt32P(s) - } - - if s, ok := block["week_days"].(*schema.Set); ok && s.Len() > 0 { - var slice []scheduler.DayOfWeek - for _, m := range s.List() { - slice = append(slice, scheduler.DayOfWeek(m.(string))) - } - schedule.WeekDays = &slice - } - - if s, ok := block["month_days"].(*schema.Set); ok && s.Len() > 0 { - schedule.MonthDays = set.ToSliceInt32P(s) - } - if s, ok := block["monthly_occurrences"].(*schema.Set); ok && s.Len() > 0 { - var slice []scheduler.JobRecurrenceScheduleMonthlyOccurrence - for _, e := range s.List() { - b := e.(map[string]interface{}) - slice = append(slice, scheduler.JobRecurrenceScheduleMonthlyOccurrence{ - Day: scheduler.JobScheduleDay(b["day"].(string)), - Occurrence: utils.Int32(int32(b["occurrence"].(int))), - }) - } - schedule.MonthlyOccurrences = &slice - } - - // if non of these are set and we try and send out a empty JobRecurrenceSchedule block - // the API will not respond so kindly - if schedule.Minutes != nil || - schedule.Hours != nil || - schedule.WeekDays != nil || - schedule.MonthDays != nil || - schedule.MonthlyOccurrences != nil { - recurrence.Schedule = &schedule - } - return &recurrence -} - -// flatten (API --> terraform) - -func flattenAzureArmSchedulerJobActionRequest(d *schema.ResourceData, blockName string, request *scheduler.HTTPRequest) []interface{} { - block := map[string]interface{}{} - - if v := request.URI; v != nil { - block["url"] = *v - } - if v := request.Method; v != nil { - block["method"] = *v - } - if v := request.Body; v != nil { - block["body"] = *v - } - - if v := request.Headers; v != nil { - headers := map[string]interface{}{} - for k, v := range v { - headers[k] = *v - } - - block["headers"] = headers - } - - if auth := request.Authentication; auth != nil { - authBlock := map[string]interface{}{} - - if basic, ok := auth.AsBasicAuthentication(); ok { - block["authentication_basic"] = []interface{}{authBlock} - - if v := basic.Username; v != nil { - authBlock["username"] = *v - } - - //password is not returned so lets fetch it - if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_basic.0.password", blockName)); ok { - authBlock["password"] = v.(string) - } - } else if cert, ok := auth.AsClientCertAuthentication(); ok { - block["authentication_certificate"] = []interface{}{authBlock} - - if v := cert.CertificateThumbprint; v != nil { - authBlock["thumbprint"] = *v - } - if v := cert.CertificateExpirationDate; v != nil { - authBlock["expiration"] = (*v).Format(time.RFC3339) - } - if v := cert.CertificateSubjectName; v != nil { - authBlock["subject_name"] = *v - } - - //these properties not returned, so lets grab them - if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_certificate.0.pfx", blockName)); ok { - authBlock["pfx"] = v.(string) - } - if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_certificate.0.password", blockName)); ok { - authBlock["password"] = v.(string) - } - } else if oauth, ok := auth.AsOAuthAuthentication(); ok { - block["authentication_active_directory"] = []interface{}{authBlock} - - if v := oauth.Audience; v != nil { - authBlock["audience"] = *v - } - if v := oauth.ClientID; v != nil { - authBlock["client_id"] = *v - } - if v := oauth.Tenant; v != nil { - authBlock["tenant_id"] = *v - } - - //secret is not returned - if v, ok := d.GetOk(fmt.Sprintf("%s.0.authentication_active_directory.0.secret", blockName)); ok { - authBlock["secret"] = v.(string) - } - } - } - - return []interface{}{block} -} - -func flattenAzureArmSchedulerJobActionQueueMessage(d *schema.ResourceData, blockName string, qm *scheduler.StorageQueueMessage) []interface{} { - block := map[string]interface{}{} - - if v := qm.StorageAccount; v != nil { - block["storage_account_name"] = *v - } - if v := qm.QueueName; v != nil { - block["storage_queue_name"] = *v - } - if v := qm.Message; v != nil { - block["message"] = *v - } - - //sas_token is not returned by the API - if v, ok := d.GetOk(fmt.Sprintf("%s.0.sas_token", blockName)); ok { - block["sas_token"] = v.(string) - } - - return []interface{}{block} -} - -func flattenAzureArmSchedulerJobActionRetry(retry *scheduler.RetryPolicy) []interface{} { - block := map[string]interface{}{} - - if v := retry.RetryInterval; v != nil { - block["interval"] = *v - } - if v := retry.RetryCount; v != nil { - block["count"] = *v - } - - return []interface{}{block} -} - -func flattenAzureArmSchedulerJobSchedule(recurrence *scheduler.JobRecurrence) []interface{} { - block := map[string]interface{}{} - - block["frequency"] = string(recurrence.Frequency) - - if v := recurrence.Interval; v != nil { - block["interval"] = *v - } - if v := recurrence.Count; v != nil { - block["count"] = *v - } - if v := recurrence.EndTime; v != nil { - block["end_time"] = (*v).Format(time.RFC3339) - } - - if schedule := recurrence.Schedule; schedule != nil { - if v := schedule.Minutes; v != nil { - block["minutes"] = set.FromInt32Slice(*v) - } - if v := schedule.Hours; v != nil { - block["hours"] = set.FromInt32Slice(*v) - } - - if v := schedule.WeekDays; v != nil { - s := &schema.Set{F: schema.HashString} - for _, v := range *v { - s.Add(string(v)) - } - block["week_days"] = s - } - if v := schedule.MonthDays; v != nil { - block["month_days"] = set.FromInt32Slice(*v) - } - - if monthly := schedule.MonthlyOccurrences; monthly != nil { - s := &schema.Set{F: resourceAzureRMSchedulerJobMonthlyOccurrenceHash} - for _, e := range *monthly { - m := map[string]interface{}{ - "day": string(e.Day), - } - - if v := e.Occurrence; v != nil { - m["occurrence"] = int(*v) - } - - s.Add(m) - } - block["monthly_occurrences"] = s - } - } - - return []interface{}{block} -} - -func resourceAzureRMSchedulerJobMonthlyOccurrenceHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - //day returned by azure is in a different case then the API constants - buf.WriteString(fmt.Sprintf("%s-", strings.ToLower(m["day"].(string)))) - buf.WriteString(fmt.Sprintf("%d-", m["occurrence"].(int))) - } - - return hashcode.String(buf.String()) -} diff --git a/azurerm/internal/services/scheduler/resource_arm_scheduler_job_collection.go b/azurerm/internal/services/scheduler/resource_arm_scheduler_job_collection.go deleted file mode 100644 index 991b7dde6d2a..000000000000 --- a/azurerm/internal/services/scheduler/resource_arm_scheduler_job_collection.go +++ /dev/null @@ -1,318 +0,0 @@ -// nolint: megacheck -// entire automation SDK has been depreciated in v21.3 in favor of logic apps, an entirely different service. -package scheduler - -import ( - "fmt" - "log" - "regexp" - "time" - - "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" - "github.com/hashicorp/go-azure-helpers/response" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/helper/validation" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func resourceArmSchedulerJobCollection() *schema.Resource { - return &schema.Resource{ - Create: resourceArmSchedulerJobCollectionCreateUpdate, - Read: resourceArmSchedulerJobCollectionRead, - Update: resourceArmSchedulerJobCollectionCreateUpdate, - Delete: resourceArmSchedulerJobCollectionDelete, - - DeprecationMessage: "Scheduler Job Collection has been deprecated in favour of Logic Apps - more information can be found at https://docs.microsoft.com/en-us/azure/scheduler/migrate-from-scheduler-to-logic-apps", - - Importer: &schema.ResourceImporter{ - State: schema.ImportStatePassthrough, - }, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(30 * time.Minute), - Read: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(30 * time.Minute), - Delete: schema.DefaultTimeout(30 * time.Minute), - }, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: validation.StringMatch( - regexp.MustCompile("^[a-zA-Z][-_a-zA-Z0-9]{0,99}$"), - "Job Collection Name name must be 1 - 100 characters long, start with a letter and contain only letters, numbers, hyphens and underscores.", - ), - }, - - "location": azure.SchemaLocation(), - - "resource_group_name": azure.SchemaResourceGroupName(), - - "tags": tags.Schema(), - - "sku": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.Free), - string(scheduler.Standard), - string(scheduler.P10Premium), - string(scheduler.P20Premium), - }, true), - }, - - //optional - "state": { - Type: schema.TypeString, - Optional: true, - Default: string(scheduler.Enabled), - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.Enabled), - string(scheduler.Suspended), - string(scheduler.Disabled), - }, true), - }, - - "quota": { - Type: schema.TypeList, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - - //max_job_occurrence doesn't seem to do anything and always remains empty - - "max_job_count": { - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntAtLeast(0), - }, - - "max_recurrence_frequency": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - ValidateFunc: validation.StringInSlice([]string{ - string(scheduler.Minute), - string(scheduler.Hour), - string(scheduler.Day), - string(scheduler.Week), - string(scheduler.Month), - }, true), - }, - - // API documentation states the MaxRecurrence.Interval "Gets or sets the interval between retries." - // however it does appear it is the max interval allowed for recurrences - "max_retry_interval": { - Type: schema.TypeInt, - Optional: true, - Computed: true, - Deprecated: "Renamed to `max_recurrence_interval` to match azure", - ValidateFunc: validation.IntAtLeast(1), //changes depending on the frequency, unknown maximums - }, - - "max_recurrence_interval": { - Type: schema.TypeInt, - Optional: true, - ValidateFunc: validation.IntAtLeast(1), //changes depending on the frequency, unknown maximums - }, - }, - }, - }, - }, - } -} - -func resourceArmSchedulerJobCollectionCreateUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobCollectionsClient - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - - name := d.Get("name").(string) - location := azure.NormalizeLocation(d.Get("location").(string)) - resourceGroup := d.Get("resource_group_name").(string) - t := d.Get("tags").(map[string]interface{}) - - log.Printf("[DEBUG] Creating/updating Scheduler Job Collection %q (resource group %q)", name, resourceGroup) - - if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := client.Get(ctx, resourceGroup, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - } - - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_scheduler_job_collection", *existing.ID) - } - } - - collection := scheduler.JobCollectionDefinition{ - Location: utils.String(location), - Tags: tags.Expand(t), - Properties: &scheduler.JobCollectionProperties{ - Sku: &scheduler.Sku{ - Name: scheduler.SkuDefinition(d.Get("sku").(string)), - }, - }, - } - - if state, ok := d.Get("state").(string); ok { - collection.Properties.State = scheduler.JobCollectionState(state) - } - collection.Properties.Quota = expandAzureArmSchedulerJobCollectionQuota(d) - - //create job collection - collection, err := client.CreateOrUpdate(ctx, resourceGroup, name, collection) - if err != nil { - return fmt.Errorf("Error creating/updating Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - //ensure collection actually exists and we have the correct ID - collection, err = client.Get(ctx, resourceGroup, name) - if err != nil { - return fmt.Errorf("Error reading Scheduler Job Collection %q after create/update (Resource Group %q): %+v", name, resourceGroup, err) - } - - d.SetId(*collection.ID) - - return resourceArmSchedulerJobCollectionRead(d, meta) -} - -func resourceArmSchedulerJobCollectionRead(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobCollectionsClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - - name := id.Path["jobCollections"] - resourceGroup := id.ResourceGroup - - log.Printf("[DEBUG] Reading Scheduler Job Collection %q (resource group %q)", name, resourceGroup) - - collection, err := client.Get(ctx, resourceGroup, name) - if err != nil { - if utils.ResponseWasNotFound(collection.Response) { - d.SetId("") - return nil - } - - return fmt.Errorf("Error making Read request on Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - - //standard properties - d.Set("name", collection.Name) - d.Set("resource_group_name", resourceGroup) - if location := collection.Location; location != nil { - d.Set("location", azure.NormalizeLocation(*location)) - } - - //resource specific - if properties := collection.Properties; properties != nil { - if sku := properties.Sku; sku != nil { - d.Set("sku", sku.Name) - } - d.Set("state", string(properties.State)) - - if err := d.Set("quota", flattenAzureArmSchedulerJobCollectionQuota(properties.Quota)); err != nil { - return fmt.Errorf("Error setting quota for Job Collection %q (Resource Group %q): %+v", *collection.Name, resourceGroup, err) - } - } - - return tags.FlattenAndSet(d, collection.Tags) -} - -func resourceArmSchedulerJobCollectionDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client).Scheduler.JobCollectionsClient - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - - name := id.Path["jobCollections"] - resourceGroup := id.ResourceGroup - - log.Printf("[DEBUG] Deleting Scheduler Job Collection %q (resource group %q)", name, resourceGroup) - - future, err := client.Delete(ctx, resourceGroup, name) - if err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error issuing delete request for Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - } - - if err = future.WaitForCompletionRef(ctx, client.Client); err != nil { - if !response.WasNotFound(future.Response()) { - return fmt.Errorf("Error waiting for deletion of Scheduler Job Collection %q (Resource Group %q): %+v", name, resourceGroup, err) - } - } - - return nil -} - -func expandAzureArmSchedulerJobCollectionQuota(d *schema.ResourceData) *scheduler.JobCollectionQuota { - if qb, ok := d.Get("quota").([]interface{}); ok && len(qb) > 0 { - quota := scheduler.JobCollectionQuota{ - MaxRecurrence: &scheduler.JobMaxRecurrence{}, - } - - quotaBlock := qb[0].(map[string]interface{}) - - if v, ok := quotaBlock["max_job_count"].(int); ok { - quota.MaxJobCount = utils.Int32(int32(v)) - } - if v, ok := quotaBlock["max_recurrence_frequency"].(string); ok { - quota.MaxRecurrence.Frequency = scheduler.RecurrenceFrequency(v) - } - if v, ok := quotaBlock["max_recurrence_interval"].(int); ok && v > 0 { - quota.MaxRecurrence.Interval = utils.Int32(int32(v)) - } else if v, ok := quotaBlock["max_retry_interval"].(int); ok && v > 0 { // todo remove once max_retry_interval is removed - quota.MaxRecurrence.Interval = utils.Int32(int32(v)) - } - - return "a - } - - return nil -} - -func flattenAzureArmSchedulerJobCollectionQuota(quota *scheduler.JobCollectionQuota) []interface{} { - if quota == nil { - return nil - } - - quotaBlock := make(map[string]interface{}) - - if v := quota.MaxJobCount; v != nil { - quotaBlock["max_job_count"] = *v - } - if recurrence := quota.MaxRecurrence; recurrence != nil { - if v := recurrence.Interval; v != nil { - quotaBlock["max_recurrence_interval"] = *v - quotaBlock["max_retry_interval"] = *v // todo remove once max_retry_interval is retired - } - - quotaBlock["max_recurrence_frequency"] = string(recurrence.Frequency) - } - - return []interface{}{quotaBlock} -} diff --git a/azurerm/internal/services/scheduler/tests/data_source_scheduler_job_collection_test.go b/azurerm/internal/services/scheduler/tests/data_source_scheduler_job_collection_test.go deleted file mode 100644 index 94a8f07bf2ac..000000000000 --- a/azurerm/internal/services/scheduler/tests/data_source_scheduler_job_collection_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package tests - -import ( - "fmt" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" -) - -func TestAccDataSourceAzureRMSchedulerJobCollection_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_scheduler_job_collection", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceSchedulerJobCollection_basic(data), - Check: checkAccAzureRMSchedulerJobCollection_basic(data.ResourceName), - }, - }, - }) -} - -func TestAccDataSourceAzureRMSchedulerJobCollection_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "data.azurerm_scheduler_job_collection", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - Steps: []resource.TestStep{ - { - Config: testAccDataSourceSchedulerJobCollection_complete(data), - Check: checkAccAzureRMSchedulerJobCollection_complete(data.ResourceName), - }, - }, - }) -} - -func testAccDataSourceSchedulerJobCollection_basic(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJobCollection_basic(data, "") - return fmt.Sprintf(` -%s - -data "azurerm_scheduler_job_collection" "test" { - name = "${azurerm_scheduler_job_collection.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" -} -`, template) -} - -func testAccDataSourceSchedulerJobCollection_complete(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJobCollection_complete(data) - return fmt.Sprintf(` -%s - -data "azurerm_scheduler_job_collection" "test" { - name = "${azurerm_scheduler_job_collection.test.name}" - resource_group_name = "${azurerm_resource_group.test.name}" -} -`, template) -} diff --git a/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_collection_test.go b/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_collection_test.go deleted file mode 100644 index 6ae8f522ee4f..000000000000 --- a/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_collection_test.go +++ /dev/null @@ -1,207 +0,0 @@ -// nolint: megacheck -// entire automation SDK has been depreciated in v21.3 in favor of logic apps, an entirely different service. -package tests - -import ( - "fmt" - "testing" - - "github.com/Azure/azure-sdk-for-go/services/scheduler/mgmt/2016-03-01/scheduler" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func TestAccAzureRMSchedulerJobCollection_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job_collection", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJobCollection_basic(data, ""), - Check: checkAccAzureRMSchedulerJobCollection_basic(data.ResourceName), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJobCollection_requiresImport(t *testing.T) { - if !features.ShouldResourcesBeImported() { - t.Skip("Skipping since resources aren't required to be imported") - return - } - - data := acceptance.BuildTestData(t, "azurerm_scheduler_job_collection", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJobCollection_basic(data, ""), - Check: checkAccAzureRMSchedulerJobCollection_basic(data.ResourceName), - }, - data.RequiresImportErrorStep(func(data acceptance.TestData) string { - return testAccAzureRMSchedulerJobCollection_requiresImport(data, "") - }), - }, - }) -} - -func TestAccAzureRMSchedulerJobCollection_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job_collection", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobCollectionDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJobCollection_basic(data, ""), - Check: checkAccAzureRMSchedulerJobCollection_basic(data.ResourceName), - }, - { - Config: testAccAzureRMSchedulerJobCollection_complete(data), - Check: checkAccAzureRMSchedulerJobCollection_complete(data.ResourceName), - }, - data.ImportStep(), - }, - }) -} - -func testCheckAzureRMSchedulerJobCollectionDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Scheduler.JobCollectionsClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_scheduler_job_collection" { - continue - } - - name := rs.Primary.Attributes["name"] - resourceGroup := rs.Primary.Attributes["resource_group_name"] - - resp, err := client.Get(ctx, resourceGroup, name) - - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return nil - } - - return err - } - - return fmt.Errorf("Scheduler Job Collection still exists:\n%#v", resp) - } - - return nil -} - -func testCheckAzureRMSchedulerJobCollectionExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Scheduler.JobCollectionsClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("Not found: %q", resourceName) - } - - 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 Scheduler Job Collection: %q", name) - } - - resp, err := client.Get(ctx, resourceGroup, name) - - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Scheduler Job Collection %q (resource group: %q) was not found: %+v", name, resourceGroup, err) - } - - return fmt.Errorf("Bad: Get on schedulerJobCollectionsClient: %+v", err) - } - - return nil - } -} - -func testAccAzureRMSchedulerJobCollection_basic(data acceptance.TestData, additional string) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_scheduler_job_collection" "test" { - name = "acctest-%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" - %s -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, additional) -} - -func testAccAzureRMSchedulerJobCollection_requiresImport(data acceptance.TestData, additional string) string { - template := testAccAzureRMSchedulerJobCollection_basic(data, additional) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job_collection" "import" { - name = "${azurerm_scheduler_job_collection.test.name}" - location = "${azurerm_scheduler_job_collection.test.location}" - resource_group_name = "${azurerm_scheduler_job_collection.test.resource_group_name}" - sku = "${azurerm_scheduler_job_collection.test.sku}" - - %s -} -`, template, additional) -} - -func testAccAzureRMSchedulerJobCollection_complete(data acceptance.TestData) string { - return testAccAzureRMSchedulerJobCollection_basic(data, ` - state = "disabled" - quota { - max_recurrence_frequency = "Hour" - max_recurrence_interval = 10 - max_job_count = 10 - } -`) -} - -func checkAccAzureRMSchedulerJobCollection_basic(resourceName string) resource.TestCheckFunc { - return resource.ComposeTestCheckFunc( - testCheckAzureRMSchedulerJobCollectionExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "name"), - resource.TestCheckResourceAttrSet(resourceName, "location"), - resource.TestCheckResourceAttrSet(resourceName, "resource_group_name"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttr(resourceName, "state", string(scheduler.Enabled)), - ) -} - -func checkAccAzureRMSchedulerJobCollection_complete(resourceName string) resource.TestCheckFunc { - return resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobCollectionExists(resourceName), - resource.TestCheckResourceAttrSet(resourceName, "name"), - resource.TestCheckResourceAttrSet(resourceName, "location"), - resource.TestCheckResourceAttrSet(resourceName, "resource_group_name"), - resource.TestCheckResourceAttr(resourceName, "tags.%", "0"), - resource.TestCheckResourceAttr(resourceName, "state", string(scheduler.Disabled)), - resource.TestCheckResourceAttr(resourceName, "quota.0.max_job_count", "10"), - resource.TestCheckResourceAttr(resourceName, "quota.0.max_recurrence_interval", "10"), - resource.TestCheckResourceAttr(resourceName, "quota.0.max_recurrence_frequency", "hour"), - ) -} diff --git a/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_test.go b/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_test.go deleted file mode 100644 index 17891c2d8c95..000000000000 --- a/azurerm/internal/services/scheduler/tests/resource_arm_scheduler_job_test.go +++ /dev/null @@ -1,910 +0,0 @@ -// nolint: megacheck -// entire automation SDK has been depreciated in v21.3 in favor of logic apps, an entirely different service. -package tests - -import ( - "fmt" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func TestAccAzureRMSchedulerJob_web_basic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_basic(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "http://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_requiresImport(t *testing.T) { - if !features.ShouldResourcesBeImported() { - t.Skip("Skipping since resources aren't required to be imported") - return - } - - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_basic(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "http://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - ), - }, - data.RequiresImportErrorStep(testAccAzureRMSchedulerJob_web_requiresImport), - }, - }) -} - -func TestAccAzureRMSchedulerJob_storageQueue(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_storageQueue(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttrSet(data.ResourceName, "action_storage_queue.0.storage_account_name"), - resource.TestCheckResourceAttrSet(data.ResourceName, "action_storage_queue.0.storage_queue_name"), - resource.TestCheckResourceAttrSet(data.ResourceName, "action_storage_queue.0.sas_token"), - resource.TestCheckResourceAttr(data.ResourceName, "action_storage_queue.0.message", "storage message"), - ), - }, - data.ImportStep("action_storage_queue.0.sas_token"), - }, - }) -} - -func TestAccAzureRMSchedulerJob_storageQueue_errorAction(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_storageQueue_errorAction(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "http://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttrSet(data.ResourceName, "error_action_storage_queue.0.storage_account_name"), - resource.TestCheckResourceAttrSet(data.ResourceName, "error_action_storage_queue.0.storage_queue_name"), - resource.TestCheckResourceAttrSet(data.ResourceName, "error_action_storage_queue.0.sas_token"), - resource.TestCheckResourceAttr(data.ResourceName, "error_action_storage_queue.0.message", "storage message"), - ), - }, - data.ImportStep("error_action_storage_queue.0.sas_token"), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_put(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_put(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "http://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "put"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.body", "this is some text"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_authBasic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_authBasic(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.authentication_basic.0.username", "login"), - ), - }, - data.ImportStep("action_web.0.authentication_basic.0.password"), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_authCert(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_authCert(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.authentication_certificate.0.thumbprint", "42C107874FD0E4A9583292A2F1098E8FE4B2EDDA"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.authentication_certificate.0.subject_name", "CN=Terraform App Gateway, OU=Azure, O=Terraform Tests, S=Some-State, C=US"), - ), - }, - data.ImportStep("action_web.0.authentication_certificate.0.pfx", - "action_web.0.authentication_certificate.0.password"), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_authAd(t *testing.T) { - if os.Getenv(resource.TestEnvVar) == "" { - t.Skipf("Skipping since %q isn't set", resource.TestEnvVar) - return - } - - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - clientId := os.Getenv("ARM_CLIENT_ID") - tenantId := os.Getenv("ARM_TENANT_ID") - secret := os.Getenv("ARM_CLIENT_SECRET") - - env, err := acceptance.Environment() - if err != nil { - t.Fatalf("Error loading Environment: %+v", err) - return - } - - audience := env.ServiceManagementEndpoint - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_authAd(data, tenantId, clientId, secret, audience), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.authentication_active_directory.0.tenant_id", tenantId), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.authentication_active_directory.0.client_id", clientId), - resource.TestCheckResourceAttrSet(data.ResourceName, "action_web.0.authentication_active_directory.0.audience"), - ), - }, - data.ImportStep("action_web.0.authentication_active_directory.0.secret"), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_retry(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_retry(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "retry.0.interval", "00:05:00"), - resource.TestCheckResourceAttr(data.ResourceName, "retry.0.count", "10"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_recurring(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_recurring(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "minute"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.interval", "5"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "10"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_recurringDaily(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_recurringDaily(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "day"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "100"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.hours.#", "2"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.minutes.#", "4"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_recurringWeekly(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_recurringWeekly(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "week"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "100"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.week_days.#", "2"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_recurringMonthly(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_recurringMonthly(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "month"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "100"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.month_days.#", "4"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_recurringMonthlyOccurrences(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_recurringMonthlyOccurrences(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "month"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "100"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.#", "3"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.2181640481.day", "sunday"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.2181640481.occurrence", "1"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.2956940195.day", "sunday"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.2956940195.occurrence", "3"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.679325150.day", "sunday"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.monthly_occurrences.679325150.occurrence", "-1"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_errorAction(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_errorAction(data), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "get"), - resource.TestCheckResourceAttr(data.ResourceName, "error_action_web.0.url", "https://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "error_action_web.0.method", "get"), - ), - }, - data.ImportStep(), - }, - }) -} - -func TestAccAzureRMSchedulerJob_web_complete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_scheduler_job", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMSchedulerJobDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMSchedulerJob_web_complete(data, "2019-07-07T07:07:07-07:00"), - Check: resource.ComposeAggregateTestCheckFunc( - testCheckAzureRMSchedulerJobExists(data.ResourceName), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.url", "http://example.com"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.method", "put"), - resource.TestCheckResourceAttr(data.ResourceName, "action_web.0.body", "this is some text"), - resource.TestCheckResourceAttr(data.ResourceName, "retry.0.interval", "00:05:00"), - resource.TestCheckResourceAttr(data.ResourceName, "retry.0.count", "10"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.frequency", "month"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.count", "100"), - resource.TestCheckResourceAttr(data.ResourceName, "recurrence.0.month_days.#", "4"), - resource.TestCheckResourceAttr(data.ResourceName, "start_time", "2019-07-07T14:07:07Z"), - ), - }, - data.ImportStep(), - }, - }) -} - -func testCheckAzureRMSchedulerJobDestroy(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Scheduler.JobsClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_scheduler_job.test" { - continue - } - - name := rs.Primary.Attributes["name"] - resourceGroup := rs.Primary.Attributes["resource_group_name"] - jobCollection := rs.Primary.Attributes["job_collection_name"] - - resp, err := client.Get(ctx, resourceGroup, jobCollection, name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return nil - } - - return err - } - - return fmt.Errorf("Scheduler Job Collection still exists:\n%#v", resp) - } - - return nil -} - -func testCheckAzureRMSchedulerJobExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - client := acceptance.AzureProvider.Meta().(*clients.Client).Scheduler.JobsClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("Not found: %q", resourceName) - } - - name := rs.Primary.Attributes["name"] - resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] - jobCollection := rs.Primary.Attributes["job_collection_name"] - - if !hasResourceGroup { - return fmt.Errorf("Bad: no resource group found in state for Scheduler Job: %q", name) - } - - resp, err := client.Get(ctx, resourceGroup, jobCollection, name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - return fmt.Errorf("Scheduler Job %q (resource group: %q) was not found: %+v", name, resourceGroup, err) - } - - return fmt.Errorf("Bad: Get on schedulerJobsClient: %+v", err) - } - - return nil - } -} - -func testAccAzureRMSchedulerJob_template(data acceptance.TestData) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_scheduler_job_collection" "test" { - name = "acctest-%d-job_collection" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - sku = "Standard" -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_basic(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - //need a valid URL here otherwise on a slow connection job might fault before the test check - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "http://example.com" - method = "get" - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_requiresImport(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_web_basic(data) - //need a valid URL here otherwise on a slow connection job might fault before the test check - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "import" { - name = "${azurerm_scheduler_job.test.name}" - resource_group_name = "${azurerm_scheduler_job.test.resource_group_name}" - job_collection_name = "${azurerm_scheduler_job.test.job_collection_name}" - - action_web { - url = "http://example.com" - method = "get" - } -} -`, template) -} - -func testAccAzureRMSchedulerJob_web_put(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "http://example.com" - method = "put" - body = "this is some text" - - headers = { - "Content-Type" = "text" - } - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_authBasic(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - - authentication_basic { - username = "login" - password = "apassword" - } - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_authCert(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(`%s -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - - authentication_certificate { - pfx = "${filebase64("testdata/application_gateway_test.pfx")}" - password = "terraform" - } - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_authAd(data acceptance.TestData, tenantId, clientId, secret, audience string) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(`%s -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - - authentication_active_directory { - tenant_id = "%s" - client_id = "%s" - secret = "%s" - audience = "%s" - } - } -} -`, template, data.RandomInteger, tenantId, clientId, secret, audience) -} - -func testAccAzureRMSchedulerJob_web_retry(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - retry { - interval = "00:05:00" //5 min - count = 10 - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_recurring(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - recurrence { - frequency = "minute" - interval = 5 - count = 10 - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_recurringDaily(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - recurrence { - frequency = "day" - count = 100 - hours = [0, 12] - minutes = [0, 15, 30, 45] - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_recurringWeekly(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - recurrence { - frequency = "week" - count = 100 - week_days = ["Sunday", "Saturday"] - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_recurringMonthly(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - recurrence { - frequency = "month" - count = 100 - month_days = [-11, -1, 1, 11] - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_recurringMonthlyOccurrences(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(`%s -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - recurrence { - frequency = "month" - count = 100 - - monthly_occurrences { - day = "sunday" - occurrence = 1 - } - - monthly_occurrences { - day = "sunday" - occurrence = 3 - } - - monthly_occurrences { - day = "sunday" - occurrence = -1 - } - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_errorAction(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(` -%s - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "https://example.com" - method = "get" - } - - error_action_web { - url = "https://example.com" - method = "get" - } -} -`, template, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_web_complete(data acceptance.TestData, time string) string { - template := testAccAzureRMSchedulerJob_template(data) - return fmt.Sprintf(`%s -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "http://example.com" - method = "put" - body = "this is some text" - - headers = { - "Content-Type" = "text" - } - } - - retry { - interval = "00:05:00" //5 min - count = 10 - } - - recurrence { - frequency = "month" - count = 100 - month_days = [-11, -1, 1, 11] - } - - start_time = "%s" -} -`, template, data.RandomInteger, time) -} - -func testAccAzureRMSchedulerJob_storageQueue(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - //need a valid URL here otherwise on a slow connection job might fault before the test check - return fmt.Sprintf(`%[1]s -resource "azurerm_storage_account" "test" { - name = "acctest%[2]s" - resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" - account_tier = "Standard" - account_replication_type = "LRS" -} - -resource "azurerm_storage_queue" "test" { - name = "acctest-%[3]d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - storage_account_name = "${azurerm_storage_account.test.name}" -} - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%[3]d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_storage_queue { - storage_account_name = "${azurerm_storage_account.test.name}" - storage_queue_name = "${azurerm_storage_queue.test.name}" - sas_token = "${azurerm_storage_account.test.primary_access_key}" - message = "storage message" - } -} -`, template, data.RandomString, data.RandomInteger) -} - -func testAccAzureRMSchedulerJob_storageQueue_errorAction(data acceptance.TestData) string { - template := testAccAzureRMSchedulerJob_template(data) - //need a valid URL here otherwise on a slow connection job might fault before the test check - return fmt.Sprintf(` -%s - -resource "azurerm_storage_account" "test" { - name = "acctest%s" - resource_group_name = "${azurerm_resource_group.test.name}" - location = "${azurerm_resource_group.test.location}" - account_tier = "Standard" - account_replication_type = "LRS" -} - -resource "azurerm_storage_queue" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - storage_account_name = "${azurerm_storage_account.test.name}" -} - -resource "azurerm_scheduler_job" "test" { - name = "acctest-%d-job" - resource_group_name = "${azurerm_resource_group.test.name}" - job_collection_name = "${azurerm_scheduler_job_collection.test.name}" - - action_web { - url = "http://example.com" - method = "get" - } - - error_action_storage_queue { - storage_account_name = "${azurerm_storage_account.test.name}" - storage_queue_name = "${azurerm_storage_queue.test.name}" - sas_token = "${azurerm_storage_account.test.primary_access_key}" - message = "storage message" - } -} -`, template, data.RandomString, data.RandomInteger, data.RandomInteger) -} diff --git a/azurerm/internal/services/scheduler/tests/testdata/application_gateway_test.pfx b/azurerm/internal/services/scheduler/tests/testdata/application_gateway_test.pfx deleted file mode 100644 index 691fa08577cf8afdfc91a241bc623883f5b132fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4213 zcmY+GWl$81w}*G>rQxN!muATYN$Ji7B%~z-L0Ca)Sdea|m+p{Ix}{<122mPhX%K0- zzBBjU|Ggj1oSEl0=X`yB5Co|w1`rd1Acf+9cq7y!u84rRzEwuo4BMl%Eh0}l{_z`>jBvG1qU z?e?(Y*J2~LXFI74Kl_=zjvHoU=s72yM6IC zbCe)wQyC&AlRGx`&)vc}W@t7aVTn1@wpWx6e^eWz-ZQP=)~cxWdwWV6ZdcK3#on2e z7_~4W#EY;lM+&E?V>{go5oqHiKZZ%t^=dDPPPsQe!=DetF28s}Wxhu@)mDjv*vr0R zN+9oAfO+YkBi3Ol`8#z!xl?Yy{VfGKY$~kkJbBWHvPG|Fm7N^CaOk6 z!<|8)d#H9{%OFo@tsDl};)E*d=~ZkG>ZNN==+aXF!A4z6Z94c;TQ$Jv@?AMyiu+ZFn=4 zTUPI9{oF>q)|jr-PUu#@zuuLGQ^}_~aLavep3mwW{Lqs&>*>Ahhc0#hvbK2S19GPI`xBU!}7buz1EEM^q zl`$){pIGShBy!w^hwwwev;}Te$x#6O{R_sZu<8y_YQwe0Ik~K6UBMP^xTyN2kDTVd zD3hYzkt*mm1BP!|bt9GzXz|JXczT&Rsi!Ngvs`E0GneVwZcIt_UB@7}>Xv3|TbGaG~ zqcv^i_JgI&iNy~eqbG4dZVq`>vjt>sTA5Jvd^9J~U0I_D23}Cc$bz+c|axa7e0n3}8o}50Vnqpkn%teQ;_RaX-%-SCc?Q^$8hK<% zzjc~@lh|9OYo0Q^#MT5@isFcgOg-xPUSL|>6xL%cL2(`bQ~87#Hs=Rj%fFj&<~#U! z7QoY7xswx^L6Lq+5DW@BvrGI#uq@Nh@0#~9DrPQ10!O+)Z0Y-4#JxS0|FzVUukbM% z=;jZbe~#qszgS(I){@1^OZ0QdW4{Cgbnc0{=B9Itl{RFU@NJJ_*sC<6jXYbzw)|{I zfSc9UHbJ~IaEAjkFnnxXa`M6`>VhLPA&Q8n&qBSiSFEGpWd8^-f3q6G$xavAU<+mX zme(4oib-u}h5B0bKI-~sWu%iu*L`QdWQyd8$mq6tPzpPGZJSL9tz!{_LMawJibUiC49YZ+v*sN04@$O|N%5+sa=IkY-;43GHHSLbvL3-j3bCI4 z9e>(z7RcXE_fvi{-lkr#sn0O;qrr&wAL6IAvP9)5ZJOCz8|iq!S$}7t3PWHw6!my8 zZcM06O3P(Zsj);V$pfG1FBeER#&K~*^^R%W!Qdc4pv%iWD}&vYsyio$%1m5nzRvBB zQd{@I%c^VmQ4LfZO6@04W%#vx%J5IEAP%1{*8mKYvp@K)V$5{~;jJOvKm_06yQ-x1 zmS#{mcbKf{OhYrMNEQ;rBK@*KU_VYSAjGcPI->}J0FC?~apWUFZCD6U(_j4g@6_NB z{EtTPff#>7pTE%S|JeoeU%Rj^nwWZ>;#>V|m%r!wLw}re%UJN31WGJO!=|6F30;Ru zZ$HAq?~=IJ03D=I_GE5gT)Ei??aI|}8$1g@`0#KxKv3$4wQXS_; z!SCoJytrRs)G)U+*ye(Q^rf_X7kdi=DROMyS-sL%6vpWA{W+i9FNyDfP`%^M318xn zz1WS_kvi9ZV%6d++nQy`nHgOx_XbS;JO^q-B~AmRusH?%u}rs!q~LAZ%BB1pdcA53 zZHL9vMqjOm6L&vXmU6V7W7WcdYKFDr&BzZ%iLS;G%eQ27(%@$nx#op73-s65saMegfD;i}r$?SEHKXfDVzV>$W zSa#p(fdpV|?Sht_zE!ET)A^=w!JnuhjD%QNxwp%wS7o#U4(FEF3^$vUo>#P#Gy25F ziCttJafzK8X;PPji)H;4Ui*+fg*4q{fm@}iFeT&ka%0(S&1RPh?54Hhq??=s@@ZG~ z;kbWfu9%J(q9M>q_4tVtSkjvu*nS0ceQwzFqm~aNVi8(fw3OO@gm(H>Ii&Qkkg9pu zg@oOey2u+4nWH8(q){WJ&k+)YQvIlvw!QyV9W-4$h*!y?JD` zKQI*uK?#REqf47@A=DQ)sF>BtH&Ky=Qgm9lme}o{JgYk~d9Av=e;f!l@tG}WI)p4x zP+QisKLTdHEO~oG7ble}uhTSI2rNznV@Zt19aUhlgG=frT$gx<@;_8vy}7dg@i}x; z-5L++PozLX=MsNS`12OV0j{v_txep#r_@LmYoy3ZNLF3J-;~#42bkFEraHmCXQwT$ z1TM%3-nSX7d88Q)ivA7#nD4rjK))MqDY-=Ir8wNG*LO2sn`zm$7Pwc4^`<>1{zi2Q z(n7yvaV!UCnIhRL`F8VNUNfy(=*oiL_D8^UFD=6 zi^fMwKQdXJ9~l4SV{8roK}dzn3cV8!(E8-5zUG_p4v8S9cRDce32Z2p=SnR&CAD=vU0t%j3lf1-NQPhu-@LsREm=szBzwkR)=z!Qogt- zJdw~Hm|fj=w^5Eo4kkCxhXpC33~#5HqJq%PoQjORJHA2MvZXt412!j4siDAj;N0|WpprTO0q6up6%ugZj;RiEQX|W zk@l$m{%8lph#lNW6_$zGrEBq@TO*-Rv0XUHO}Z;`W}>_NBIze+kNjoQbU*Cxz|+gh zg~P)kY$!fdonxnVrN121dnFZa8YE%uvmflLNhLTPq$m3hhR&M`n^#nZ1x&u+a(Goo zwjLp}Bz4{DlBZ!Q+5EE`@;hHNtRO)Jxi$ZgG%`TaHjR_3ZGc-kd$fdxj=PfQAd@4q z_9K8bJ>R3d5F=j1SSgR}oq_qO_ExL=JMPwHhf{D?_vaOh2J{A3(-^&kGH=S@&o{)Q z~B3q3ug8yzGPx0s!E9Ywbg5i51r?QP(dt4L{6TCv7 z7kQ+$!c2Hd)z@}NFPE(ypn_wwj1=E^`e3{`L8%gUb#FJ1e&?1fPTN7XLEi^c_k?f8 ze@I5RZvXrwIoWxu#*dMf%A&4%hmLz~a+}0mViePiU3WAFe9{~c`~shEVrbi+*f|>6 zxLrQh!c(wu4A(PlL+B{hASkm)-v6fZr4c;7!P)nZv@?(Yi zAZ8vm;#u-=pxzTeC9ERP=SX+q@ z)fHrMb`*08=Iv(?-h5EW0@UiDKf*Eb9jRcSQIMg5vR^PD$8WUx7$Ad<<>^UqOV-PX zeRO#^=>_u?5#<%9$d%O<WsM15pZ7VNoc4#f{XP+OBvel2UjEN=V%P ze6#`)hOk0FIM{r|m>6`}04$0}f@fZN@u;gi)PP0@-*(&Pazurerm_route_table -
  • - azurerm_scheduler_job_collection -
  • -
  • azurerm_servicebus_namespace
  • @@ -2099,19 +2095,6 @@ -
  • - Scheduler Resources - -
  • -
  • Search Resources