AWS Certified DevOps Engineer Notes
buildspec.yml). This file should live in the root folder of the repositorybuildspec.yml - Deep Diveenv - environment variables (for more details, see environment variables bellow). The type of these can be:
variable: plain text variablesparameter-store: variables from SSM Parameter Storesecrets-manager: variables from AWS Secrets Managerinstall
nodejs: 18, java: corretto17pre_build
buildpost_build
finally block: the commands from this block is executed wether or not the actual commands from the commands block succeeded.jar packagesversion: 0.2
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- aws ecr get-login-password --region $AWS_DEFAULT_REGION | docker login --username AWS --password-stdin $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG .
- docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
AWS_DEFAULT_REGION, AWS_REGION: the region where the build is runningCODEBUILD_BUILD_ID: CodeBuild ID of the buildCODEBUILD_BUILD_NUMBER: current build numberHOME: always set to /rootstart-build API call)printenvReport Group in buildpsec.yml file with information about tests