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_postgresql_flexible_server_virtual_endpoint #26708

Merged
merged 53 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
09d93de
add virtual endpoint client to postgres client.go
bruceharrison1984 Jul 16, 2024
67bf096
expose virtual endpoint client
bruceharrison1984 Jul 16, 2024
03f55af
add resource file
bruceharrison1984 Jul 16, 2024
3bbfa30
build out methods
bruceharrison1984 Jul 17, 2024
30dcc27
complete initial pass
bruceharrison1984 Jul 17, 2024
bb92560
all behaviors implemented
bruceharrison1984 Jul 18, 2024
7c19ec8
fix index error
bruceharrison1984 Jul 18, 2024
3af434c
workaround api limitation
bruceharrison1984 Jul 18, 2024
b55d0ae
refine behavior
bruceharrison1984 Jul 18, 2024
2dbd15b
remove unnecessary update or create logic
bruceharrison1984 Jul 18, 2024
a2a9436
add test file
bruceharrison1984 Jul 18, 2024
b3463ee
complete basic tests
bruceharrison1984 Jul 18, 2024
1865594
fix tests
bruceharrison1984 Jul 18, 2024
7bb3895
first tests pass
bruceharrison1984 Jul 19, 2024
8e9c97c
complete tests
bruceharrison1984 Jul 19, 2024
9f5f19f
fix fmt
bruceharrison1984 Jul 19, 2024
6c10c9e
add docs page
bruceharrison1984 Jul 19, 2024
3a10a84
fix description
bruceharrison1984 Jul 19, 2024
93821c1
lock region during test
bruceharrison1984 Jul 19, 2024
f058493
fix typo
bruceharrison1984 Jul 19, 2024
e4d91f7
update docs
bruceharrison1984 Jul 19, 2024
3b4fbbd
fix timeouts
bruceharrison1984 Jul 19, 2024
429ead5
Merge branch 'main' into 25803
bruceharrison1984 Jul 24, 2024
ecb3882
Merge branch 'hashicorp:main' into 25803
bruceharrison1984 Jul 31, 2024
f544df8
update to new format
bruceharrison1984 Jul 31, 2024
e6a4847
Merge branch 'hashicorp:main' into 25803
bruceharrison1984 Jul 31, 2024
07cb86c
add service to typed services list
bruceharrison1984 Jul 31, 2024
d00bc17
add properties to state upon read
bruceharrison1984 Jul 31, 2024
c9b5d2e
get rid of if/else nesting
bruceharrison1984 Jul 31, 2024
1689b34
alphabetize services lists
bruceharrison1984 Aug 1, 2024
3d7a797
Update internal/services/postgres/custompollers/postgresql_flexible_s…
bruceharrison1984 Aug 1, 2024
b8e3e5d
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
e729ac0
add validation to name prop
bruceharrison1984 Aug 1, 2024
47c0439
reorder services
bruceharrison1984 Aug 1, 2024
d26fe7f
remove test provider feature
bruceharrison1984 Aug 1, 2024
3e05563
Update website/docs/r/azurerm_postgresql_flexible_server_virtual_endp…
bruceharrison1984 Aug 1, 2024
5705d35
Update website/docs/r/azurerm_postgresql_flexible_server_virtual_endp…
bruceharrison1984 Aug 1, 2024
46ae634
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
c1f3127
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
34ff00f
add pointer import
bruceharrison1984 Aug 1, 2024
43a6320
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
a21a38a
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
8a274a8
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
a53f639
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
db01698
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
7124d5d
fixup
bruceharrison1984 Aug 1, 2024
b180319
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 1, 2024
0045f4f
fix fmt
bruceharrison1984 Aug 1, 2024
6552b4c
add test for update
bruceharrison1984 Aug 1, 2024
5b8adeb
slightly tweak test for readability
bruceharrison1984 Aug 1, 2024
b72af1f
rename docs page, add note
bruceharrison1984 Aug 7, 2024
c1c6a8b
shorten resource names to avoid errors
bruceharrison1984 Aug 7, 2024
1e03cf7
Update internal/services/postgres/postgresql_flexible_server_virtual_…
bruceharrison1984 Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions internal/provider/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
eventhub.Registration{},
fluidrelay.Registration{},
graphservices.Registration{},
storagecache.Registration{},
hybridcompute.Registration{},
iothub.Registration{},
iotcentral.Registration{},
iothub.Registration{},
keyvault.Registration{},
kusto.Registration{},
labservice.Registration{},
Expand All @@ -187,36 +186,38 @@ func SupportedTypedServices() []sdk.TypedServiceRegistration {
maintenance.Registration{},
managedhsm.Registration{},
media.Registration{},
monitor.Registration{},
mobilenetwork.Registration{},
monitor.Registration{},
mssql.Registration{},
mssqlmanagedinstance.Registration{},
mysql.Registration{},
network.Registration{},
netapp.Registration{},
network.Registration{},
networkfunction.Registration{},
newrelic.Registration{},
nginx.Registration{},
orbital.Registration{},
paloalto.Registration{},
policy.Registration{},
postgres.Registration{},
privatednsresolver.Registration{},
recoveryservices.Registration{},
redis.Registration{},
redhatopenshift.Registration{},
redis.Registration{},
resource.Registration{},
search.Registration{},
securitycenter.Registration{},
sentinel.Registration{},
serviceconnector.Registration{},
servicefabricmanaged.Registration{},
servicenetworking.Registration{},
signalr.Registration{},
springcloud.Registration{},
storage.Registration{},
storagecache.Registration{},
storagemover.Registration{},
signalr.Registration{},
subscription.Registration{},
orbital.Registration{},
streamanalytics.Registration{},
search.Registration{},
springcloud.Registration{},
securitycenter.Registration{},
subscription.Registration{},
systemcentervirtualmachinemanager.Registration{},
vmware.Registration{},
voiceservices.Registration{},
Expand All @@ -234,7 +235,6 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
analysisservices.Registration{},
apimanagement.Registration{},
appconfiguration.Registration{},
springcloud.Registration{},
applicationinsights.Registration{},
arckubernetes.Registration{},
attestation.Registration{},
Expand All @@ -250,16 +250,16 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
compute.Registration{},
confidentialledger.Registration{},
connections.Registration{},
containers.Registration{},
consumption.Registration{},
containers.Registration{},
cosmos.Registration{},
customproviders.Registration{},
dashboard.Registration{},
databasemigration.Registration{},
databoxedge.Registration{},
databricks.Registration{},
datadog.Registration{},
datafactory.Registration{},
databasemigration.Registration{},
databoxedge.Registration{},
dataprotection.Registration{},
datashare.Registration{},
desktopvirtualization.Registration{},
Expand All @@ -272,31 +272,31 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
eventhub.Registration{},
firewall.Registration{},
frontdoor.Registration{},
storagecache.Registration{},
hsm.Registration{},
hdinsight.Registration{},
healthcare.Registration{},
iothub.Registration{},
hsm.Registration{},
iotcentral.Registration{},
iothub.Registration{},
iottimeseriesinsights.Registration{},
keyvault.Registration{},
kusto.Registration{},
legacy.Registration{},
lighthouse.Registration{},
loadbalancer.Registration{},
loganalytics.Registration{},
logic.Registration{},
logz.Registration{},
machinelearning.Registration{},
maintenance.Registration{},
managedapplications.Registration{},
lighthouse.Registration{},
managementgroup.Registration{},
managedhsm.Registration{},
managedidentity.Registration{},
managementgroup.Registration{},
maps.Registration{},
mariadb.Registration{},
media.Registration{},
mixedreality.Registration{},
monitor.Registration{},
managedidentity.Registration{},
mssql.Registration{},
mssqlmanagedinstance.Registration{},
mysql.Registration{},
Expand All @@ -320,12 +320,13 @@ func SupportedUntypedServices() []sdk.UntypedServiceRegistration {
servicebus.Registration{},
servicefabric.Registration{},
signalr.Registration{},
springcloud.Registration{},
sql.Registration{},
storage.Registration{},
storagecache.Registration{},
streamanalytics.Registration{},
subscription.Registration{},
synapse.Registration{},
iottimeseriesinsights.Registration{},
trafficmanager.Registration{},
videoanalyzer.Registration{},
vmware.Registration{},
Expand Down
9 changes: 9 additions & 0 deletions internal/services/postgres/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
flexibleserverdatabases "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2022-12-01/databases"
flexibleserverfirewallrules "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2022-12-01/firewallrules"
flexibleservers "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2023-06-01-preview/servers"
flexibleservervirtualendpoints "github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2023-06-01-preview/virtualendpoints"
"github.com/hashicorp/terraform-provider-azurerm/internal/common"
)

Expand All @@ -40,6 +41,7 @@ type Client struct {
VirtualNetworkRulesClient *virtualnetworkrules.VirtualNetworkRulesClient
ServerAdministratorsClient *serveradministrators.ServerAdministratorsClient
ReplicasClient *replicas.ReplicasClient
VirtualEndpointClient *flexibleservervirtualendpoints.VirtualEndpointsClient
}

func NewClient(o *common.ClientOptions) (*Client, error) {
Expand Down Expand Up @@ -133,6 +135,12 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
}
o.Configure(flexibleServerAdministratorsClient.Client, o.Authorizers.ResourceManager)

virtualEndpointClient, err := flexibleservervirtualendpoints.NewVirtualEndpointsClientWithBaseURI(o.Environment.ResourceManager)
if err != nil {
return nil, fmt.Errorf("building FlexibleServerVirtualEndpoint client: %+v", err)
}
o.Configure(virtualEndpointClient.Client, o.Authorizers.ResourceManager)

return &Client{
ConfigurationsClient: configurationsClient,
DatabasesClient: databasesClient,
Expand All @@ -149,5 +157,6 @@ func NewClient(o *common.ClientOptions) (*Client, error) {
VirtualNetworkRulesClient: virtualNetworkRulesClient,
ServerAdministratorsClient: serverAdministratorsClient,
ReplicasClient: replicasClient,
VirtualEndpointClient: virtualEndpointClient,
}, nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

package custompollers

import (
"context"
"fmt"
"time"

"github.com/hashicorp/go-azure-sdk/resource-manager/postgresql/2023-06-01-preview/virtualendpoints"
"github.com/hashicorp/go-azure-sdk/sdk/client"
"github.com/hashicorp/go-azure-sdk/sdk/client/pollers"
)

var _ pollers.PollerType = &postgresFlexibleServerVirtualEndpointPoller{}

type postgresFlexibleServerVirtualEndpointPoller struct {
client *virtualendpoints.VirtualEndpointsClient
id virtualendpoints.VirtualEndpointId
}

// Workaround due to Azure performing a pseudo-soft delete on virtual endpoints.
//
// - The `DELETE` endpoint does not fully delete the resource, it sets `properties.members` to nil
//
// - Subsequent `GET` operations for the endpoint will always return 200 with empty metadata, so Terraform will hang on `DELETE`
//
// - The only way to currently check for deletion is to check the `properties.members` property
func NewPostgresFlexibleServerVirtualEndpointDeletePoller(client *virtualendpoints.VirtualEndpointsClient, id virtualendpoints.VirtualEndpointId) *postgresFlexibleServerVirtualEndpointPoller {
return &postgresFlexibleServerVirtualEndpointPoller{
client: client,
id: id,
}
}

func (p postgresFlexibleServerVirtualEndpointPoller) Poll(ctx context.Context) (*pollers.PollResult, error) {
resp, err := p.client.Get(ctx, p.id)
if err != nil {
return nil, fmt.Errorf("retrieving %s: %+v", p.id, err)
}

model := resp.Model

if model != nil && model.Properties != nil {
if model.Properties.Members != nil {
return &pollers.PollResult{
HttpResponse: &client.Response{
Response: resp.HttpResponse,
},
PollInterval: 5 * time.Second,
Status: pollers.PollingStatusInProgress,
}, nil
}

return &pollers.PollResult{
HttpResponse: &client.Response{
Response: resp.HttpResponse,
},
PollInterval: 5 * time.Second,
Status: pollers.PollingStatusSucceeded,
}, nil
}

return nil, pollers.PollingFailedError{
HttpResponse: &client.Response{
Response: resp.HttpResponse,
},
Message: fmt.Sprintf("failed to delete %s", p.id),
}
}
Loading
Loading