‫So back into y API gateway
‫I want to test canary but I'm gonna make
‫a few changes to make it very clear.
‫So, I want to have my current prod stage
‫to point to the version one of my lambda function.
‫So I want my prod stage to point to version one
‫so I'm going to make a change.
‫I'm gon ago to API gateway and I'm going to create a GET.
‫And this one, so I will change this integration
‫so it says lambda proxy,
‫but the lambda function is going to be authorized
‫to read into is version one, so I do colon one,
‫this is version one of my lambda application.
‫So we're about to give API gateway permission
‫to invoke our lambda function, where I'll way yes,
‫you can do this and this is perfect.
‫So I want to deploy that change into my prod stage
‫so I will deploy this API into my prod stage
‫and I'll deploy it.
‫So this means that if I go to my prod stage now and open it
‫it says, "Hello from Lambda"
‫and it should say version one very very soon
‫so let's wait a little bit, here we go.
‫"Hello from Lambda version one" so my prod stage
‫is now pointing to version one
‫and I want to be able to test the version two
‫of my Lambda function.
‫So for this I'm gonna go and create a canary,
‫create a canary, and now we can configure the canary itself.
‫So what's the percentage of traffic
‫I want to redirect to my canary?
‫So in the real world you would say something like 5 percent,
‫a very small amount, but for us because we want
‫to be able to shown you how that works,
‫we'll say 50 percent, so that 50 percent of the traffic
‫will go to my canary and 50 percent will go to prod.
‫We haven't done any canary deployment just yet,
‫so we'll need to do one right now,
‫and for the stage variables
‫we could override them for the canary,
‫but this is not necessary for this hands-on
‫as well as we can use a stage cache.
‫So let's do our canary deploy
‫so I'm gonna go back to my resources,
‫go to my first GET at the root
‫and then we'll change the integration request
‫and now it'll say version two.
‫I will save this, so I will save it here,
‫press okay so that my API gateway has the power
‫to invoke this lambda function
‫and then I will deploy this, so I will deploy this API,
‫but this time I will deploy it into the canary of prod.
‫So it says, "You're deploying this API only to the canary"
‫and then, "To promote it use the promote button."
‫So I'll deploy this API
‫and now the canary deployment has been done,
‫so if I go back to my prod API and refresh this page,
‫I see, "Hello from V1" right now,
‫but if I refresh I see, "Hello from V2."
‫And if I refresh again V1, and again V2, and so on.
‫So as you can see the more I refresh I see V1 and V2,
‫50 per see, so 50 percent chance of getting V1
‫and 50 percent chance of getting V2.
‫And so that means that my canary is working
‫and that some users are seeing the version two lambda
‫and some users are seeing the version one lambda function.
‫And that's the whole power of canaries.
‫So then I would ensure my system would work correctly,
‫would look at the metrics, would look at the logs,
‫see if I get any errors and if I'm happy
‫with this new version, then I can promote the canary
‫and say, "Okay, you want to update the canary deployment,
‫"the stage variables, and set the canary percentage to zero"
‫so this would effectively promote my lambda function,
‫my newer lambda function into the stage.
‫So now the canary has been promoted and if I refresh now
‫the only thing I should be seeing is V2,
‫so yes, I only see version two
‫because I have promoted my canary.
‫And that's it this is how canaries work,
‫it could be quiet complicated to get your head around
‫the complexity of stage variables, canaries, versions,
‫aliases, and so on in API gateway
‫but hopefully that was a good introduction
‫and the exam will just test you on these concepts
‫not on their implementations.
‫So I hope that was helpful
‫and I will see you in the next lecture.