S3 integration with Vapor

We use S3 to store files in the cloud for easy and secure access. We use some Vapor packages to integrate Vapor application with S3. The implementation is different for the Vapor versions.

Vapor 4 Integration


Add the S3 package to the dependencies and target.

dependencies: [
    .package(name: "AWSSDKSwift", url: "https://github.com/swift-aws/aws-sdk-swift.git", from: "4.7.0"),
targets: [
    .target(name: "App", dependencies: [
        .product(name: "S3", package: "AWSSDKSwift"),

How to add autoincrement field in Vapor

We have created a new model in Vapor with id as UUID and other fields.

// Property Wrapper
@ID(key: .id)
var id: UUID?

Now we got a requirment to add an autoincrement field which can be used to identify the object like model_number. Since the default id field is UUID we cannot use the exisitng id for this purpose. If we are creating a new model with this scenario, we could have used the id as an autoincrement identifier:

// Migration
.field("id", .int, .identifier(auto: true))

Sendgrid integration with Vapor

SendGrid is a customer communication platform for transactional and marketing email. SendGrid provides a cloud-based service that assists businesses with email delivery. How can we integrate Sendgrid with our Web application (Vapor) to send emails?


Vapor 4 migration issues and fixes

I was working on a software product with backend server implemented using Swift and Vapor. We were using Vapor 3 and wanted to migrate it to Vapor 4, since Vapor 4 released on Apr 2020. We followed the upgrading link from Vapor docs to start the upgrading process. In this blog post I will give some additional information about the issues we had faced while upgrading to Vapor 4.


Kubernetes Cluster Setup with AWS Cloud Provider


In my previous blog post, I have shown you how to setup a Kubernetes cluster on AWS EC2 instances. I tried deploying a sample application with a public docker image from DockerHub and it is working fine. But when I tried to deploy an application with an image from the AWS ECR, we started getting permission errors. Even though I have given all the necessary permissions for the instance profile role, the pod couldn’t fetch the image from ECR and showing ImagePullBackOff error.

Then we found this documentation from Kubernetes where they are saying “Verify kubelet is running with –cloud-provider=aws” to make it work.