Skip to content

effordDev/sf-files-2-s3

Repository files navigation

Salesforce Files to Amazon S3

Deploy to Salesforce
Deploy via sfdx

Setup

1. Create New Bucket in S3

Choose the appropriate region for you:

image

Make sure ACLs disabled is true

image

Block all public access is true

image

Once created, navigate to your new created bucket. Go to the permissions tab and copy the below code into the 'Cross-origin resource sharing (CORS)' settings (Be sure to add your salesforce domain in AllowedOrigins (EG https://reidsdevorg2-dev-ed.lightning.force.com)):

[
    {
        "AllowedHeaders": [
            "*"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD",
            "POST",
            "PUT",
            "DELETE"
        ],
        "AllowedOrigins": [
            "YOUR SALESFORCE DOMAIN HERE",
        ],
        "ExposeHeaders": [
            "Access-Control-Allow-Origin"
        ]
    }
]

In the search bar navigate to IAM. Select 'Users' on the left side of the menu. Select 'Add users'.

Name your user (recommend putting salesforce in the name) and select 'Access key - Programmatic access' for the credential type.

image

Select 'Next: Permissions' and 'Attach existing policies directly', search for 'AmazonS3FullAccess' and check that policy. Select 'Next: Tags', Select 'Create user'.

Warning BE SURE TO COPY THE ACCESS KEY ID AND THE SECRET ACCESS KEY BEFORE CLOSING THIS PAGE.

2. Custom Metadata Configuration

In Salesforce, Setup > Custom Code > Custom Metadata Types > Amazon S3 Select 'Manage Amazon S3's' Create a new Amazon_S3__mdt record named Amazon_S3_Integration image

Fill out the information in the record from S3. Create a Bucket for sandbox testing, just be sure put 'sandbox' in the name to differenciate.
image

Navigate to Lightning page and search 'Amazon s3 Files', drag component to page and configure as needed.

2022-11-02.15-49-11.mov

image

Coded while petting 😸 and listening to 🧃🌎