Info: This is our first post of a serie of coauthoring articles with @kharec
Serverless SFTP with AWS Transfer for SFTP
Sometimes in web world, we need to quickly deploy a space to share datas with programs or with other humans.
One of the numerous solutions is an SFTP space out there. But you know: create the server, configure the service, partition the users, the permissions, the folders, etc… It’s getting heavy faster than a speeding bullet!
So at Amazon Web Services, they implemented a service to create SFTP server/account, quickly and easily, backed onto an S3 bucket. And the beauty of it : no servers to manage at all !
Today, we present you AWS Transfer for SFTP !
Why using SFTP on AWS
For enterprise ETL systems, batch processing, legacy use cases. Main advantages of this managed service solution are: built-in auto-scaling capabilities, native high availability without managing a single server, patching, OS maintenance, networking, and security.
Automated Deployment
Using AWS CloudFormation
Deploying your server:
Using Terraform
|
|
Manual deployment (Using Console)
-
Connect to AWS Console
-
Go to AWS Transfer for SFTP Service
-
Create Server
-
Basic configuration:
- Public or Private
- Customize your endpoint DNS name
- Identity Provider: Internal or using API Gateway (custom) Using Internal, the user base will be managed by the service (!= IAM users)
Using awscli
You can go from nothing to a fully functional SFTP server, users included, with the formidable awscli. In this article, we suppose that you already installed it. So, first things first, let’s create the server.
Once it’s created and online, we can get all its information via the following command :
|
|
We get an endpoint as well and we can see it in the console :
Let’s try our endpoint :
OK, it’s up.
Now let’s create the user to connect and exploit our SFTP server. Note that we have created an IAM Role that has been applied with the policy AmazonS3FullAccess for the process. To create the user, we provide the ARN of this role.
Now, to access our SFTP, we have to authenticate with an ssh key, as AWS Transfer doesn’t support the password authentication. To do that, we need to import our public key to this server and for this user.
|
|
Easy ! Finally, let’s try and connect:
Pricing
You will be charged for two types of usage on Transfer for SFTP:
- Time your SFTP endpoint is provisioned: 0,30$ per hour
- Data Transfer (IN and OUT) $0.04 per gigabyte (GB) transferred
As you may already know, on AWS, the data transfer IN is usually free, this is not the case with this AWS Managed Service.
Example:
- full-time SFTP Endpoint: $216 monthly
- 10GB uploaded: $12 monthly
- Monthly total: $228
Source: AWS Transfer for SFTP - Pricing - Give a try on the pricing calculator embedded on this page.
Challengers
- Any type of instance in any cloud (GCP, Azure, Digital Ocean) with an SFTP server installed on it.
- AWS S3 bucket
- Azure Storage blobs
- Google Cloud Storage
Known limitations
No user quota
You have to know that you cannot apply quotas on an SFTP user. So he can upload as much as he wants. It can be a weakness in you bill.
No user chroot
If you have more than one user on your SFTP endpoint, you have to know that you cannot restrict your users into a directory as you can with OpenSSH.
No filetype filtering
In AWS Transfer, you cannot apply some policy to restrict the filetypes sent. It can be a security problem, your users can upload any type of files.
No IP restrictions
You cannot apply a security group or equivalent to restrict your SFTP endpoint by IP. Even if the authentication is key-based, it can be an issue.
Alternatives
In case SFTP is not a mandatory protocol for you, you can use cheaper options:
- AWS CLI (
aws s3 sync
,aws s3 cp
,aws s3 presign
) - S3 API backed Software (S3 Browser, Cloudberry, Cyberduck, Filezilla Pro, …)
- S3 Console with least privilege rights for your users
We hope you enjoyed this article. If you want to know more, feel free to discuss it with us on social networks or by email !
That’s all folks!
zoph.