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

provider/azurerm: Add resource azurerm_sql_elasticpool #14099

Conversation

dominik-lekse
Copy link
Contributor

This pull request adds the resource azurerm_sql_elasticpool to create and manage Azure SQL Elastic Pools.

Notes:

  • In contrast to the existing resources to manage Azure SQL related functionality, azurerm_sql_elasticpool uses the azure-sdk-for-go. For this purpose, I have added it to the vendor dependencies.

Related issues and pull requests:

Acceptance tests:

TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMSqlElasticPool_ -timeout 120m
=== RUN   TestAccAzureRMSqlElasticPool_importBasic
--- PASS: TestAccAzureRMSqlElasticPool_importBasic (146.96s)
=== RUN   TestAccAzureRMSqlElasticPool_basic
--- PASS: TestAccAzureRMSqlElasticPool_basic (145.20s)
=== RUN   TestAccAzureRMSqlElasticPool_resizeDtu
--- PASS: TestAccAzureRMSqlElasticPool_resizeDtu (187.22s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	479.408s

Tasks:

  • Resource azurerm_sql_elasticpool
  • Acceptance test TestAccAzureRMSqlElasticPool_basic (verifies creating a SQL Elasticpool)
  • Acceptance test TestAccAzureRMSqlElasticPool_resizeDtu (verifies resizing the DTU limit of a SQL Elasticpool)
  • Import acceptance test TestAccAzureRMSqlElasticPool_importBasic (verifies a SQL Elasticpool can be imported)
  • Documentation
  • Review

Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dominik-lekse

Thanks for this PR :)

I've reviewed and left some comments inline, but it otherwise looks good to me :)

Tests Pass:

$ envchain azurerm make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMSqlElasticPool'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/05/02 08:40:45 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/azurerm -v -run=TestAccAzureRMSqlElasticPool -timeout 120m
=== RUN   TestAccAzureRMSqlElasticPool_importBasic
--- PASS: TestAccAzureRMSqlElasticPool_importBasic (132.54s)
=== RUN   TestAccAzureRMSqlElasticPool_basic
--- PASS: TestAccAzureRMSqlElasticPool_basic (144.69s)
=== RUN   TestAccAzureRMSqlElasticPool_resizeDtu
--- PASS: TestAccAzureRMSqlElasticPool_resizeDtu (257.79s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	535.042s

Thanks!

@@ -99,6 +100,11 @@ type ArmClient struct {
serviceBusSubscriptionsClient servicebus.SubscriptionsClient

keyVaultClient keyvault.VaultsClient

sqlDatabasesClient sql.DatabasesClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're currently using the Riviera SDK for this functionality, this client isn't used. As such - is it possible to remove it for the moment?


sqlDatabasesClient sql.DatabasesClient
sqlElasticPoolsClient sql.ElasticPoolsClient
sqlRecommendedElasticPoolsClient sql.RecommendedElasticPoolsClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're currently using the Riviera SDK for this functionality, this client isn't used. As such - is it possible to remove it for the moment?

sqlDatabasesClient sql.DatabasesClient
sqlElasticPoolsClient sql.ElasticPoolsClient
sqlRecommendedElasticPoolsClient sql.RecommendedElasticPoolsClient
sqlServersClient sql.ServersClient
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given we're currently using the Riviera SDK for this functionality, this client isn't used. As such - is it possible to remove it for the moment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the unused clients except for sqlElasticPoolsClient which is used by the resource. I assume, Terraform has deprecated the Riviera SDK and will prefer the Azure RM Go SDK, right?

d.Set("server_name", serverName)
d.Set("edition", string(elasticPool.Edition))
d.Set("dtu", int(*elasticPool.Dtu))
d.Set("db_dtu_min", int(*elasticPool.DatabaseDtuMin))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worth checking that resp.ElasticPoolProperties isn't nil before assigning these, to prevent a possible crash?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe guard is now included.

… to verify creating a SQL database in an SQL elastic pool
…o SDK clients; Safe guard ElasticPoolProperties in resourceArmSqlElasticPoolRead
@dominik-lekse
Copy link
Contributor Author

Thanks for the feedback @tombuildsstuff. With the recent commits, I addressed your comments. In addition, I have included the changes proposed in #12678 in this pull request to allow managing databases in elastic pools. Also, the test TestAccAzureRMSqlDatabase_elasticPool is now completed, i.e. it verifies creating a database in a new elastic pool using the new resource.

=== RUN   TestAccAzureRMSqlDatabase_elasticPool
--- PASS: TestAccAzureRMSqlDatabase_elasticPool (186.53s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/azurerm	186.553s

@tombuildsstuff tombuildsstuff self-assigned this May 2, 2017
Copy link
Member

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dominik-lekse

Thanks for pushing those fixes and integrating #12678

I've taken another look and pushed a small fix for a typo in the documentation - but this is looking great :)

Thanks for this contribution - it's great to see this merged :)

@tombuildsstuff
Copy link
Member

Tests pass:
screen shot 2017-05-03 at 05 57 50

@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@hashicorp hashicorp locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants