Deploy pgadmin using Code Engine and connect to your Databases for PostgreSQL instance
With this tutorial, deploy pgadmin using Code Engine and connect to your Databases for PostgreSQL instance. pgadmin is a web interface that allows you to view and modify the data in your PostgreSQL database. Code Engine is a a fully managed, serverless platform that allows you to run workloads without worrying about deploying infrastructure. PostgreSQL is an open source database that has a strong reputation for its reliability, flexibility, and support of open technical standards.
Code Engine is a paid-for service, so following this tutorial will incur charges.
Before you start
Before you begin, ensure you have the following:
- An IBM Cloud Account.
- Terraform - to deploy infrastructure
- A Databases for PostgreSQL instance
Obtain an API key to deploy infrastructure to your account
Follow these steps to create an IBM Cloud API key that enables Terraform to provision infrastructure into your account. You can create up to 20 API keys.
For security reasons, the API key is only available to be copied or downloaded at the time of creation. If the API key is lost, you must create a new API key.
Clone the project
git clone https://github.com/IBM/ibm-postgresql-pgadmin-codeengine.git
Install the infrastructure
-
Navigate into the
terraform
folder of the cloned project.cd ibm-postgresql-pgadmin-codeengine/terraform
-
On your machine, create a document that is named
terraform.tfvars
, with the following fields:ibmcloud_api_key = "<your_api_key_from_step_1>" region = "<your_region>" pg_admin_username = "<username_for_pgadmin>" (has to be an email address e.g. user@domain.com) pg_admin_password = "<a_password_for_the_pgadmin_user>" pg_user = "<database_user>" pg_password = "<database_user_password" pg_host = "<host_of_your_postgres_instance>" (e.g. something.databases.appdomain.cloud) pg_port = "<instance_port>"
The
terraform.tfvars
document contains variables that you might want to keep secret. -
Install the infrastructure with the following command:
terraform init terraform apply --auto-approve
Visit your pgadmin deployment
The previous step produces a URL, which is the public URL of your pgadmin deployment. It looks something like: https://pgadmin-app.1834dcfgrtygbg.eu-gb.codeengine.appdomain.cloud
.
Visit that URL in your web browser. You should see the pgadmin login screen where you can log in with the pgadmin credentials you defined above. Once you are logged in, connect to the PostgreSQL database using the Connect to Server dialog. You need the pg_host
, pg_port
, pg_user
and pg_password
defined above. You can set the ssl mode
value in the Parameters
section to Allow
to override certificate validation (this is acceptable for testing purposes, but you may need a more secure connection for production deployments). You can now access your postgresql deployment!
This tutorial incurs some Code Engine charges. After you finish this tutorial, remove all the infrastructure by going to the terraform
directory of the project and using the command:
terraform destroy