This repository contains an automated deployment system for n8n with workflow import capabilities. Deploy n8n on Azure or AWS with a single command, including automatic workflow import!
n8n is a workflow automation platform that helps you connect different apps and services together. Think of it like Zapier or Make.com, but:
- β Self-hosted (you own your data)
- β Free (no monthly subscription fees)
- β More powerful (custom code, complex logic)
- β Privacy-focused (everything runs on your servers)
Example: Automatically save Gmail attachments to Google Drive, send Slack notifications when someone fills out a form, or sync data between different databases.
This project automatically deploys n8n to the cloud with just one command!
Perfect for:
- π’ Businesses wanting to automate workflows
- π¨βπ» Developers building automation solutions
- π Teams migrating from Zapier/Make.com
- π Anyone needing workflow automation with custom hosting
- π One-Command Deployment: Deploy complete n8n infrastructure with a single command
- π Automatic Workflow Import: Import all your workflows automatically during deployment
- βοΈ Multi-Cloud Support: Deploy on Azure Virtual Machines or AWS EC2 instances
- π SSL Certificates: Automatic SSL certificate generation with Let's Encrypt
- π Comprehensive Monitoring: Built-in logging and status monitoring
- π‘οΈ Security Best Practices: Secure configurations and network access controls
techdome-n8n/
βββ deploy.sh # π Main deployment script (all-in-one)
βββ import_workflows.py # π₯ Workflow import script
βββ workflows/ # π Place your workflow files here
β βββ 0001_Telegram_Schedule_Automation_Scheduled.json
β βββ 0002_Manual_Totp_Automation_Triggered.json
β βββ ... (your workflow files)
βββ environments/ # π Environment configurations
β βββ dev/ # Development environment
β β βββ azure/ # Azure development settings
β β βββ aws/ # AWS development settings
β βββ prod/ # Production environment
β βββ azure/ # Azure production settings
β βββ aws/ # AWS production settings
βββ modules/ # π§ Reusable Terraform modules
βββ n8n/ # Common n8n configuration
βββ azure-vm/ # Azure VM infrastructure
βββ aws-ec2/ # AWS EC2 infrastructure
-
Azure CLI: Install and configure Azure CLI
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash az login -
Service Principal: Create a service principal with Contributor role
az ad sp create-for-rbac --name "terraform-sp" --role="Contributor" --scopes="/subscriptions/YOUR_SUBSCRIPTION_ID"
-
SSH Key Pair: Generate SSH key pair for VM access
ssh-keygen -t rsa -b 4096 -f ~/.ssh/azure_n8n_key
-
AWS CLI: Install and configure AWS CLI
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install aws configure
-
IAM User: Create IAM user with appropriate permissions
- EC2 Full Access
- VPC Full Access
- CloudWatch Full Access
-
Key Pair: Create EC2 key pair
aws ec2 create-key-pair --key-name n8n-dev-key --query 'KeyMaterial' --output text > ~/.ssh/n8n-dev-key.pem chmod 400 ~/.ssh/n8n-dev-key.pem
Place your n8n workflow JSON files in the workflows/ directory:
# Copy your workflow files to the workflows directory
cp my-workflow.json workflows/# Deploy n8n with automatic workflow import
./deploy.shThat's it! The script will guide you through the deployment process with simple questions.
When you run ./deploy.sh, you'll be asked these simple questions:
Available cloud providers:
1. Azure (Azure Virtual Machines)
2. AWS (Amazon EC2)
Select cloud provider (1 for Azure, 2 for AWS): 1
What to choose:
- Choose 1 for Azure if you want to deploy on Microsoft Azure
- Choose 2 for AWS if you want to deploy on Amazon Web Services
Available environments:
1. Development (dev) - Smaller instances, basic storage
2. Production (prod) - Larger instances, premium storage, restricted access
Select environment (1 for dev, 2 for prod): 1
What to choose:
- Choose 1 for development/testing (cheaper, smaller resources)
- Choose 2 for production use (more powerful, more expensive)
Enter your domain name (e.g., example.com): yourdomain.com
What to enter: Your domain name (e.g., techdome.ai, mycompany.com)
Enter subdomain for n8n (default: n8n): dev-n8n
What to enter: A subdomain for your n8n instance (e.g., n8n, dev-n8n, workflows)
Final URL will be: https://dev-n8n.yourdomain.com
Enter your email for SSL certificate (e.g., admin@example.com): admin@yourdomain.com
What to enter: Your email address for Let's Encrypt SSL certificate notifications
Enter timezone (default: Asia/Kolkata): Asia/Kolkata
What to enter: Your timezone (e.g., America/New_York, Europe/London, Asia/Tokyo)
Do you have an SSH key pair ready? (y/N): n
What to choose:
- Choose y if you already have an SSH key pair
- Choose n to generate a new SSH key pair automatically
Available actions:
1. Plan - Show what will be created/changed (safe, no changes made)
2. Apply - Create/update the infrastructure
3. Destroy - Remove all created infrastructure
Select action (1 for plan, 2 for apply, 3 for destroy): 2
What to choose:
- Choose 1 to see what will be created (preview only)
- Choose 2 to actually deploy n8n
- Choose 3 to remove/destroy existing deployment
Do you want to proceed with the current configuration? (y/N): y
What to choose: Type y to start the deployment
The deployment process automatically:
-
ποΈ Creates Infrastructure (~5-8 minutes)
- Virtual Machine/Instance
- Network security groups
- Storage accounts
- Public IP address
-
π³ Installs n8n (~3-5 minutes)
- Docker and Docker Compose
- n8n with PostgreSQL database
- Traefik reverse proxy
- SSL certificate setup
-
π₯ Imports Workflows (~30 seconds)
- Copies workflow files to the server
- Imports each workflow into n8n
- Shows import status for each file
-
β Completes Deployment
- Provides access URLs
- Shows SSH connection details
- Displays next steps
π Starting import of 5 workflows...
============================================================
[1/5] Processing: 0001_Telegram_Schedule_Automation_Scheduled.json
β
Imported: 0001_Telegram_Schedule_Automation_Scheduled.json
[2/5] Processing: 0002_Manual_Totp_Automation_Triggered.json
β
Imported: 0002_Manual_Totp_Automation_Triggered.json
...
π Import Summary:
β
Successfully imported: 5
β Failed imports: 0
π Total files processed: 5
π All workflows imported successfully!
After deployment, you'll see output like:
π n8n URL: https://dev-n8n.yourdomain.com
π₯οΈ VM IP: 172.191.57.45
What to do:
- Log into your domain registrar (GoDaddy, Cloudflare, etc.)
- Add an A record:
dev-n8nβ172.191.57.45 - Wait 5-10 minutes for DNS to propagate
- URL:
https://dev-n8n.yourdomain.com(SSL certificate is automatic!) - First Time: You'll be prompted to create an admin account
- Workflows: Your imported workflows will be available immediately
- β n8n web interface loads
- β All imported workflows are visible
- β SSL certificate is active (green lock icon)
- β Database is working (create a test workflow)
SSH into your server to check logs:
# Connect to your server
ssh azureuser@172.191.57.45 # (use your actual IP)
# Check if all services are running
cd /opt/n8n
sudo docker compose ps
# View n8n logs
sudo docker compose logs -f n8n- Development: Uses smaller instance sizes and less restrictive security settings
- Production: Uses larger instances, premium storage (Azure), and restrictive security groups
- n8n Module: Modify
modules/n8n/user-data.shto change the deployment script - Azure Module: Modify
modules/azure-vm/main.tfto change Azure-specific settings - AWS Module: Modify
modules/aws-ec2/main.tfto change AWS-specific settings
- Create new environment directory (e.g.,
terraform/environments/staging/azure) - Copy and modify configuration files from existing environments
- Update terraform.tfvars with environment-specific values
- SSH Access: Restrict SSH access to specific IP addresses
- Database Password: Use strong, unique passwords for each environment
- Network Security: Configure appropriate security groups/NSGs
- SSL/TLS: Let's Encrypt certificates are automatically configured
- Regular Updates: Keep the n8n Docker image updated
Problem: You deployed successfully but can't access https://dev-n8n.yourdomain.com
Solutions:
- Check DNS: Make sure you added the A record correctly
- Wait for DNS: DNS can take 5-30 minutes to propagate
- Check IP: Verify you're using the correct public IP from deployment output
- Try HTTP: Temporarily try
http://dev-n8n.yourdomain.com(will redirect to HTTPS)
Problem: Browser shows "Not Secure" or certificate warnings
Solutions:
- Wait: SSL certificates take 2-5 minutes to generate after DNS propagates
- Check DNS: Ensure DNS is pointing to the correct server
- Restart Services: SSH to server and run
sudo docker compose restart traefik
Problem: The deployment script shows errors
Solutions:
- Check Prerequisites: Ensure Azure CLI or AWS CLI is installed and configured
- Check Permissions: Verify your account has permission to create resources
- Try Again: Sometimes cloud providers have temporary issues, try running
./deploy.shagain - Check Logs: Look at the error messages for specific guidance
Problem: Can't SSH to the server
Solutions:
- Wait: Server might still be starting up (wait 2-3 minutes)
- Check IP: Use the correct public IP from deployment output
- Check Key: Ensure you're using the correct SSH key path
- Network: Check if your IP is allowed in security groups
Problem: Workflows didn't import during deployment
Solutions:
- Check Files: Ensure workflow files are valid JSON in the
workflows/directory - Manual Import: SSH to server and run
python3 ~/import_workflows.py - Check Logs: Look for import errors in the deployment output
- Verify Format: Ensure workflow files have required fields (name, id, nodes, connections)
If you're still having issues:
-
Check Logs: SSH to your server and run:
cd /opt/n8n sudo docker compose logs -f -
Check Status: Verify all services are running:
sudo docker compose ps
-
Restart Services: Try restarting everything:
sudo docker compose restart
To remove your n8n deployment and clean up all resources:
# Run the deployment script and select "destroy"
./deploy.shWhen prompted, select:
- Your cloud provider (Azure/AWS)
- Your environment (dev/prod)
- Action: Choose 3 (Destroy)
This will safely remove all created resources including:
- Virtual machines/instances
- Storage accounts
- Network security groups
- Public IP addresses
- All associated resources
- Follow the existing module structure
- Update documentation for any changes
- Test changes in development environment before production
- Use appropriate variable validation and descriptions
This project is licensed under the MIT License.