agentleFS
carlosmscabralcarlosmscabral/cabral-skills/skills/aws-lambda-to-cloud-run-migration/SKILL.md

aws-lambda-to-cloud-run-migration

Skill1 starsChanged 4 months agoApache-2.0View on GitHub

Migrates AWS Lambda functions to Google Cloud Run. Analyzes AWS lock-ins (SNS, SQS, SDKs, IAM, Cold Starts), build/trigger mechanisms (API Gateway vs direct), and service integrations to provide a detailed migration report, containerization tips, and GCP service mapping.

The file

Show its rules and text

We split this skill into the rules it gives an agent

15 rules. About 0 are common, 7 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Before starting or when you need specific details, load the following resources into context:

    line 23
  2. Very specific:

    references/migration_guide.md: Read this for the end-to-end migration strategy and detailed step-by-step methodology.

    line 26
  3. Very specific:

    references/advanced_mapping.md: Read this when you encounter complex AWS services (beyond basic SNS/SQS) that need to be mapped to GCP …

    line 27
  4. Very specific:

    references/containerization.md: Read this for boilerplate Dockerfiles and Cloud Run constraints (e.g., port handling) across Node.js, …

    line 28
  5. Very specific:

    references/iac_translation.md: Read this for migrating AWS SAM, Serverless Framework, AWS CDK, or raw AWS Terraform (.tf) files to GCP.

    line 29
  6. Very specific:

    references/export_guide.md: Read this for strategies on exporting current AWS configurations (like CloudFormation or SAM templates) for …

    line 30
  7. Distinctive:

    If the user's environment has the following MCP servers installed, you MUST use them to gather up-to-date information during the migration:

    line 34
  8. Distinctive:

    When provided with Lambda code or configuration (e.g., SAM, CloudFormation, Serverless Framework, AWS CDK, or AWS Terraform), follow these …

    line 64
  9. Very specific:

    Identify SDK Usage: Look for boto3 (Python), aws-sdk (Node.js/Go/Java), or aws/aws-sdk-php (PHP).

    line 67
  10. Very specific:

    If the Lambda is triggered by API Gateway, Webhooks, or real-time events (Pub/Sub) → Cloud Run Service.

    line 76
  11. Distinctive:

    If the Lambda is a cron job (EventBridge scheduled), a data processing script, or an asynchronous batch task → Cloud Run Job.

    line 77
  12. Distinctive:

    Database Access: Check for DynamoDB (map to Firestore/Spanner) or RDS (map to Cloud SQL).

    line 83
  13. Distinctive:

    All migrated code must be containerized.

    line 103
  14. Very specific:

    Entry point: Ensure the application listens on 0.0.0.0:$PORT.

    line 105
  15. Distinctive:

    If information is missing, use these prompts to guide the user:

    line 109

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

AWS Lambda to Google Cloud Run Migration Skill

This skill assists in the assessment, analysis, and migration of AWS Lambda functions to Google Cloud Run, following the official Google Cloud migration framework.

When to Use This Skill

Positive Triggers

  • Migrating a single AWS Lambda function to Google Cloud Run.
  • Per-function AST analysis (analyze_lambda.py) for AWS SDK lock-ins (SNS, SQS, DynamoDB, S3).
  • Containerization (Dockerfile generation) and runtime conversion (Flask, Express, FastAPI, Go net/http, FrankenPHP).
  • Infrastructure as Code (IaC) translation (AWS SAM, Serverless Framework, CDK, or AWS .tf to GCP Terraform or gcloud scripts).

Negative Triggers (When NOT to Use)

  • Fleet discovery, multi-function monorepos (2+ Lambdas), domain consolidation strategy, or migration wave sequencing across multiple functions -> Delegate to aws-lambda-fleet-to-cloud-run.

Available Resources

Before starting or when you need specific details, load the following resources into context:

  • scripts/analyze_lambda.py: ALWAYS run this script first on the target directory (e.g., python scripts/analyze_lambda.py <target_dir>). Use the optional --output <dir> flag to control where migration_manifest.json is written (defaults to the current working directory, not the source tree). Use --summary for a human-readable terminal overview. It uses AST parsing, IaC traversal, composer.json, package.json, and requirements.txt scanning to automatically discover AWS SDK lock-ins, connection pools, and triggers, generating a migration_manifest.json file. You MUST read this JSON file immediately after running the script to understand the application's AWS footprint.
  • references/migration_guide.md: Read this for the end-to-end migration strategy and detailed step-by-step methodology.
  • references/advanced_mapping.md: Read this when you encounter complex AWS services (beyond basic SNS/SQS) that need to be mapped to GCP equivalents.
  • references/containerization.md: Read this for boilerplate Dockerfiles and Cloud Run constraints (e.g., port handling) across Node.js, Python, PHP, Java, and Go.
  • references/iac_translation.md: Read this for migrating AWS SAM, Serverless Framework, AWS CDK, or raw AWS Terraform (.tf) files to GCP. Covers two output paths: Path A (Terraform google provider) for production-grade IaC, and Path B (Cloud Build + gcloud run deploy) for scripted/CI-CD migrations.
  • references/export_guide.md: Read this for strategies on exporting current AWS configurations (like CloudFormation or SAM templates) for analysis.

Recommended External Tools

If the user's environment has the following MCP servers installed, you MUST use them to gather up-to-date information during the migration:

  • AWS Documentation Tools (mcp_aws-docs_*): Use search_documentation and read_documentation to look up precise behaviors of AWS Lambda features, API Gateway event payloads, or AWS SDK constraints.
  • Google Developer Knowledge Tools (mcp_developer-knowledge_*): Use search_documents and get_documents to find the latest official guides, API references, and best practices for Cloud Run, Eventarc, Pub/Sub, and GCP IAM.

1. Migration Framework

Phase 1: Assess & Discover

  • Inventory: Catalog all Lambda functions, triggers, and dependencies.
  • Complexity Assessment:
    • Low Complexity: Stateless, simple HTTP trigger, minimal AWS SDK usage.
    • Medium Complexity: Uses S3/SNS/SQS, VPC access, or Lambda Layers.
    • High Complexity: Part of a Step Function, custom Runtimes, or heavy AWS-specific orchestration.

Phase 2: Plan & Foundation

  • Resource Hierarchy: Define GCP Projects and Folders.
  • IAM Strategy: Map AWS IAM Roles to GCP Service Accounts.
  • Networking: Plan VPC Connectors or Direct VPC Egress for internal access.

Phase 3: Migrate & Refactor

  • Containerization: Convert code to OCI-compliant images. → ACTION: Load references/containerization.md to select the right Buildpack or Dockerfile strategy for your target language (including FrankenPHP/RoadRunner for PHP).
  • Service Mapping: Replace AWS services with GCP equivalents. → ACTION: If dealing with API Gateway, SNS, SQS, or direct invokes, load references/advanced_mapping.md for proper translation architectures.
  • Infrastructure as Code (IaC): Convert AWS deployment templates to Terraform or a scripted gcloud + Cloud Build pipeline. → ACTION: Load references/iac_translation.md if the user provides template.yaml, serverless.yml, CDK code, or AWS Terraform (.tf) files. The guide offers two GCP deployment paths: Path A (Terraform) for production repeatability, and Path B (Scripted — Cloud Build + gcloud run deploy) for fast migrations. Ask the user which they prefer before generating output.
  • Data Migration: Plan migration for RDS/DynamoDB if necessary.

Phase 4: Optimize

  • Scaling: Configure Min/Max instances and Concurrency.
  • Performance: Enable Startup CPU Boost for cold start mitigation.

2. Analysis Workflow

When provided with Lambda code or configuration (e.g., SAM, CloudFormation, Serverless Framework, AWS CDK, or AWS Terraform), follow these steps:

#1 - Lock-in Analysis

  • Identify SDK Usage: Look for boto3 (Python), aws-sdk (Node.js/Go/Java), or aws/aws-sdk-php (PHP). Highlight specific service calls. Check composer_analysis in the output manifest for Laravel, Symfony, or Slim markers.
  • Messaging Services: Identify dependencies on SNS (Simple Notification Service) or SQS (Simple Queue Service).
  • Raw API Calls vs. SDKs: Identify usage of requests, axios, guzzle, or curl to call AWS services directly. Highlight hardcoded Client IDs, Client Secrets, or API Keys.
  • Auth Strategy: Note if the code manually signs requests (SigV4) or uses basic auth. In GCP, we prioritize using GCP Client Libraries which handle authentication transparently via the attached Service Account. → ACTION: Load references/migration_guide.md if you find hardcoded secrets or raw HTTP calls that need refactoring to Workload Identity.
  • Triggers: Determine if it's an HTTP-based trigger (API Gateway, ALB) or event-driven (S3, DynamoDB Streams). For PHP, check if Bref (php-82-fpm or php-82) is used in serverless.yml.
  • Cold Start Considerations: Note memory settings and runtime version, as these impact cold start profiles.

#2 - Build and Trigger Analysis

  • Execution Paradigm (CRITICAL): You must determine if this code should be a Service or a Job.
    • If the Lambda is triggered by API Gateway, Webhooks, or real-time events (Pub/Sub) → Cloud Run Service. It must listen on $PORT.
    • If the Lambda is a cron job (EventBridge scheduled), a data processing script, or an asynchronous batch task → Cloud Run Job. It does not need a web server; it should just execute as a script and exit.
  • Port Handling (For Services): AWS Lambda doesn't listen on a port. A Cloud Run Service MUST listen on the port defined by the PORT environment variable (default 8080).

#3 - Integration & Auth Analysis

  • IAM Strategy: Map AWS IAM Execution Roles to GCP IAM Service Accounts.
  • Networking: Identify if the Lambda is in a VPC (for RDS, internal ELBs) and recommend Serverless VPC Access or Direct VPC egress on GCP.
  • Database Access: Check for DynamoDB (map to Firestore/Spanner) or RDS (map to Cloud SQL).

3. Migration Paths

Service Mapping Table

AWS ServiceGoogle Cloud EquivalentMigration Strategy
API Gateway / ALBCloud Run built-in URL / GCLBUse built-in HTTPS URL; add Global LB for WAF or multi-region.
SNSPub/Sub (Topics)Push subscriptions trigger Cloud Run URLs directly.
SQSCloud Tasks / Pub/SubUse Cloud Tasks for rate-limiting/queuing; Pub/Sub for async events.
EventBridge / CronEventarc / Cloud SchedulerUse Cloud Scheduler for cron; Eventarc for cross-service events.
IAM RoleIAM Service AccountAttach the service account to the Cloud Run service.
DynamoDBFirestore / Spanner / Cloud SQLFirestore for document-model; Spanner for relational scale; Cloud SQL for RDS migrations.
S3Cloud StorageDirect equivalent; use FUSE mount for file-system access patterns.
Lambda LayersMulti-stage Docker buildsShared libraries become Docker COPY --from base image layers.
Step FunctionsCloud WorkflowsConvert ASL (Amazon States Language) to YAML Workflows; orchestrates HTTP calls to Cloud Run.
Secrets Manager / SSMSecret ManagerMount as volume (preferred) or env var in Cloud Run.
SES (Email)SendGrid / Mailchimp (3rd party)No native GCP email service; use a transactional email provider via Cloud Run env vars.

Containerization

All migrated code must be containerized. Cloud Run requires an OCI-compliant image.

  • Language Frameworks: Convert raw Lambda handlers into web servers (e.g., Flask, Express, FastAPI, Go net/http).
  • Entry point: Ensure the application listens on 0.0.0.0:$PORT.

4. Interactive Guidance

If information is missing, use these prompts to guide the user:

  • "Could you provide the template.yaml (SAM), serverless.yml, CDK stack, or Terraform .tf files to analyze the triggers and IAM roles?" (→ ACTION: If the user doesn't know how to get these, load references/export_guide.md to help them export their AWS config).
  • "Does this Lambda require access to internal VPC resources like RDS or a private API?"
  • "Is the traffic pattern predictable (allowing for Min Instances) or highly bursty (requiring Cold Start optimization)?"
  • "For the GCP deployment: would you prefer Path A — Terraform (production-grade IaC, repeatable, state-managed) or Path B — Scripted (gcloud run deploy + Cloud Build, faster to get started)? → ACTION: Load references/iac_translation.md and present both options with trade-offs before generating any output templates."

5. Final Deliverable Structure

Your final report should include:

  1. Status Quo Analysis: Detailed breakdown of current AWS dependencies.
  2. Lock-in Highlights: Code snippets from the source that are "AWS-specific" and need refactoring.
  3. Target Architecture: A proposed GCP diagram/description.
  4. Migration Steps: Sequential steps for containerization, IAM setup, and service mapping.
  5. Code Snippets: "Before" (AWS SDK) vs "After" (GCP Client Library) examples.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.