-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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_workflow
#1266
Conversation
azurerm_logic_app_workspace
azurerm_logic_app_workflow
b5f3b03
to
b6b8d44
Compare
MaxItems: 1, | ||
Elem: &schema.Resource{ | ||
Schema: map[string]*schema.Schema{ | ||
"recurrence": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are so many other triggers than recurrence trigger. https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-actions-triggers
Type: schema.TypeList, | ||
Optional: true, | ||
Computed: true, | ||
MaxItems: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There could be more than 1 actions.
Type: schema.TypeList, | ||
Optional: true, | ||
Computed: true, | ||
MaxItems: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1 is not enough.
|
||
"resource_group_name": resourceGroupNameSchema(), | ||
|
||
"parameters": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two different parameters here. One is the workflow parameter, the other is the definition parameter.
|
||
_, err := client.CreateOrUpdate(ctx, resourceGroup, name, properties) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message is not consistent with other return
statements. Provide more detailed info.
|
||
read, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refine error message here.
|
||
id, err := parseAzureResourceID(d.Id()) | ||
if err != nil { | ||
return err |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
||
id, err := parseAzureResourceID(d.Id()) | ||
if err != nil { | ||
return err |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
b6b8d44
to
4d77253
Compare
4d77253
to
7937447
Compare
fb1580c
to
44d75bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some feedback given below, but I do not think anything is blocking 👍
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
d.SetId("") | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this data source be returning an error here?
Config: config, | ||
Check: resource.ComposeTestCheckFunc( | ||
testCheckAzureRMLogicAppWorkflowExists(dataSourceName), | ||
resource.TestCheckResourceAttr(dataSourceName, "parameters.%", "0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nitpick: should we use resource.TestCheckResourceAttrPair()
for these rather than hardcoding the expectations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's an enhancement we should make, but across all resources (since a lot of tests follow this pattern); going to skip this for now.
"github.com/hashicorp/terraform/helper/resource" | ||
) | ||
|
||
func TestAccAzureRMLogicAppActionCustom_importBasic(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point for consideration: In AWS-land, we've been adding the import TestStep
directly to the pertinent acceptance tests to reduce:
- Indirection/missed tests with having a separate test file
- File sprawl (relating to above)
- Creating 2x the same resources for testing (potentially more false positives)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not opposed to that approach (we've started doing it for some resources) - but I think that's a larger project outside the scope of this PR - so I'm going to skip this for now.
read, err := client.Get(ctx, resourceGroup, logicAppName) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(read.Response) { | ||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should print a log message when removing from state, e.g. log.Printf("[WARN] Logic App (%s) not found, removing from state", d.Id())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on reflection this should be returning an error, since this is the Create method for a sub-resource (updated)
} | ||
|
||
if read.WorkflowProperties == nil { | ||
return fmt.Errorf("[ERROR] Error parsing Logic App Workflow - `WorkflowProperties` is nil") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a corrective action possible here, even if that means stating that the API response was unexpected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, if this happens the API's returning data that doesn't confirm to the schema - so this is to prevent crashes
return fmt.Errorf("Not found: %s", name) | ||
} | ||
|
||
logicAppId := rs.Primary.Attributes["logic_app_id"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be coming from rs.Primary.ID
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could parse it out of that, but this is a Terraform internal ID (from {logicAppID}/{type}/{name}
) so I don't think that gains us anything in this instance
return nil | ||
} | ||
|
||
func validateLogicAppTriggerHttpRequestRelativePath(v interface{}, k string) (ws []string, errors []error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be replaced with validation.ValidateRegexp()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so that function checks the string itself is a valid regex, rather than testing for a specific regex; whilst I thought we had a validate method for that I couldn't seem to find it (although I may have missed it)?
name := d.Get("name").(string) | ||
resourceGroup := d.Get("resource_group_name").(string) | ||
location := azureRMNormalizeLocation(d.Get("location").(string)) | ||
parameters := expandLogicAppWorkflowParameters(d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we generally prefer to be more explicit with our expand methods if possible (making it support map[string]interface{}
instead). Passing the raw *schema.ResourceData
could introduce subtle maintenance issues, especially if its used across multiple resources.
return fmt.Errorf("[ERROR] Error creating Logic App Workflow %q (Resource Group %q): %+v", name, resourceGroup, err) | ||
} | ||
|
||
read, err := client.Get(ctx, resourceGroup, name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing this SDK read here is necessary because the SDK create function does not provide the ID -- it feels extraneous to do this and should probably be avoided if possible (e.g. generate the ID from given arguments). The resource read function can catch non-existent IDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we do this across the provider since the URI used for Create doesn't always match the URI used for Get, unfortunately
resp, err := client.Get(ctx, resourceGroup, name) | ||
if err != nil { | ||
if utils.ResponseWasNotFound(resp.Response) { | ||
d.SetId("") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same issue here where we should provide logging message when removing resource from state.
Tests pass: ``` $ acctests azurerm TestAccAzureRMLogicAppWorkflow_ === RUN TestAccAzureRMLogicAppWorkflow_empty --- PASS: TestAccAzureRMLogicAppWorkflow_empty (97.38s) === RUN TestAccAzureRMLogicAppWorkflow_tags --- PASS: TestAccAzureRMLogicAppWorkflow_tags (83.56s) === RUN TestAccAzureRMLogicAppWorkflow_actionHTTP --- PASS: TestAccAzureRMLogicAppWorkflow_actionHTTP (75.25s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 256.212s ``` Fixes #610
``` $ acctests azurerm TestAccAzureRMLogicAppWorkflow_ === RUN TestAccAzureRMLogicAppWorkflow_importEmpty --- PASS: TestAccAzureRMLogicAppWorkflow_importEmpty (71.95s) === RUN TestAccAzureRMLogicAppWorkflow_importTags --- PASS: TestAccAzureRMLogicAppWorkflow_importTags (69.51s) === RUN TestAccAzureRMLogicAppWorkflow_empty --- PASS: TestAccAzureRMLogicAppWorkflow_empty (66.77s) === RUN TestAccAzureRMLogicAppWorkflow_tags --- PASS: TestAccAzureRMLogicAppWorkflow_tags (81.51s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 289.789s ```
Tests pass: ``` $ acctests azurerm TestAccAzureRMLogicAppActionHttp_ === RUN TestAccAzureRMLogicAppActionHttp_basic --- PASS: TestAccAzureRMLogicAppActionHttp_basic (65.75s) === RUN TestAccAzureRMLogicAppActionHttp_headers --- PASS: TestAccAzureRMLogicAppActionHttp_headers (61.97s) === RUN TestAccAzureRMLogicAppActionHttp_disappears --- PASS: TestAccAzureRMLogicAppActionHttp_disappears (77.38s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 205.136s ```
…gic_app_trigger_recurrence` - Adding documentation for all of the resources - Making the test check functions more generic
``` $ acctests azurerm TestAccDataSourceAzureRMLogicAppWorkflow_ === RUN TestAccDataSourceAzureRMLogicAppWorkflow_basic --- PASS: TestAccDataSourceAzureRMLogicAppWorkflow_basic (69.73s) === RUN TestAccDataSourceAzureRMLogicAppWorkflow_tags --- PASS: TestAccDataSourceAzureRMLogicAppWorkflow_tags (67.28s) PASS ok github.com/terraform-providers/terraform-provider-azurerm/azurerm 137.042s ```
44d75bd
to
70762ae
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks! |
This PR adds support for Logic Apps. After initially making this a huge self-contained resource, I've pivoted to adding split-out resources for the Actions and Triggers. This allows us to provide better Diff's for specific actions, whilst still allowing for custom Actions and Triggers via the
_custom
suffixed resources.Adds the following resources:
Fixes #610