Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Requiring existing resources to be imported / support for timeouts #1746

Closed
wants to merge 154 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
e285ef1
Adding wrappers for obtaining the Create/Update timeout / an import e…
tombuildsstuff Aug 9, 2018
6ff5ae9
App Service: support for both Timeouts and requiring Import before Up…
tombuildsstuff Aug 9, 2018
3f35429
App Gateway: requiring import/timeouts
tombuildsstuff Aug 9, 2018
7d1aa07
AppInsights: requiring import/timeouts
tombuildsstuff Aug 9, 2018
fa39509
Application Security Group: requiring import / timeouts
tombuildsstuff Aug 9, 2018
97971f2
Automation: requiring import / timeouts
tombuildsstuff Aug 9, 2018
a45272b
Auto Scale: requiring import / timeouts
tombuildsstuff Aug 9, 2018
4740f88
Availability Set: requiring import / timeouts
tombuildsstuff Aug 9, 2018
a92a15b
timeouts & import check for service bus resources
katbyte Aug 10, 2018
27388f4
AzureAD: requiring import/timeouts
tombuildsstuff Aug 10, 2018
1c6f1de
CDN: requiring import/timeouts
tombuildsstuff Aug 10, 2018
fa0acd0
Container Group: requiring import / timeouts
tombuildsstuff Aug 10, 2018
fa3a680
Container Service: requiring import / timeouts
tombuildsstuff Aug 10, 2018
b9c384a
Container Service: removing crash points
tombuildsstuff Aug 10, 2018
73c0472
Container Registry: import support / timeouts
tombuildsstuff Aug 13, 2018
48e8e7e
Container Service: fixing crashes/adding import support
tombuildsstuff Aug 13, 2018
6a8425e
Container Service: documenting the import support
tombuildsstuff Aug 13, 2018
68fdec4
CosmosDB: requiring import/timeouts
tombuildsstuff Aug 14, 2018
c0a3260
Data Lake Analytics: requiring import/timeouts
tombuildsstuff Aug 14, 2018
9f704fa
Data Lake Analytics firewall rule: requiring imports/timeouts
tombuildsstuff Aug 14, 2018
a7ff715
Fixing a broken reference
tombuildsstuff Aug 14, 2018
4d3bb27
Data Lake Store Account: requiring import/timeouts
tombuildsstuff Aug 14, 2018
d796baf
Data Lake Store File: support for timeouts
tombuildsstuff Aug 14, 2018
b17d4f0
Data Lake Store Firewall Rule: requiring import/timeouts
tombuildsstuff Aug 14, 2018
ce9df43
DNS A Record: requiring import/timeouts
tombuildsstuff Aug 14, 2018
2b60fd6
DNS AAAA: requiring import/timeouts
tombuildsstuff Aug 14, 2018
9247947
DNS CAA: requiring import/timeouts
tombuildsstuff Aug 14, 2018
096351b
DNS CNAME: requiring import/timeouts
tombuildsstuff Aug 14, 2018
09e1827
DNS MX: requiring import/timeouts
tombuildsstuff Aug 14, 2018
664db0c
DNS NS: requiring import/timeouts
tombuildsstuff Aug 14, 2018
994856e
DNS PTR: requiring import/timeouts
tombuildsstuff Aug 14, 2018
0f62f0e
DNS SRV: requiring import/timeouts
tombuildsstuff Aug 14, 2018
c6b39db
DNS TXT: requiring import/timeouts
tombuildsstuff Aug 14, 2018
eb98139
DNS Zone: requiring imports/timeouts
tombuildsstuff Aug 14, 2018
5f37d06
EventGrid: requiring import/timeouts
tombuildsstuff Aug 15, 2018
e257e6b
EventHub: requiring imports/supporting timeouts
tombuildsstuff Aug 15, 2018
1e06218
EventHub Auth Rule: requiring imports/timeouts
tombuildsstuff Aug 15, 2018
bc11ebb
EventHub Consumer Group: require import/timeouts
tombuildsstuff Aug 15, 2018
c3004c9
EventHub Namespace: requiring import/timeous
tombuildsstuff Aug 15, 2018
db4b4ba
App Service Active Slot: timeouts
tombuildsstuff Aug 16, 2018
131b171
Refactorign the tests for Automation Scheduler to match the others
tombuildsstuff Aug 16, 2018
88701d8
Refactoring the CosmosDB Account tests to match the rest of the codebase
tombuildsstuff Aug 16, 2018
01169de
Adding acceptance tests for the import requirement
tombuildsstuff Aug 16, 2018
2b16417
EventHub: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
8f131e7
ExpressRoute: refactoring to match the other resources
tombuildsstuff Aug 17, 2018
5e7c0fc
ExpressRoute: requiring import/timeouts
tombuildsstuff Aug 17, 2018
85c1f78
ERC Auth: requiring import/timeouts
tombuildsstuff Aug 17, 2018
357fe08
ERC Peerings: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
f58fdb0
Function Apps: requiring import/timeouts
tombuildsstuff Aug 17, 2018
31c780e
Image: requiring import/timeouts
tombuildsstuff Aug 17, 2018
1854f08
IoTHub: requiring import/timeouts
tombuildsstuff Aug 17, 2018
4d11678
Key Vault: requiring import/timeouts
tombuildsstuff Aug 17, 2018
224e6c3
Key Vault Access Policy: requiring import
tombuildsstuff Aug 17, 2018
233292d
Key Vault Cert: requiring import/timeout
tombuildsstuff Aug 17, 2018
6aea64b
Key Vault Key: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
9c0f969
Key Vault Secret: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
579f02f
Kubernetes Cluster: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
b8f30e1
Local Network Gateway: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
d1c50cc
Log Analytics Solution: requiring import/timeouts
tombuildsstuff Aug 17, 2018
069423b
Log Analytics Workspace: requires import / timeouts
tombuildsstuff Aug 17, 2018
fc41505
Managed Disks: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
36df821
Management Lock: requiring import/timeouts
tombuildsstuff Aug 17, 2018
0ce9eca
Metric Alert Rule: requiring imports/timeouts
tombuildsstuff Aug 17, 2018
58b4b6e
Monitor Action Group: requires import/timeouts
tombuildsstuff Aug 17, 2018
8072974
MySQL Config: timeouts
tombuildsstuff Aug 17, 2018
ddc5dbb
MySql Database: requiring import/timeouts
tombuildsstuff Aug 17, 2018
d3b0f29
MySql Firewall Rule: requiring import/timeouts
tombuildsstuff Aug 17, 2018
f4e50a5
MySQL Server: requiring import/timeouts
tombuildsstuff Aug 17, 2018
90430db
Network Interface: requiring import/timeouts
tombuildsstuff Aug 17, 2018
01d8560
Network Security Group: requiring import/timeouts
tombuildsstuff Aug 17, 2018
f698647
Network Security Rule: requiring import/timeouts
tombuildsstuff Aug 17, 2018
cd3be06
Network Watcher: requiring import/timeouts
tombuildsstuff Aug 17, 2018
fb4a413
Notification Hub: requiring import/timeouts
tombuildsstuff Aug 17, 2018
5f4c5a5
Notification Hub Auth Rule: requiring import/timeouts
tombuildsstuff Aug 17, 2018
bbbd6e5
Notification Hub Namespace: requiring import/timeouts
tombuildsstuff Aug 17, 2018
051485d
Packet Capture: requiring import/timeouts
tombuildsstuff Aug 17, 2018
a8f640b
Policy Assignment: requiring import / timeouts
tombuildsstuff Aug 17, 2018
0786560
Policy Definition: requiring import/timeouts
tombuildsstuff Aug 17, 2018
c41f494
Postgres Config: timeouts
tombuildsstuff Aug 17, 2018
98abadc
PostgreSQL Database: requiring import/timeouts
tombuildsstuff Aug 17, 2018
27d0a26
PostgreSQL Firewall Rule: requiring import/timeouts
tombuildsstuff Aug 17, 2018
0519ffe
PostgreSQL Server: requiring import/timeouts
tombuildsstuff Aug 17, 2018
41bfb2e
Public IP: requiring import/timeouts
tombuildsstuff Aug 17, 2018
03ddb93
Recovery Services Vault: requiring import/timeouts
tombuildsstuff Aug 17, 2018
e81c391
Redis Cache: requiring import/timeouts
tombuildsstuff Aug 17, 2018
c9c98cc
Redis Firewall Rule: requiring import/timeouts
tombuildsstuff Aug 17, 2018
8343571
Relay Namespace: requiring import/timeouts
tombuildsstuff Aug 17, 2018
3c6cae3
Role Assignment: requiring import/timeouts
tombuildsstuff Aug 17, 2018
e261b5e
Role Definition: requiring import/timeouts
tombuildsstuff Aug 17, 2018
22abe24
Fixing broken requiresImport tests
tombuildsstuff Aug 18, 2018
a99514f
Fixing the broken test
tombuildsstuff Aug 20, 2018
a8f06cb
Logic Apps: requiring import/timeouts
tombuildsstuff Aug 20, 2018
13fac6c
Route: requiring import/timeouts
tombuildsstuff Aug 20, 2018
56cde66
Route Table: requiring import/timeouts
tombuildsstuff Aug 20, 2018
8c82f5e
Scheduler Job: requires import/timeouts
tombuildsstuff Aug 20, 2018
ec8ab15
Scheduler Job Collection: requiring import/timeouts
tombuildsstuff Aug 20, 2018
c1cd767
Search: requiring import/timeouts
tombuildsstuff Aug 20, 2018
d2d58e7
Service Fabric: requiring import/timeouts
tombuildsstuff Aug 20, 2018
aff6520
ServiceBus Namespace: tests
tombuildsstuff Aug 20, 2018
a764045
ServiceBus Namespace Auth Rules: tests
tombuildsstuff Aug 20, 2018
c5d26cc
ServiceBus Queue: tests
tombuildsstuff Aug 20, 2018
e436f9f
ServiceBus Queue Auth Rules: requiring import/timeouts
tombuildsstuff Aug 20, 2018
2d6fb59
Making the error messages consistent
tombuildsstuff Aug 20, 2018
2646c46
ServiceBus Subscription: tests
tombuildsstuff Aug 20, 2018
b0e0085
ServiceBus Subscription: refactoring the tests to be readable
tombuildsstuff Aug 20, 2018
a52ddee
ServiceBus Subscription Rule: refactoring
tombuildsstuff Aug 20, 2018
b4ab12e
ServiceBus Subscription Rule: tests
tombuildsstuff Aug 20, 2018
a005de7
ServiceBus Topic: tests
tombuildsstuff Aug 20, 2018
cdeada1
Topic Auth Rule: tests
tombuildsstuff Aug 20, 2018
8dcc773
Snapshot: requiring import/timeouts
tombuildsstuff Aug 20, 2018
ab25da5
Subnet: requiring import/timeout
tombuildsstuff Aug 20, 2018
78fb17d
User Assigned Identity: requiring import/timeouts
tombuildsstuff Aug 20, 2018
d9daae7
Fixing the build
tombuildsstuff Aug 20, 2018
a144d55
Traffic Manager Endpoints: requiring import/timeouts
tombuildsstuff Aug 20, 2018
7c4aefd
Traffic Manager Profile: requiring import/timeouts
tombuildsstuff Aug 20, 2018
91c106a
Virtual Network Gateway: requiring import/timeouts
tombuildsstuff Aug 20, 2018
8d24c26
Virtual Network Gateway Connection: requiring import/timeouts
tombuildsstuff Aug 21, 2018
500855f
Virtual Network Peering: requiring import/timeouts
tombuildsstuff Aug 21, 2018
d28c580
Fixing the build
tombuildsstuff Aug 21, 2018
16b7ea8
SQL Admin: requires import/timeouts
tombuildsstuff Aug 21, 2018
c19f4f2
SQL Database: requiring import/timeouts
tombuildsstuff Aug 21, 2018
c3ed2c9
SQL ElasticPool: requiring import/timeouts
tombuildsstuff Aug 21, 2018
1ba0f55
SQL Firewall Rules: requiring import/timeouts
tombuildsstuff Aug 21, 2018
9d6c96e
SQL Server: requiring import/timeouts
tombuildsstuff Aug 21, 2018
789b34a
SQL Virtual Network Rules: requiring import/timeouts
tombuildsstuff Aug 21, 2018
5cc0441
Load Balancer: requiring import/timeouts. Removing dead code
tombuildsstuff Aug 22, 2018
943eeff
LB Backend Address Pools: requiring import/timeouts
tombuildsstuff Aug 22, 2018
c058bd0
Load Balancer NAT Pool: requiring import/timeouts
tombuildsstuff Aug 22, 2018
0636306
Load Balancer Probe: requiring import/timeouts
tombuildsstuff Aug 22, 2018
6f5263e
Load Balancer NAT Rules: requiring import/timeouts
tombuildsstuff Aug 22, 2018
66c4630
Refactoring to a test helper
tombuildsstuff Aug 22, 2018
7360f73
Removing dead code
tombuildsstuff Aug 22, 2018
e436c7f
Load Balancer Rule: requiring import/timeouts
tombuildsstuff Aug 22, 2018
a17b156
Storage Account: requiring import/timeouts
tombuildsstuff Aug 22, 2018
1656391
Storage Blob: requires import/timeouts
tombuildsstuff Aug 23, 2018
0628f6c
Storage Container: requiring import/timeouts
tombuildsstuff Aug 23, 2018
619c5fa
Storage Queue: requiring import/timeouts
tombuildsstuff Aug 23, 2018
8225672
Storage Share: requiring import/timeouts
tombuildsstuff Aug 23, 2018
0322ee7
Storage Table: requiring import/timeouts
tombuildsstuff Aug 23, 2018
980d3f3
Fixing the build
tombuildsstuff Aug 23, 2018
46fc61e
Template Deployment: requiring import / timeouts
tombuildsstuff Aug 30, 2018
d0a15cb
Template Deployment: retrieving the template
tombuildsstuff Aug 31, 2018
bc33b78
Virtual Machine: requiring import/timeouts
tombuildsstuff Aug 31, 2018
1291fc3
VM Data Disk Attachment: requiring import/timeouts
tombuildsstuff Aug 31, 2018
1ae1577
Virtual Machine Extension: requiring import/timeouts
tombuildsstuff Aug 31, 2018
1d4394b
VM Scale Set: requiring import/timeouts
tombuildsstuff Aug 31, 2018
fd277d0
Virtual Network: requiring import/timeouts
tombuildsstuff Aug 31, 2018
ba84174
Resource Group: requiring import
tombuildsstuff Aug 31, 2018
a50d6e8
Removing the default timeout
tombuildsstuff Aug 31, 2018
af9f4de
Setting a default timeout for the tests
tombuildsstuff Sep 1, 2018
f7a2233
Data Lake Store File: requiring import
tombuildsstuff Sep 6, 2018
a1f17ef
PostgreSQL Virtual Network Rule: requiring import/timeouts
tombuildsstuff Sep 6, 2018
0b461b7
Management Group: requiring import/timeouts
tombuildsstuff Sep 6, 2018
00d1be8
Temp: sdk fixes proposed in https://github.com/Azure/go-autorest/pull…
tombuildsstuff Sep 11, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"net/http/httputil"
"os"
"sync"
"time"

appinsights "github.com/Azure/azure-sdk-for-go/services/appinsights/mgmt/2015-05-01/insights"
"github.com/Azure/azure-sdk-for-go/services/automation/mgmt/2015-10-31/automation"
Expand Down Expand Up @@ -264,7 +263,6 @@ func (c *ArmClient) configureClient(client *autorest.Client, auth autorest.Autho
client.Authorizer = auth
client.Sender = autorest.CreateSender(withRequestLogging())
client.SkipResourceProviderRegistration = c.skipProviderRegistration
client.PollingDuration = 60 * time.Minute
}

func withRequestLogging() autorest.SendDecorator {
Expand Down
6 changes: 4 additions & 2 deletions azurerm/data_source_scheduler_job_collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,25 @@ func TestAccDataSourceAzureRMSchedulerJobCollection_complete(t *testing.T) {
}

func testAccDataSourceSchedulerJobCollection_basic(rInt int, location string) string {
template := testAccAzureRMSchedulerJobCollection_basic(rInt, location)
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}"
}
`, testAccAzureRMSchedulerJobCollection_basic(rInt, location, ""))
`, template)
}

func testAccDataSourceSchedulerJobCollection_complete(rInt int, location string) string {
template := testAccAzureRMSchedulerJobCollection_complete(rInt, location)
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}"
}
`, testAccAzureRMSchedulerJobCollection_complete(rInt, location))
`, template)
}
40 changes: 0 additions & 40 deletions azurerm/express_route_circuit.go

This file was deleted.

8 changes: 8 additions & 0 deletions azurerm/helpers/tf/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package tf

import "fmt"

func ImportAsExistsError(resourceName, id string) error {
msg := "A resource with the ID %q already exists - to be managed via Terraform this resource needs to be imported into the State. Please see the resource documentation for %q for more information."
return fmt.Errorf(msg, id, resourceName)
}
11 changes: 11 additions & 0 deletions azurerm/helpers/tf/timeouts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package tf

import "github.com/hashicorp/terraform/helper/schema"

func TimeoutForCreateUpdate(d *schema.ResourceData) string {
if d.IsNewResource() {
return schema.TimeoutCreate
}

return schema.TimeoutUpdate
}
68 changes: 0 additions & 68 deletions azurerm/import_arm_app_service_hostname_binding_test.go

This file was deleted.

91 changes: 0 additions & 91 deletions azurerm/loadbalancer.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package azurerm

import (
"context"
"fmt"
"net/http"
"regexp"
"strings"

"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2018-04-01/network"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)

Expand Down Expand Up @@ -43,20 +41,6 @@ func retrieveLoadBalancerById(loadBalancerId string, meta interface{}) (*network
return &resp, true, nil
}

func findLoadBalancerBackEndAddressPoolByName(lb *network.LoadBalancer, name string) (*network.BackendAddressPool, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.BackendAddressPools == nil {
return nil, -1, false
}

for i, apc := range *lb.LoadBalancerPropertiesFormat.BackendAddressPools {
if apc.Name != nil && *apc.Name == name {
return &apc, i, true
}
}

return nil, -1, false
}

func findLoadBalancerFrontEndIpConfigurationByName(lb *network.LoadBalancer, name string) (*network.FrontendIPConfiguration, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.FrontendIPConfigurations == nil {
return nil, -1, false
Expand All @@ -71,81 +55,6 @@ func findLoadBalancerFrontEndIpConfigurationByName(lb *network.LoadBalancer, nam
return nil, -1, false
}

func findLoadBalancerRuleByName(lb *network.LoadBalancer, name string) (*network.LoadBalancingRule, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.LoadBalancingRules == nil {
return nil, -1, false
}

for i, lbr := range *lb.LoadBalancerPropertiesFormat.LoadBalancingRules {
if lbr.Name != nil && *lbr.Name == name {
return &lbr, i, true
}
}

return nil, -1, false
}

func findLoadBalancerNatRuleByName(lb *network.LoadBalancer, name string) (*network.InboundNatRule, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.InboundNatRules == nil {
return nil, -1, false
}

for i, nr := range *lb.LoadBalancerPropertiesFormat.InboundNatRules {
if nr.Name != nil && *nr.Name == name {
return &nr, i, true
}
}

return nil, -1, false
}

func findLoadBalancerNatPoolByName(lb *network.LoadBalancer, name string) (*network.InboundNatPool, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.InboundNatPools == nil {
return nil, -1, false
}

for i, np := range *lb.LoadBalancerPropertiesFormat.InboundNatPools {
if np.Name != nil && *np.Name == name {
return &np, i, true
}
}

return nil, -1, false
}

func findLoadBalancerProbeByName(lb *network.LoadBalancer, name string) (*network.Probe, int, bool) {
if lb == nil || lb.LoadBalancerPropertiesFormat == nil || lb.LoadBalancerPropertiesFormat.Probes == nil {
return nil, -1, false
}

for i, p := range *lb.LoadBalancerPropertiesFormat.Probes {
if p.Name != nil && *p.Name == name {
return &p, i, true
}
}

return nil, -1, false
}

func loadbalancerStateRefreshFunc(ctx context.Context, client network.LoadBalancersClient, resourceGroupName string, loadbalancer string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
res, err := client.Get(ctx, resourceGroupName, loadbalancer, "")
if err != nil {
return nil, "", fmt.Errorf("Error issuing read request in loadbalancerStateRefreshFunc to Azure ARM for Load Balancer '%s' (RG: '%s'): %s", loadbalancer, resourceGroupName, err)
}

return res, *res.LoadBalancerPropertiesFormat.ProvisioningState, nil
}
}

func validateLoadBalancerPrivateIpAddressAllocation(v interface{}, k string) (ws []string, errors []error) {
value := strings.ToLower(v.(string))
if value != "static" && value != "dynamic" {
errors = append(errors, fmt.Errorf("LoadBalancer Allocations can only be Static or Dynamic"))
}
return
}

// sets the loadbalancer_id in the ResourceData from the sub resources full id
func loadBalancerSubResourceStateImporter(d *schema.ResourceData, m interface{}) ([]*schema.ResourceData, error) {
r, err := regexp.Compile(`.+\/loadBalancers\/.+?\/`)
Expand Down
30 changes: 22 additions & 8 deletions azurerm/logic_apps.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
package azurerm

import (
"context"
"fmt"
"log"

"github.com/Azure/azure-sdk-for-go/services/logic/mgmt/2016-06-01/logic"
"github.com/hashicorp/terraform/helper/schema"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf"
"github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils"
)

// NOTE: this file is not a recommended way of developing Terraform resources; this exists to work around the fact that this API is dynamic (by it's nature)

func resourceLogicAppActionUpdate(d *schema.ResourceData, meta interface{}, logicAppId string, name string, vals map[string]interface{}) error {
return resourceLogicAppComponentUpdate(d, meta, "Action", "actions", logicAppId, name, vals)
func resourceLogicAppActionUpdate(d *schema.ResourceData, meta interface{}, logicAppId string, name string, vals map[string]interface{}, resourceName string) error {
return resourceLogicAppComponentUpdate(d, meta, "Action", "actions", logicAppId, name, vals, resourceName)
}

func resourceLogicAppTriggerUpdate(d *schema.ResourceData, meta interface{}, logicAppId string, name string, vals map[string]interface{}) error {
return resourceLogicAppComponentUpdate(d, meta, "Trigger", "triggers", logicAppId, name, vals)
func resourceLogicAppTriggerUpdate(d *schema.ResourceData, meta interface{}, logicAppId string, name string, vals map[string]interface{}, resourceName string) error {
return resourceLogicAppComponentUpdate(d, meta, "Trigger", "triggers", logicAppId, name, vals, resourceName)
}

func resourceLogicAppComponentUpdate(d *schema.ResourceData, meta interface{}, kind string, propertyName string, logicAppId string, name string, vals map[string]interface{}) error {
func resourceLogicAppComponentUpdate(d *schema.ResourceData, meta interface{}, kind string, propertyName string, logicAppId string, name string, vals map[string]interface{}, resourceName string) error {
client := meta.(*ArmClient).logicWorkflowsClient
ctx := meta.(*ArmClient).StopContext

Expand Down Expand Up @@ -56,6 +58,14 @@ func resourceLogicAppComponentUpdate(d *schema.ResourceData, meta interface{}, k

definition := read.WorkflowProperties.Definition.(map[string]interface{})
vs := definition[propertyName].(map[string]interface{})

idString := fmt.Sprintf("%s/%s/%s", *read.ID, propertyName, name)
if d.IsNewResource() {
if _, exists := vs[name]; exists {
return tf.ImportAsExistsError(resourceName, idString)
}
}

vs[name] = vals
definition[propertyName] = vs

Expand All @@ -68,13 +78,15 @@ func resourceLogicAppComponentUpdate(d *schema.ResourceData, meta interface{}, k
Tags: read.Tags,
}

_, err = client.CreateOrUpdate(ctx, resourceGroup, logicAppName, properties)
waitCtx, cancel := context.WithTimeout(ctx, d.Timeout(tf.TimeoutForCreateUpdate(d)))
defer cancel()
_, err = client.CreateOrUpdate(waitCtx, resourceGroup, logicAppName, properties)
if err != nil {
return fmt.Errorf("Error updating Logic App Workspace %q (Resource Group %q) for %s %q: %+v", logicAppName, resourceGroup, kind, name, err)
}

if d.IsNewResource() {
d.SetId(fmt.Sprintf("%s/%s/%s", *read.ID, propertyName, name))
d.SetId(idString)
}

return nil
Expand Down Expand Up @@ -130,7 +142,9 @@ func resourceLogicAppComponentRemove(d *schema.ResourceData, meta interface{}, k
Tags: read.Tags,
}

_, err = client.CreateOrUpdate(ctx, resourceGroup, logicAppName, properties)
waitCtx, cancel := context.WithTimeout(ctx, d.Timeout(schema.TimeoutDelete))
defer cancel()
_, err = client.CreateOrUpdate(waitCtx, resourceGroup, logicAppName, properties)
if err != nil {
return fmt.Errorf("Error removing %s %q from Logic App Workspace %q (Resource Group %q): %+v", kind, name, logicAppName, resourceGroup, err)
}
Expand Down
Loading