-
Notifications
You must be signed in to change notification settings - Fork 84
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
feat(subscription): optional use of AzAPI for Subscription creation #234
Conversation
Thanks @danwatco this looks great. Appreciate you taking the time to create some tests too. I think one scenario that needs to be tested with deployment tests is one of using AzAPI to create the subscription alias and then AzureRM to manage the management group association. If you are happy to copy one of the other deployment tests in the subscription submodule then feel free to modify that, if not I can do it. |
Have had a shot here - feel free to change/update |
} | ||
}) | ||
} | ||
|
||
# This resource ensures that we can manage the management group for the subscription | ||
# throughout its lifecycle. | ||
resource "azurerm_management_group_subscription_association" "this" { | ||
count = var.subscription_management_group_association_enabled ? 1 : 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.
@luke-taylor You don't need this block if using AzAPI, so you can count = 0 it.
Thanks for this @danwatco - @luke-taylor has implemented this in #253 |
Overview/summary
This PR adds functionality to create a subscription using the
azapi_resource
resource type rather than usingazurerm_subscription
. This is useful in situations where the principal running Terraform doesn't have access to the default management group where subscriptions are created. By using the API, we can provide themanagementGroupId
parameter and the subscription is then created in the provided management group, avoiding the need to have creation permissions underneath the default management group.Written unit and deployment tests (feedback welcome, my first time writing Go tests). Unable to run deployment tests so needs some testing there.
Testing evidence
There is some concerns that the management group association may cause an import error but yet to be tested.
As part of this pull request I have
make fmt
&make docs
to format your code and update documentation.