How to add Object Storage (S3 bucket) in AWS Lightsail instance?
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
AWS Lightsail provides object storage in the form of S3 bucket that you can attach to your Lightsail instance to store any static contents like images. S3 bucket is one of the cheapest cloud storages and can greatly reduce your storage cost.
How to add Object Storage (S3 bucket) in AWS Lightsail instance?
Prerequisites:
How to create Object Storage (S3 bucket) for AWS Lightsail instance?
Step 1: Login to AWS management console.
Step 2: Navigate to Lightsail console.
Step 3: In the Lightsail portal select “Storage” tab, click on “Create bucket”.
Note: Additional cost is associated with creating an object storage.
Select storage plan and provide a name and click “Create bucket”.
Note: The name must be unique across AWS.
How to upload and download objects in AWS Lightsail from console:
Step 1: In Lightsail portal => Click Storage => Select your bucket.
Step 2: Select “Storage” tab and click “Upload” to upload a new object in Lightsail object storage.
Select the object that you want to upload and upload to Lightsail object storage.
Step 3: Once the object is uploaded, you can download the object by selecting the object and clicking on the download icon.
How to access object storage from AWS Lightsail instance:
Step 1: In your object storage page, select the “Permissions” tab and click “Attach instance”. Select your Lightsail instance and click “Attach”.
Step 2: Upload an object to Lightsail object storage from AWS Lightsail instance
Connect to your Lightsail instance
1 2 3 4 5 6 7 8 |
## Create a new file echo "hello world" > hello.txt ## Upload the file to object storage aws s3api put-object --bucket techaffaire-object-storage --key mydir/myfile.txt --body hello.txt ## List all your files and folders aws s3 ls s3://techaffaire-object-storage/ --recursive |
How to use Lightsail object storage in your WordPress website hosted in AWS Lightsail:
Step 1: Change the object storage permission to allow objects to be public.
In Lightsail portal => Click Storage => Select your bucket.
Go to “Permissions” tab and click “Change permissions”. Select “Individual objects can be made public and read-only” and click “Save”.
Step 2: Login to your WordPress dashboard and install and activate the WP Offload Media Lite plugin.
Step 3: In the WP Offload Media Lite plugin setting, select “Amazon S3” with IAM role option and click “Next”.
Click “Browse existing buckets” and select the object storage that you have created previously.
Enable “Force HTTPS” and “Remove Files From Server” and click “Save Changes”.
Now all your media files will be uploaded to your object storage. Test it out by uploading an image in your WordPress media library.
You can also view all uploaded media in your Lightsail object storage console.
Hope you have enjoyed this article. To get more details on Lightsail, please refer below official documentation.
https://lightsail.aws.amazon.com/ls/docs/en_us/all