Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New resource: azurerm_logic_app_standard #13196

Merged
merged 19 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
df2880b
Initial logic app resource creation
dylanmorley Aug 27, 2021
8829747
validate and parse support for logic app standard
dylanmorley Aug 28, 2021
6fe47b7
Linted, formatting and docs
dylanmorley Aug 28, 2021
72d613c
Favour the logic validate package over MSI
dylanmorley Aug 28, 2021
30eecfb
Added support for passing a custom content share name
dylanmorley Aug 28, 2021
e6d4dec
Removed not relevant parameters for logic apps
dylanmorley Aug 28, 2021
70ac4aa
removed not used setting
dylanmorley Aug 28, 2021
13ef0c0
supporting bundle settings + container mode
dylanmorley Aug 31, 2021
25ecfce
fixed up page sub category
dylanmorley Aug 31, 2021
5c1c191
Merge remote-tracking branch 'origin/main' into feautre/logic-app-res…
dylanmorley Sep 10, 2021
979686a
Support vnet route all
dylanmorley Sep 13, 2021
ca66164
Updating tests and fixing content share setting
dylanmorley Sep 17, 2021
e35f93e
Merge remote-tracking branch 'origin/main' into feautre/logic-app-res…
dylanmorley Sep 17, 2021
1719364
Added setting storage_account_share_name for controlling share name
dylanmorley Sep 18, 2021
f83854e
Added vet setting to docs. Renamed test method names to follow LogicA…
dylanmorley Sep 18, 2021
b6187e1
Removing user identity support - Logic Apps currently only support Sy…
dylanmorley Sep 18, 2021
d898347
fixed up lint / remove not needed error
dylanmorley Sep 18, 2021
e3508ff
Removed client_cert_mode abbreviation and renamed bundle_version_range
dylanmorley Sep 27, 2021
a019c50
Merge branch 'main' into feautre/logic-app-resource
dylanmorley Sep 29, 2021
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
1,465 changes: 1,465 additions & 0 deletions internal/services/logic/logic_app_standard_resource.go

Large diffs are not rendered by default.

2,310 changes: 2,310 additions & 0 deletions internal/services/logic/logic_app_standard_resource_test.go

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions internal/services/logic/parse/logic_app_standard.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"fmt"
"strings"

"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
)

type LogicAppStandardId struct {
SubscriptionId string
ResourceGroup string
SiteName string
}

func NewLogicAppStandardID(subscriptionId, resourceGroup, siteName string) LogicAppStandardId {
return LogicAppStandardId{
SubscriptionId: subscriptionId,
ResourceGroup: resourceGroup,
SiteName: siteName,
}
}

func (id LogicAppStandardId) String() string {
segments := []string{
fmt.Sprintf("Site Name %q", id.SiteName),
fmt.Sprintf("Resource Group %q", id.ResourceGroup),
}
segmentsStr := strings.Join(segments, " / ")
return fmt.Sprintf("%s: (%s)", "Logic App Standard", segmentsStr)
}

func (id LogicAppStandardId) ID() string {
fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Web/sites/%s"
return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroup, id.SiteName)
}

// LogicAppStandardID parses a LogicAppStandard ID into an LogicAppStandardId struct
func LogicAppStandardID(input string) (*LogicAppStandardId, error) {
id, err := azure.ParseAzureResourceID(input)
if err != nil {
return nil, err
}

resourceId := LogicAppStandardId{
SubscriptionId: id.SubscriptionID,
ResourceGroup: id.ResourceGroup,
}

if resourceId.SubscriptionId == "" {
return nil, fmt.Errorf("ID was missing the 'subscriptions' element")
}

if resourceId.ResourceGroup == "" {
return nil, fmt.Errorf("ID was missing the 'resourceGroups' element")
}

if resourceId.SiteName, err = id.PopSegment("sites"); err != nil {
return nil, err
}

if err := id.ValidateNoEmptySegments(input); err != nil {
return nil, err
}

return &resourceId, nil
}
112 changes: 112 additions & 0 deletions internal/services/logic/parse/logic_app_standard_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package parse

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"testing"

"github.com/hashicorp/terraform-provider-azurerm/internal/resourceid"
)

var _ resourceid.Formatter = LogicAppStandardId{}

func TestLogicAppStandardIDFormatter(t *testing.T) {
actual := NewLogicAppStandardID("12345678-1234-9876-4563-123456789012", "resGroup1", "site1").ID()
expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1"
if actual != expected {
t.Fatalf("Expected %q but got %q", expected, actual)
}
}

func TestLogicAppStandardID(t *testing.T) {
testData := []struct {
Input string
Error bool
Expected *LogicAppStandardId
}{

{
// empty
Input: "",
Error: true,
},

{
// missing SubscriptionId
Input: "/",
Error: true,
},

{
// missing value for SubscriptionId
Input: "/subscriptions/",
Error: true,
},

{
// missing ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/",
Error: true,
},

{
// missing value for ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/",
Error: true,
},

{
// missing SiteName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/",
Error: true,
},

{
// missing value for SiteName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/",
Error: true,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1",
Expected: &LogicAppStandardId{
SubscriptionId: "12345678-1234-9876-4563-123456789012",
ResourceGroup: "resGroup1",
SiteName: "site1",
},
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1",
Error: true,
},
}

for _, v := range testData {
t.Logf("[DEBUG] Testing %q", v.Input)

actual, err := LogicAppStandardID(v.Input)
if err != nil {
if v.Error {
continue
}

t.Fatalf("Expect a value but got an error: %s", err)
}
if v.Error {
t.Fatal("Expect an error but didn't get one")
}

if actual.SubscriptionId != v.Expected.SubscriptionId {
t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId)
}
if actual.ResourceGroup != v.Expected.ResourceGroup {
t.Fatalf("Expected %q but got %q for ResourceGroup", v.Expected.ResourceGroup, actual.ResourceGroup)
}
if actual.SiteName != v.Expected.SiteName {
t.Fatalf("Expected %q but got %q for SiteName", v.Expected.SiteName, actual.SiteName)
}
}
}
1 change: 1 addition & 0 deletions internal/services/logic/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@ func (r Registration) SupportedResources() map[string]*pluginsdk.Resource {
"azurerm_logic_app_trigger_recurrence": resourceLogicAppTriggerRecurrence(),
"azurerm_logic_app_workflow": resourceLogicAppWorkflow(),
"azurerm_integration_service_environment": resourceIntegrationServiceEnvironment(),
"azurerm_logic_app_standard": resourceLogicAppStandard(),
}
}
1 change: 1 addition & 0 deletions internal/services/logic/resourceids.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package logic
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=IntegrationAccountSchema -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/integrationAccounts/integrationAccount1/schemas/schema1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=IntegrationAccountSession -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/integrationAccounts/integrationAccount1/sessions/session1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=IntegrationServiceEnvironment -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/integrationServiceEnvironments/ise1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=LogicAppStandard -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Workflow -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/workflows/workflow1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Trigger -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/workflows/workflow1/triggers/trigger1
//go:generate go run ../../tools/generator-resource-id/main.go -path=./ -name=Action -id=/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/group1/providers/Microsoft.Logic/workflows/workflow1/actions/action1
23 changes: 23 additions & 0 deletions internal/services/logic/validate/logic_app_standard_id.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package validate

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import (
"fmt"

"github.com/hashicorp/terraform-provider-azurerm/internal/services/logic/parse"
)

func LogicAppStandardID(input interface{}, key string) (warnings []string, errors []error) {
v, ok := input.(string)
if !ok {
errors = append(errors, fmt.Errorf("expected %q to be a string", key))
return
}

if _, err := parse.LogicAppStandardID(v); err != nil {
errors = append(errors, err)
}

return
}
76 changes: 76 additions & 0 deletions internal/services/logic/validate/logic_app_standard_id_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package validate

// NOTE: this file is generated via 'go:generate' - manual changes will be overwritten

import "testing"

func TestLogicAppStandardID(t *testing.T) {
cases := []struct {
Input string
Valid bool
}{

{
// empty
Input: "",
Valid: false,
},

{
// missing SubscriptionId
Input: "/",
Valid: false,
},

{
// missing value for SubscriptionId
Input: "/subscriptions/",
Valid: false,
},

{
// missing ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/",
Valid: false,
},

{
// missing value for ResourceGroup
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/",
Valid: false,
},

{
// missing SiteName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/",
Valid: false,
},

{
// missing value for SiteName
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/",
Valid: false,
},

{
// valid
Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/resGroup1/providers/Microsoft.Web/sites/site1",
Valid: true,
},

{
// upper-cased
Input: "/SUBSCRIPTIONS/12345678-1234-9876-4563-123456789012/RESOURCEGROUPS/RESGROUP1/PROVIDERS/MICROSOFT.WEB/SITES/SITE1",
Valid: false,
},
}
for _, tc := range cases {
t.Logf("[DEBUG] Testing Value %s", tc.Input)
_, errors := LogicAppStandardID(tc.Input, "test")
valid := len(errors) == 0

if tc.Valid != valid {
t.Fatalf("Expected %t but got %t", tc.Valid, valid)
}
}
}
16 changes: 16 additions & 0 deletions internal/services/logic/validate/logic_app_standard_name.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package validate

import (
"fmt"
"regexp"
)

func LogicAppStandardName(v interface{}, k string) (warnings []string, errors []error) {
value := v.(string)

if matched := regexp.MustCompile(`^[0-9a-zA-Z-]{1,60}$`).Match([]byte(value)); !matched {
errors = append(errors, fmt.Errorf("%q may only contain alphanumeric characters and dashes and up to 60 characters in length", k))
}

return warnings, errors
}
Loading