Send and retrieve files by using an SFTP connector - Amazon Transfer Family
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Send and retrieve files by using an SFTP connector

SFTP connectors extend the capabilities of Amazon Transfer Family to communicate with remote servers both in the cloud and on-premises. You can integrate data that's generated and stored in remote sources with your Amazon hosted data warehouses for analytics, business applications, reporting, and auditing.

To initiate a file transfer to a remote SFTP server, you use the StartFileTransfer API operation, which uses SFTP connectors to perform the transfer. Each StartFileTransfer request can contain 10 distinct paths.

You can monitor your file transfers by checking your server logs. Connector activity is logged to log streams that have the format of aws/transfer/connector-id, for example, aws/transfer/c-1234567890abcdef0. If you don't see any logs for your connector, make sure that you have specified a logging role with the correct permissions for your connector.

For details on creating connectors, see Configure SFTP connectors.

To send and retrieve files by using an SFTP connector, you use the start-file-transfer Amazon Command Line Interface (Amazon CLI) command. You specify the following parameters, depending on whether you're sending files (outbound transfers) or receiving files (inbound transfers).

  • Outbound transfers

    • send-file-paths contains from one to ten source file paths, for files to transfer to the partner's SFTP server.

    • remote-directory-path is the remote path to send a file to on the customer's SFTP server.

  • Inbound transfers

    • retrieve-file-paths contains from one to ten remote paths. Each path specifies a location for transferring files from the partner's SFTP server to your Transfer Family server.

    • local-directory-path is the Amazon S3 location (bucket and optional prefix) where your files are stored.

To send files, you specify the send-file-paths and remote-directory-path parameters. You can specify up to 10 files for the send-file-paths parameter. The following example command sends the files named /DOC-EXAMPLE-SOURCE-BUCKET/file1.txt and /DOC-EXAMPLE-SOURCE-BUCKET/file2.txt, located in Amazon S3 storage, to the /tmp directory on your partner's SFTP server. To use this example command, replace the DOC-EXAMPLE-SOURCE-BUCKET with your own bucket.

aws transfer start-file-transfer --send-file-paths /DOC-EXAMPLE-SOURCE-BUCKET/file1.txt /DOC-EXAMPLE-SOURCE-BUCKET/file2.txt \ --remote-directory-path /tmp --connector-id c-1111AAAA2222BBBB3 --region us-east-2

To receive files, you specify the retrieve-file-paths and local-directory-path parameters. The following example retrieves the files /my/remote/file1.txt and /my/remote/file2.txt on the partner's SFTP server, and places it in the Amazon S3 location /DOC-EXAMPLE-BUCKET/prefix. To use this example command, replace the user input placeholders with your own information.

aws transfer start-file-transfer --retrieve-file-paths /my/remote/file1.txt /my/remote/file2.txt \ --local-directory-path /DOC-EXAMPLE-BUCKET/prefix --connector-id c-2222BBBB3333CCCC4 --region us-east-2

The previous examples specify absolute paths on the SFTP server. You can also use relative paths: that is, paths that are relative to the SFTP user's home directory. For example, if the SFTP user is marymajor and their home directory on the SFTP server is /users/marymajor/, the following command sends /DOC-EXAMPLE-SOURCE-BUCKET/file1.txt to /users/marymajor/test-connectors/file1.txt

aws transfer start-file-transfer --send-file-paths /DOC-EXAMPLE-SOURCE-BUCKET/file1.txt \ --remote-directory-path test-connectors --connector-id c-2222BBBB3333CCCC4 --region us-east-2