This project uses Terraform to automate the deployment of a Neo4j database instance, configured with Docker and Nginx. Bash scripts are utilized for task automation during cloud instance initialization, ensuring a seamless setup process.
.
├── cloudinit.tf # Terraform file for cloud-init configurations
├── keys # Directory to store SSH keys (not included for security reasons)
├── locals.tf # File defining local variables
├── main.tf # Main Terraform configuration file
├── outputs.tf # Outputs definitions for Terraform
├── provider.tf # Terraform provider configurations
├── README.md # Project documentation
├── scripts # Directory containing initialization and setup scripts
│ ├── docker_setup.sh # Script to install and configure Docker
│ ├── init.cfg # Configuration file for initialization
│ ├── setup_neo4j.sh # Script to install and configure Neo4j
│ ├── setup_nginx.sh # Script to install and configure Nginx
│ ├── swap_dockerdata.sh # Script to configure swap space for Docker
│ └── volumes.sh # Script to set up Docker volumes
├── security.tf # Security configurations such as security groups
├── terraform.tfstate # Terraform state file (generated by Terraform)
├── terraform.tfstate.backup # Backup of the Terraform state file
├── terraform.tfvars # File to define variable values
├── variables.tf # Terraform variable definitions
└── versions.tf # File defining provider and Terraform versions
Before deploying, ensure the following prerequisites are met:
- Terraform: Install the latest version of Terraform (installation guide).
- AWS Account: This project is designed for deployment on AWS. Ensure you have credentials set up.
- SSH Keys: Place your SSH private and public keys in the
keys
directory (or configure accordingly).
-
Clone the Repository
git clone [email protected]:anilrajrimal1/automated-neo4j-deployment.git cd neo4j-terraform
-
Configure Variables
Edit the
terraform.tfvars
file to match your environment and preferences. Example variables include:region = "ap-south-1" instance_type = "t2.medium" key_name = "Anil_Key"
-
Initialize Terraform
Run the following command to initialize the Terraform working directory:
terraform init
-
Plan the Deployment
Preview the actions Terraform will take:
terraform plan
-
Apply the Configuration
Deploy the infrastructure:
terraform apply
Confirm the prompt to proceed with the deployment.
-
Access Neo4j
Once the deployment is complete, retrieve the public IP or DNS from the Terraform output:
terraform output
Use the public address to access Neo4j via the web interface or API.
The scripts
directory contains essential scripts for instance initialization:
- docker_setup.sh: Installs and configures Docker.
- init.cfg: Contains initialization configurations.
- setup_neo4j.sh: Automates the setup and configuration of Neo4j.
- setup_nginx.sh: Sets up Nginx as a reverse proxy.
- swap_dockerdata.sh: Configures swap space and changes the DockerData default location to the directory EBS mounted.
- volumes.sh: Checks the attached EBS and mount it to /srv/Projects directory.
The security.tf
file includes configurations for security groups to control access to the instances. Ensure to review and customize these settings to match your security requirements.
Terraform manages the infrastructure state using the terraform.tfstate
file. It is essential to back up this file and avoid manual modifications.
To destroy the deployed resources and avoid incurring additional costs, run:
terraform destroy
Confirm the prompt to proceed with resource destruction.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.