Skip to content
Back to skills

Beanstalk Deploy

BSecurity

Robust deployment patterns for Elastic Beanstalk with GitHub Actions, Pulumi, and edge case handling

  • 122 stars
  • 0 votes
  • 0 copies
  • 6 views
  • Added December 21, 2025
devopsawsgitdocumentation

Security analysis

B88/100
  • criticalSends environment variables or credentials to an external URL

Pro shows the line behind each finding and how to fix it

Scanned February 12, 2026

npx -y skills add pr-pm/prpm --skill beanstalk-deploy --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Beanstalk Deploy?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Beanstalk Deploy
[![Security: B β€” Skills Directory](https://www.skillsdirectory.com/api/skills/pr-pm-beanstalk-deploy/badge)](https://www.skillsdirectory.com/skills/pr-pm-beanstalk-deploy)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: beanstalk-deploy
description: "Robust deployment patterns for Elastic Beanstalk with GitHub Actions, Pulumi, and edge case handling"
---

# AWS Elastic Beanstalk Deployment Best Practices

Apply these production-tested patterns when working with Elastic Beanstalk deployments, especially with GitHub Actions and Pulumi infrastructure.

## 🎯 Core Principles

1. **Always verify infrastructure health** before deploying
2. **Never assume resources are ready** - implement retry logic
3. **Handle terminated environments** gracefully with state cleanup
4. **Use concurrency control** to prevent deployment conflicts
5. **Pre-install dependencies** for faster, more reliable deploys
6. **Implement comprehensive error handling** with fallbacks

## πŸ—οΈ Infrastructure Health Checks

**ALWAYS check infrastructure status before deploying:**

```yaml
- name: Check infrastructure status
  run: |
    echo "πŸ” Checking infrastructure status..."

    # Get environment name from Pulumi state (without deploying)
    EB_ENVIRONMENT_NAME=$(pulumi stack output ebEnvironmentName 2>/dev/null || echo "")

    if [ -z "$EB_ENVIRONMENT_NAME" ]; then
      echo "πŸ” No environment found in Pulumi state. Will deploy infrastructure..."
    else
      echo "πŸ” Checking environment status: $EB_ENVIRONMENT_NAME"

      # Check if environment exists and is healthy
      EB_ENV_STATUS=$(aws elasticbeanstalk describe-environments \
        --environment-names "$EB_ENVIRONMENT_NAME" \
        --query "Environments[0].Status" --output text 2>/dev/null || echo "NOT_FOUND")

      if [ "$EB_ENV_STATUS" = "Terminated" ] || [ "$EB_ENV_STATUS" = "NOT_FOUND" ]; then
        echo "⚠️  Environment is $EB_ENV_STATUS. Deleting from Pulumi state..."

        # Delete environment from Pulumi state
        EB_URN=$(pulumi stack --show-urns | awk '/aws:elasticbeanstalk\/environment:Environment/ {print $1; exit}')
        if [ -n "$EB_URN" ]; then
          echo "πŸ”§ Deleting: $EB_URN"
          pulumi state delete "$EB_URN" --force
        fi

        echo "πŸ”„ Infrastructure will be recreated..."
      else
        echo "βœ… Environment exists: $EB_ENV_STATUS"

        # Check if infrastructure changes needed
        if pulumi preview --diff --expect-no-changes 2>/dev/null; then
          echo "βœ… No infrastructure changes needed"
        else
          echo "πŸ”„ Infrastructure changes detected"
        fi
      fi
    fi
```

**Why**: Prevents deploying to orphaned resources, automatically recovers from terminated environments, saves money on zombie resources.

## ⏳ Beanstalk Readiness Verification

**ALWAYS wait for environment to be fully ready:**

```yaml
- name: Verify Elastic Beanstalk environment exists
  run: |
    echo "πŸ” Verifying Elastic Beanstalk environment..."
    EB_ENVIRONMENT_NAME="${{ steps.get-resources.outputs.eb_environment_name }}"

    # Wait until environment exists
    echo "⏳ Waiting for environment to exist..."
    aws elasticbeanstalk wait environment-exists \
      --environment-names "$EB_ENVIRONMENT_NAME" || true

    # Wait until environment is Ready (with 30 retries)
    for i in {1..30}; do
      ENV_STATUS=$(aws elasticbeanstalk describe-environments \
        --environment-names "$EB_ENVIRONMENT_NAME" \
        --query "Environments[0].Status" --output text 2>/dev/null || echo "NOT_FOUND")
      ENV_HEALTH=$(aws elasticbeanstalk describe-environments \
        --environment-names "$EB_ENVIRONMENT_NAME" \
        --query "Environments[0].Health" --output text 2>/dev/null || echo "UNKNOWN")

      echo "⏳ EB Status: $ENV_STATUS, Health: $ENV_HEALTH (attempt $i/30)"

      if [ "$ENV_STATUS" = "Ready" ]; then
        echo "βœ… Environment is Ready"
        break
      fi
      sleep 20  # Wait 20 seconds between checks (10 minutes total)
    done

    if [ "$ENV_STATUS" != "Ready" ]; then
      echo "⚠️  Environment not Ready after 10 minutes. Continuing with caution..."
    fi
```

**Why**: Prevents timing-related failures, ensures environment is provisioned before app deployment, provides visibility into provisioning progress.

See full documentation for complete deployment patterns, Pulumi configuration, monitoring, and production checklist.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…