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

feat(pci cloud db) - add ovh_cloud_project_database_postgresql_connection_pool resource & … #514

Conversation

julianguinard
Copy link
Contributor

Description

This adds a new add ovh_cloud_project_database_postgresql_connection_pool resource & datasource to manage Public Cloud Databases postgresql connection pools

It relies on /cloud/project/{serviceName}/database/postgresql/{clusterId}/connectionPool/* APIV6 routes:

Type of change

  • New feature (non-breaking change which adds functionality)
  • Documentation update

How Has This Been Tested?

  • Test :
make testacc TESTARGS="-run TestAccCloudProjectDatabasePostgresqlConnectionPool_importBasic"`
=== RUN   TestAccCloudProjectDatabasePostgresqlConnectionPool_importBasic
    provider_test.go:332: Read Cloud Project /cloud/project/9a37012689924595bf55df59a2b1f5b6 -> status: 'ok', desc: '(POC) AI'
--- PASS: TestAccCloudProjectDatabasePostgresqlConnectionPool_importBasic (363.45s)
PASS

Test Configuration:

  • Terraform version: terraform version: Terraform v1.2.9
  • Existing HCL configuration you used:

Creating a database in a Postgresql 15 database cluster, then a user for it & a connection pool for that user so he can access this database

resource "ovh_cloud_project_database" "db" {
	service_name = "XXXXXX"
	description  = "test-pg-cluster"
	engine       = "postgresql"
	version      = "15"
	plan         = "essential"
	nodes {
		region     = "GRA"
	}
	flavor = "db1-4"
}

resource "ovh_cloud_project_database_database" "database" {
  service_name  = ovh_cloud_project_database.db.service_name
  engine        = ovh_cloud_project_database.db.engine
  cluster_id    = ovh_cloud_project_database.db.id
  name          = "mydatabase"
}

resource "ovh_cloud_project_database_postgresql_user" "user" {
	service_name = ovh_cloud_project_database.db.service_name
	cluster_id   = ovh_cloud_project_database.db.id
	name		 = "johndoe"
	roles 		 = ["replication"]
}

resource "ovh_cloud_project_database_postgresql_connection_pool" "connection_pool" {
  service_name = ovh_cloud_project_database.db.service_name
  cluster_id   = ovh_cloud_project_database.db.id
  database_id = ovh_cloud_project_database_database.database.id
  name = "test_connection_pool"
  user_id = ovh_cloud_project_database_postgresql_user.user.id
  mode = "session"
  size = 13
}

data "ovh_cloud_project_database_postgresql_connection_pool" "connection_pool" {
  service_name = ovh_cloud_project_database_postgresql_connection_pool.connection_pool.service_name
  cluster_id   = ovh_cloud_project_database_postgresql_connection_pool.connection_pool.cluster_id
  name         = ovh_cloud_project_database_postgresql_connection_pool.connection_pool.name
}

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added acceptance tests that prove my fix is effective or that my feature works
  • New and existing acceptance tests pass locally with my changes

@julianguinard julianguinard changed the title add ovh_cloud_project_database_postgresql_connection_pool resource & … feat(pci cloud db) - add ovh_cloud_project_database_postgresql_connection_pool resource & … Dec 14, 2023
Copy link
Contributor

@lpatte lpatte left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution.
LGTM in general.
Only some comment to simplify code and remove unused parameters

@julianguinard
Copy link
Contributor Author

Thank you for your contribution. LGTM in general. Only some comment to simplify code and remove unused parameters

Thanks for your review Ludwig, suggestions applied there

@julianguinard julianguinard requested a review from lpatte December 15, 2023 15:37
lpatte
lpatte previously approved these changes Dec 15, 2023
Copy link
Contributor

@amstuta amstuta left a comment

Choose a reason for hiding this comment

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

Apart from the style comments, OK to merge

serviceName := d.Get("service_name").(string)
clusterId := d.Get("cluster_id").(string)

endpoint := fmt.Sprintf("/cloud/project/%s/database/%s/%s/connectionPool",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
endpoint := fmt.Sprintf("/cloud/project/%s/database/%s/%s/connectionPool",
endpoint := fmt.Sprintf("/cloud/project/%s/database/postgresql/%s/connectionPool",

no need to insert this dynamically

@julianguinard
Copy link
Contributor Author

julianguinard commented Jan 10, 2024

@amstuta style suggestions applied here
Needs re-approval

@amstuta amstuta merged commit 49e2bc4 into ovh:master Jan 10, 2024
@julianguinard julianguinard deleted the add_ovh_cloud_project_database_postgresql_connection_pool branch September 23, 2024 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants