You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- AWS [Route 53](https://aws.amazon.com/route53/) Hosted Zone (For setting up TLS) for a domain or sub-domain you control
14
+
- You must have AWS Access Keys and a default region in your Terraform environment (See section on required IAM Permissions)
15
+
- The DLE runs on an EC2 instance which can be accessed using a selected set of SSH keys uploaded to EC2. Use the Terraform parameter `aws_keypair` to specify which EC2 Keypair to use
16
+
- Required IAM Permissions: to successfully run this Terraform module, the IAM User/Role must have the following permissions:
17
+
* Read/Write permissions on EC2
18
+
* Read/Write permissions on Route53
19
+
* Read/Write permissions on Cloudwatch
20
+
21
+
## How to use
22
+
-:construction: Currently, it is supposed that you run `terraform` commands on a Linux machine. MacOS and Windows support is not yet implemented (but planned).
23
+
- It is recommended to clone this Git repository and adjust for your needs. Below we provide the detailed step-by-step instructions for quick start (see "Quick start") for a PoC setup
24
+
- To configure parameters used by Terraform (and the Database Lab Engine itself), you will need to modify `terraform.tfvars` and create a file with secrets (`secret.tfvars`)
25
+
- This Terraform module can be run independently or combined with any other standard Terraform module. You can learn more about using Terraform and the Terraform CLI [here](https://www.terraform.io/docs/cli/commands/index.html)
26
+
- The variables can be set in multiple ways with the following precedence order (lowest to highest):
27
+
- default values in `variables.tf`
28
+
- values defined in `terraform.tfvars`
29
+
- values passed on the command line
30
+
- All variables starting with `postgres_` represent the source database connection information for the data (from that database) to be fetched by the DLE. That database must be accessible from the instance hosting the DLE (that one created by Terraform)
31
+
32
+
## Quick start
33
+
The following steps were tested on Ubuntu 20.04 but supposed to be valid for other Linux distributions without significant modification.
34
+
35
+
1. SSH to any machine with internet access, it will be used as deployment machine
36
+
1. Install Terraform https://learn.hashicorp.com/tutorials/terraform/install-cli. Example for Ubuntu:
public_dns_name = "demo-api-engine.aws.postgres.ai"# todo: this should be URL, not hostname – further we'll need URL, with protocol – `https://`
107
+
```
108
+
109
+
1. To verify result and check the progress, you might want to connect to the just-created EC2 machine using IP address or hostname from the Terraform output. In our example, it can be done using this one-liner (you can find more about DLE logs and configuration on this page: https://postgres.ai/docs/how-to-guides/administration/engine-manage):
2021/07/02 10:28:51 [INFO] Server started listening on :2345.
117
+
```
118
+
– it means that the DLE server started successfully and is waiting for you commands
119
+
120
+
1. Sign in to the [Postgres.ai Platform](https://console.postgres.ai/) and register your new DLE server:
121
+
1. Go to `Database Lab > Instances`in the left menu
122
+
1. Press the "Add instance" button
123
+
1. `Project` – specify any name (this is how your DLE server will be named in the platform)
124
+
1. `Verification token` – use the token generated above (`verification_token` value);do NOT press the "Generate" button here
125
+
1. `URL` – use the value generated above // todo: not convenient, we need URL but reported was only hostname
126
+
1. Press the "Verify URL" button to check the connectivity. Then press "Add". If everything is right, you should see the DLE page with green "OK" status:
1. Add Joe chatbot for efficient SQL optimization workflow:
129
+
1. Go to the "SQL Optimization > Ask Joe" page using the left menu, click the "Add instance" button, specify the same project as you defined in the previous step
130
+
1. `Signing secret` – use `platform_joe_signing_secret` from the Terraform output
131
+
1. `URL` – use `public_dns_name` values from the Terraform output with port `444`;in our example, it's `https://demo-api-engine.aws.postgres.ai:444`
132
+
1. Press "Verify URL" to check connectivity and then press "Add". You should see:
Now you can start using Joe chatbot for SQL execution plans troubleshooting and verification of optimization ideas. As a quick test, go to `SQL Optimization > Ask Joe` in the left menu, and enter `\dt+` command (a psql command to show the list of tables with sizes). You should see how Joe created a thin clone behind the scenes and immediately ran this psql command, presenting the result to you:
1. Set up [DB migration checker](https://postgres.ai/docs/db-migration-checker). Prepare a repository with your DB migrations(Flyway, Sqitch, Liquibase, etc.):
139
+
1. Add secrets:
140
+
- `DLMC_CI_ENDPOINT` - an endpoint of your Database Lab Migration Checker service – use `vcs_db_migration_checker_registration_url` from the Terraform output
141
+
- `DLMC_VERIFICATION_TOKEN` - verification token for the Database Lab Migration Checker API – use `vcs_db_migration_checker_verification_token` from the Terraform output
142
+
1. Configure a new workflow in the created repository (see an example of configuration: https://github.com/postgres-ai/green-zone/blob/master/.github/workflows/main.yml)
143
+
- add a custom action: https://github.com/marketplace/actions/database-lab-realistic-db-testing-in-ci
144
+
- provide input params for the action (the full list of available input params)
145
+
- provide environment variables:
146
+
- `DLMC_CI_ENDPOINT` - use a CI Checker endpoint from the repository secrets
147
+
- `DLMC_VERIFICATION_TOKEN` - use a verification token from the repository secrets
148
+
149
+
1. Install and try the client CLI (`dblab`)
150
+
1. Follow the [guide](https://postgres.ai/docs/how-to-guides/cli/cli-install-init) to install Database Lab CLI
151
+
1. Initialize CLI:
152
+
```shell
153
+
dblab init --environment-id=<ANY NAME FOR ENVIRONMENT> --url=https://<public_dns_name> --token=<your_personal_token_from_postgres_ai_platform>
154
+
```
155
+
1. Try it:
156
+
```shell
157
+
dblab instance status
158
+
```
159
+
It should return the OK status:
160
+
```json
161
+
{
162
+
"status": {
163
+
"code": "OK",
164
+
"message": "Instance is ready"
165
+
},
166
+
...
167
+
}
168
+
```
169
+
170
+
This is it!
171
+
172
+
If you need to remove everything created by this Terraform module, you can simply run `terraform destroy`. Do not forget to do it if you're just experimenting. Otherwise, if you leave infrastructure blocks running, they might significantly affect your AWS bill (depending on the EC2 instance family you've chosen, the disk type, and size).
173
+
174
+
## Important Note
175
+
When the DLE creates new database clones, it makes them available on incremental ports in the 6000 range (e.g. 6000, 6001, ...). The DLE CLI will also report that the clone is available on a port in the 6000 range. However, please note that these are the ports when accessing the DLE from `localhost`. This Terraform module deploys [Envoy](https://www.envoyproxy.io/) to handle SSL termination and port forwarding to connect to DLE generated clones.
11
176
12
177
Follow the [how-to guide](https://postgres.ai/docs/how-to-guides/administration/install-database-lab-with-terraform) to install Database Lab with Terraform on AWS
0 commit comments