diff --git a/internal/services/resource/client/client.go b/internal/services/resource/client/client.go index e0b2a5fe7124f..07bc82cc5aafa 100644 --- a/internal/services/resource/client/client.go +++ b/internal/services/resource/client/client.go @@ -5,26 +5,29 @@ package client import ( "fmt" - "github.com/Azure/azure-sdk-for-go/services/preview/resources/mgmt/2019-06-01-preview/templatespecs" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2015-12-01/features" // nolint: staticcheck "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources" // nolint: staticcheck "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/privatelinkassociation" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts" "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) type Client struct { - DeploymentsClient *resources.DeploymentsClient - DeploymentScriptsClient *deploymentscripts.DeploymentScriptsClient - FeaturesClient *features.Client - GroupsClient *resources.GroupsClient - LocksClient *managementlocks.ManagementLocksClient - ResourceProvidersClient *providers.ProvidersClient - ResourcesClient *resources.Client - TagsClient *resources.TagsClient - TemplateSpecsVersionsClient *templatespecs.VersionsClient + DeploymentsClient *resources.DeploymentsClient + DeploymentScriptsClient *deploymentscripts.DeploymentScriptsClient + FeaturesClient *features.Client + GroupsClient *resources.GroupsClient + LocksClient *managementlocks.ManagementLocksClient + PrivateLinkAssociationClient *privatelinkassociation.PrivateLinkAssociationClient + ResourceManagementPrivateLinkClient *resourcemanagementprivatelink.ResourceManagementPrivateLinkClient + ResourceProvidersClient *providers.ProvidersClient + ResourcesClient *resources.Client + TagsClient *resources.TagsClient + TemplateSpecsVersionsClient *templatespecs.VersionsClient options *common.ClientOptions } @@ -51,6 +54,12 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(locksClient.Client, o.Authorizers.ResourceManager) + resourceManagementPrivateLinkClient, err := resourcemanagementprivatelink.NewResourceManagementPrivateLinkClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building ResourceManagementPrivateLink client: %+v", err) + } + o.Configure(resourceManagementPrivateLinkClient.Client, o.Authorizers.ResourceManager) + resourceProvidersClient, err := providers.NewProvidersClientWithBaseURI(o.Environment.ResourceManager) if err != nil { return nil, fmt.Errorf("building Providers client: %+v", err) @@ -67,15 +76,16 @@ func NewClient(o *common.ClientOptions) (*Client, error) { o.ConfigureClient(&tagsClient.Client, o.ResourceManagerAuthorizer) return &Client{ - GroupsClient: &groupsClient, - DeploymentsClient: &deploymentsClient, - DeploymentScriptsClient: deploymentScriptsClient, - FeaturesClient: &featuresClient, - LocksClient: locksClient, - ResourceProvidersClient: resourceProvidersClient, - ResourcesClient: &resourcesClient, - TagsClient: &tagsClient, - TemplateSpecsVersionsClient: &templatespecsVersionsClient, + GroupsClient: &groupsClient, + DeploymentsClient: &deploymentsClient, + DeploymentScriptsClient: deploymentScriptsClient, + FeaturesClient: &featuresClient, + LocksClient: locksClient, + ResourceManagementPrivateLinkClient: resourceManagementPrivateLinkClient, + ResourceProvidersClient: resourceProvidersClient, + ResourcesClient: &resourcesClient, + TagsClient: &tagsClient, + TemplateSpecsVersionsClient: &templatespecsVersionsClient, options: o, }, nil diff --git a/internal/services/resource/registration.go b/internal/services/resource/registration.go index ca79a6e488522..aaec2742104cc 100644 --- a/internal/services/resource/registration.go +++ b/internal/services/resource/registration.go @@ -64,6 +64,7 @@ func (r Registration) DataSources() []sdk.DataSource { func (r Registration) Resources() []sdk.Resource { return []sdk.Resource{ ResourceProviderRegistrationResource{}, + ResourceManagementPrivateLinkResource{}, ResourceDeploymentScriptAzurePowerShellResource{}, ResourceDeploymentScriptAzureCliResource{}, } diff --git a/internal/services/resource/resource_management_private_link_resource.go b/internal/services/resource/resource_management_private_link_resource.go new file mode 100644 index 0000000000000..3b07685581c88 --- /dev/null +++ b/internal/services/resource/resource_management_private_link_resource.go @@ -0,0 +1,153 @@ +package resource + +import ( + "context" + "fmt" + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonschema" + "github.com/hashicorp/go-azure-helpers/resourcemanager/location" + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" + "time" +) + +var _ sdk.Resource = ResourceManagementPrivateLinkResource{} + +type ResourceManagementPrivateLinkResource struct{} + +func (r ResourceManagementPrivateLinkResource) ModelObject() interface{} { + return &ResourceManagementPrivateLinkResourceSchema{} +} + +type ResourceManagementPrivateLinkResourceSchema struct { + Location string `tfschema:"location"` + Name string `tfschema:"name"` + PrivateEndpointConnections []string `tfschema:"private_endpoint_connections"` + ResourceGroupName string `tfschema:"resource_group_name"` +} + +func (r ResourceManagementPrivateLinkResource) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return resourcemanagementprivatelink.ValidateResourceManagementPrivateLinkID +} + +func (r ResourceManagementPrivateLinkResource) ResourceType() string { + return "azurerm_resource_management_private_link" +} + +func (r ResourceManagementPrivateLinkResource) Arguments() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "name": { + ForceNew: true, + Required: true, + Type: pluginsdk.TypeString, + ValidateFunc: validation.StringIsNotEmpty, + }, + "resource_group_name": commonschema.ResourceGroupName(), + "location": commonschema.Location(), + } +} + +func (r ResourceManagementPrivateLinkResource) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{ + "private_endpoint_connections": { + Computed: true, + Elem: &pluginsdk.Schema{ + Type: pluginsdk.TypeString, + }, + Type: pluginsdk.TypeList, + }, + } +} + +func (r ResourceManagementPrivateLinkResource) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Resource.ResourceManagementPrivateLinkClient + + var config ResourceManagementPrivateLinkResourceSchema + if err := metadata.Decode(&config); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + subscriptionId := metadata.Client.Account.SubscriptionId + + id := resourcemanagementprivatelink.NewResourceManagementPrivateLinkID(subscriptionId, config.ResourceGroupName, config.Name) + + existing, err := client.Get(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for the presence of an existing %s: %+v", id, err) + } + } + if !response.WasNotFound(existing.HttpResponse) { + return metadata.ResourceRequiresImport(r.ResourceType(), id) + } + + payload := resourcemanagementprivatelink.ResourceManagementPrivateLinkLocation{ + Location: pointer.To(location.Normalize(config.Location)), + } + + if _, err := client.Put(ctx, id, payload); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r ResourceManagementPrivateLinkResource) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Resource.ResourceManagementPrivateLinkClient + schema := ResourceManagementPrivateLinkResourceSchema{} + + id, err := resourcemanagementprivatelink.ParseResourceManagementPrivateLinkID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.Get(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(*id) + } + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + if model := resp.Model; model != nil { + schema.Name = id.ResourceManagementPrivateLinkName + schema.ResourceGroupName = id.ResourceGroupName + schema.Location = location.NormalizeNilable(model.Location) + } + + return metadata.Encode(&schema) + }, + } +} + +func (r ResourceManagementPrivateLinkResource) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.Resource.ResourceManagementPrivateLinkClient + + id, err := resourcemanagementprivatelink.ParseResourceManagementPrivateLinkID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + if _, err := client.Delete(ctx, *id); err != nil { + return fmt.Errorf("deleting %s: %+v", *id, err) + } + + return nil + }, + } +} diff --git a/internal/services/resource/resource_management_private_link_resource_test.go b/internal/services/resource/resource_management_private_link_resource_test.go new file mode 100644 index 0000000000000..af15014d0c092 --- /dev/null +++ b/internal/services/resource/resource_management_private_link_resource_test.go @@ -0,0 +1,107 @@ +package resource_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type ResourceManagementPrivateLinkTestResource struct{} + +func TestAccResourceManagementPrivateLink_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_management_private_link", "test") + r := ResourceManagementPrivateLinkTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + +func TestAccResourceManagementPrivateLink_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_resource_management_private_link", "test") + r := ResourceManagementPrivateLinkTestResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (r ResourceManagementPrivateLinkTestResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + id, err := resourcemanagementprivatelink.ParseResourceManagementPrivateLinkID(state.ID) + if err != nil { + return nil, err + } + + resp, err := clients.Resource.ResourceManagementPrivateLinkClient.Get(ctx, *id) + if err != nil { + return nil, fmt.Errorf("reading %s: %+v", *id, err) + } + + return utils.Bool(resp.Model != nil), nil +} + +func (r ResourceManagementPrivateLinkTestResource) basic(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_resource_management_private_link" "test" { + location = azurerm_resource_group.test.location + name = "acctestrmpl-${var.random_string}" + resource_group_name = azurerm_resource_group.test.name +} +`, r.template(data)) +} + +func (r ResourceManagementPrivateLinkTestResource) requiresImport(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_resource_management_private_link" "import" { + location = azurerm_resource_management_private_link.test.location + name = azurerm_resource_management_private_link.test.name + resource_group_name = azurerm_resource_management_private_link.test.resource_group_name +} +`, r.basic(data)) +} + +func (r ResourceManagementPrivateLinkTestResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +variable "primary_location" { + default = %q +} +variable "random_integer" { + default = %d +} +variable "random_string" { + default = %q +} + +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestrg-${var.random_integer}" + location = var.primary_location +} +`, data.Locations.Primary, data.RandomInteger, data.RandomString) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/README.md new file mode 100644 index 0000000000000..bf06000f7aa50 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/README.md @@ -0,0 +1,105 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink` Documentation + +The `resourcemanagementprivatelink` SDK allows for interaction with the Azure Resource Manager Service `resources` (API Version `2020-05-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink" +``` + + +### Client Initialization + +```go +client := resourcemanagementprivatelink.NewResourceManagementPrivateLinkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ResourceManagementPrivateLinkClient.Delete` + +```go +ctx := context.TODO() +id := resourcemanagementprivatelink.NewResourceManagementPrivateLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceManagementPrivateLinkValue") + +read, err := client.Delete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceManagementPrivateLinkClient.Get` + +```go +ctx := context.TODO() +id := resourcemanagementprivatelink.NewResourceManagementPrivateLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceManagementPrivateLinkValue") + +read, err := client.Get(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceManagementPrivateLinkClient.List` + +```go +ctx := context.TODO() +id := resourcemanagementprivatelink.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceManagementPrivateLinkClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := resourcemanagementprivatelink.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +read, err := client.ListByResourceGroup(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ResourceManagementPrivateLinkClient.Put` + +```go +ctx := context.TODO() +id := resourcemanagementprivatelink.NewResourceManagementPrivateLinkID("12345678-1234-9876-4563-123456789012", "example-resource-group", "resourceManagementPrivateLinkValue") + +payload := resourcemanagementprivatelink.ResourceManagementPrivateLinkLocation{ + // ... +} + + +read, err := client.Put(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/client.go new file mode 100644 index 0000000000000..de7671f91dd5e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/client.go @@ -0,0 +1,26 @@ +package resourcemanagementprivatelink + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceManagementPrivateLinkClient struct { + Client *resourcemanager.Client +} + +func NewResourceManagementPrivateLinkClientWithBaseURI(sdkApi sdkEnv.Api) (*ResourceManagementPrivateLinkClient, error) { + client, err := resourcemanager.NewResourceManagerClient(sdkApi, "resourcemanagementprivatelink", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ResourceManagementPrivateLinkClient: %+v", err) + } + + return &ResourceManagementPrivateLinkClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/id_resourcemanagementprivatelink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/id_resourcemanagementprivatelink.go new file mode 100644 index 0000000000000..c02c6039a4519 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/id_resourcemanagementprivatelink.go @@ -0,0 +1,127 @@ +package resourcemanagementprivatelink + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = ResourceManagementPrivateLinkId{} + +// ResourceManagementPrivateLinkId is a struct representing the Resource ID for a Resource Management Private Link +type ResourceManagementPrivateLinkId struct { + SubscriptionId string + ResourceGroupName string + ResourceManagementPrivateLinkName string +} + +// NewResourceManagementPrivateLinkID returns a new ResourceManagementPrivateLinkId struct +func NewResourceManagementPrivateLinkID(subscriptionId string, resourceGroupName string, resourceManagementPrivateLinkName string) ResourceManagementPrivateLinkId { + return ResourceManagementPrivateLinkId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + ResourceManagementPrivateLinkName: resourceManagementPrivateLinkName, + } +} + +// ParseResourceManagementPrivateLinkID parses 'input' into a ResourceManagementPrivateLinkId +func ParseResourceManagementPrivateLinkID(input string) (*ResourceManagementPrivateLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceManagementPrivateLinkId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceManagementPrivateLinkId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ResourceManagementPrivateLinkName, ok = parsed.Parsed["resourceManagementPrivateLinkName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceManagementPrivateLinkName", *parsed) + } + + return &id, nil +} + +// ParseResourceManagementPrivateLinkIDInsensitively parses 'input' case-insensitively into a ResourceManagementPrivateLinkId +// note: this method should only be used for API response data and not user input +func ParseResourceManagementPrivateLinkIDInsensitively(input string) (*ResourceManagementPrivateLinkId, error) { + parser := resourceids.NewParserFromResourceIdType(ResourceManagementPrivateLinkId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + var ok bool + id := ResourceManagementPrivateLinkId{} + + if id.SubscriptionId, ok = parsed.Parsed["subscriptionId"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", *parsed) + } + + if id.ResourceGroupName, ok = parsed.Parsed["resourceGroupName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", *parsed) + } + + if id.ResourceManagementPrivateLinkName, ok = parsed.Parsed["resourceManagementPrivateLinkName"]; !ok { + return nil, resourceids.NewSegmentNotSpecifiedError(id, "resourceManagementPrivateLinkName", *parsed) + } + + return &id, nil +} + +// ValidateResourceManagementPrivateLinkID checks that 'input' can be parsed as a Resource Management Private Link ID +func ValidateResourceManagementPrivateLinkID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseResourceManagementPrivateLinkID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Resource Management Private Link ID +func (id ResourceManagementPrivateLinkId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Authorization/resourceManagementPrivateLinks/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.ResourceManagementPrivateLinkName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Resource Management Private Link ID +func (id ResourceManagementPrivateLinkId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftAuthorization", "Microsoft.Authorization", "Microsoft.Authorization"), + resourceids.StaticSegment("staticResourceManagementPrivateLinks", "resourceManagementPrivateLinks", "resourceManagementPrivateLinks"), + resourceids.UserSpecifiedSegment("resourceManagementPrivateLinkName", "resourceManagementPrivateLinkValue"), + } +} + +// String returns a human-readable description of this Resource Management Private Link ID +func (id ResourceManagementPrivateLinkId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Resource Management Private Link Name: %q", id.ResourceManagementPrivateLinkName), + } + return fmt.Sprintf("Resource Management Private Link (%s)", strings.Join(components, "\n")) +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_delete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_delete.go new file mode 100644 index 0000000000000..76165c51e7ba7 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_delete.go @@ -0,0 +1,47 @@ +package resourcemanagementprivatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// Delete ... +func (c ResourceManagementPrivateLinkClient) Delete(ctx context.Context, id ResourceManagementPrivateLinkId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_get.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_get.go new file mode 100644 index 0000000000000..ad6d192a7b123 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_get.go @@ -0,0 +1,51 @@ +package resourcemanagementprivatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceManagementPrivateLink +} + +// Get ... +func (c ResourceManagementPrivateLinkClient) Get(ctx context.Context, id ResourceManagementPrivateLinkId) (result GetOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_list.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_list.go new file mode 100644 index 0000000000000..49e07b6e02bee --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_list.go @@ -0,0 +1,53 @@ +package resourcemanagementprivatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceManagementPrivateLinkListResult +} + +// List ... +func (c ResourceManagementPrivateLinkClient) List(ctx context.Context, id commonids.SubscriptionId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/resourceManagementPrivateLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_listbyresourcegroup.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_listbyresourcegroup.go new file mode 100644 index 0000000000000..0cd1bc7ee96e3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_listbyresourcegroup.go @@ -0,0 +1,53 @@ +package resourcemanagementprivatelink + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListByResourceGroupOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceManagementPrivateLinkListResult +} + +// ListByResourceGroup ... +func (c ResourceManagementPrivateLinkClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/providers/Microsoft.Authorization/resourceManagementPrivateLinks", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_put.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_put.go new file mode 100644 index 0000000000000..3c1239d2acf19 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/method_put.go @@ -0,0 +1,56 @@ +package resourcemanagementprivatelink + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PutOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ResourceManagementPrivateLink +} + +// Put ... +func (c ResourceManagementPrivateLinkClient) Put(ctx context.Context, id ResourceManagementPrivateLinkId, input ResourceManagementPrivateLinkLocation) (result PutOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + if err = resp.Unmarshal(&result.Model); err != nil { + return + } + + return +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelink.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelink.go new file mode 100644 index 0000000000000..4d6fae849129d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelink.go @@ -0,0 +1,12 @@ +package resourcemanagementprivatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceManagementPrivateLink struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *ResourceManagementPrivateLinkEndpointConnections `json:"properties,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinkendpointconnections.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinkendpointconnections.go new file mode 100644 index 0000000000000..dcc9f39f7efdc --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinkendpointconnections.go @@ -0,0 +1,8 @@ +package resourcemanagementprivatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceManagementPrivateLinkEndpointConnections struct { + PrivateEndpointConnections *[]string `json:"privateEndpointConnections,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklistresult.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklistresult.go new file mode 100644 index 0000000000000..35b96202b68f0 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklistresult.go @@ -0,0 +1,8 @@ +package resourcemanagementprivatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceManagementPrivateLinkListResult struct { + Value *[]ResourceManagementPrivateLink `json:"value,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklocation.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklocation.go new file mode 100644 index 0000000000000..c2b90fa1753fd --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/model_resourcemanagementprivatelinklocation.go @@ -0,0 +1,8 @@ +package resourcemanagementprivatelink + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceManagementPrivateLinkLocation struct { + Location *string `json:"location,omitempty"` +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/version.go new file mode 100644 index 0000000000000..127e1df827f57 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink/version.go @@ -0,0 +1,12 @@ +package resourcemanagementprivatelink + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2020-05-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/resourcemanagementprivatelink/%s", defaultApiVersion) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index d4a959cd387de..d256359899431 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -801,6 +801,8 @@ github.com/hashicorp/go-azure-sdk/resource-manager/redisenterprise/2022-01-01/re github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/hybridconnections github.com/hashicorp/go-azure-sdk/resource-manager/relay/2021-11-01/namespaces github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/managementlocks +github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/privatelinkassociation +github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-05-01/resourcemanagementprivatelink github.com/hashicorp/go-azure-sdk/resource-manager/resources/2020-10-01/deploymentscripts github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-06-01/policyassignments github.com/hashicorp/go-azure-sdk/resource-manager/resources/2022-09-01/providers diff --git a/website/docs/r/resource_management_private_link.html.markdown b/website/docs/r/resource_management_private_link.html.markdown new file mode 100644 index 0000000000000..67de1b7e9efbb --- /dev/null +++ b/website/docs/r/resource_management_private_link.html.markdown @@ -0,0 +1,61 @@ +--- +subcategory: "Management" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_resource_management_private_link" +description: |- + Manages a Resource Management Private Link. +--- + +# azurerm_resource_management_private_link + +Manages a Resource Management Private Link. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} +resource "azurerm_resource_management_private_link" "example" { + name = "example" + resource_group_name = azurerm_resource_group.example.name + location = azurerm_resource_group.example.location +} +``` + +## Arguments Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of this Resource Management Private Link. Changing this forces a new Resource Management Private Link to be created. + +* `resource_group_name` - (Required) Specifies the name of the Resource Group within which this Resource Management Private Link should exist. Changing this forces a new Resource Management Private Link to be created. + +* `location` - (Required) The Azure Region where the Resource Management Private Link should exist. Changing this forces a new Resource Management Private Link to be created. + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Resource Management Private Link. + +* `private_endpoint_connections` - A list of private endpoint connections. + +--- + +## Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating this Resource Management Private Link. +* `delete` - (Defaults to 30 minutes) Used when deleting this Resource Management Private Link. +* `read` - (Defaults to 5 minutes) Used when retrieving this Resource Management Private Link. + +## Import + +An existing Resource Management Private Link can be imported into Terraform using the `resource id`, e.g. + +```shell +terraform import azurerm_resource_management_private_link.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Authorization/resourceManagementPrivateLinks/link1 +```