DEV Community

selvakumar palanisamy
selvakumar palanisamy

Posted on

API deployment -Release options

Application frequently deploy updates to introduce new features in their stack. But updating the production is risky and may introduce bugs .Canary / blue green deployments help to mitigate the risk.

Design a release strategy to partially deploy a new feature and shift some percentage of traffic to a new version of the application. This allows to verify stability and reduce risk associated with the new release. After gaining confidence in the new version, continually increment traffic until all traffic flows to the new release.

Multiple options are available to partially deploy a new feature and shift some percentage of traffic to a new version of the application.

image

Option1: Lambda Weighted Alias Routing

  1.Create two different versions of lambda functions

  2.Create Alias with routing config and 
    additional weights to route the traffic  
Enter fullscreen mode Exit fullscreen mode

Prodversion:
  Type: AWS::Lambda::Version
  Properties:
    FunctionName: !Ref function
    Description: v1
Stageversion:
  Type: AWS::Lambda::Version
  Properties:
    FunctionName: !Ref function
    Description: v2
alias:
  Type: AWS::Lambda::Alias
  Properties:
    FunctionName: !Ref function
    FunctionVersion: !GetAtt ProdVersion.Version
    Name: BLUE
    RoutingConfig:
      AdditionalVersionWeights:
        - FunctionVersion: !GetAtt Stageversion.Version
          FunctionWeight: 0.5

Update the alias to modify the routing

          aws lambda update-alias --name routing-alias --function-name $function  \
          --function-version 1 --routing-config AdditionalVersionWeights={}
         
          aws lambda update-alias --name routing-alias --function-name $function  \
          --function-version 2 --routing-config AdditionalVersionWeights={}

image

Option2:Route based Lambda Alias

   1.Create 2 different function versions and aliases 
      lamda-function:stage ,lamda-function:prod

   2. Create dynamic resources in AWS API gateway 
      (API – Call lambda with aliases)
      Integration Request Lambda function name: 
      lambda-function:${stageVariables.env}

   3. Create deployment stages and variables in 
      API gateway -  Prod deployment Stage , 
      Staging  deployment stage
Enter fullscreen mode Exit fullscreen mode

image

Option3: Release using Code deploy and SAM template – Pre and Post traffic hook Lambdas

1.Use SAM based deployment.

2.Include code deploy and lambda weighted Alias. 

3.Pre and post traffic lambda functions to include 
  test scenarios.

4.Cloud watch to monitor the health and to rollback 
  deployment based on the lambda execution error alerts
Enter fullscreen mode Exit fullscreen mode

image

Option 4: API Based Route

1.Create baseline deployment with two stage 
  variables [Prod ,Stage].
2.Create canary deployment on the prod stage to 
  create API test version including traffic 
  split between prod and test API version.
3.Promote the Canary to reset the canary 
  percentage to Zero.
Enter fullscreen mode Exit fullscreen mode

image

Top comments (0)