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 Resources: azurerm_postgresql_* #210

Merged
merged 25 commits into from
Sep 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d8c142d
Adding support for PostgreSQL Servers
tombuildsstuff Jul 9, 2017
02b3713
Adding support for PostgreSQL Databases
tombuildsstuff Jul 9, 2017
83f333a
Adding support for Firewall Rules
tombuildsstuff Jul 9, 2017
ce73d01
Moving the intInSlice validator into the azurerm package
tombuildsstuff Jul 10, 2017
fdc7f9e
adding postgres configurations
tombuildsstuff Jul 14, 2017
b9dcc26
Vendoring the Postgresql sdk
tombuildsstuff Aug 3, 2017
b2eac49
Fixing rebase issues
tombuildsstuff Aug 3, 2017
58946b4
Fixing the build
tombuildsstuff Aug 3, 2017
2be6cdc
Fixing the tests
tombuildsstuff Aug 3, 2017
8c533f5
Fixing the vet issue
tombuildsstuff Aug 3, 2017
e03908f
actually creating the configurations client
tombuildsstuff Aug 3, 2017
6bb8da0
PR comments
tombuildsstuff Aug 4, 2017
28c2e4f
Documentation updates
tombuildsstuff Aug 4, 2017
ae9189b
Combining the DB + SQL sidebar navs
tombuildsstuff Aug 4, 2017
f2c67d3
Fixing the build
tombuildsstuff Aug 4, 2017
0a646bb
Test covering updating the password + ssl requirement
tombuildsstuff Aug 4, 2017
732ef6d
Testing additional configuration values
tombuildsstuff Aug 4, 2017
b2508aa
Updating the acceptance tests to check for the reset value
tombuildsstuff Aug 19, 2017
dd1262d
Updating the CheckDelete to check the Configuration's been deleted
tombuildsstuff Aug 19, 2017
6b569c1
Making the location dynamic
tombuildsstuff Aug 20, 2017
2f52538
Resolving rebase issues
tombuildsstuff Sep 5, 2017
e9b1264
Updating the tests to the new format
tombuildsstuff Sep 5, 2017
f66404e
Adding some addiitonal resource value tests
tombuildsstuff Sep 5, 2017
5ebf58b
Review fixes
tombuildsstuff Sep 5, 2017
d9ba935
Splitting the SKU assignment out
tombuildsstuff Sep 5, 2017
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
30 changes: 30 additions & 0 deletions azurerm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/graphrbac"
"github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network"
"github.com/Azure/azure-sdk-for-go/arm/postgresql"
"github.com/Azure/azure-sdk-for-go/arm/redis"
"github.com/Azure/azure-sdk-for-go/arm/resources/resources"
"github.com/Azure/azure-sdk-for-go/arm/resources/subscriptions"
Expand Down Expand Up @@ -90,6 +91,11 @@ type ArmClient struct {
eventHubConsumerGroupClient eventhub.ConsumerGroupsClient
eventHubNamespacesClient eventhub.NamespacesClient

postgresqlConfigurationsClient postgresql.ConfigurationsClient
postgresqlDatabasesClient postgresql.DatabasesClient
postgresqlFirewallRulesClient postgresql.FirewallRulesClient
postgresqlServersClient postgresql.ServersClient

providers resources.ProvidersClient
resourceGroupClient resources.GroupsClient
tagsClient resources.TagsClient
Expand Down Expand Up @@ -401,6 +407,30 @@ func (c *Config) getArmClient() (*ArmClient, error) {
vnpc.Sender = autorest.CreateSender(withRequestLogging())
client.vnetPeeringsClient = vnpc

pcc := postgresql.NewConfigurationsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&pcc.Client)
pcc.Authorizer = auth
pcc.Sender = autorest.CreateSender(withRequestLogging())
client.postgresqlConfigurationsClient = pcc

pdbc := postgresql.NewDatabasesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&pdbc.Client)
pdbc.Authorizer = auth
pdbc.Sender = autorest.CreateSender(withRequestLogging())
client.postgresqlDatabasesClient = pdbc

pfwc := postgresql.NewFirewallRulesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&pfwc.Client)
pfwc.Authorizer = auth
pfwc.Sender = autorest.CreateSender(withRequestLogging())
client.postgresqlFirewallRulesClient = pfwc

psc := postgresql.NewServersClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&psc.Client)
psc.Authorizer = auth
psc.Sender = autorest.CreateSender(withRequestLogging())
client.postgresqlServersClient = psc

rtc := network.NewRouteTablesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&rtc.Client)
rtc.Authorizer = auth
Expand Down
77 changes: 77 additions & 0 deletions azurerm/import_arm_postgresql_configuration_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMPostgreSQLConfiguration_importBackslashQuote(t *testing.T) {
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_backslashQuote(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMPostgreSQLConfiguration_importClientMinMessages(t *testing.T) {
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_clientMinMessages(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccAzureRMPostgreSQLConfiguration_importDeadlockTimeout(t *testing.T) {
resourceName := "azurerm_postgresql_configuration.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLConfiguration_deadlockTimeout(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLConfigurationDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
31 changes: 31 additions & 0 deletions azurerm/import_arm_postgresql_database_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMPostgreSQLDatabase_importBasic(t *testing.T) {
resourceName := "azurerm_postgresql_database.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLDatabase_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLDatabaseDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
31 changes: 31 additions & 0 deletions azurerm/import_arm_postgresql_firewall_rule_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMPostgreSQLFirewallRule_importBasic(t *testing.T) {
resourceName := "azurerm_postgresql_firewall_rule.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLFirewallRule_basic(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLFirewallRuleDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}
60 changes: 60 additions & 0 deletions azurerm/import_arm_postgresql_server_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package azurerm

import (
"testing"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMPostgreSQLServer_importBasicNinePointFive(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLServer_basicNinePointFive(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"administrator_login_password", // not returned as sensitive
},
},
},
})
}

func TestAccAzureRMPostgreSQLServer_importBasicNinePointSix(t *testing.T) {
resourceName := "azurerm_postgresql_server.test"

ri := acctest.RandInt()
config := testAccAzureRMPostgreSQLServer_basicNinePointSix(ri, testLocation())

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMPostgreSQLServerDestroy,
Steps: []resource.TestStep{
{
Config: config,
},
{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"administrator_login_password", // not returned as sensitive
},
},
},
})
}
37 changes: 21 additions & 16 deletions azurerm/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ func Provider() terraform.ResourceProvider {
"azurerm_network_interface": resourceArmNetworkInterface(),
"azurerm_network_security_group": resourceArmNetworkSecurityGroup(),
"azurerm_network_security_rule": resourceArmNetworkSecurityRule(),
"azurerm_postgresql_configuration": resourceArmPostgreSQLConfiguration(),
"azurerm_postgresql_database": resourceArmPostgreSQLDatabase(),
"azurerm_postgresql_firewall_rule": resourceArmPostgreSQLFirewallRule(),
"azurerm_postgresql_server": resourceArmPostgreSQLServer(),
"azurerm_public_ip": resourceArmPublicIp(),
"azurerm_redis_cache": resourceArmRedisCache(),
"azurerm_resource_group": resourceArmResourceGroup(),
Expand Down Expand Up @@ -239,22 +243,23 @@ var providerRegistrationOnce sync.Once

func determineAzureResourceProvidersToRegister(providerList []resources.Provider) map[string]struct{} {
providers := map[string]struct{}{
"Microsoft.Cache": struct{}{},
"Microsoft.Cdn": struct{}{},
"Microsoft.Compute": struct{}{},
"Microsoft.ContainerRegistry": struct{}{},
"Microsoft.ContainerService": struct{}{},
"Microsoft.DocumentDB": struct{}{},
"Microsoft.EventGrid": struct{}{},
"Microsoft.EventHub": struct{}{},
"Microsoft.KeyVault": struct{}{},
"microsoft.insights": struct{}{},
"Microsoft.Network": struct{}{},
"Microsoft.Resources": struct{}{},
"Microsoft.Search": struct{}{},
"Microsoft.ServiceBus": struct{}{},
"Microsoft.Sql": struct{}{},
"Microsoft.Storage": struct{}{},
"Microsoft.Cache": {},
"Microsoft.Cdn": {},
"Microsoft.Compute": {},
"Microsoft.ContainerRegistry": {},
"Microsoft.ContainerService": {},
"Microsoft.DBforPostgreSQL": {},
"Microsoft.DocumentDB": {},
"Microsoft.EventGrid": {},
"Microsoft.EventHub": {},
"Microsoft.KeyVault": {},
"microsoft.insights": {},
"Microsoft.Network": {},
"Microsoft.Resources": {},
"Microsoft.Search": {},
"Microsoft.ServiceBus": {},
"Microsoft.Sql": {},
"Microsoft.Storage": {},
}

// filter out any providers already registered
Expand Down
Loading