Learn how to set up Amazon S3 for image storage.
- [Narrator] To add S3 interaction to our flask application for storing the images, you'll need to get credentials from the AWS console. Point your browser to https aws.amazon.com/console. If you do not yet have an AWS login you'll need to create one. You can use your standard login from amazon.com for this. Once you've done that you're ready to work with the S3 console. So sign into the console.
The first step we're going to do is to create a bucket. So under services, you'll see all of the AWS services available. Under storage you'll see S3. From here, select create bucket. You need to create a unique name here. Notice that is has to be unique across all of amazon. Something like first initial, last name, flask will work. I'll put kirstenhunter-flask, and the region I'm going to select US West.
That's what you'll want to select as well. Then click next. We're going to leave all these options unselected, they're not necessary for our application. Select next. Uncheck all of the security restrictions, what happens is you're able to manage the access control list for the buckets, but we're going to leave them open so that we can see them with the application that we're creating. So click next.
Get all of the information about the bucket you've created, so that you know that it's ready, to go, and create bucket. So the bucket has been created, you can see here kirstenhunter-flask. And the next thing that we need to do, is we need to set up credentials to make it possible for us to access those images. Whether we're running on our own local file system, or on Heroku. So the next thing we need to do is, services, under security, over here, IAM.
And we're going to create a new user. And use the credentials for that. So, we'll add the user, and the username, we can say: FlaskImages. This does not need to be unique across all of Amazon. So you can use a name that is meaningful to you. We need to click programmatic access, because that the kind of access that we want. The next thing we want to do, is to set the permissions. So, we're going to attach existing policies directly to that user.
And just search for S3, and you see AmazonS3FullAccess, that's what we want to give it. We don't need to add any tags. So, this is our conformation page, telling us exactly what we've created. And we can create the user. Now, these credentials you're going to need to copy, and paste, into a file, just as you did with the URL for the Postgres database. You won't be able to see these credentials again.
If you loose track of the credentials, you'll need to create a new set of credentials. They can do the same thing, but it will be another process to go through. So, save these out into a file, so that you have them when we need them later.
- Working with the Flask command line
- Using response templates
- Creating web forms
- Connecting to a database
- Authenticating users
- Uploading images to an S3 pipeline
- Deploying Flask applications to Heroku with Git