Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/bgdnvk/clanker/llms.txt

Use this file to discover all available pages before exploring further.

The apply command executes infrastructure plans generated by maker mode. It runs AWS CLI commands with progress tracking, error handling, and automatic retries.

Usage

clanker ask --apply [flags]

Input methods

clanker ask --apply --plan-file plan.json

Examples

Basic workflow

# 1. Generate plan
clanker ask --maker "create an s3 bucket for logs" > plan.json

# 2. Review plan
cat plan.json | jq

# 3. Apply plan
clanker ask --apply --plan-file plan.json

Multi-resource deployment

# Generate complex infrastructure plan
clanker ask --maker \
  "deploy a web app with ALB, ECS cluster, and RDS database" \
  > webapp-plan.json

# Review and apply
clanker ask --apply --plan-file webapp-plan.json

Destructive operations

# Generate plan with deletions
clanker ask --maker --destroyer \
  "delete test s3 buckets" \
  > cleanup-plan.json

# Review carefully before applying
cat cleanup-plan.json | jq '.commands[] | .reason'

# Apply
clanker ask --apply --plan-file cleanup-plan.json

Flags

--apply
boolean
default:"false"
required
Enable apply mode to execute a plan
--plan-file
string
Path to plan JSON file. If not provided, reads from stdin
--profile
string
AWS profile to use for execution (overrides plan’s profile)
--destroyer
boolean
default:"false"
Confirm that destructive operations are allowed (safety check)
--debug
boolean
default:"false"
Show detailed execution logs including command output

Execution flow

When you apply a plan:

1. Plan validation

  • Validates JSON structure
  • Checks for required fields
  • Verifies command syntax
  • Validates AWS profile credentials

2. Pre-execution checks

  • Resolves AWS profile and region
  • Verifies AWS CLI is installed
  • Tests AWS credentials
  • Checks for destructive operations

3. Command execution

  • Executes commands sequentially
  • Substitutes variables (${VAR}) from previous outputs
  • Captures command outputs
  • Handles errors with automatic retries

4. Progress tracking

[1/5] Creating VPC...
✓ VPC created: vpc-0abc123

[2/5] Creating subnet...
✓ Subnet created: subnet-0def456

[3/5] Creating security group...
✓ Security group created: sg-0ghi789

[4/5] Creating EC2 instance...
✓ Instance launched: i-0jkl012

[5/5] Configuring instance...
✓ Configuration complete

5. Error handling

  • Captures error messages
  • Uses AI to analyze and suggest fixes
  • Retries failed commands with corrections
  • Provides rollback guidance if needed

Variable substitution

The apply command automatically replaces variables in commands:
{
  "commands": [
    {
      "args": ["ec2", "create-vpc", "--cidr-block", "10.0.0.0/16"],
      "produces": {"VPC_ID": "output:VpcId"}
    },
    {
      "args": [
        "ec2",
        "create-subnet",
        "--vpc-id",
        "${VPC_ID}",
        "--cidr-block",
        "10.0.1.0/24"
      ]
    }
  ]
}
  1. First command creates VPC and captures VPC ID
  2. Second command uses ${VPC_ID} which gets replaced with actual ID
  3. Result: --vpc-id vpc-0abc123

Error recovery

When a command fails:

1. AI analyzes the error

✗ Command failed: s3api create-bucket --bucket my-bucket
Error: BucketAlreadyExists

[AI] Analyzing error...
[AI] Bucket name 'my-bucket' is already taken globally
[AI] Suggested fix: Use unique bucket name 'my-bucket-20260301-103045'

2. Automatic retry

[Retry 1/3] Creating bucket with unique name...
✓ Bucket created: my-bucket-20260301-103045

3. Manual intervention

If automatic retry fails, you can:
  • Fix the plan and re-apply
  • Continue from specific command
  • Roll back changes

CloudFormation integration

For plans that use CloudFormation:
# Plan includes CloudFormation stack creation
clanker ask --maker "create vpc using cloudformation" > cfn-plan.json

# Apply waits for stack completion
clanker ask --apply --plan-file cfn-plan.json
Output:
[1/2] Creating CloudFormation stack...
✓ Stack creation initiated: my-vpc-stack

[2/2] Waiting for stack completion...
⏳ CREATE_IN_PROGRESS (10s)
⏳ CREATE_IN_PROGRESS (20s)
✓ CREATE_COMPLETE (45s)

Stack outputs:
  VpcId: vpc-0abc123
  SubnetId: subnet-0def456

Kubernetes plan execution

For Kubernetes plans (using kubectl/helm/eksctl):
# Generate Kubernetes deployment plan
clanker ask --maker "deploy nginx to kubernetes" > k8s-plan.json

# Apply executes kubectl/helm commands
clanker ask --apply --plan-file k8s-plan.json

Multi-cloud plans

Apply automatically detects the cloud provider:
# AWS plan
clanker ask --apply --plan-file aws-plan.json

# GCP plan
clanker ask --apply --plan-file gcp-plan.json

# Azure plan
clanker ask --apply --plan-file azure-plan.json

# Cloudflare plan
clanker ask --apply --plan-file cloudflare-plan.json

Output

Apply command outputs:
  • Command execution progress
  • Success/failure status for each command
  • Resource IDs and ARNs
  • Error messages with AI suggestions
  • Final summary

Safety features

Destructive operation checkPlans with destructive operations require --destroyer flag:
clanker ask --apply --destroyer --plan-file cleanup-plan.json
Dry run simulationWhile there’s no built-in dry-run mode, you can review the plan before applying:
# Show all commands that will be executed
cat plan.json | jq -r '.commands[] | .args | join(" ")'
IdempotencyMany AWS CLI commands are not idempotent. Re-applying the same plan may fail or create duplicate resources. Review the plan carefully before re-applying.

Best practices

Test in dev environment first
# Generate plan for dev
clanker ask --maker --profile dev "create resources" > plan.json

# Apply to dev
clanker ask --apply --profile dev --plan-file plan.json

# After testing, apply to prod
clanker ask --apply --profile prod --plan-file plan.json
Enable debug for troubleshooting
clanker ask --apply --debug --plan-file plan.json
Save plan execution logs
clanker ask --apply --plan-file plan.json 2>&1 | tee apply.log

Troubleshooting

AWS CLI not found

# Install AWS CLI
brew install awscli  # macOS
apt-get install awscli  # Ubuntu/Debian

Invalid credentials

# Verify credentials
aws sts get-caller-identity --profile dev

# For SSO profiles
aws sso login --profile dev

Command timeouts

# Increase timeout with debug mode
clanker ask --apply --debug --plan-file plan.json

Partial execution

If a plan fails mid-execution:
  1. Review the error message
  2. Fix the issue (manually or regenerate plan)
  3. Create a new plan that continues from where it failed
  4. Apply the continuation plan

See also