Deployment helpers map a small target name to the destination and caching policy used by the publish command.

Program

Play the script to choose the target and see the destination plan.

target
deploy_target_plan.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash

target="staging"
if [ "$target" = "prod" ]; then
    destination="s3://app-prod"
    cache="max-age=300"
else
    destination="s3://app-staging"
    cache="no-cache"
fi
echo "$target -> $destination ($cache)"
#!/usr/bin/env bash

target="prod"
if [ "$target" = "prod" ]; then
    destination="s3://app-prod"
    cache="max-age=300"
else
    destination="s3://app-staging"
    cache="no-cache"
fi
echo "$target -> $destination ($cache)"
  1. target ← staging

    3target="staging"4if [ "$target" = "prod" ]; then
    values this stepstagingtarget
  2. if [ "$target" = "prod" ]; then

    3target="staging"4if [ "$target" = "prod" ]; then5    destination="s3://app-prod"
    values this stepstagingtarget
  3. destination ← s3://app-staging

    7else8    destination="s3://app-staging"9    cache="no-cache"
    values this steps3://app-stagingdestination
  4. cache ← no-cache

    8    destination="s3://app-staging"9    cache="no-cache"10fi
    values this stepno-cachecache
  5. echo "$target -> $destination ($cache)"

    10fi11echo "$target -> $destination ($cache)"
    outputstaging -> s3://app-staging (no-cache)
    values this stepstagingtargets3://app-stagingdestinationno-cachecache
  1. target ← prod

    3target="prod"4if [ "$target" = "prod" ]; then
    values this stepprodtarget
  2. if [ "$target" = "prod" ]; then

    3target="prod"4if [ "$target" = "prod" ]; then5    destination="s3://app-prod"
    values this stepprodtarget
  3. destination ← s3://app-prod

    4if [ "$target" = "prod" ]; then5    destination="s3://app-prod"6    cache="max-age=300"
    values this steps3://app-proddestination
  4. cache ← max-age=300

    5    destination="s3://app-prod"6    cache="max-age=300"7else
    values this stepmax-age=300cache
  5. echo "$target -> $destination ($cache)"

    10fi11echo "$target -> $destination ($cache)"
    outputprod -> s3://app-prod (max-age=300)
    values this stepprodtargets3://app-proddestinationmax-age=300cache
target A deployment target is a small name for an environment.
destination The destination should be derived from the target, not typed repeatedly.
cache policy Deployment scripts often pair a destination with a cache setting.