Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Okay, so let's practice using EC2 Image Builder.
So let's go into the EC2 Image Builder service
and have a play with it.
So I'm into the service,
we can get started, we can create an image pipeline.
And so here's our first pipeline,
we'll call it my demo pipeline,
and then we have the option to create a build schedule.
So as we can see here,
we can schedule it to happen every week on Monday at 9:00 AM
and customize this.
And we can also say that you should run
at the scheduled time only if there are dependency updates,
these kind of things,
or just run every time based on schedule.
We can specify CRON expression,
but we'll just have it manual
because we're running it manually in this hands-on.
I'll click on next,
next we are to choose a recipe.
And so a recipe is a document
that defines how the source image is going to be customized.
And we need to create a new recipe
because we don't have one yet.
And here we have two options,
we can create either an AMI
out of the EC2 Image Builder service,
or a Docker image,
but for this instance,
we'll use an AMI.
Okay, so we'll call it MyDemoRecipe.
We need to provide a version, so 1.0.0,
and then we need to select a source image.
So we can either create one from images created by AWS,
or enter a custom AMI ID.
So we'll just go with managed images,
we'll choose Amazon Linux 2,
but we have different options as well as you can see.
We'll scroll down,
the image origins going to be quick start
from Amazon-managed,
and for the image ARN,
please choose Amazon Linux 2 x86, okay?
Do not choose ARM64, choose x86,
otherwise you will see an error later on.
Then we'll click on use the latest available OS version,
we'll scroll down,
and here is the interesting part,
so components, is how do we want to customize our image.
So we can apply the build components
that are pre-created by AWS,
for example,
if we wanted to have Java on our image and our AMI,
currently, there is no Java on Amazon Linux 2,
but if you select amazon-corretto-11-headless,
then you would have Java 11 being installed on your AMI,
so great.
And if you go to the next page,
there's another thing I want to install
which is aws-cli-version-2-linux,
so currently only version 1 is installed onto my AMI,
but if I wanted to upgrade it to version 2
then I could select this build component.
And it is possible for you to really create
your own build component if you wanted to,
if you wanted to customize and install your own application,
for example.
Okay, so let's scroll down,
and as we can see now we have the two components,
we can reorder in which order they're going to be installed,
so we can say first install the cli-version-2,
and then install the Java 11 from Amazon called corretto.
Okay next, how do we want to test
that the AMI is working, post-build?
We have different tests available here,
we can create our own test,
but I'm going to skip this
because we don't want to run any tests on our instance.
And then I will click on next.
Okay so next, how do we want to create this AMI?
On what type of EC2 instances
do we want to create our image?
And so, as we can see here,
we can either create the infrastructure
using service defaults,
or create a new infrastructure configuration.
So we want to select the last option,
and for this we'll create an IAM role,
so we'll call it the IAM role here,
see we have to choose?
Currently we have no results available,
but I'm going to go ahead
and create a new role for EC2 Image Builder.
So I'll click on create new role,
and I'm going to roles,
and I'll go and click on create role
for AWS service,
and this is going to be a role for EC2 instances.
Next, permissions.
And so here we need to start attaching policies.
So if I go back to the EC2 Image Builder,
and click on create using service defaults,
it says that here,
in order to have a correct role,
we need to create a role name with this role name.
So I'm going to,
sorry, the role name will have a letter,
but we need to attach some policies to it.
So we need to attach this first policy, called the
EC2InstanceProfileForImageBuilder.
We need to attach the second policy,
which is ECRContainerBuilds
if we wanted to create Docker images,
and the last, we need to attach is
the AmazonSSMManagedInstanceCore managed policy.
So all these things are necessary
for EC2 Image Builder to work.
I click on add tags,
next review,
and the role name,
I'm just going to give the default role name right here.
So I'm creating this role manually
because when I did create it automatically,
it wasn't correctly working,
so I wanna make sure this is done correctly.
So we have this create role dialogue,
and we're good to go.
Okay, so the role has been created.
Here's my EC2InstanceProfileForImageBuilder
that has been created.
And now in the image builder,
I'm going to click on
create new infrastructure configuration,
MyDemoInfra,
and the IM role I'm going to choose
is the role I just created right now
called the EC2InstanceProfileForImageBuilder.
Okay, now why do we do this?
Well, because we want to be able to customize
the AWS infrastructure,
and as such, I want the instant type to be of type t2.micro,
and the reason I'm doing this
is that I really want to be able to run
on the fridge here for this hands-on,
so that you don't pay any money.
If you were to run with the default settings,
then it will start launching an M5 large instance,
and you will have to pay for it, obviously.
As you can see, the t2.micro only has the x86 architecture,
it doesn't have the ARM64,
and this is why we've selected an AMI that was x86,
and not ARM64.
So next I scroll down, click on next.
And then for distribution settings,
we can either use the default,
and see that my AMI
is going to be distributed in the region I'm in,
which is eu-west-2.
But you could create a new distribution setting,
and in here you can set up region 1,
but also set up region 2,
and region 3, for example,
if you wanted to distribute your AMI
to different regions automatically,
which is really, really handy,
but for this hands-on,
we'll just use a service defaults,
and have the AMI in one region.
I'll click on next.
Everything does look good to me,
and I will click on create pipeline.
Okay, so everything has been created.
Now, let's click on our pipeline,
MyDemoPipeline,
and I'm going to do action,
and run pipeline,
and this is going to start an execution.
And so here I can click on view details,
and we're going to go straight into the execution.
So here is the output image, it is pending.
I'm going to click on it,
this opens a new screen,
and I'm going to wait until the build starts.
Okay, so my instance is now in the building stage,
and so that means that if I go into the EC2 service,
I should start seeing an EC2 instance.
So let's go into the EC2 service,
let's close this, go to instances,
close this again,
and we have here our build instance for my demo recipe.
So this instance was created by EC2 Image Builder,
and you can verify it by going into tags, for example.
And you can see that the created by tag
is for EC2 Image Builder,
the Ec2ImageBuilderArn
corresponds to the image we created,
and the name is build instance for my demo recipe.
So some stuff is happening right now on my instance,
as we can see the IAM role for my instance
is EC2InstanceProfileForImageBuilder,
which is the role that we have created just before
that contains the three policies
that we've attached manually to make sure
that everything was working correctly.
So what I'm going to do now
is just pause the video,
and wait for the build stage to be done.
So I just refreshed the page,
and the status is now testing.
So let's go have a look at what's happening here.
So if I go into my instances and refresh this,
we can see that my builder instance has now been terminated,
because we have built the AMI from it,
and my test instance is now running.
And if I look at my test instance and scroll down,
we can see that the AMI right here,
which I'm going to click on,
the AMI is a new AMI that has been created.
And the AMI name is MyDemoRecipe,
and contains the timestamp of when it was created.
So now the test instance is actually launched
from this new AMI, and is being tested.
So this AMI, as we can see if we go to the tags,
has been created by the EC2 Image Builder service,
and we can see the ARN right here as well.
So this is quite cool,
because now we can see that the AMI
has been automatically created,
and now it's in the test phase.
So let's wait a little bit until the test is done.
Okay, so now the status is distributing,
so the test phase is now done,
so there was no test being run on our AMI, obviously,
but if they were any tests,
then the test instance would've been running this test.
So now the instant test is also being terminated
which is good.
And then we are in the last stage
which is the distribution setting.
So if we look at it,
right now we only distribute to one region,
which is eu-west-2,
which is where the AMI was created,
so nothing much is going to happen.
But if we were distributing that image
into the United States,
into Southeast Asia, all these kind of places,
then the distribution would happen right now.
Okay, so my image is now available,
and this was good.
So if you go to images,
we can see that it was created, so perfect.
So let's just make sure that it actually did
what I wanted to do.
So if I go and launch an instance,
so I will call this one,
Test from AMI,
and I will choose my AMIs,
and I will choose the demo recipe
that I just created using the EC2 Image Builder service.
I will scroll down,
I will choose t2.micro,
I will proceed without a key pair,
because I will use EC2 instance connect
to run some commands.
Then for network settings,
I'm going to edit it,
and then choose an existing security group,
I'll choose my Launch-wizard-1.
So we can ssh into our instance, scroll down,
and actually none of the rest is necessary,
so I'll just click on launch instance,
and I'm good to go.
So my instance is now launching.
So my instance is now running,
so I'll click on connect,
I will use the EC2 instance connect service
and the username has to change,
it is ec2-user,
because we created a custom AMI,
we need to tell AWS
that we still want to use the ec2-user user
which is coming from Amazon Linux 2.
So I am into my image,
and we can verify two things.
Number one, that the aws-cli version 2 was installed,
so as we can see, it says version 2.7.0,
so indeed version 2 was installed,
which is an upgrade,
and then we can also verify that Java was installed.
And for this, we can verify indeed
that's we are running the openjdk version 11,
which is Amazon Corretto 11.
So our EC2 Image Builder works,
and we exactly had the output we wanted.
So now just to clean up what we have,
let's just terminate our instance.
Next, what you can do is go into your AMIs,
and from here, you can actually deregister your AMI,
and finally, in snapshots,
you can take your snapshots.
And I got two, 'cause I got different ones
but take the snapshot that was created
by the EC2 Image Builder,
which is this one,
and then action, delete snapshots,
and you are good to go.
Okay, you can leave the pipeline running
because while this is a manual pipeline,
so it's not going to run on its own.
So that's it for this lecture,
I hope you liked it,
and I will see you in the next lecture.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.