Skip to content

anilrajrimal1/automated-neo4j-deployment

Repository files navigation

Neo4j Terraform Deployment

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.

Project Structure

.
├── 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

Prerequisites

Before deploying, ensure the following prerequisites are met:

  1. Terraform: Install the latest version of Terraform (installation guide).
  2. AWS Account: This project is designed for deployment on AWS. Ensure you have credentials set up.
  3. SSH Keys: Place your SSH private and public keys in the keys directory (or configure accordingly).

Setup and Deployment

  1. Clone the Repository

    git clone [email protected]:anilrajrimal1/automated-neo4j-deployment.git
    cd neo4j-terraform
  2. 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"
  3. Initialize Terraform

    Run the following command to initialize the Terraform working directory:

    terraform init
  4. Plan the Deployment

    Preview the actions Terraform will take:

    terraform plan
  5. Apply the Configuration

    Deploy the infrastructure:

    terraform apply

    Confirm the prompt to proceed with the deployment.

  6. 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.

Scripts

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.

Security

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.

State Management

Terraform manages the infrastructure state using the terraform.tfstate file. It is essential to back up this file and avoid manual modifications.

Clean-Up

To destroy the deployed resources and avoid incurring additional costs, run:

terraform destroy

Confirm the prompt to proceed with resource destruction.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributions

Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes.

About

Fully automated deployment of neo4j using terraform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published