How to do it...

  1. In a new file, define the template version and description:
      AWSTemplateFormatVersion: "2010-09-09"  
Description: Create a weighted DNS setup for canary deployments.
  1. Start the Parameters section and the required parameters:
      Parameters: 
HostedZoneName:
Type: String
Description: The hosted zone to create records in

DomainName:
Type: String
Description: The domain name to create in the hosted zone

OldResource:
Type: String
Description: The older resource domain name

NewResource:
Type: String
Description: The newer resource domain name
  1. Include the optional parameters (such as those with defaults) in the Parameters section:
      OldWeight: 
Type: Number
Default: 1
Description: The ratio of requests to send to the older endpoint

NewWeight:
Type: Number
Default: 0
Description: The ratio of requests to send to the newer endpoint
  1. Start the Resources section of the template, and define your record set group:
      Resources: 
RecordSetGroup:
Type: AWS::Route53::RecordSetGroup
Properties:
HostedZoneName: !Ref HostedZoneName
Comment: Canary deployment record set group
RecordSets:
- Name: !Join [ ".", [ Ref: DomainName, Ref:
HostedZoneName ] ]
Type: CNAME
TTL: "300"
SetIdentifier: Old
Weight: !Ref OldWeight
ResourceRecords:
- !Ref OldResource
- Name: !Join [ ".", [ Ref: DomainName, Ref:
HostedZoneName ] ]
Type: CNAME
TTL: "300"
SetIdentifier: New
Weight: !Ref NewWeight
ResourceRecords:
- !Ref NewResource
  1. Save the template with a known filename; for example, 07-canary-deployments.yaml.
  2. Launch the template with the following CLI command:
      aws cloudformation create-stack 
--stack-name canary
--template-body file://07-canary-deployments.yaml
--parameters
ParameterKey=DomainName,ParameterValue=<your-domain-name>
ParameterKey=OldResource,ParameterValue=<old-resource-dns>
ParameterKey=NewResource,ParameterValue=<new-resource-dns>
ParameterKey=HostedZoneName,ParameterValue=<your-hosted-zone>
  1. When ready, update the stack to change (just) the domain weighting with the following CLI command:
      aws cloudformation update-stack 
--stack-name canary
--parameters
ParameterKey=HostedZoneName,UsePreviousValue=true
ParameterKey=DomainName,UsePreviousValue=true
ParameterKey=OldResource,UsePreviousValue=true
ParameterKey=NewResource,UsePreviousValue=true
ParameterKey=OldWeight,ParameterValue=0
ParameterKey=NewWeight,ParameterValue=1
--use-previous-template
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset