通过邮件自动创建和删除AWS RDS数据库
这是一个DevOps, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 Ssh, Code, Gmail, GoogleSheets 等节点。 使用Terraform通过邮件命令创建和删除AWS RDS数据库
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
使用的节点 (8)
{
"id": "RkDlxaIfbpwgxyDO",
"meta": {
"instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281"
},
"name": "通过邮件自动创建和删除AWS RDS数据库",
"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数据库管理器"
},
"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": ""
},
"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`**"
},
"typeVersion": 1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "dfa9a87a-d049-4fe3-9151-954bf1d37081",
"connections": {
"Gmail Trigger": {
"main": [
[
{
"node": "Parse Email Content",
"type": "main",
"index": 0
}
]
]
},
"Manage RDS Instance": {
"main": [
[
{
"node": "Update Google Sheet",
"type": "main",
"index": 0
}
]
]
},
"Parse Email Content": {
"main": [
[
{
"node": "Manage RDS Instance",
"type": "main",
"index": 0
}
]
]
},
"Update Google Sheet": {
"main": [
[
{
"node": "Send Confirmation Email",
"type": "main",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 开发运维, 多模态 AI
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Oneclick AI Squad
@oneclick-aiThe 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.
分享此工作流