[Music]
hi my name is Nikki and I'm a senior
technical product manager at AWS heavily
focused on the dotnet developer
experience today we're going to be
talking about dotnet core on code builds
let's begin by discussing what code
build is and how we can use it so code
build is a fully managed build service
that compiles your source code runs
tests and produces software packages
that are ready for deployment with code
build you won't need to provision manage
or scale your own build servers it
scales continuously it can process
multiple builds at the same time so
nothing is left waiting in the queue you
can get started right now by using
prepackaged built environments or you
can create custom build environments
using your own build tools and also it's
important to note that with code build
you are charged by the minute for the
compute resources you use so you can add
code build as a build or text action to
a stage or a pipeline in AWS code fine
so basically code build would be a part
of continuous integration continuous
delivery and obviously AWS code pipeline
is our continuous delivery service that
enables you to model visualize and
automate the steps required to release
your code so before we get started with
the demo it's important to have the
following information and plan our build
essentially so the first thing we need
to know is where is your source code is
it in github is it in code commit is it
an s3 and then the second thing would be
which build commands do we need to run
and in what order do we need to install
something pre build for example or post
builds and then you know which runtimes
do we need to build so in this case it's
going to be done at core and do you need
AWS resources that aren't provided
automatically by AWS code build so you
know we're gonna give code build an iam
service role and we need to give that
service role the policies necessary to
carry out the actions that needs to take
on other AWS services and then lastly do
you want code build to work with your
VPC yes or no so in this case it's
going to be necessary but it would be if
you wanted to use it in with a V PC so
now let's get into the demo and we're
gonna go into the AWS management console
to take a look at what code build looks
like so now we are in the AWS management
console and you can find code billed
under developer tools so we're just
gonna go ahead and click on it and then
we would like to make sure that we're in
the right region so for me that's us
East one then I'm going to go ahead and
create a project I'm going to choose a
project name so for the purposes of this
demo code build net test works for me
I'm not going to add a description but
you can source providers this is going
to be what I mentioned earlier where is
your source code my source code is in
code commit so then once I choose code
commit I have the option to choose the
repository which in this case it's going
to be the chat bot Lex repository I
actually built the AWS chat pod which is
pretty cool git clone depth how many
layers deep do I want to go cloning so
only one there's only a master branch in
this repository and then if I turn build
badge on my build status is actually
visible from a public IP and it's
embeddable so I want to leave that off
for now environment image I'm going to
use an image managed by AWS code build
but if you wanted to specify a docker
image you could select the environment
type and a custom image type or one from
Amazon Elastic container registry if you
chose other then you would specify your
custom image ID but again for the
purposes of this demo I'm going to use
an image managed by AWS code build I'm
going to choose Ubuntu for the operating
system for the runtime obviously dotnet
core since we are building a dotnet core
project and I wrote my project in dotnet
core 2.0 so for a runtime version I'm
going to choose 2.0 privileged so this
you would check if you wanted your
builds to get root privileges or your
docker images I don't need that so I'm
not going to check that and then the
build spec so here I have the option
to either choose use the builds back um
will file in the source code root
directory or insert build commands in
this case I actually made a build spec
Hamel file and let's talk about what
that is for a second so let's switch
over to visual studio this is my build
spec UML file a built spec file is just
a it's a build specification file that
includes you know the building compiling
running tests basically any command that
you need to run to tell code build to
build your project correctly and also
the artifacts so the artifacts are going
to be files that the server that you're
deploying to needs to use to build your
project correctly once it gets on the
server so in this case I'm willing to
tell code build to compile my code and
then I want to restore the NuGet
packages and then in the build I want to
just go ahead and build it and then I
want to publish it and so I'm publishing
it to a file called build output and I'm
actually including that file in my
artifacts along with scripts and an app
spec yamo and so the again the app spec
yeah Mel is going to tell the server
that you're deploying to how to use
these scripts and the binaries that you
just output so in the app spec mo you
can see here you know I'm telling it
which script to run before install after
install I'm stopping if there's an
existing application on this server I'm
stopping it an Apache before I install
or do anything before I put it back
basically so that's the point of the app
spec and the build spec and they are
yeah Mel files and you can create them
in Visual Studio so in this case going
back to the console I have created my
builds back llamo file and it is in my
root directory of my code commit
repository so I'm going to call it
builds back if it was not in the root
directory of my code commit I would need
to specify the path here so you know as
an example test slash whatever it is but
not necessary here certificates I don't
have any
Civic server certificates so I do not
need to install them but if I did I
couldn't post them on s3 and install
from their artifacts so if I wanted to
save my artifacts from the project we
just talked about the artifacts that I
chose for this project I could specify
s3 and why would I do this I would save
my artifacts so that code pipeline could
pick up the binaries and go to the next
stage of the pipeline but in this case
I'm just running this build and it is
not a part of a code pipeline so I do
not need to save my artifact so I'm
going to say no artifacts and I'd also
don't need to cache them for any amount
of time so then moving on to service
role I've already created a iam service
role which has a long not so a cool name
but that's ok so I could also create one
if I wanted to and AWS code build will
modify it so that it can be used with
the build project which is pretty cool
I'm gonna choose an existing role and my
role is this long name I don't have a VP
C so I'm gonna say no VP see if I look
at Advanced Settings timeout is one hour
that's perfectly fine my build is very
small I don't have an encryption key
because I'm not encrypting my artefact
files but if I was I would put one here
compute Type three gigs of memory is
perfectly fine two virtual cores is
excellent so I'm not going to change
that environment variables so
environment variables we're going to
talk about them for a second so these
are all the environment variables that
you can use in your build commands so
back in your build spec file if you
wanted to specify something for a
specific command you could use any of
these environment variables and you
would just have to specify them in the
console and add value tags this is going
to be important if I'm using several AWS
services for this project if I tag it in
all the services that I'm using then I
can track the exact cost that that
project is costing me and possibly
better manage the resource
configurations of the project
in this case I do not have any other
services being used for this project so
I'm not going to tag it going ahead and
click continue on this page is just
basically making me review the settings
that I chose which look great to me so
I'm going to say save and build I'm
gonna choose the branch which again was
the master branch because that's all
that's in there and then I'm going to
click start build so this is pretty cool
because on this page you can actually
watch the build happen in action and as
you're watching it you know second here
the logs will actually show up so you
can see very quickly and very
specifically where the build failed so
it's in progress should take a few
seconds it actually tells you how many
seconds each phase took so succeeded 20
seconds now it's downloading my source
code so now the build blogs show up and
you can see very quickly what's
happening and then you know you can see
that it's installing it's in pre build
all the builds commands from the build
spec file you can see you at which stage
it's entering them so you can scroll
through and then it's now in pre build
looks like install succeeded now it's
building my project and then it's going
to you know publish it to the output so
you can see exactly the code line that
was from the build spec file running in
the build logs and then now my build has
succeeded and completed and all stages
succeeded so my project works and it is
ready to be deployed to a server so if
it was a part of a code pipeline code
deploy would pick this up and send it to
the server that I wanted to deploy to so
now we are going to do this same demo
but from the terminal so I wrote this
little note of the important
man's if you were doing this exact same
process from the terminal so the first
thing you're gonna do is you're gonna
generate the JSON skeleton and the JSON
skeleton is just going to be a JSON
object full of all the settings that we
just set in the GUI on the console now
in a JSON object so let's just copy this
and open the terminal and so once we
once we do this we get this nice empty
JSON object that we can then copy to a
JSON file called create - J create -
project jason so i already have one here
for us so I'm going to open mine so this
is mine I already have it prefilled out
ready to go and I have saved it to my
desktop so now what I'm gonna do is I'm
gonna come back and I'm gonna take this
command AWS code build create - project
and then I'm specifying that this is the
name of my file and I've already made
sure that I'm in the right place in my
terminal so you can see I'm on the
desktop I'm going to click enter and
then it should tell me inside here if it
was successfully created
I can also check the console though so
let's do that let's go back here so I
did this in another region so we could
make sure that it was created properly
and there it is there is the project
that I just created from the command
line
so now let's build it so that's one last
command which is AWS code build start
build and then you indicate the project
name which my project name was code
build test on it ok so we're gonna go
back to the terminal we're gonna paste
the command and then we're gonna type
code build test dotnet and click enter
and then it should say that the build
status is in progress and then again we
should be able to watch it from here if
we refresh click in here
in progress this is the one I just
started from the command line
and now we can see that it's already in
progress and it is provisioning and we
can continue to watch it just like we
did the other one again seeing the build
logs as it happens this one is going
very quickly so install variety and pre
build now it should be done very fast
this is a smaller project so now we're
in build and again if you pay attention
you can see the same commands that you
indicated in your build spec file being
spit out by the build logs and now it's
completed and you have now built your
code build project from the terminal
with the completion of this terminal
demonstration using the AWS CLI this
actually completes the dotnet core on
code build demonstration so now that you
have created your code build project and
it has successfully built you can add it
as a part of your continuous integration
continuous delivery pipeline using AWS
code pipeline and code deploy for more
information on AWS code pipeline and
continuous integration and continuous
delivery with AWS please see the link
below in the description of this video
thank you so much for watching and I
hope you enjoyed
[Music]