📺 Develpreneur YouTube Episode

Video + transcript

Intro To AWS S3 With Python

2023-10-17 •Youtube

Detailed Notes

We start a new series of tutorials as we build out a backup system that drops archive files into Amazon's S3 and related storage. This episode gets us started with the Boto3 library and AWS command line interface configuration. We wrap it up with a simple script to list the S3 buckets on our account.

You can find out more through our online classes at https://school.develpreneur.com and register for free. Registration will add you to our email list and you will periodically receive coupons for courses as well as notifications of the latest releases.

Transcript Text
[Music]
well hello and welcome back we are
embarking on something a little
different uh this time we're going to
spend a little bit of time we're
building a script that is in Python
we're going to utilize Amazon
AWS or S3 and all of those related
buckets and what we're going to do is
it's really going to be something rather
simple utility where we can take a file
that is a
backup uh eventually we're going to
actually build this it's going to go you
point it to a folder it's going to grab
all that stuff it's going to uh you
compress it all together throw it into
effectively a you know a tar file if you
know anything about that and then we'll
shove it out to S3 and then we'll also
have the ability to pull those things
back down a lot of this is related to
using Amazon's CLI their command line
interface and a thing called Bodo
boo3 which is a library for Python and
we'll go ahead and get started and just
go as far as we can with each of these
episodes this one really going to get
set up so the first thing you need to do
with this uh the photo is you're going
to have to pip 3 install it it's just
B3 and it will take a second to do it I
and by a second I mean a couple of
them and then we're ready to
go so what I've got here
is I think it's called this yep what
I've got here is a really simple
script and I grabbed this
from uh some examples that are out there
if you go out and we'll get a uh I'll
have a list out there link out in the
notes for
this let's do this
um and uh there's a lot of great
examples uh the first we're going to do
is we're just going to go out to our
buckets if you don't know much about
S3 it is uh such it's a file storage
system uh it's I think I forget what the
three s's are it's a simple something
storage and what it does is it allows us
to put files out there in folders and
then we can always retrieve them back
via essentially URL and there's some
other things we can do around a
permissions and such so we're going to
do first we're just going to do a super
simple client that allows us to connect
to our
account and then pull a directory of the
uh of the folders that we have oops go
to this one because it's easier to read
and they're called buckets our folders
are essentially our folders are called
buckets and so all we're going to do is
we're going to connect uh to S3 and this
can go to uh other AWS Services as well
so we're keeping it oh it's simple
storage service that's what it was um so
we're going to keep it you know sort of
sticking to that for now uh we may
Branch out in future items or future
episodes so right now it's just going to
come in we just print a little line and
then we're just going to walk through
each buckets and each bucket and print
the bucket name so it's fairly
straightforward um and all we need
really all we need here is the boo3
because you're going to see we're using
it to connect and uh then we're just
going to get all the buckets and then
we're just printing it out so I've got a
few other things floating in there at
Imports that we will use later but not
right now um let me get out of
this so now if I take this little script
that I wrote we're going to
find that oops it's not python it's
Python 3 so if I try to run it this
probably what's going to happen so we've
we've installed Bodo 3 and basically
what's going to end up is you're going
to get some variation of access toide
and the reason that is is because we
need to have the command line interface
set up in order to do this and so order
to use the python Library we need to
have the command line interface set up
now if you come to this link uh which I
will throw that in there as
well uh this is a c my
downloads and it's really simple it's
just amazon.com uh aws.amazon.com
CLI and then it will do a you've got a
little getting started over here uh you
can basically grab it for Windows for
Mac uh Linux Amazon Linux so we're going
to do for this one we're going to do the
Linux
installer
and so I can actually do let's see if
this is updating I don't have to worry
about
this uh so I'm going to come in and I'm
just going to pull it down it used to be
that there was a package for it
apparently so let's go set this up in
our
server uh that's good enough place for
it okay got
it and then I just want to unzip it so I
need to get uh to do this I need to get
unzip so I'm going to do unzip on dbn I
can go out there basically if you just
go Google unzip dbn1 or what whatever
your operating your Linux operating
system is you can do that you may
already have unzip available uh in this
case I did not so now I uh pulled that
out
and I'm assuming I got it all uh should
be all
there interesting enough
okay and then I should be able to once I
unzip
it do a AWS
[Music]
install oh for some reason it did not
unzip right uh let's see oh I did not
unzip it that's why uh unzip there we
go I installed it I forgot to unzip it
now we'll go in and then we're just
going to run this uh install so now I'm
going to have the Amazon command line
interface will be in installed uh there
we go so now I should be able to do uh
it's I believe it's AWS
C well let's go back and look so it's
just a I need to do a configure which is
AWS
configure and what it's going to do is
going to ask me for a key and
a a password and so what I need for that
is I need to go over and we'll just do
this if I want to do um
AWS access key let's call it S3 we'll do
that and it'll take us security
credentials and this will walk you
through setting those up uh so you'll
basically have to go get yours you'll
need to log into your account so that
you can go uh with your access keys and
you'll be able to see where they're at
and where you're able to set those up
I'm not going to go into that because
your account may look a little bit
different and I don't want to expose my
my keys uh so I'm going to jump back in
a second I'm going to go ahead and enter
my two uh if you need something if you
need to reach out to me definitely email
them and we can always walk you through
it uh but I'm going to go ahead and
enter these keys and I'll be right back
it's going to ask you a couple of things
it's going to ask you a default region
and some things like that you don't need
those uh what that's going to do is
that's going to set everything up for
you so that once you've got your B3
installed plus your um your command line
your CLI configured then what you should
get and this is where you be able to
test it is if you run that back up you
should be able to see that hey wh that
it connected and it's going to give you
some buckets now in this case I've got
four buckets in there and so it's just
going to list through each of those and
so I've got a very simple uh sort of
hello world uh program going on
here
[Music]
Transcript Segments
0

[Music]

16.76

well hello and welcome back we are

19.76

embarking on something a little

20.8

different uh this time we're going to

22.359

spend a little bit of time we're

23.72

building a script that is in Python

28.359

we're going to utilize Amazon

30.599

AWS or S3 and all of those related

33.92

buckets and what we're going to do is

35.719

it's really going to be something rather

37.239

simple utility where we can take a file

39.16

that is a

40.2

backup uh eventually we're going to

41.96

actually build this it's going to go you

43.36

point it to a folder it's going to grab

44.68

all that stuff it's going to uh you

46.64

compress it all together throw it into

49.16

effectively a you know a tar file if you

51.719

know anything about that and then we'll

53.76

shove it out to S3 and then we'll also

56.359

have the ability to pull those things

58

back down a lot of this is related to

60.96

using Amazon's CLI their command line

63.08

interface and a thing called Bodo

67

boo3 which is a library for Python and

70.72

we'll go ahead and get started and just

72.56

go as far as we can with each of these

73.799

episodes this one really going to get

75.04

set up so the first thing you need to do

78.28

with this uh the photo is you're going

80.759

to have to pip 3 install it it's just

86.56

B3 and it will take a second to do it I

89.92

and by a second I mean a couple of

92

them and then we're ready to

94.24

go so what I've got here

99

is I think it's called this yep what

102.72

I've got here is a really simple

104.68

script and I grabbed this

108.84

from uh some examples that are out there

111.479

if you go out and we'll get a uh I'll

113.719

have a list out there link out in the

116.64

notes for

118.079

this let's do this

126.56

um and uh there's a lot of great

129.879

examples uh the first we're going to do

131.44

is we're just going to go out to our

132.68

buckets if you don't know much about

135.44

S3 it is uh such it's a file storage

138.84

system uh it's I think I forget what the

141.64

three s's are it's a simple something

144.56

storage and what it does is it allows us

148.12

to put files out there in folders and

150.48

then we can always retrieve them back

151.879

via essentially URL and there's some

154.48

other things we can do around a

155.64

permissions and such so we're going to

157.8

do first we're just going to do a super

159.68

simple client that allows us to connect

163.239

to our

164.159

account and then pull a directory of the

168.319

uh of the folders that we have oops go

171.56

to this one because it's easier to read

173.2

and they're called buckets our folders

175.04

are essentially our folders are called

177.519

buckets and so all we're going to do is

179.4

we're going to connect uh to S3 and this

182.36

can go to uh other AWS Services as well

185.2

so we're keeping it oh it's simple

187.12

storage service that's what it was um so

190.56

we're going to keep it you know sort of

192.36

sticking to that for now uh we may

194.12

Branch out in future items or future

198.08

episodes so right now it's just going to

199.959

come in we just print a little line and

201.2

then we're just going to walk through

201.959

each buckets and each bucket and print

203.76

the bucket name so it's fairly

207.159

straightforward um and all we need

209.319

really all we need here is the boo3

212.56

because you're going to see we're using

213.64

it to connect and uh then we're just

216.76

going to get all the buckets and then

218.12

we're just printing it out so I've got a

219.64

few other things floating in there at

220.959

Imports that we will use later but not

223.2

right now um let me get out of

227.2

this so now if I take this little script

229.879

that I wrote we're going to

233.36

find that oops it's not python it's

236.36

Python 3 so if I try to run it this

239.439

probably what's going to happen so we've

240.92

we've installed Bodo 3 and basically

244.079

what's going to end up is you're going

245.12

to get some variation of access toide

248.48

and the reason that is is because we

250.239

need to have the command line interface

252.68

set up in order to do this and so order

254.56

to use the python Library we need to

257.919

have the command line interface set up

260.239

now if you come to this link uh which I

263.28

will throw that in there as

267.4

well uh this is a c my

272.479

downloads and it's really simple it's

274.4

just amazon.com uh aws.amazon.com

279.199

CLI and then it will do a you've got a

281.919

little getting started over here uh you

284.919

can basically grab it for Windows for

286.759

Mac uh Linux Amazon Linux so we're going

289.32

to do for this one we're going to do the

290.919

Linux

293.08

installer

298.039

and so I can actually do let's see if

301.12

this is updating I don't have to worry

303.28

about

304.16

this uh so I'm going to come in and I'm

307.52

just going to pull it down it used to be

308.919

that there was a package for it

310.28

apparently so let's go set this up in

313.639

our

316.44

server uh that's good enough place for

318.4

it okay got

320.24

it and then I just want to unzip it so I

324.639

need to get uh to do this I need to get

326.44

unzip so I'm going to do unzip on dbn I

329

can go out there basically if you just

330.88

go Google unzip dbn1 or what whatever

334

your operating your Linux operating

335.319

system is you can do that you may

336.479

already have unzip available uh in this

338.72

case I did not so now I uh pulled that

343.16

out

345.479

and I'm assuming I got it all uh should

349.24

be all

351

there interesting enough

354.56

okay and then I should be able to once I

357.319

unzip

358.479

it do a AWS

362.53

[Music]

367.919

install oh for some reason it did not

370.16

unzip right uh let's see oh I did not

372.599

unzip it that's why uh unzip there we

379.199

go I installed it I forgot to unzip it

381.68

now we'll go in and then we're just

383.52

going to run this uh install so now I'm

385.84

going to have the Amazon command line

388.56

interface will be in installed uh there

390.759

we go so now I should be able to do uh

394.8

it's I believe it's AWS

398.12

C well let's go back and look so it's

401.52

just a I need to do a configure which is

403.199

AWS

404.919

configure and what it's going to do is

406.639

going to ask me for a key and

410.479

a a password and so what I need for that

414.479

is I need to go over and we'll just do

417.08

this if I want to do um

420.84

AWS access key let's call it S3 we'll do

424.44

that and it'll take us security

426.52

credentials and this will walk you

428.36

through setting those up uh so you'll

430.639

basically have to go get yours you'll

431.84

need to log into your account so that

434

you can go uh with your access keys and

436.879

you'll be able to see where they're at

438.72

and where you're able to set those up

441.44

I'm not going to go into that because

442.4

your account may look a little bit

443.36

different and I don't want to expose my

446.639

my keys uh so I'm going to jump back in

448.96

a second I'm going to go ahead and enter

450.28

my two uh if you need something if you

453.08

need to reach out to me definitely email

454.44

them and we can always walk you through

455.759

it uh but I'm going to go ahead and

458.56

enter these keys and I'll be right back

460.68

it's going to ask you a couple of things

462.12

it's going to ask you a default region

464.759

and some things like that you don't need

466.28

those uh what that's going to do is

467.919

that's going to set everything up for

469.199

you so that once you've got your B3

472.879

installed plus your um your command line

477.4

your CLI configured then what you should

480.479

get and this is where you be able to

482.72

test it is if you run that back up you

485.36

should be able to see that hey wh that

487.919

it connected and it's going to give you

490.24

some buckets now in this case I've got

492.879

four buckets in there and so it's just

495.4

going to list through each of those and

497.68

so I've got a very simple uh sort of

500.039

hello world uh program going on

508.24

here

510.72

[Music]