-: In the last section, we wired up a security group
to all three of our different important resources.
The Elastic BeanStalk Instance, RDS and EC.
Now, the very last piece of configuration
we have to do now is make sure
that our different containers inside
of the Elastic BeanStalk Instance
know how to reach out to RDS and EC.
And so to do so,
we have to set a couple of environment variables
just as we did previously
inside of our Docker composed file.
So remember inside of Docker Compose,
on our API or the Express server
we set up this list of different environment variables
and we did the same thing for our worker process as well.
Here it is right here.
We set up the Redis host and the Redis port.
So in order for both our Express API,
and the Redis server
versus me the worker to work correctly
we have to provide these different environment variables.
So that's what we're going to do
by using the console over on Elastic BeanStalk.
So I'm gonna make sure that I'm still looking
at my Elastic BeanStalk Instance.
I'm gonna find configuration on the left hand side
and then I'll select modify on the software card.
I went there really quickly, sorry about that.
On the software card, I'll select modify
and then down at the very bottom,
I'll see the different environment properties I can set up.
Now, I'll be honest with you,
these environment properties
do not get their values hidden over here.
And so once you enter these properties in
potentially other people could come to this page
and see your database password.
I've looked at the Elastic BeanStalk documentation
and supposedly this is nonetheless
where we're supposed to put these passwords.
I don't know if there's a better place out there.
If there is, I encourage you to add a note on this lecture
and say, "Hey, here would be a better way of doing this".
This is one of my kind of weak points in this regard.
So let's get to it.
We're gonna add on a collection
of different environment variables here.
We're gonna go just straight down this list
with all the different variables.
So the first one will add in is the Redis host.
So the name will be Redis host.
And then the value is not going to be simply
just like you know, Redis or anything like that.
It's going to be the actual endpoint or URL
of our running Elastic Cash Instance.
So to get that, we need to actually flip on over
to the Elastic Cash Dashboard one more time.
So I'm gonna scroll up, I'll go to services,
and then I'm going to open up Elastic Cash in a new tab.
And then I'll close the services drop down and go back down
to Environment Properties.
Now in the second tab that I just opened up,
I can look at Redis, I can click on the little arrow
right here to expand it.
And you're gonna see primary endpoint listed right here.
So we're gonna copy that primary endpoint.
Now note on the primary endpoint,
there's the colon 6, 3, 7, 9 to designate the port.
We don't want to copy that, so I'm gonna make sure
that I copy everything to the left of that colon.
So I'm gonna copy that.
I'll go back over to my Environment properties,
and for Redis host,
I'm gonna paste in the value of that endpoint.
Now take note on the very right hand side over here
I do not have a colon.
I do not have the 6, 3, 7, 9.
So please make sure that you trim that off as well.
So next up we'll do our Redis port.
So I'll again copy the name of the variable over,
and as you might guess,
we're using the default port of 6, 3, 7, 9.
So I'll set a value of 6, 3, 7, 9 like so.
All right, that's it for Redis.
So now we're going to move on to PG user,
all the other Postgres variables as well.
So for PG user, I'll copy that over.
And this is where I hope you still have that document
where we saved some of the different user names and whatnot.
So this is the different variables that we entered
when we created our RDS Instance or the Postgres Instance.
So my username that I used was simply Postgres.
So I will copy Postgres over for the PG user entry.
Next step, we need our PG.
Let's skip on down to the password
because those should really be right in a row.
So my PG password was Postgres password
and that's what I wrote down in my document over here.
Next step, we need our PG host.
So I'll put in PG Host.
We again need to open up the RDS dashboard just like we did
with Elastic Cash
and get the endpoint for our Postgres Instance.
So I'll flip back over to that second tab.
I'll again go up to services.
I'll go back to the RDS dashboard.
I'll click on the Instances section.
I'll open up the database Instance
and then finally down towards the bottom
and that details section, oh, not details
but Connect right here, I'll find the endpoint listed.
So I'm gonna copy that entire endpoint
and then I'll paste it back over
on my environment properties for the PG host, like so.
Okay, so we've got PG, User, password, and Host.
I think we just got a couple more here.
So we got PG database.
So that's our next key PG database for that.
My database name was Fib Values,
that's what I called my database.
And then finally we got our PG port.
That's the very last one, PG Port.
And as you can see over on the dashboard,
we did not change the default port of 5, 4, 3, 2.
Okay, now quick pause right here.
I gotta tell ya, in all the courses I've ever done
the most common air that I ever see in my life
this is repeated over and over and over again.
The most common air by far is people entering
in these environment properties
with incorrect spellings for the names or incorrect values.
So at this point, I gotta ask you please
I beg you triple check the names
of all the environment properties listed over here.
And I'm gonna tell you right now
if your application worked successfully
in our development environment
when we were using Docker Compose
but does not work properly,
when you push it up to Elastic BeanStalk
or you push it up to production
one of the first things that I will tell you
to troubleshoot is to come look at these variable names
and all the different values and triple check
to make sure that they are correct.
So I ask you again,
please triple check the names, triple check your values,
make sure you've got the correct things in here.
Now, once you've got everything entered in successfully,
will hit the apply button on the bottom right hand side.
Okay, so that's gonna make a couple changes
and apply them to our environment.
Okay, so that's pretty much it.
That's all we gotta do for setup.
Now, one little piece of trivia here
something you might be curious about.
Back when we put together the Docker composed file,
we had to manually specify all these environment variables
and specifically pass them into this specific service.
And we did the same thing for Redis on the worker
down here as well.
Now on Elastic BeanStalk,
when you set up those environment variables
they automatically get added
to all of the different containers
that you listed inside that Docker run AWS.JSON file.
So every single one of these containers has automatic access
to that set of environment variables.
So we do not have to do any additional environment variable
mapping, that makes life a little bit easier.
Okay, So that's pretty much it.
That's all we had to do for the AWS setup.
So now the very last thing we have to do
is couple more changes to the Travis.yml file
to make sure that after we successfully build
all these images and push them off to Docker hub,
we are gonna do that little tap on the shoulder
of Elastic Beanstalk and tell it to repo all the images
and attempt to deploy them.
So let's do another quick break.
Come back to the next section and start to wrap up
the Travis.yml file.