Devops AWS unit 5
Devops AWS unit 5
In-place deployment:-
• In-place Deployment is a deployment strategy where the application on each compute
resource (or instance) is stopped, the latest version is installed, and then the updated
application is started and validated.
• This approach involves minimal disruption to the underlying infrastructure since new
resources are not created; instead, updates happen directly on the existing resources.
• Only deployments that use the EC2/On-Premises compute platform can use in-place
deployments.
Advantages :
1. Application deployments with minimal disturbance to underlying infrastructure.
2. Application deployment without creating new infrastructure
3. Minimizes infrastructure costs and management overhead associated with creating new
resources
Disadvantage :
1. The availability of your application can be affected during these deployments
2. There may be a temporary period when the application is unavailable. This is because
instances are taken offline during the deployment and only brought back online once the
deployment is complete.
Blue/green deployments:-
• A blue/green deployment is a deployment strategy in which you create two separate, but
identical environments.
• One environment (blue) is running the current application version and one environment
(green) is running the new application version.
• Using a blue/green deployment strategy increases application availability and reduces
deployment risk by simplifying the rollback process if a deployment fails.
• Once testing has been completed on the green environment, live application traffic is
directed to the green environment and the blue environment is deprecated.
• A number of AWS deployment services support blue/green deployment strategies
including Elastic Beanstalk, OpsWorks, CloudFormation, CodeDeploy, and Amazon ECS
Advantages :
1. Minimize downtime during application updates, mitigating risks surrounding downtime
and rollback functionality.
2. Enables to launch a new version (green) of your application alongside the old version
(blue), and monitor and test the new version before you reroute traffic to it, rolling back
on issue detection.
Disadvantages:
1. Requires double infrastructure temporarily, leading to increased costs.
2. Maintaining and synchronizing two identical environments can be challenging.
3. Difficult to keep data consistent across both environments in real-time.
The AppSpec file is a critical component in AWS CodeDeploy, serving as a configuration file
to manage deployments. It provides instructions for how the deployment should proceed on
each instance. The AppSpec file can be formatted in YAML or JSON and plays an essential
role in defining the deployment process.
Example:-
AppSpec file structure for Amazon ECS deployments
When deploying updates to serverless applications in AWS, particularly with AWS Lambda,
several deployment strategies are available to manage how traffic shifts from the current
version to the updated one. These strategies are designed to minimize disruption, allow
testing of new versions, and control the risk associated with new deployments. Here’s an
overview of the main strategies:
1. Blue/Green Deployment on AWS Lambda
• In a blue/green deployment, two environments are created: the "blue" environment
with the current version and the "green" environment with the updated version. Traffic
is then shifted from the blue to the green environment in increments based on the
deployment configuration.
• Traffic shifting options include canary, linear, or all-at-once, which control how
traffic moves to the updated Lambda function.
2. Canary Deployment
• Traffic is shifted in two increments.
• During the first increment, a specified percentage of traffic is shifted to the updated
Lambda function, allowing you to test the new version with a smaller load.
• After a defined interval (in minutes), the remaining traffic is then shifted to the
updated version.
• This strategy allows a quick rollback if issues arise, as only a small portion of traffic
is initially exposed to the new version.
3. Linear Deployment
• In a linear deployment, traffic is shifted gradually in equal increments over time.
• Each increment moves a specific percentage of traffic to the new version, with a set
time interval between increments.
• For example, if you choose a 10% increment every 5 minutes, then 10% of traffic
moves to the new version every 5 minutes until it reaches 100%.
• This approach reduces the risk associated with deployment by slowly exposing users
to the new version.
4. All-at-Once Deployment
• In an all-at-once deployment, 100% of traffic is shifted from the old version to the
updated Lambda function in one go.
• This is the fastest deployment option but also carries the highest risk, as any issues
with the new version affect all users immediately.
• This strategy is often used for small changes with minimal impact or when quick
deployment is necessary.
Each deployment strategy provides a balance between risk and deployment speed. Choosing
the appropriate strategy depends on factors like the criticality of the application, testing
requirements, and acceptable downtime.
Deployment fails with the message “Validation of PKCS7 signed message failed” :
This error message indicates the instance is running a version of the CodeDeploy agent that
supports only the SHA-1 hash algorithm.
Deployment or redeployment of the same files to the same instance locations fail with
the error "The deployment failed because a specified file already exists at this location"
When CodeDeploy tries to deploy a file to an instance but a file with the same name already
exists in the specified target location, the deployment to that instance may fail.
You may receive the error message "The deployment failed because a specified file already
exists at this location: location-name
Windows PowerShell scripts fail to use the 64-bit version of Windows PowerShell by
default
By default, CodeDeploy uses the 32-bit version of Windows PowerShell for deployment
scripts. If a script requires 64-bit functionality (e.g., for higher memory usage or 64-bit
libraries), it may fail or crash.
The deployment failed because one or more of the lifecycle event validation
functions failed
This error might occur if you specified a Lambda function in the AppSpec file's Hooks
section, but the Lambda function returned Failed to CodeDeploy when it
called PutLifecycleEventHookExecutionStatus. This failure indicates to CodeDeploy that
the lifecycle validation test failed.
The ELB could not be updated due to the following error: Primary taskset target
group must be behind listener
This error might occur if you have configured an optional test listener, and it is
configured with wrong target group
Only ALB supports gradual traffic routing, use AllAtOnce Traffic routing instead
when you create/update Deployment group
This error might occur if you're using a Network Load Balancer and tried to use a
predefined deployment configuration other than CodeDeployDefault.ECSAllAtOnce.
Even though my deployment succeeded, the replacement task set fails the Elastic
Load Balancing health checks, and my application is down
Even though CodeDeploy indicates that my deployment succeeded, the replacement task
set fails the health checks from Elastic Load Balancing, and my application is down.
AWS CodePipeline, is a continuous delivery service that automates the building, testing,
and deployment of your software into production.
CodePipeline automates the steps required to release your software changes continuously.
• Continuous delivery : Every software change is automatically built, tested, and
deployed to production. Before the final push to production, a person, an automated test,
or a business rule decides when the final push should occur. Although every successful
software change can be immediately released to production with continuous delivery, not
all changes need to be released right away.
• Continuous integration : Members of a team use a version control system and
frequently integrate their work to the same location, such as a main branch. Each change
is built and verified to detect integration errors as quickly as possible
Types of pipeline :
• V1 type pipelines have a JSON structure that contains standard pipeline, stage, and action-
level parameters.
• V2 type pipelines have the same structure as a V1 type, along with additional parameters for
release safety and trigger configuration
CodePipeline can deploy applications to EC2 instances by using CodeDeploy, AWS Elastic
Beanstalk, or AWS OpsWorks Stacks. CodePipeline can also deploy container-based
applications to services by using Amazon ECS. Developers can also use the integration points
provided with CodePipeline to plug in other tools or services, including build services, test
providers, or other deployment targets or systems
Q 8. Explain IaC service provided by AWS. OR Explain Cloud Formation
service.
AWS CloudFormation is a service that helps you model and set up your AWS resources so
that you can spend less time managing those resources and more time focusing on your
applications that run in AWS. You create a template that describes all the AWS resources that
you want (like Amazon EC2 instances or Amazon RDS DB instances), and CloudFormation
takes care of provisioning and configuring those resources for you. You don't need to
individually create and configure AWS resources and figure out what's dependent on what;
CloudFormation handles that.
Dependency error
Add a DependsOn attribute to resources that depend on other resources in your template.
No updates to perform
CloudFormation requires actual updates to parameters or template content to recognize a
stack update. Modifications like deletion policies, update policies, conditions, or output
declarations alone don’t trigger an update. To apply such changes without altering
functionality, add or change a metadata attribute, which CloudFormation doesn’t process
but will register as an update.