With the AWS Developer Tools you can host your code, build, test, and deploy your application quickly and effectively. AWS provides a suite of tools including software development kits (SDKs), code editors, and continuous integration and delivery (CI/CD) services for DevOps software development.
AWS CodeArtifact | AWS CodeCommit | AWS CodeBuild | AWS CodeDeploy | AWS CodePipeline | AWS CodeStar | AWS X-Ray
You can define the specific commands that you want AWS CodeBuild to perform, such as installing build tool packages, running unit tests, and packaging your code.
The build specification (buildspec.yaml
) is a YAML file that lets you choose the commands to run at each phase of the build and other settings.
Phases:
Install
: install dependencies you may need for the build.
Pre-build
: final commands to execute before build.
Build
: actual build commands.
Post build
: finishing touches (e.g. zip file output).
The code sample shows the contents of a buildspec.yml
file that is being used to build a Docker image and push it to Amazon Elastic Container Registry (ECR):
version: 0.2
phases:
install:
runtime-versions:
docker: 18
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION)
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
Useful exam tips
You must have a
buildspec.yml
file at the root of your source code.
CodeDeploy is a deployment service that automates application deployments to Amazon EC2 instances, on-premises instances, serverless Lambda functions, or Amazon ECS services. An AWS CodeDeploy application contains information about what to deploy and how to deploy it.
CodeDeploy provides two deployment type options – in-place and blue/green
.
Need to choose the compute platform:
- EC2 - In-Place, Blue/Green
- On Premises - In-place
- Lambda - Blue/Green
- ECS - Blue/Green
You can configure CodeDeploy to auto-update on boot by setting the AUTOUPDATE
variable to true.
The application specification file (AppSpec.yml
file) is a YAML-formatted, or JSON-formatted file used by CodeDeploy to manage a deployment. Example:
version: 0.0
os: linux
files:
- source: /
destination: /var/www/html/WordPress
hooks
BeforeInstall:
- location: scripts/install_dependencies.sh
timeout: 300
runas: root
AfterInstall:
- location: scripts/change_permissions.sh
timeout: 300
runas: root
ApplicationStart:
- location: scripts/start_server.sh
- location: scripts/create_test_db.sh
timeout: 300
runas: root
ApplicationStop:
- location: scripts/stop_server.sh
timeout: 300
runas: root
Here is an example of an AppSpec.yml
file written in YAML for deploying an Amazon ECS service:
version: 0.0
Resources:
- TargetService:
Type: AWS::ECS::Service
Properties:
TaskDefinition: "arn:aws:ecs:us-east-1:111222333444:task-definition/my-task-definition-family-name:1"
LoadBalancerInfo:
ContainerName: "SampleApplicationName"
ContainerPort: 80
# Optional properties
PlatformVersion: "LATEST"
NetworkConfiguration:
AwsvpcConfiguration:
Subnets: ["subnet-1234abcd","subnet-5678abcd"]
SecurityGroups: ["sg-12345678"]
AssignPublicIp: "ENABLED"
Hooks:
- BeforeInstall: "LambdaFunctionToValidateBeforeInstall"
- AfterInstall: "LambdaFunctionToValidateAfterTraffic"
- AfterAllowTestTraffic: "LambdaFunctionToValidateAfterTestTrafficStarts"
- BeforeAllowTraffic: "LambdaFunctionToValidateBeforeAllowingProductionTraffic"
- AfterAllowTraffic: "LambdaFunctionToValidateAfterAllowingProductionTraffic"
The format of the AppSpec.yaml
file for use with AWS Lambda is as follows:
version: 0.0
Resources:
- myLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Name: "myLambdaFunction"
Alias: "myLambdaFunctionAlias"
CurrentVersion: "1"
TargetVersion: "2"
Hooks:
- BeforeAllowTraffic: "LambdaFunctionToValidateBeforeTrafficShift"
- AfterAllowTraffic: "LambdaFunctionToValidateAfterTrafficShift"
Useful exam tips
CodeDeploy provides two deployment type options –
in-place
andblue/green
.
in-place
deployment strategy works only inEC2/On-Premises
deployments.
All AWS Lambda and Amazon ECS deployments only support
blue/green
. An EC2/On-Premises deployment can bein-place or blue/green
.
The hooks in
AppSpec.yml
file are different for each type of compute platform.
AWS CodePipeline is a fully managed continuous delivery service that helps you automate your release pipelines for fast and reliable application and infrastructure updates. CodePipeline automates the build, test, and deploy phases of your release process every time there is a code change, based on the release model you define.
Key CodePipeline Concepts
Pipelines:
A workflow that describes how software changes go through the release process.
Artifacts:
- Files or changes that will be worked on by the actions and stages in the pipeline.
- Each pipeline stage can create “artifacts”.
- Artifacts are passed, stored in Amazon S3, and then passed on to the next stage.
Stages:
- Pipelines are broken up into stages, e.g., build stage, deployment stage.
- Each stage can have sequential actions and or parallel actions.
- Stage examples would be build, test, deploy, load test etc.
- Manual approval can be defined at any stage.
- Approval actions can't be added to
Source stages
. Source stages can contain only source actions.
Actions:
Stages contain at least one action, these actions take some action on artifacts and will have artifacts as either an input, and output, or both.
Transitions:
The progressing from one stage to another inside of a pipeline.
AWS CodeStar enables you to quickly develop, build, and deploy applications on AWS. AWS CodeStar provides a unified user interface, enabling you to easily manage your software development activities in one place.
With AWS CodeStar, you can set up your entire continuous delivery toolchain in minutes, allowing you to start releasing code faster.
Exam tip: If an exam scenario requires a unified development toolchain, and mentions collaboration between team members, synchronization, and centralized management of the CI/CD pipeline this will be CodeStar rather than CodePipeline or CodeCommit.
It is a specialized service that enables developers to create, manage, and deploy application configurations quickly and efficiently. It also provides the functionality to manage feature flags, a powerful technique that allows developers to test and control new features in live environments without affecting all users.
With AWS AppConfig
, developers can gradually introduce new features, control who can access them based on specific criteria such as user role or location, and easily update or revert features without deploying new code. This capability helps developers seamlessly control the visibility and access of new features while keeping them hidden until they’re ready for release.
It also enables you to define different environments, such as production, development, and testing. You can also create configuration profiles and deployment strategies using this tool.