Setting up a custom hostname for the s3ftp service is as simple as defining a DNS CNAME.
To provide a custom hostname for your s3ftp service, you must own an internet domain and have DNS delegation setup for your domain. You can register and configure DNS using AWS Route53. If you use a different DNS provider you will have to research how to define a CNAME record in your DNS domain.
The following steps will describe how to setup a custom hostname using AWS Route53. This assumes the DNS zone for your custom hostname is hosted in Route53 in the same account as your s3ftp stack.
Create an AWS Route53 Alias record
If your DNS is hosted in AWS Route53 in the same account as your s3ftp stack, navigate to the Route53 Hosted Zones page and locate your zone. We need the Hosted zone ID which is displayed on this page in the right hand column. Copy the Hosted zone ID value.
Next, navigate to the AWS Cloudformation console, select the s3ftp stack you deployed earlier and then click the
You should see the following Update stack screen. Use the current template and click
You will progress to the Specify stack details page where cloudformation stack parameters can be updated.
On the parameters page, scroll down and enter values in the Route53HostedZoneId and CustomHostname fields. Our example adds files.flottflott.com. Click
Click through the Configure stack options page.
On the Review stack page, check your zoneid and hostname parameters are correct. Then scroll to the bottom of the page, click the checkbox to acknowledge that AIM resources may be created and finally click
The stack should take a few minutes before moving to an
UPDATE_COMPLETEstate. You should now have a new Route53 DNS record pointing to your s3ftp service.
Confirm DNS resolution
Now in a terminal you can confirm that DNS resolution is working as expected. Change the hostname to your custom hostname.
% dig +short files.flottflott.com 22.214.171.124 126.96.36.199
% nslookup files.flottflott.com Server: 188.8.131.52 Address: 184.108.40.206#53 Non-authoritative answer: Name: files.flottflott.com Address: 220.127.116.11 Name: files.flottflott.com Address: 18.104.22.168
If you get an error from either of the above commands and cannot resolve your custom hostname, you may have a DNS delegation problem. Check the authorative DNS name servers defined within your Domain Name registrar. Ensure that your Route53 DNS servers are defined as the authorative DNS servers for your domain.
Connect to your sftp server using custom hostname
Now that your DNS record is setup, you should be able to connect to your sftp server using your custom domain name.
% sftp -i ~/.ssh/hermione email@example.com The authenticity of host 'files.flottflott.com (22.214.171.124)' can't be established. ECDSA key fingerprint is SHA256:lsmaz5dFSxkSpBSutLIkIpeE4QrDltQci+BSVfVzQMw. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'files.flottflott.com' (ECDSA) to the list of known hosts. UNAUTHORIZED ACCESS TO THIS DEVICE IS PROHIBITED. All activities performed on this device are logged and monitored. Connected to files.flottflott.com. sftp> ls -l -rw-r--r-- 0 10000 10000 10485760 Feb 12 06:44 spellbook.dat sftp>
For other DNS providers
If you use a different DNS provider other than AWS Route53, you will need to determine the steps to add a CNAME record to your domain.
In all cases you will need to know the s3ftp service hostname to point your CNAME at.
In the AWS Cloudformation console where you deployed the stack, select the s3ftp stack and the navigate to the Outputs tab.
Grab the value of the SftpHostname cloudformation output. With this value you should fairly easily be able to create a DNS CNAME record in your own domain to point to the s3ftp service.