Narrator: Now that our Elastic Beanstalk instance
has been created, we're gonna start to configure
Travis CI to automatically deploy our application over
to AWS once our tests has successfully passed.
So to do so, we're gonna add some more configuration
to the travis.yml file
that we had created inside of our route project directory.
I'm gonna open up my code editor and then
inside of here I'm gonna find the travis.yml file.
You'll recall that we currently have the
before install and script sections inside of here
and both those are concerned solely
with putting together our initial image
and then running some tests using that image.
I'm gonna add in another section towards the bottom
of this file
called, as you might guess, deploy.
So inside this section we're gonna add in a bunch
of configuration to tell Travis CI exactly how
to take our application and deploy it off to AWS.
Now, some of these settings that we're gonna put
in here are gonna be a little bit laborious
so I really gotta ask you to watch really closely
and make sure that you follow along as closely as possible.
Now, the first option we're gonna add in here
is gonna be really easy and straightforward.
We're gonna say provider is Elastic Beanstalk.
All one word like so.
Travis CI comes pre configured
to deploy our application to a handful of different
providers or hosting providers such as AWS or
Digital Ocean or whichever other you can possibly imagine.
And so by just saying ProviderElasticBeanstalk
we're essentially telling Travis CI that,
Hey, we want you to use this set of instructions
to attempt to automatically deploy our application.
So by just specifying that right there, Travis CI
is gonna really do a lot of stuff for us automatically.
Now we're gonna still provide a lot of other options in
here as well to just provide some further customization.
The next one we're going to provide is region.
Now region is gonna be a little bit of a tough one
because the region that you're gonna specify depends
upon exactly where you originally created your
Elastic Beanstalk instance.
Let me tell you what I mean by that.
If you flip back over to your Elastic Beanstalk dashboard
which should look like this
I want you to look very closely at that URL, again.
I'm gonna copy the URL and I'm gonna put it over
into my code editor just so you can read mine very easily.
So when you created your Elastic Beanstalk instance
you created it in a particular region.
And when I say region, I'm talking about
like area of the earth or
kind of continent essentially.
So me personally, I created the region in the,
to me the Elastic Beanstalk instance
in the region, US-West-2.
So right here you need to specify whatever region
your Elastic Beanstalk instance was just created in.
You might have something like US-East-1, US-West-1,
you might have a totally different country inside of here.
It's gonna be up to you to find whichever code it is
and you're gonna take that code
and put it in as the region wrapped inside of quotes.
So I'll say US-West-2, and again, what you put
in here is going to be whatever you see right there
before the ElasticBeanstalk.com.
All right, so once we got that in there
we're then gonna add in a couple other options.
We're gonna specify the name of our app.
Now the name of the app is the same name
that you had created
back over here on the Elastic Beanstalk Dashboard.
So you see how we have all applications right here.
The first word right after that is the name of your app.
So I called my docker, you might have called yours something
like docker - react.
Whatever you have right there,
you're gonna take it letter for letter
and you're gonna enter it in as the app right here.
And so for me, I'm gonna put in simply docker, like so.
The next configuration piece we're gonna add in
is the environment name.
So when we created the application
of docker or docker - react,
that's kind of just setting up
a common set of configuration.
The actual app that's running inside of here
it's not really referred to as an app
but instead referred to as an environment.
And so the environment is gonna be the last piece on there.
For me, my environment name is docker-env.
So you're gonna take whatever's listed right there,
you're gonna copy it,
and then we're gonna put it right in there for env.
All right, so that's looking pretty good.
Now the next piece of configuration here
is gonna be just a little bit nastier
than the two we just went through.
We're gonna put in a bucket name.
So when Travis decides to deploy your code base
it's gonna take all of the files
inside of your GitHub repository.
It's gonna zip them all up into one single file
and then it's going to copy all them
over to an, excuse me, an S3 bucket
which is essentially a hard drive running on AWS.
Once it copies all those files over,
Travis CI is then going to essentially poke
at Elastic Beanstalk and say,
Hey, I just uploaded this new zip file.
Use that to redeploy your application.
So we need to provide the name of the bucket
that Travis CI is going to put our zip file into.
Now that might sound like it's a little complicated.
The good news here is that
this has been a S3 bucket that is already
automatically generated for you when you initially
created the Elastic Beanstalk instance.
All we have to do is get the name of it.
So to get the name, we're gonna go up to services up here
and then we're gonna do a search for S3.
And then you should see S3 Scalable Storage in the cloud.
Then on here you're gonna look up and down this list.
You'll notice that I have a tremendous number
but hopefully you'll have a little, little bit fewer
than what I have.
You're looking for something like this right here.
You should see one called Elastic Beanstalk -
and then the name of the region
that your bucket or, excuse me, that your
Elastic Beanstalk was placed in.
So like I just said, mine is US-West-2.
So I'm going to be looking for something like
Elastic Beanstalk-US-West-2.
and mine is right there.
So I'm going to
click on that thing
and then I'll see the name of the bucket right up here
and it might be a little bit,
I'm having a tough time, select it myself.
There we go.
If I just right click it
I get the full selection and I can copy it.
So I'll take that back over.
And for the bucket name, I'm gonna paste it in like so.
And then we're going to also do the bucket path.
So this bucket right here where this S3 bucket
that's holding all these different files
it gets reused for all other different
Elastic Beanstalk environments that you create.
So as you can see, I've got a couple
of different environments that have been created over time.
And so inside of here, I'm going to be looking
for the folder that is essentially the name of my project.
Now, when you first create your Elastic Beanstalk instance
chances are it's not going to create a folder
by default automatically.
That folder is only going to be created the
first time that you do a deploy.
So by default, the bucket path
that you're supposed to use is going to be exactly equal
to the app name.
So you see I have app right here.
I'm gonna use the exact name for my bucket path.
So for me, I have docker as my app name
and I'm going to copy that right down to bucket path.
Again, you might have used something like docker - react.
So make sure if you have the different app name
make sure you use it in there as well.
All right, so now last thing we're gonna do in here
for right now, remember back to the entire
deployment flow that we spoke about a while ago.
We had said that we wanted to make sure that anytime
we deploy, or excuse me, we push our code
up to a feature branch on the GitHub repository,
we had said that we're going to make a pull request to merge
into master.
And we had said that the master branch
was essentially gonna be our very special branch.
Anytime we merge code into master
that means it is time to deploy our application.
If we just merge code or push code up to the feature branch
we don't want to deploy the app.
We don't wanna deploy the app using just the feature branch.
The feature branch is for active development
and it might have new features that are not
ready to be deployed.
So the last piece of configuration
that we're gonna put in there for right now,
we're gonna say only attempt to deploy the application
when the master branch gets some new code.
So as a very last thing that I'll do for right now, I'll say
on branch master like so,
and so, as you might guess
this essentially means anytime we push code
to branch master, that's the time to deploy.
All right, so I think that's good for right now.
Now there's gonna be two other tiny pieces
of configuration we have to add in
but those are gonna take just a little bit of time.
So take a quick pause right here
and continue the next section
and handle those two last pieces.