-: In the last section, we added in a tremendous amount
of configuration to our travis.yml file.
Now, the last thing we have to add in here
is a set of API keys that are going to give access
to our AWS account over to Travis CI.
The last thing we have to do
is generate that set of API keys
and then enter them into this travis.yml script.
So let's get to it.
I'm going to first get started
by opening up my AWS console again.
I'll then find the services tab at the top
and I'm going to search for IAM.
IAM is a service that is used to manage API keys
that can be used by outside services.
On the left hand side, let me zoom in here,
we're gonna find the section of users
'cause we're essentially gonna get generate a new user
that is going to be used by Travis CI.
Then at the top, I'll find add user
and then I'll provide a username.
So I'll give this a descriptive name,
how about something like Docker React Travis CI?
And then underneath that,
I'm going to give programmatic access only.
The set of API keys that we're gonna generate here
are only going to be used by Travis CI
through network request.
Travis CI is never going to be making direct use
of the AWS Management Console.
Then hit next for permissions.
And then we're going to attach existing policies directly.
So we don't have any other policy groups
or any other existing users.
We're gonna add some direct policies.
Now, these policies right here are essentially permissions.
We are granting permissions to this new user
that we are creating.
So right now, we're essentially listing out
all the different things that this new user
is going to have the ability to do.
In particular, we wanna make sure that this new user
has the ability to deploy our application
to Elastic Beanstalk.
So I'm going to search for Beanstalk
and then I'll see a bunch of different policies
that have been pre-generated by AWS up here.
You can look at the description of each.
By far, the easiest one to use
is Provides Full Access right here.
So I'm going to make sure that I find Provides Full Access,
and I'll go all the way over to the left hand side,
and click on that checkbox,
and then I'll click on Next Review,
and then I'll create user.
So that generates a set of API keys
that can be used by Travis CI to deploy our application.
Now, this is really important.
The secret access key that has been generated
is only going to be shown to you exactly one time.
So when you click on Show right here
and it shows you that API key,
you need to make sure that you write this thing down
because if you want to get access to this key again,
well, you can't.
You would have to regenerate the key entirely.
So we're going to now use the access key ID
and the secret access key.
Now, one quick thing.
We do not want to take those keys directly, our keys,
and put them directly into our travis.yml file.
Remember, right now, our GitHub repository
is entirely public.
So if we put those GitHub...
Or I mean, those AWS keys into our repo
and then push that up to GitHub, everyone in the world
is gonna have access to our AWS account.
And so above all, we're gonna make sure
that we do not put those keys directly in here.
Instead, we're gonna make use of a feature
of environment secrets provided by Travis CI.
So I'm gonna go back over to my Travis dashboard.
Remember, you can get here at travis-ci.org,
and I'm gonna pull up my project.
So again, I called mine Docker React.
Then on the right hand side, I'll find the More Options
and I'll go to Settings.
We can then scroll down a little bit
and find Environment Variables right here.
So this right here is where we are going to stash
those secret keys.
These environment variables are going to be encrypted
and stored by Travis CI.
So we don't have to worry about outside people
getting access to those keys
and kinda making use of them in a bad way.
With each key, we provide a name and a value for that key.
So the first key that we're going to define
as an environment variable is our access key.
So I'm going to copy the access key
then I'll provide a name over here of AWS access key
and I'll paste the value in like so.
And notice how we're going to make sure
that "Display value in build log" is not checked
'cause we do not want to display this value in the log.
I'll then click on Add and as you can see,
it essentially gets tucked away
and I can no longer really get access to it.
All right, now we're gonna do the secret as well.
So I'll copy the secret,
make sure you get the entire secret.
I'll go back over and I'll define a second key.
I'll call this one AWS secret key
and I'll paste in the value for that as well.
And then I'll hit Add.
All right, so we've now got our two access keys,
our both the access key and the secret key
successfully encrypted on Travis CI.
We'll now go back over to our travis.yml file
and inside of here, we're gonna say,
"Hey, I have an access key for you, but you're gonna get it
from the local environment configuration."
So I'll say, "Access key ID is going to come
from the environment variable of $ AWS_ACCESS_KEY,
and for secret access key,
AWS_SECRET_KEY."
And I personally, actually had to wrap this
in double quotes like so.
So you might wanna do that as well.
According to the documentation, I don't think you have to,
but I found that you had to.
Okay, so that's pretty much it.
So now, after Travis CI attempts to build our project
and run our tests,
it will then attempt to deploy our application
over to Elastic Beanstalk.
So as the very last thing,
we're going to commit all the work that we have now done
and we're going push it up to the master branch on GitHub.
Again, we're going to eventually use this
kind of nice feature branch flow.
But for right now,
we just wanna make sure things are working,
so we're gonna push directly to master.
So I'm gonna go back over to my terminal,
I'll do a git status and just double check to make sure...
Yep, I changed that file.
I'll do a git add, a git commit,
and I'll say something like, "Added Travis deploy config,"
and then I'll do a git push origin master.
All right, so now again, if I flip back over to Travis CI
and go back to my dashboard for my project,
in just a moment or two, I'll see something up here
right here that says, "Okay, we're running a new build."
And just like before, you might have to refresh the page
to get that to actually pop up.
So I'll do so now
and it looks like it's not quite coming in just yet
but it should, just any moment.
So let's take a quick break right here.
I'll let the build finish up
and then we'll continue in the next section.