Welcome back to BackSpace Academy. In this part two of our Continuous 2
Integration and Continuous Delivery lab, we're going to be creating a Code 3
Pipeline that is going to integrate between our Github repository and our 4
Elastic Beanstalk Environment so that we can have Continuous Delivery whenever we 5
make changes to our code in that Github repository. So first off we go to 6
services and Code Pipeline, and I'll just open that in a new tab so that I can get 7
back to Elastic Beanstalk if I need to. 8
Okay so we need to first off create a Pipeline. 9
We'll give that pipeline a name and, we're going to allow Code Pipeline 10
service to create a new role for us so that it can access our resources. We 11
make sure that allow CodePipeline to create service role is checked. We 12
use our default location so Codepipeline will create an artifact store a 13
bucket in our Amazon s3 account for our artifacts. We'll click on next. Now our 14
source provider. Now we're going to be using Github but if you click on this 15
you can see that there's a lot of different options there available. 16
We've got AWS CodeCommit which is pretty well exactly the same as Github, 17
it's a Git repository but it's hosted on AWS. We've also got their 18
Amazon ECR or the elastic container service registry. We can get an image 19
from that and we can push that through in a CodePipeline as well or, we could 20
also have our code located in an Amazon s3 bucket but, we're going to select 21
Github. Once we select Github we have a button here to connect 22
to our Github account. So we click on that and we 23
log into our account and we give Codepipeline permission. Once 24
we have done that we can then select our repository. We need to go back into 25
our Github account now. We go to our repository. So we just select our 26
account here and we go to your repositories and we find our AWS - node js - eb 27
repository that we forked from Backspace' Academy and the name of it. 28
We just select up here. We just copy all that and we'll paste that in. 29
We're going to use the master branch and we're going to use 30
Github webhooks We've got two options here. AWS Codepipeline can poll the 31
Github repository for changes or we can work the other way round. 32
Github can notify through an event, a webhook event, can notify Codepipeline 33
whenever changes occur which is a much better option. So we'll select that and 34
click on next. We're not going to implement a build stage in 35
this so we'll skip that build stage but if there was a build process that needed 36
to occur we could do that here but we're going to skip that. We need to select 37
where we're going to deploy to, who our deployment provider is. There's a 38
number of options here that we can deploy to. We've got 39
Cloudformation, Opsworks, Amazon ECS but we're going to be deploying to Elastic 40
Beanstalk so we select that. Now we need to give Codepipeline the details 41
of our application and environment. Select our application that we created 42
and the environment that we created in Elastic Beanstalk. Once we've done that 43
we can click on next and we've completed that pipeline. So we've got our pipeline 44
there the name of it, it's going to be having an s3 bucket for the artifacts, 45
it's going to create a service role there, we're going to be using Github and 46
it's not going to be polling for source changes, it's going to be using webhook 47
events from Github to notify when these changes occur. We're not 48
going to be having a build stage and we're going to be using that Elastic 49
Beanstalk environment to deploy to. Everything looks fine let's click on 50
create pipeline. 51
Okay so that has started and we'll give that a few minutes to finish its process 52
and we'll come back to it. Okay so after five or ten minutes. You can see 53
there six minutes ago it did that part of it and from it ran about ten or 54
eleven minutes. We've got this deployed. What we can do is we can go back into 55
Elastic Beanstalk and we can click on our URL. We can see there that 56
background has changed. Now if you find the background hasn't changed it's most 57
probably that the old page is being cached in your browser cache. So just make 58
sure that you delete your history from the last hour or two or whenever 59
you started the lab and that will get you back in with this new 60
lime green background. So we're going to make a change to our code and see 61
if that pushes through and changes the color again. I'm just going to go into 62
that repository and if we go back into the AWS nodejs - EB 63
repository and if we go into static and apss/css and we can edit this background color. 64
So we just click on the edit button here, the the pencil on the right 65
and we're going to change that to orange. Scroll down and just commit changes. 66
Okay so that should now push out through to our environment. If we go back into 67
our Codepipeline and if we refresh this, there we can see that we've got 68
a new deploy running there. So it's picked up on that and it's doing a new 69
deployment there, in progress. So again after about five or ten minutes that 70
change will be deployed out to our Elastic Beanstalk environment. 71
Okay so it's been only a couple of minutes or so and it's already deployed that out. 72
We go again go back into our code or into our Elastic Beanstalk 73
environment or click on the URL. So it's still lime green so if we refresh it 74
maybe. No it's not working. So we just go into our history and change that. 75
I'm just going to clear browsing data for the last hour. We just want to clear 76
cached images and files. So if i refresh that now again. 77
There we can see we've got our orange background there. That's all working 78
pretty good. We've pushed that change through. It's all working quite well. 79
What we need to do now is that we need to go and clean everything up so we don't get 80
a big bill. We've got a highly available environment here. We're 81
going to have a load balancer. We're going to have more than one ec2 82
instance probably. So we need to make sure we delete that so that we don't get 83
a big bill at the end of the month. Just close that. The first thing we need 84
to do is we need to delete this pipeline. So we get click on pipelines and edit 85
and delete. 86
Okay so it's successfully being deleted. What we need to do now is delete that 87
Elastic Beanstalk environment so you go into actions, terminate environment and 88
we just need to put the name of the environment in there 89
and terminate. Once that's terminated we can then go into our Codepipeline 90
and we can actually delete the whole application. 91
We just delete that now. Okay so that brings us to the end of this two part lab and I 92
look forward to seeing you in the next one.