AWS Amazon S3 File System Association

This page shows how to write Terraform for Amazon S3 File System Association and write them securely.

aws_storagegateway_file_system_association (Terraform)

The File System Association in Amazon S3 can be configured in Terraform with the resource name aws_storagegateway_file_system_association. The following sections describe how to use the resource and its parameters.

Example Usage from GitHub

An example could not be found in GitHub.

Review your Terraform file for AWS best practices

Shisho Cloud, our free checker to make sure your Terraform configuration follows best practices, is available (beta).


The following arguments are supported:

  • gateway_arn - (Required) The Amazon Resource Name (ARN) of the gateway.
  • location_arn - (Required) The Amazon Resource Name (ARN) of the Amazon FSx file system to associate with the FSx File Gateway.
  • username - (Required) The user name of the user credential that has permission to access the root share of the Amazon FSx file system. The user account must belong to the Amazon FSx delegated admin user group.
  • password - (Required, sensitive) The password of the user credential.
  • audit_destination_arn - (Optional) The Amazon Resource Name (ARN) of the storage used for the audit logs.
  • cache_attributes - (Optional) Refresh cache information. see Cache Attributes for more details.
  • tags - (Optional) Key-value map of resource tags. If configured with a provider default_tags configuration block present, tags with matching keys will overwrite those defined at the provider-level.


  • cache_stale_timeout_in_seconds - (Optional) Refreshes a file share's cache by using Time To Live (TTL). TTL is the length of time since the last refresh after which access to the directory would cause the file gateway to first refresh that directory's contents from the Amazon S3 bucket. Valid Values: 0 or 300 to 2592000 seconds (5 minutes to 30 days). Defaults to 0

In addition to all arguments above, the following attributes are exported:

  • id - Amazon Resource Name (ARN) of the FSx file system association
  • arn - Amazon Resource Name (ARN) of the newly created file system association.
  • tags_all - A map of tags assigned to the resource, including those inherited from the provider default_tags configuration block.

Explanation in Terraform Registry

Associate an Amazon FSx file system with the FSx File Gateway. After the association process is complete, the file shares on the Amazon FSx file system are available for access through the gateway. This operation only supports the FSx File Gateway type. FSx File Gateway requirements.

Tips: Best Practices for The Other AWS Amazon S3 Resources

In addition to the aws_s3_bucket_public_access_block, AWS Amazon S3 has the other resources that should be configured for security reasons. Please check some examples of those resources and precautions.



Ensure S3 bucket-level Public Access Block restricts public bucket policies

It is better to enable S3 bucket-level Public Access Block if you don't need public buckets.



Ensure S3 bucket access policy is well configured

It is better to configure the S3 bucket access policy properly to limit it unless explicitly required.

Review your AWS Amazon S3 settings

In addition to the above, there are other security points you should be aware of making sure that your .tf files are protected in Shisho Cloud.

CloudFormation Example

CloudFormation code does not have the related resource.

Frequently asked questions

What is AWS Amazon S3 File System Association?

AWS Amazon S3 File System Association is a resource for Amazon S3 of Amazon Web Service. Settings can be wrote in Terraform.