This terraform module will be able to manage subscriptions for CSP and Enterprise agreements.
you need to configure the restful provider. make sure to ask the saas team to whitelist your outgoing ip.
provider "restful" {
base_url = "https://your-csp-app-uri-here"
header = {
Content-Type = "application/json"
}
security = {
apikey = [
{
in = "header"
name = "x-functions-key"
value = "x-functions-value"
},
{
in = "header"
name = "x-customer-key"
value = "x-customer-value"
},
]
}
}
for variables, you need to provide a sku as well, the default is Production, which translates to 0001, which is fine, setting to DevTest translates to 0002.
the following options are available:
"enabledAzurePlans": [
{
"skuId": "0001",
"skuDescription": "Microsoft Azure Plan"
}
{
"skuId": "0002",
"skuDescription": "Microsoft Azure Plan for DevTest"
},
]
- login with your credentials
az login -t your-tenant-id-here
az billing account list --query "[].id"
# or
$AccountName = (az billing account list --query "[].id" -o json) | ConvertFrom-Json
The output will give you your account name if you want to see all details, remove the query part.
- check your billing information
az billing profile list --account-name $AccountName --expand "InvoiceSections" --query "[].invoiceSections[].value[].id"
Name | Version |
---|---|
terraform | ~> 1.7 |
azapi | 2.0.1 |
azurerm | ~> 4.0 |
restful | 0.14.0 |
Name | Version |
---|---|
azapi | 2.0.1 |
azurerm | ~> 4.0 |
restful | 0.14.0 |
No modules.
Name | Type |
---|---|
azapi_resource.subscription | resource |
azurerm_management_group_subscription_association.this | resource |
restful_operation.subscription | resource |
azurerm_billing_mca_account_scope.this | data source |
azurerm_client_config.current | data source |
azurerm_subscriptions.this | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
channel | Billing channel to be used by the subscription | string |
n/a | yes |
name | Name of the Subscription to be created | string |
n/a | yes |
billing_account_name | The name of the billing account, only needed if channel is set to ea | string |
null |
no |
billing_profile_name | The name of the billing profile, only needed if channel is set to ea | string |
null |
no |
invoice_section_name | The name of the invoice section, only needed if channel is set to ea | string |
null |
no |
owner_id | Id of the subscription owner, only needed if channel is set to ea. | string |
null |
no |
parent_management_group_id | The Id of the parent management group, only needed if channel is set to ea | string |
null |
no |
sku | Type of subscription to create | string |
"Production" |
no |
tags | Tags to add to the subscription, only needed if channel is set to ea. | map(string) |
null |
no |
Name | Description |
---|---|
subscription | Created subscription details |
Copyright: Schuberg Philis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.