メールを使ってAWS RDSデータベースを自動作成・削除

中級

これはDevOps, Multimodal AI分野の自動化ワークフローで、8個のノードを含みます。主にSsh, Code, Gmail, GoogleSheetsなどのノードを使用。 メールによるコマンドでTerraformでAWS RDSデータベースを作成・削除

前提条件
  • Googleアカウント + Gmail API認証情報
  • Google Sheets API認証情報
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "RkDlxaIfbpwgxyDO",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281"
  },
  "name": "Automate Create and Delete AWS RDS Databases with Email",
  "tags": [],
  "nodes": [
    {
      "id": "4d5c0f8a-53b6-4032-abda-0a9ccf35f38d",
      "name": "ワークフロー概要",
      "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": "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トリガー",
      "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": "メール内容解析",
      "type": "n8n-nodes-base.code",
      "position": [
        960,
        500
      ],
      "parameters": {},
      "typeVersion": 2
    },
    {
      "id": "f5be0da2-a40b-42a0-837d-4bcb1e4176da",
      "name": "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": "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": "確認メール送信",
      "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": "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
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

中級 - DevOps, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

関連ワークフロー

GoogleスプレッドシートからAWS EC2インスタンスを起動する
Terraformを使用してGoogleスプレッドシートからAWS EC2インスタンスを起動
Ssh
Gmail
Google Sheets
+
Ssh
Gmail
Google Sheets
8 ノードOneclick AI Squad
DevOps
AIを活用したリード生成による不動産権益メールと電話販売
Llama AI、VAPIコール、Gmailマーケティングで不動産マーケティングを自動化する
Code
Wait
Gmail
+
Code
Wait
Gmail
23 ノードOneclick AI Squad
リードナーチャリング
放射線画像から詳細なレポートへの変換ツール
GPT-4 VisionとPDFメールを使用して放射線画像を患者フレンドリーなレポートに変換
Code
Wait
Gmail
+
Code
Wait
Gmail
12 ノードOneclick AI Squad
文書抽出
Excel + AIによるスマートメールマーケティングジェネレーター(シートからインボックス)
Googleスプレッドシートを使ってLlama AIを使ってパーソナライズされたマーケティングメールを生成する
Code
Gmail
Google Sheets
+
Code
Gmail
Google Sheets
7 ノードOneclick AI Squad
ソーシャルメディア
AWS Azure GCPマルチクラウドコスト監視と予算制御アラート
AWS Azure GCPのマルチクラウドコスト監視と予算制御アラート
If
Code
Cron
+
If
Code
Cron
12 ノードOneclick AI Squad
DevOps
メール経由でAWS IAMユーザー管理
メールによるコマンドを使用したAWS IAMユーザー管理の自動化
Code
Aws Iam
Switch
+
Code
Aws Iam
Switch
13 ノードOneclick AI Squad
DevOps
ワークフロー情報
難易度
中級
ノード数8
カテゴリー2
ノードタイプ5
難易度説明

経験者向け、6-15ノードの中程度の複雑さのワークフロー

作成者
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.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34