Créer et supprimer automatiquement des bases de données AWS RDS par e-mail

Intermédiaire

Ceci est unDevOps, Multimodal AIworkflow d'automatisation du domainecontenant 8 nœuds.Utilise principalement des nœuds comme Ssh, Code, Gmail, GoogleSheets. Créer et supprimer des bases de données AWS RDS par e-mail avec Terraform

Prérequis
  • Compte Google et informations d'identification Gmail API
  • Informations d'identification Google Sheets API
Aperçu du workflow
Visualisation des connexions entre les nœuds, avec support du zoom et du déplacement
Exporter le workflow
Copiez la configuration JSON suivante dans n8n pour importer et utiliser ce workflow
{
  "id": "RkDlxaIfbpwgxyDO",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281"
  },
  "name": "Automate Create and Delete AWS RDS Databases with Email",
  "tags": [],
  "nodes": [
    {
      "id": "4d5c0f8a-53b6-4032-abda-0a9ccf35f38d",
      "name": "Aperçu du workflow",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1160,
        60
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 360,
        "content": "## 🚀 AWS RDS Database Manager\n\n### Features:\n• Monitors Gmail for 'Create RDS' or 'Delete RDS' email requests\n• Extracts database details from emails\n• Creates or deletes RDS instances via AWS API using Terraform\n• Updates status in Google Sheets\n• Sends confirmation emails\n• Error handling with notifications\n• Triggered by email arrival\n\n### Trigger: Gmail email receipt"
      },
      "typeVersion": 1
    },
    {
      "id": "56cf5386-1289-4749-97de-cb854afb1c3c",
      "name": "Variables Terraform",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        120
      ],
      "parameters": {
        "color": 6,
        "width": 460,
        "height": 260,
        "content": "\n### **`terraform.tfvars`** (example values)\n\n```hcl\naws_region       = \"us-east-1\"\ndb_identifier    = \"my-rds-instance\"\ndb_engine        = \"mysql\"\ninstance_class   = \"db.t3.micro\"\nallocated_storage = 20\ndb_username      = \"admin\"\ndb_password      = \"securepassword123\"\ndb_name          = \"MyRDSDatabase\"\n```\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "397dce95-bdb4-4570-90a5-41b58cd2071d",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmail",
      "position": [
        740,
        500
      ],
      "webhookId": "6df043bb-0aec-43ce-9e9f-9e0078699b58",
      "parameters": {
        "operation": "trigger"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PcTqvGU9uCunfltE",
          "name": "Gmail account - test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "b904b90e-6495-4c19-a28b-afc37b3e0c1a",
      "name": "Analyser le contenu de l'e-mail",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        500
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "f5be0da2-a40b-42a0-837d-4bcb1e4176da",
      "name": "Gérer l'instance RDS",
      "type": "n8n-nodes-base.ssh",
      "position": [
        1180,
        500
      ],
      "parameters": {
        "command": "=$json.operation === 'create' ?\n`# Variables\nSERVER_USER=\"{{ $json.server_user }}\"\nSERVER_IP=\"{{ $json.server_ip }}\"\nWORKSPACE_NAME=\"{{ $json.db_identifier }}\"\nPWD=\"{{ $json.pwd }}\"\n\n# SSH and run Terraform commands\necho \"$PWD\" | ssh ${SERVER_USER}@${SERVER_IP} \"\n    cd /path/to/terraform/project &&\n    terraform workspace new ${WORKSPACE_NAME} || terraform workspace select ${WORKSPACE_NAME} &&\n    terraform init &&\n    terraform plan -out=tfplan &&\n    terraform apply -auto-approve tfplan\n\"` :\n`# Variables\nSERVER_USER=\"{{ $json.server_user }}\"\nSERVER_IP=\"{{ $json.server_ip }}\"\nWORKSPACE_NAME=\"{{ $json.db_identifier }}\"\nPWD=\"{{ $json.pwd }}\"\n\n# SSH and run Terraform destroy\necho \"$PWD\" | ssh ${SERVER_USER}@${SERVER_IP} \"\n    cd /path/to/terraform/project &&\n    terraform workspace select ${WORKSPACE_NAME} &&\n    terraform destroy -auto-approve\n\"`",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "id": "ilPh8oO4GfSlc0Qy",
          "name": "SSH Password account - test "
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2ca5d24d-3476-44db-a935-b359eef7d5f7",
      "name": "Mettre à jour la feuille Google",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1400,
        500
      ],
      "parameters": {
        "columns": {
          "value": {
            "region": "={{ $json.region }}",
            "db_name": "={{ $json.db_name }}",
            "endpoint": "={{ $json.endpoint || 'N/A' }}",
            "db_engine": "={{ $json.db_engine }}",
            "operation": "={{ $json.operation }}",
            "timestamp": "={{ $now.toISO() }}",
            "db_identifier": "={{ $json.db_identifier }}",
            "instance_class": "={{ $json.instance_class }}",
            "requester_email": "={{ $json.requester_email }}",
            "operation_status": "={{ $json.operation_status || 'Completed' }}",
            "allocated_storage": "={{ $json.allocated_storage }}"
          },
          "schema": [
            {
              "id": "timestamp",
              "type": "string",
              "displayName": "Timestamp",
              "canBeUsedToMatch": true
            },
            {
              "id": "operation",
              "type": "string",
              "displayName": "Operation",
              "canBeUsedToMatch": true
            },
            {
              "id": "db_identifier",
              "type": "string",
              "displayName": "DB Identifier",
              "canBeUsedToMatch": true
            },
            {
              "id": "db_name",
              "type": "string",
              "displayName": "DB Name",
              "canBeUsedToMatch": true
            },
            {
              "id": "db_engine",
              "type": "string",
              "displayName": "DB Engine",
              "canBeUsedToMatch": true
            },
            {
              "id": "instance_class",
              "type": "string",
              "displayName": "Instance Class",
              "canBeUsedToMatch": true
            },
            {
              "id": "allocated_storage",
              "type": "number",
              "displayName": "Allocated Storage",
              "canBeUsedToMatch": true
            },
            {
              "id": "region",
              "type": "string",
              "displayName": "Region",
              "canBeUsedToMatch": true
            },
            {
              "id": "endpoint",
              "type": "string",
              "displayName": "Endpoint",
              "canBeUsedToMatch": true
            },
            {
              "id": "operation_status",
              "type": "string",
              "displayName": "Operation Status",
              "canBeUsedToMatch": true
            },
            {
              "id": "requester_email",
              "type": "string",
              "displayName": "Requester Email",
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "RDS_Operations",
          "cachedResultName": "RDS Operations"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_RDS_SHEET_ID",
          "cachedResultName": "RDS Operations"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "2948754e-620d-457f-80fc-8568a27782f2",
      "name": "Envoyer un e-mail de confirmation",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1620,
        500
      ],
      "webhookId": "deecfd5d-f72b-41dc-abe9-2de86022cfcd",
      "parameters": {
        "sendTo": "={{ $json.requester_email }}",
        "message": "=$json.operation === 'create' ?\n`<h2>🚀 RDS Database Creation Confirmation</h2><br><br><strong>Great news!</strong> Your RDS database has been created successfully.<br><br><div style=\"background-color: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #28a745;\"><h3>📋 Database Details</h3><p><strong>DB Name:</strong> {{ $json.db_name }}<br><strong>DB Identifier:</strong> <code>{{ $json.db_identifier }}</code><br><strong>DB Engine:</strong> {{ $json.db_engine }}<br><strong>Instance Class:</strong> {{ $json.instance_class }}<br><strong>Allocated Storage:</strong> {{ $json.allocated_storage }} GB<br><strong>Region:</strong> {{ $json.region }}<br><strong>Endpoint:</strong> {{ $json.endpoint || 'Not available yet' }}</p></div><br><div style=\"background-color: #ffebee; padding: 15px; border-radius: 8px; border: 1px solid #f44336;\"><h4>⚠️ Important Notes</h4><ul><li>It may take a few minutes for the database to be fully available</li><li>Secure your credentials: <code>{{ $json.db_username }}/{{ $json.db_password }}</code></li><li>Remember to delete the database when no longer needed to avoid charges</li></ul></div><br><h3>🔗 AWS Console Link</h3><p><a href=\"https://{{ $json.region }}.console.aws.amazon.com/rds/home?region={{ $json.region }}#database:id={{ $json.db_identifier }}\" style=\"background-color: #007bff; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px;\">View in AWS Console</a></p><br><p>If you have any questions, please contact the infrastructure team.</p><br><p><em>This database was created automatically via n8n workflow.</em></p>` :\n`<h2>🗑️ RDS Database Deletion Confirmation</h2><br><br><strong>Success!</strong> Your RDS database has been deleted.<br><br><div style=\"background-color: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #dc3545;\"><h3>📋 Database Details</h3><p><strong>DB Name:</strong> {{ $json.db_name }}<br><strong>DB Identifier:</strong> <code>{{ $json.db_identifier }}</code><br><strong>Region:</strong> {{ $json.region }}</p></div><br><p>If you have any questions, please contact the infrastructure team.</p><br><p><em>This database was deleted automatically via n8n workflow.</em></p>`",
        "options": {
          "ccList": "infrastructure@company.com"
        },
        "subject": "={{ $json.operation === 'create' ? '✅ AWS RDS Database Created Successfully - ' + $json.db_name : '🗑️ AWS RDS Database Deleted Successfully - ' + $json.db_name }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PcTqvGU9uCunfltE",
          "name": "Gmail account - test"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "54738eab-47eb-4177-bd57-713c80d9e465",
      "name": "Configuration Terraform",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -60,
        0
      ],
      "parameters": {
        "color": 3,
        "width": 640,
        "height": 1480,
        "content": "### **`main.tf`**\n\n```hcl\n# Configure AWS provider\nprovider \"aws\" {\n  region  = var.aws_region\n  profile = var.aws_profile\n}\n\n# Create RDS instance\nresource \"aws_db_instance\" \"example\" {\n  identifier           = var.db_identifier\n  engine               = var.db_engine\n  instance_class       = var.instance_class\n  allocated_storage    = var.allocated_storage\n  username             = var.db_username\n  password             = var.db_password\n  skip_final_snapshot  = true\n\n  tags = {\n    Name = var.db_name\n  }\n}\n\n# Output RDS endpoint\noutput \"rds_endpoint\" {\n  value = aws_db_instance.example.endpoint\n}\n```\n\n---\n\n### **`variables.tf`**\n\n```hcl\nvariable \"aws_region\" {\n  description = \"AWS region to deploy in\"\n  type        = string\n}\n\nvariable \"aws_profile\" {\n  description = \"AWS CLI profile to use\"\n  type        = string\n  default     = \"default\"\n}\n\nvariable \"db_identifier\" {\n  description = \"RDS database identifier\"\n  type        = string\n}\n\nvariable \"db_engine\" {\n  description = \"Database engine (e.g., mysql, postgres)\"\n  type        = string\n}\n\nvariable \"instance_class\" {\n  description = \"RDS instance class\"\n  type        = string\n  default     = \"db.t3.micro\"\n}\n\nvariable \"allocated_storage\" {\n  description = \"Storage size in GB\"\n  type        = number\n  default     = 20\n}\n\nvariable \"db_username\" {\n  description = \"Database admin username\"\n  type        = string\n}\n\nvariable \"db_password\" {\n  description = \"Database admin password\"\n  type        = string\n  sensitive   = true\n}\n\nvariable \"db_name\" {\n  description = \"RDS database Name tag\"\n  type        = string\n}\n```\n\n---\n\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "dfa9a87a-d049-4fe3-9151-954bf1d37081",
  "connections": {
    "397dce95-bdb4-4570-90a5-41b58cd2071d": {
      "main": [
        [
          {
            "node": "b904b90e-6495-4c19-a28b-afc37b3e0c1a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f5be0da2-a40b-42a0-837d-4bcb1e4176da": {
      "main": [
        [
          {
            "node": "2ca5d24d-3476-44db-a935-b359eef7d5f7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b904b90e-6495-4c19-a28b-afc37b3e0c1a": {
      "main": [
        [
          {
            "node": "f5be0da2-a40b-42a0-837d-4bcb1e4176da",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2ca5d24d-3476-44db-a935-b359eef7d5f7": {
      "main": [
        [
          {
            "node": "2948754e-620d-457f-80fc-8568a27782f2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Foire aux questions

Comment utiliser ce workflow ?

Copiez le code de configuration JSON ci-dessus, créez un nouveau workflow dans votre instance n8n et sélectionnez "Importer depuis le JSON", collez la configuration et modifiez les paramètres d'authentification selon vos besoins.

Dans quelles scénarios ce workflow est-il adapté ?

Intermédiaire - DevOps, IA Multimodale

Est-ce payant ?

Ce workflow est entièrement gratuit et peut être utilisé directement. Veuillez noter que les services tiers utilisés dans le workflow (comme l'API OpenAI) peuvent nécessiter un paiement de votre part.

Informations sur le workflow
Niveau de difficulté
Intermédiaire
Nombre de nœuds8
Catégorie2
Types de nœuds5
Description de la difficulté

Adapté aux utilisateurs expérimentés, avec des workflows de complexité moyenne contenant 6-15 nœuds

Auteur
Oneclick AI Squad

Oneclick AI Squad

@oneclick-ai

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

Liens externes
Voir sur n8n.io

Partager ce workflow

Catégories

Catégories: 34