Iniciar instancia de AWS EC2 desde Google Sheets

Intermedio

Este es unDevOps, Multimodal AIflujo de automatización del dominio deautomatización que contiene 8 nodos.Utiliza principalmente nodos como Ssh, Gmail, GoogleSheets, ScheduleTrigger. Iniciar instancias de AWS EC2 desde Hojas de Google con Terraform

Requisitos previos
  • Cuenta de Google y credenciales de API de Gmail
  • Credenciales de API de Google Sheets
Vista previa del flujo de trabajo
Visualización de las conexiones entre nodos, con soporte para zoom y panorámica
Exportar flujo de trabajo
Copie la siguiente configuración JSON en n8n para importar y usar este flujo de trabajo
{
  "id": "5T0q54z7XbP4rDKb",
  "meta": {
    "instanceId": "dd69efaf8212c74ad206700d104739d3329588a6f3f8381a46a481f34c9cc281",
    "templateCredsSetupCompleted": true
  },
  "name": "Launch AWS EC2 Instances from Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "7b6273c0-bbfc-4f5d-aecb-288b154300cc",
      "name": "Resumen del Flujo de Trabajo",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        920,
        -860
      ],
      "parameters": {
        "width": 420,
        "height": 300,
        "content": "## 🚀 AWS EC2 Auto Launcher\n\n### Features:\n• Reads launch requests from Google Sheets\n• Launches EC2 instances via AWS API\n• Updates status in spreadsheet\n• Sends detailed confirmation emails\n• Error handling with notifications\n• Scheduled or manual execution\n\n### Triggers: Daily at 9 AM or Manual"
      },
      "typeVersion": 1
    },
    {
      "id": "b6c7b146-2815-4669-bdf0-f0cad7b7a0d7",
      "name": "Nota Adhesiva",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        -980
      ],
      "parameters": {
        "color": 5,
        "width": 580,
        "height": 1140,
        "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 EC2 instance\nresource \"aws_instance\" \"example\" {\n  ami           = var.ami_id\n  instance_type = var.instance_type\n  key_name      = var.key_name\n\n  tags = {\n    Name = var.instance_name\n  }\n}\n\n# Output EC2 public IP\noutput \"ec2_public_ip\" {\n  value = aws_instance.example.public_ip\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 \"ami_id\" {\n  description = \"AMI ID for EC2 instance\"\n  type        = string\n}\n\nvariable \"instance_type\" {\n  description = \"EC2 instance type\"\n  type        = string\n  default     = \"t2.micro\"\n}\n\nvariable \"key_name\" {\n  description = \"SSH key pair name\"\n  type        = string\n}\n\nvariable \"instance_name\" {\n  description = \"EC2 instance Name tag\"\n  type        = string\n}\n```\n\n---\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "70087b97-5a6c-4a47-9c28-906f731d97ae",
      "name": "Nota Adhesiva1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        380,
        -860
      ],
      "parameters": {
        "color": 3,
        "width": 460,
        "height": 220,
        "content": "\n### **`terraform.tfvars`** (example values)\n\n```hcl\naws_region     = \"us-east-1\"\nami_id         = \"ami-0c55b159cbfafe1f0\"\ninstance_type  = \"t2.micro\"\nkey_name       = \"my-keypair\"\ninstance_name  = \"MyTerraformEC2\"\n```\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "55d7ea64-2ad7-4359-ba3c-0a589d29ce9c",
      "name": "Google Sheets Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        500,
        -480
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 10
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ef286e0d-08f4-429c-b701-448406fb950d",
      "name": "Extraer Detalles de la Instancia",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        720,
        -480
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "Launch_Requests",
          "cachedResultName": "Launch Requests"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_EC2_SHEET_ID",
          "cachedResultName": "EC2 Launch Requests"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "b74895b0-b01a-4675-9af0-8cd256016576",
      "name": "Iniciar Instancia EC2",
      "type": "n8n-nodes-base.ssh",
      "position": [
        940,
        -480
      ],
      "parameters": {
        "command": "=# Variables\nSERVER_USER=\"{{ $json.server_user }}\"\nSERVER_IP=\"{{ $json.server_ip }}\"\nWORKSPACE_NAME=\"{{ $json.workspace_name }}\"\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\"",
        "authentication": "privateKey"
      },
      "credentials": {
        "sshPrivateKey": {
          "id": "ilPh8oO4GfSlc0Qy",
          "name": "SSH Password account - test "
        }
      },
      "typeVersion": 1
    },
    {
      "id": "ee365181-a63b-4216-990b-ac2c5d721ea8",
      "name": "Actualizar Hoja Google",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1160,
        -480
      ],
      "parameters": {
        "columns": {
          "value": {
            "ami_id": "={{ $json.ami_id }}",
            "region": "={{ $json.region }}",
            "key_pair": "={{ $json.key_pair }}",
            "public_ip": "={{ $json.public_ip }}",
            "timestamp": "={{ $now.toISO() }}",
            "private_ip": "={{ $json.private_ip }}",
            "instance_id": "={{ $json.instance_id }}",
            "project_name": "={{ $json.project_name }}",
            "instance_name": "={{ $json.instance_name }}",
            "instance_type": "={{ $json.instance_type }}",
            "launch_status": "={{ $json.launch_status }}",
            "instance_state": "={{ $json.instance_state }}",
            "reservation_id": "={{ $json.reservation_id }}",
            "security_group": "={{ $json.security_group }}",
            "requester_email": "={{ $json.requester_email }}",
            "availability_zone": "={{ $json.availability_zone }}"
          },
          "schema": [
            {
              "id": "timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Launch Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "instance_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Instance Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "instance_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Instance ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "instance_type",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Instance Type",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "ami_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AMI ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "region",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Region",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "availability_zone",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Availability Zone",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "private_ip",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Private IP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "public_ip",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Public IP",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "instance_state",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Instance State",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "key_pair",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Key Pair",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "security_group",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Security Group",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "project_name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Project Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "requester_email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Requester Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "launch_status",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Launch Status",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "reservation_id",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Reservation ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "Launched_Instances",
          "cachedResultName": "Launched Instances"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "YOUR_EC2_SHEET_ID",
          "cachedResultName": "EC2 Launch Requests"
        },
        "authentication": "serviceAccount"
      },
      "credentials": {
        "googleApi": {
          "id": "ScSS2KxGQULuPtdy",
          "name": "Google Sheets- test"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "61b4af75-72fd-4da6-a2ca-e3e9a16d928e",
      "name": "Enviar Correo de Confirmación",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1380,
        -480
      ],
      "webhookId": "949ecb7a-7e69-4348-adae-6299098bd08c",
      "parameters": {
        "sendTo": "={{ $json.requester_email }}",
        "message": "=<h2>🚀 EC2 Instance Launch Confirmation</h2><br><br><strong>Great news!</strong> Your EC2 instance has been launched successfully.<br><br><div style=\"background-color: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #28a745;\"><h3>📋 Instance Details</h3><p><strong>Instance Name:</strong> {{ $json.instance_name }}<br><strong>Instance ID:</strong> <code>{{ $json.instance_id }}</code><br><strong>Instance Type:</strong> {{ $json.instance_type }}<br><strong>AMI ID:</strong> {{ $json.ami_id }}<br><strong>Region:</strong> {{ $json.region }}<br><strong>Availability Zone:</strong> {{ $json.availability_zone }}<br><strong>Current State:</strong> {{ $json.instance_state }}<br><strong>Key Pair:</strong> {{ $json.key_pair }}<br><strong>Security Group:</strong> {{ $json.security_group }}</p></div><br><div style=\"background-color: #e3f2fd; padding: 20px; border-radius: 8px; border-left: 4px solid #2196f3;\"><h3>🌐 Network Information</h3><p><strong>Private IP:</strong> {{ $json.private_ip }}<br><strong>Public IP:</strong> {{ $json.public_ip || 'Not assigned yet' }}</p></div><br><div style=\"background-color: #fff3e0; padding: 20px; border-radius: 8px; border-left: 4px solid #ff9800;\"><h3>📊 Additional Info</h3><p><strong>Launch Time:</strong> {{ $json.launch_time_aws }}<br><strong>Project:</strong> {{ $json.project_name }}<br><strong>Reservation ID:</strong> {{ $json.reservation_id }}<br><strong>Platform:</strong> {{ $json.platform }}<br><strong>Architecture:</strong> {{ $json.architecture }}</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 instance to be fully available</li><li>Public IP will be assigned once the instance is running</li><li>Remember to terminate the instance when no longer needed to avoid charges</li><li>You can connect using your key pair: <code>{{ $json.key_pair }}</code></li></ul></div><br><h3>🔗 AWS Console Link</h3><p><a href=\"https://{{ $json.region }}.console.aws.amazon.com/ec2/v2/home?region={{ $json.region }}#InstanceDetails:instanceId={{ $json.instance_id }}\" 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 or need assistance, please contact the infrastructure team.</p><br><p><em>This instance was launched automatically via n8n workflow.</em></p>",
        "options": {
          "ccList": "infrastructure@company.com"
        },
        "subject": "✅ AWS EC2 Instance Launched Successfully - {{ $json.instance_name }}"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "PcTqvGU9uCunfltE",
          "name": "Gmail account - test"
        }
      },
      "typeVersion": 2.1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "843e8aef-5fe8-413e-9a16-7c42b7575f7f",
  "connections": {
    "b74895b0-b01a-4675-9af0-8cd256016576": {
      "main": [
        [
          {
            "node": "ee365181-a63b-4216-990b-ac2c5d721ea8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ee365181-a63b-4216-990b-ac2c5d721ea8": {
      "main": [
        [
          {
            "node": "61b4af75-72fd-4da6-a2ca-e3e9a16d928e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "55d7ea64-2ad7-4359-ba3c-0a589d29ce9c": {
      "main": [
        [
          {
            "node": "ef286e0d-08f4-429c-b701-448406fb950d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ef286e0d-08f4-429c-b701-448406fb950d": {
      "main": [
        [
          {
            "node": "b74895b0-b01a-4675-9af0-8cd256016576",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
Preguntas frecuentes

¿Cómo usar este flujo de trabajo?

Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.

¿En qué escenarios es adecuado este flujo de trabajo?

Intermedio - DevOps, IA Multimodal

¿Es de pago?

Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.

Información del flujo de trabajo
Nivel de dificultad
Intermedio
Número de nodos8
Categoría2
Tipos de nodos5
Descripción de la dificultad

Adecuado para usuarios con experiencia intermedia, flujos de trabajo de complejidad media con 6-15 nodos

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

Enlaces externos
Ver en n8n.io

Compartir este flujo de trabajo

Categorías

Categorías: 34