Skip to content

How are we supposed to use pre_deployments with db_migrations? #5605

Answered by jetaggart
jetaggart asked this question in Q&A
Discussion options

You must be logged in to vote

I figured out how to solve for this, although still feels hacky. In the pipeline build phase you can change it to go off the SHA of the commit when tagging the image, so change this line in the pipeline buildspec

tag=$(echo ${CODEBUILD_BUILD_ID##*:}-$env | sed 's/:/-/g' | rev | cut -c 1-128 | rev)

to

tag=$(echo ${CODEBUILD_RESOLVED_SOURCE_VERSION##*:}-$env | sed 's/:/-/g' | rev | cut -c 1-128 | rev)

and in your migrations buildspec, use that image instead of latest:

version: 0.2

phases:
  install:
    commands:
      - echo "cd into $CODEBUILD_SRC_DIR"
      - cd $CODEBUILD_SRC_DIR
      - wget -q https://ecs-cli-v2-release.s3.amazonaws.com/copilot-linux-v1.32.1 -O copilot-linux
      …

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
8 replies
@jetaggart
Comment options

@jetaggart
Comment options

@jetaggart
Comment options

@jetaggart
Comment options

Answer selected by jetaggart
@Lou1415926
Comment options

@aburgel
Comment options

Comment options

You must be logged in to vote
2 replies
@jetaggart
Comment options

@neanias
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants