AgentSkillsCN

deploy

当用户想要将代码部署到Elastic Beanstalk时,可使用“部署”“推送到EB”“EB部署”“发布”“回滚”“恢复”“部署到生产环境”“CI/CD”“创建版本”“.ebignore”“部署策略”“EB代码源”“CodeCommit”“EB本地”“在本地测试”或“在本地运行”等指令。若要创建环境,请使用环境技能;若要部署后查看日志,请使用日志技能。

SKILL.md
--- frontmatter
name: deploy
description: This skill should be used when the user wants to deploy code to Elastic Beanstalk, says "deploy", "push to EB", "eb deploy", "release", "rollback", "revert", "deploy to production", "CI/CD", "create version", ".ebignore", "deployment strategy", "eb codesource", "CodeCommit", "eb local", "test locally", or "run locally". For environment creation use environment skill. For logs after deploy use logs skill.

Deploy to Elastic Beanstalk

Deploy application code, manage versions, rollback, and configure deployment strategies using the EB CLI.

When to Use

  • Deploy code to an environment
  • Rollback to a previous version
  • Configure deployment strategies (rolling, immutable, etc.)
  • Create application versions without deploying
  • Set up CI/CD integration
  • Configure .ebignore
  • Configure CodeCommit as deploy source
  • Test Docker app locally before deploying

When NOT to Use

  • Creating new environments → use environment skill
  • Checking status after deploy → use status skill
  • Viewing deployment logs → use logs skill
  • Changing configuration settings → use config skill

Pre-Deploy Checklist

bash
eb status    # Verify environment is Ready
eb health    # Verify health is Green

If health is Red or environment is Updating, do NOT deploy. Fix issues first.

Quick Deploy

bash
eb deploy

Deploy to specific environment:

bash
eb deploy <env-name>

Deploy with Version Label

bash
eb deploy --label "v1.2.3"
eb deploy --label "v1.2.3" --message "Release v1.2.3 - Bug fixes"

Deploy Staged Changes Only

bash
eb deploy --staged

Deploy Existing Version

bash
eb deploy --version <version-label>

Create Version Without Deploying

bash
eb deploy --process

Monitor Deployment

bash
eb events --follow

Post-Deploy Verification

bash
eb status    # Confirm version deployed
eb health    # Confirm health is Green
eb events    # Check for warnings
eb open      # Open in browser

Look for:

  • "New application version was deployed" — success
  • "Environment health has transitioned from Ok to ..." — health degradation
  • "Rolling back to version" — automatic rollback triggered

Rollback

bash
# List available versions
eb appversion

# Deploy previous known-good version
eb deploy --version <previous-version>

# Verify rollback
eb status
eb health

Deployment Strategies

  • AllAtOnce (Default) — Fastest, causes downtime
  • Rolling — Updates in batches, maintains capacity
  • RollingWithAdditionalBatch — Maintains full capacity
  • Immutable — Safest, deploys to new instances
  • TrafficSplitting — Canary deployments
  • Blue/Green — CNAME swap (see environment skill)

Configure via eb config:

yaml
aws:elasticbeanstalk:command:
  DeploymentPolicy: Rolling
  BatchSize: '30'
  BatchSizeType: Percentage

.ebignore File

code
node_modules/
.venv/
__pycache__/
dist/
build/
.env
.env.local
.idea/
.vscode/
.git/

Code Source (CodeCommit Integration)

bash
eb codesource                  # Choose between CodeCommit and local
eb codesource codecommit       # Enable CodeCommit integration
eb codesource local            # Disable CodeCommit, use local source

Note: CodeCommit integration is not available in all AWS Regions.

Local Testing (Docker)

Test Docker-based apps locally before deploying. Requires Docker installed. Linux/macOS only.

bash
eb local run                   # Run containers locally
eb local run --port 8080       # Map to specific host port
eb local status                # Check local container status
eb local open                  # Open in browser
eb local logs                  # Show log file locations
eb local setenv KEY=value      # Set local env vars
eb local printenv              # View local env vars

CI/CD Integration

bash
eb deploy --nohang    # Non-interactive deploy
eb status --wait      # Wait for completion
eb health             # Verify healthy

Composability

  • Check status after deploy: Use status skill
  • View deployment logs: Use logs skill
  • Change deployment config: Use config skill
  • Create new environment: Use environment skill
  • Manage app versions: Use app skill

Additional Resources