Why aren't changes on my Amazon S3 bucket showing on the Storage Gateway file share?

Last updated: 2020-02-04

I made changes to my Amazon Simple Storage Service (Amazon S3) bucket, such as uploading a new file or removing an existing file. However, the changes aren't propagating to my AWS Storage Gateway file share. How can I fix this?

Short Description

Storage Gateway updates the file share cache automatically when you write files to the cache locally using the file share. However, Storage Gateway doesn't automatically update the cache when you upload a file directly to Amazon S3. When you do this, you must perform a RefreshCache operation to see the changes on the file share. If you have more than one file share, then you must run the RefreshCache operation on each file share.

You can refresh the cache using the Storage Gateway console, the AWS Command Line Interface (AWS CLI), or through an AWS Lambda function.


Using the Storage Gateway console

To refresh the cache using the Storage Gateway console, see Refreshing Objects in Your Amazon S3 Bucket.

Using the AWS CLI

1.    Run the list-file-shares command:

$ aws storagegateway list-file-shares

2.    Copy the Amazon Resource Number (ARN) of the file share with the cache that you want to refresh. Then, run the refresh-cache command and enter the ARN as the value for --file-share-arn:

$ aws storagegateway refresh-cache --file-share-arn arn:aws:storagegateway:eu-west-1:12345678910:share/share-FFDEE12

As another option, you can create a script or scheduled cron job to run the refresh-cache command at certain intervals. For example, the following cron job runs the command every 12 hours:

0 */12 * * * root aws storagegateway refresh-cache --file-share-arn arn:aws:storagegateway:eu-west-1:12345678910:share/share-FFDEE12

Note: You must schedule the cron job using the credentials of an AWS Identity and Access Management (IAM) user or role that has permissions to run the refresh-cache command.

Using a Lambda function

You can create a Lambda function that runs the RefreshCache API on a certain schedule. The following example function uses boto3:

import json
import boto3
client = boto3.client('storagegateway')
def lambda_handler(event, context):
    response = client.refresh_cache(
    return 'Your FileShare Cache has been Refreshed'

Note the following considerations for automating the refresh cache operation:

Did this article help you?

Anything we could improve?

Need more help?