| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
An API platform for automating the provisioning and setting up of a replicated PostgreSQL primary-read-replica cluster on AWS resources
Clone the Repository:
git clone git@github.com:Bh-an/chalo_assignment.git
cd chalo_assignmentCreate a virtual environment and Install dependencies:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtConfiguring the API server:
# .env file example DEBUG=True # Enable debug mode (True or False) API_PORT=5000 # Port on which the API will run HOST_ADDRESS=0.0.0.0 # Host address to bind the server to (0.0.0.0 for all interfaces) ALLOWED_HOSTS=* # Comma separated list of allowed hosts, use * to allow all TERRAFORM_BINARY=terraform # Path to the terraform binary, it must exist in your PATH OUTPUT_FORMAT=json # Format of terraform output (json)
Creating and securing the Ansible Vault
Note: It is important to configure the vault manually as it will contain our replication password
mkdir ansible/vault && touch rm -f ansible/vault/vault.yamlecho "replication_password: '<your_replication_pass>'" > ansible/vault/vault.yamlansible-vault encrypt ansible/vault/vault.yamlset vault password when prompted
export ANSIBLE_VAULT_PASSWORD=<your_vault_password>Creating and storing private key files for ec2 key-pairs Create two key pairs
Make sure you set proper file level permission for ssh usage
Start the API server
python run.py/terraform/generate (POST):
Full list of variables are available in this file; bastion_key_pair and db_key_pair are required, others will default to values in file
curl -X POST -H "Content-Type: application/json" -d '{
"bastion_key_pair": "<your_bastion_key_name>",
"db_key_pair": "<your_db_key_name>",
"environment": "staging",
"replica_count": "2",
"db_instance_type": "t2.medium"
}' http://localhost:5000/terraform/generate/terraform/init (POST):
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/terraform/init/terraform/plan (POST):
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/terraform/plan/terraform/apply (POST):
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/terraform/apply/terraform/destroy (POST):
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/terraform/destroy/terraform/output (POST): * Description: Executes terraform output to fetch terraform output values. * Request Body: Optional JSON object that takes output, where if true then STDOUT is returned. * Response:
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/terraform/output/ansible/configure (POST):
The optional variables support almost variables included in the postgresql.conf file. be aware of impact changing certain values may cause key paths should contain extension if present
curl -X POST -H "Content-Type: application/json" -d '{
"bastion_key_path": "<bastion_key_path>",
"db_key_path": "<db_key_path>",
"max_connections": "50",
"max_wal_senders": "15"
}' http://localhost:5000/ansible/configure/ansible/run (POST):
curl -X POST -H "Content-Type: application/json" -d '{"output": true}' http://localhost:5000/ansible/run| Back | FazBrowse Home | New Git URL |