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_automation_webhook #13893

Merged
merged 7 commits into from
Nov 18, 2021

Conversation

wiktorn
Copy link
Contributor

@wiktorn wiktorn commented Oct 25, 2021

Fixes: #13796.

I haven't tested and I guess that it doesn't support URI rotation as I described:

it would be helpful if provider would support one of the following rotation scenarios

  • changing the name of the webhook would result in first creation of the new resource, updating references to it in dependant resources and in the end removal of old webhook (not sure if such plans are supported by terraform)
  • changing of the expiration date would generate automatically new URI which forces resource replacement and goes as above

I don't know if this is at all possible.

Test results:

TF_ACC=1 go test -v ./internal/services/automation -run=TestAccAutomationWebhook -timeout 180m -ldflags="-X=github.com/hashicorp/terraform-provider-azurerm/version.ProviderVersion=acc"
=== RUN   TestAccAutomationWebhook_basic
=== PAUSE TestAccAutomationWebhook_basic
=== RUN   TestAccAutomationWebhook_requiresImport
=== PAUSE TestAccAutomationWebhook_requiresImport
=== RUN   TestAccAutomationWebhook_WithParameters
=== PAUSE TestAccAutomationWebhook_WithParameters
=== CONT  TestAccAutomationWebhook_basic
=== CONT  TestAccAutomationWebhook_WithParameters
=== CONT  TestAccAutomationWebhook_requiresImport
--- PASS: TestAccAutomationWebhook_WithParameters (87.52s)
--- PASS: TestAccAutomationWebhook_requiresImport (101.67s)
--- PASS: TestAccAutomationWebhook_basic (149.38s)
PASS
ok      github.com/hashicorp/terraform-provider-azurerm/internal/services/automation    149.396s

I'm still working on the documentation

@wiktorn wiktorn marked this pull request as ready for review October 25, 2021 21:05
@katbyte katbyte added this to the v2.83.0 milestone Oct 27, 2021
@katbyte katbyte modified the milestones: v2.83.0, v2.84.0 Oct 29, 2021
Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks for the new resource @wiktorn - overall looks good but i had some questions/comments i've left inline

}
}

func resourceAutomationWebhookCommonSchema() map[string]*pluginsdk.Schema {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i'm not sure what we gain from this being a seperate function? could we just inline it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we can inline that. I will update PR tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Required: true,
ValidateFunc: validate.RunbookName(),
},
"run_on": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could we make this

Suggested change
"run_on": {
"run_on_worker_group": {

to be a little more explicit what it means

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

ForceNew: true,
Computed: true,
Sensitive: true,
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we validate this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, good catch. What's easy to add is: IsURLWithHTTPorHTTPS. I don't think that there is any official pattern/domain, that we can validate. IIRC API was accepting some invalid (not pointing to Azure) urls on creation (but not on update...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

}

/*
// missing workergroup creation
Copy link
Collaborator

Choose a reason for hiding this comment

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

is there no way to create a worker group yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not exposed in Azure REST API. I guess that this might be due to the fact, that worker group is created when agent is installed and registered in Azure. I assumed, that this is only resource missing in terraform, but as I've just now checked, I think it is better just to remove this case

Copy link
Collaborator

Choose a reason for hiding this comment

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

can you pass in a fake value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can pass the fake value, the only thing is, that there will be an error returned from REST API. As it is quite specific, I've implemented it right now, as expecting this specific error.

* use `run_on_worker_group` instead of `run_on`
* inline schema creation function
* enable test for checking `run_on_worker_group` using fake value and expect failure
@wiktorn wiktorn requested a review from katbyte November 4, 2021 08:52
@katbyte katbyte modified the milestones: v2.84.0, v2.85.0, v2.86.0 Nov 5, 2021
@wiktorn
Copy link
Contributor Author

wiktorn commented Nov 16, 2021

Is there something left to do on my side to get this PR merged?

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

Thanks @wiktorn! sorry for the delay in looping back here but tests pass and code looks great 🙂 Merging 🙌

@katbyte katbyte merged commit 287f81c into hashicorp:main Nov 18, 2021
katbyte added a commit that referenced this pull request Nov 18, 2021
@github-actions
Copy link

This functionality has been released in v2.86.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for azurerm_automation_webhook
2 participants