Skip to content

Guide: New Service Package#

There's a few steps involved in adding a new Service Package.

  1. Create a new directory within ./internal/services with the Service Name (see naming).

  2. Create an empty Client within the Service Package (./internal/services/{name}/client/client.go):

package client

import (
    "github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

type Client struct {
}

func NewClient(o *common.ClientOptions) *Client {
    return &Client{}
}
  1. Create an empty Registration within the Service Package (./internal/services/{name}/registration.go) which implements the TypedServiceRegistration interface:
package {name}

import (
    "github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
)

type Registration struct{}

var (
    _ sdk.TypedServiceRegistration = Registration{}
)

func (r Registration) DataSources() []sdk.DataSource {
    return []sdk.DataSource{}
}

func (r Registration) Resources() []sdk.Resource {
    return []sdk.Resource{}
}

// Name is the name of this Service
func (r Registration) Name() string {
    return "App Service"
}

// WebsiteCategories returns a list of categories which can be used for the sidebar
func (r Registration) WebsiteCategories() []string {
    return []string{
        "App Service",
    }
}
  1. Register the Service Registration.
  2. Define and Register the Client for this Service Package.
  3. Add this to the Client struct.
  4. Call the Register function.
  5. Re-run the generation to ensure the generated files are up to date (make generate).

At this point the Service Package should be registered, and you can build a new Data Source or a new Resource as required.