Cloud Command

The buddy cloud command provides tools for interacting with and managing your Stacks cloud infrastructure on AWS.

Basic Usage

# Show cloud options
buddy cloud

# SSH into cloud infrastructure
buddy cloud --ssh

# View infrastructure diff
buddy cloud --diff

Command Syntax

buddy cloud [options]
buddy cloud:add [options]
buddy cloud:remove [options]
buddy cloud:cleanup [options]
buddy cloud:optimize-cost [options]
buddy cloud:invalidate-cache [options]
buddy cloud:diff [options]

Available Commands

Cloud SSH

Connect to your cloud infrastructure via SSH:

buddy cloud --ssh
# or
buddy cloud --connect

This uses AWS Systems Manager Session Manager to connect to your jump box.

Cloud Diff

Preview infrastructure changes before deploying:

buddy cloud --diff
# or
buddy cloud:diff

Invalidate CDN Cache

Invalidate CloudFront cache:

buddy cloud --invalidate-cache
buddy cloud:invalidate-cache
buddy cloud:invalidate-cache --paths "/*"

Cloud Add Commands

Add Jump Box

Add a jump box (bastion host) to your cloud infrastructure:

buddy cloud:add --jump-box

This creates an EC2 instance that allows you to SSH into your VPC.

Cloud Remove Commands

Remove Infrastructure

Remove all cloud infrastructure:

buddy cloud:remove
# or
buddy cloud:destroy
buddy cloud:rm
buddy undeploy

Remove Jump Box

Remove only the jump box to reduce costs:

buddy cloud:remove --jump-box

Force Removal

Force deletion of stuck stacks:

buddy cloud:remove --force

Skip Confirmation

Skip confirmation prompts:

buddy cloud:remove --yes

Cloud Cleanup

Clean up retained resources after infrastructure removal:

buddy cloud:cleanup
# or
buddy cloud:clean-up

This removes:

  • Jump boxes
  • S3 buckets
  • Lambda functions
  • Log groups
  • Parameter store entries
  • VPCs and subnets
  • CDK remnants
  • IAM users

Cost Optimization

Remove non-essential resources to reduce costs:

buddy cloud:optimize-cost

By default, this removes the jump box which can be re-added later.

Options Reference

Common Options

OptionDescription
-p, --project [project]Target a specific project
--verboseEnable verbose output

Cloud Command Options

OptionDescription
--sshSSH into the cloud
--connectAlias for --ssh
--invalidate-cacheInvalidate CloudFront cache
--paths [paths]Paths to invalidate
--diffShow infrastructure diff

Cloud Remove Options

OptionDescription
--jump-boxRemove only the jump box
--forceForce deletion of stuck stacks
--yesSkip confirmation prompts

Examples

SSH into Cloud

buddy cloud --ssh

Once connected, you can:

  • Debug application issues
  • Check logs
  • Run database commands
  • Test network connectivity

Preview Infrastructure Changes

buddy cloud:diff

Review changes before deploying to avoid surprises.

Complete Infrastructure Removal

# Remove infrastructure
buddy cloud:remove

# If any resources remain, clean them up
buddy cloud:cleanup

Add Jump Box for Debugging

# Add jump box
buddy cloud:add --jump-box

# SSH into it
buddy cloud --ssh

# Remove when done (to save costs)
buddy cloud:remove --jump-box

Invalidate Specific Paths

buddy cloud:invalidate-cache --paths "/api/*,/static/*"

AWS Configuration

Environment Variables

Set these in your .env.production file:

AWS*ACCESS*KEY*ID=your-access-key
AWS*SECRET*ACCESS*KEY=your-secret-key
AWS*REGION=us-east-1
AWS*ACCOUNT*ID=123456789012

AWS Credentials File

Alternatively, configure ~/.aws/credentials:

[stacks]
aws*access*key*id = your-access-key
aws*secret*access*key = your-secret-key

[default]
aws*access*key*id = your-access-key
aws*secret*access*key = your-secret-key

Troubleshooting

SSH Connection Failed

# Ensure SSM agent is running
# Check AWS credentials
buddy cloud --ssh --verbose

Stack Stuck in DELETE*FAILED

# Use force deletion
buddy cloud:remove --force

# Then cleanup remaining resources
buddy cloud:cleanup

Access Denied Errors

  1. Check AWS credentials are valid
  2. Verify IAM permissions include necessary actions
  3. Check if MFA is required
# View detailed error
buddy cloud:remove --verbose

Resources Not Fully Removed

Some resources are retained by design (like S3 buckets with data). Use cleanup:

buddy cloud:cleanup

Credentials Expired

# Check credential validity
aws sts get-caller-identity

# Refresh credentials if needed

Best Practices

Cost Management

# Remove jump box when not needed
buddy cloud:remove --jump-box

# Or use cost optimization
buddy cloud:optimize-cost

Before Major Changes

# Always preview changes
buddy cloud:diff

# Then deploy
buddy deploy

Complete Teardown

# Step 1: Remove infrastructure
buddy cloud:remove --yes

# Step 2: Clean up remaining resources
buddy cloud:cleanup