This project contains the infrastructure for the image uploader. It uses AWS CDK to create the infrastructure.
The infrastructure consists of the following components:
- API Gateway: It is used to upload images. The API Gateway has a POST method that triggers a Lambda function to upload the image to an S3 bucket.
- Lambda Function: It is triggered by the API Gateway to upload the image to an S3 bucket and return an image's url.
- S3 Bucket: It stores the images uploaded by the users.
- CloudFront Distribution: It is used to serve the images uploaded by the users.
- S3 Bucket Policy: It allows the Lambda function to upload the image to the S3 bucket.
- CloudWatch Logs: It stores the logs of the Lambda function.
- Node.js
- AWS CLI
- AWS CDK
- AWS Account
-
Clone the repository
git clone git@github.com:Camilo-J/Backend_ImageUploader.git
-
Install the dependencies
npm install
-
Deploy the stack to AWS(AWS CLI must be configured)
cdk deploy
-
After the deployment, you will see the output of the stack. You will see the URL of the API Gateway. You can use this URL to upload images.
-
To destroy the stack
cdk destroy
To upload an image, you can use the following command:
curl -X POST -F "file=@<path_to_image>" <API_URL>
For example:
curl -X POST -F "file=@./image.jpg" https://<API_ID>.execute-api.<REGION>.amazonaws.com/prod/upload
This project is licensed under the MIT License - see the LICENSE file for details.