Overview

This project automates the transfer of email attachments from Microsoft Outlook to Amazon S3. Power Automate monitors an Outlook folder, extracts each attachment and writes it through SFTP to an AWS Transfer Family endpoint backed by an S3 bucket.

The pattern is useful when a team receives operational files by email but needs them in object storage for analytics, archiving or downstream processing. A similar flow can use SharePoint as the source.

Implementation note: I originally built this project in 2022, so some console screens may have changed. Review the current AWS Transfer Family user documentation and Microsoft SFTP-SSH connector documentation before deploying it. Keep SSH host-key validation enabled and apply least-privilege access throughout.

Architecture

The workflow separates file ingestion from storage:

  1. Outlook receives an email with one or more attachments.
  2. A Power Automate cloud flow extracts each attachment.
  3. The SFTP-SSH connector sends the file to an AWS Transfer Family endpoint.
  4. AWS Transfer Family writes the file into the selected Amazon S3 bucket.
  5. Services downstream of S3 can validate, catalogue, archive or process the object.

The implementation has six stages: create the bucket, define IAM access, create the Transfer Family server, add a user, test SFTP and build the Power Automate flow.

1. Create the Amazon S3 bucket

  1. Open the Amazon S3 console and choose Create bucket.
  2. Enter a globally unique, DNS-compliant bucket name.
  3. Select the AWS Region in which the files should reside.
  4. Keep ACLs disabled under Object Ownership.
  5. Keep Block Public Access enabled unless a separate, reviewed requirement says otherwise.
  6. Configure default encryption, versioning, lifecycle rules and tags according to your environment.
  7. Choose Create bucket.

Amazon S3 create-bucket screen

2. Create the IAM role and bucket policy

AWS Transfer Family assumes an IAM role when the service-managed user accesses Amazon S3.

  1. Open the IAM console and choose Create role.
  2. Select AWS service as the trusted entity.
  3. Choose Transfer as the service or use case.

Selecting AWS Transfer Family while creating an IAM role

Do not attach AmazonS3FullAccess. Create a policy limited to the destination bucket and to the operations required by this workflow. The following example permits bucket discovery for that one bucket and common read, write, delete and multipart-upload operations:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "BucketAccess",
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket",
                "s3:ListBucketMultipartUploads"
            ],
            "Resource": "arn:aws:s3:::[s3-bucket-name]"
        },
        {
            "Sid": "ObjectAccess",
            "Effect": "Allow",
            "Action": [
                "s3:PutObject",
                "s3:GetObject",
                "s3:DeleteObject",
                "s3:AbortMultipartUpload",
                "s3:ListMultipartUploadParts"
            ],
            "Resource": "arn:aws:s3:::[s3-bucket-name]/*"
        }
    ]
}

Replace [s3-bucket-name] with the bucket created in the previous step. Remove GetObject, DeleteObject or any other action that your workflow does not need. You can also restrict access to a prefix rather than the entire bucket.

IAM policy editor containing the S3 permissions

Name and create the policy, return to the role workflow, refresh the policy list and attach the new policy. Give the role a clear name before creating it.

IAM role showing its attached permissions policy

3. Create the SFTP server

  1. Open the AWS Transfer Family console and choose Create server.
  2. Select SFTP as the protocol.
  3. Choose Service managed as the identity provider for this implementation.
  4. Select an endpoint type that Power Automate can reach. The original implementation used a publicly accessible endpoint. Review current network, firewall and logging requirements before using that option in production.
  5. Select Amazon S3 as the storage domain.
  6. Configure a CloudWatch logging role so connection and transfer activity can be investigated.
  7. Optionally associate a custom hostname through Amazon Route 53.
  8. Create the server and wait until its status becomes available.

AWS Transfer Family server configuration

4. Add a service-managed user

Open the server and choose Add user.

AWS Transfer Family server page with the Add user action

Configure:

  1. A username dedicated to the integration.
  2. The IAM role created for access to the destination bucket.
  3. The bucket or prefix that should be used as the user’s home directory.

AWS Transfer Family user configuration with an S3 home directory

The user authenticates with an SSH key pair. Generate a dedicated key according to the AWS Transfer Family SSH key guidance. The original implementation used PuTTY Key Generator.

PuTTY Key Generator after creating an SSH key pair

Store both files securely. Never share the private key, and protect it with a passphrase where the connector and your operational process support one. Paste only the public key into the Transfer Family user’s Public key field, then create the user.

5. Test the SFTP connection

Test the endpoint with an SFTP client before introducing Power Automate. The original implementation used WinSCP.

Create a new SFTP session with:

  • Host name: the custom hostname, or the Transfer Family endpoint in the form [server-id].server.transfer.[region-id].amazonaws.com
  • Port: 22
  • User name: the service-managed username
  • Private key: the private half of the key pair

WinSCP session configuration for the Transfer Family endpoint

In WinSCP, open Advanced → SSH → Authentication and select the PPK private-key file. Verify the server fingerprint shown on first connection against a value obtained through a trusted channel before accepting it.

Upload, download and remove a test object within the permitted home directory. Confirm that the object appears at the expected S3 key and that the user cannot leave the intended bucket or prefix.

A test file uploaded to Amazon S3 through WinSCP and AWS Transfer Family

At this point the AWS side contains the S3 bucket, IAM role and policy, Transfer Family server, service-managed user and SSH key pair.

6. Build the Power Automate flow

Power Automate provides the Outlook trigger and the SFTP-SSH action that connect the two platforms. Some screenshots from the original implementation display the product’s former Microsoft Flow branding.

Power Automate templates and navigation

Choose Create → Automated cloud flow, enter a flow name and select When a new email arrives as the trigger.

Creating an automated cloud flow from an Outlook trigger

Configure the Outlook folder that the trigger should monitor. A dedicated folder works well when an Outlook rule first filters messages by sender, subject or another business condition.

Power Automate Outlook trigger configuration

Add an Apply to each control and use the message’s Attachments collection as its input.

Apply to each configured for Outlook attachments

Inside the loop, add the Create file (SFTP-SSH) action.

Selecting the SFTP-SSH Create file action

Use the same host, port and username verified with WinSCP. The connector expects a supported OpenSSH or PEM private-key format. If the key was generated in PuTTY’s PPK format, load it into PuTTY Key Generator and export an OpenSSH key.

Exporting a PuTTY private key in OpenSSH format

Copy the complete private key into the connector, including its opening and closing lines. If the key is protected, provide its passphrase through the secure passphrase field.

Keep Disable SSH host key validation turned off. Enter the server’s verified fingerprint in SSH host key fingerprint so the connector rejects a server whose host key does not match the expected value.

Power Automate SFTP-SSH connection settings

Configure the action fields:

  • Folder path: the destination folder under the user’s SFTP home directory
  • File name: the current attachment’s name
  • File content: the current attachment’s content

Power Automate Create file action mapped to the attachment name and content

Save and test the flow by sending an email with an attachment that matches the trigger conditions. If the object does not arrive, review the Power Automate run history, Transfer Family logs and destination path before broadening permissions.

Extending the pattern

The source does not have to be Outlook. The same design can begin with SharePoint and use the When a file is created or modified trigger before sending the file through the SFTP connector.

A Power Automate flow using SharePoint as the source and SFTP as the destination

After a file reaches Amazon S3, the pipeline can continue with event notifications, schema validation, malware scanning, cataloguing, archiving or downstream data processing.

The security guidance in this case study was refreshed against the AWS and Microsoft documentation linked above.