Resource: aws_storagegateway_file_system_association

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.

Example Usage

resource "aws_storagegateway_file_system_association" "example" {
  gateway_arn           = aws_storagegateway_gateway.example.arn
  location_arn          = aws_fsx_windows_file_system.example.arn
  username              = "Admin"
  password              = "avoid-plaintext-passwords"
  audit_destination_arn = aws_s3_bucket.example.arn
}

Required Services Example

data "aws_ssm_parameter" "aws_service_storagegateway_ami_FILE_S3_latest" {
  name = "/aws/service/storagegateway/ami/FILE_S3/latest"
}

resource "aws_instance" "test" {
  # If using a single root module to build full gateway stack
  # you must include the dependencies below
  depends_on = [aws_route.test, aws_vpc_dhcp_options_association.test]

  ami                         = data.aws_ssm_parameter.aws_service_storagegateway_ami_FILE_S3_latest.value
  associate_public_ip_address = true
  instance_type               = data.aws_ec2_instance_type_offering.available.instance_type
  vpc_security_group_ids      = [aws_security_group.test.id]
  subnet_id                   = aws_subnet.test[0].id
}

resource "aws_storagegateway_gateway" "test" {
  gateway_ip_address = aws_instance.test.public_ip
  gateway_name       = "test-sgw"
  gateway_timezone   = "GMT"
  gateway_type       = "FILE_FSX_SMB"

  smb_active_directory_settings {
    domain_name = aws_directory_service_directory.test.name
    password    = aws_directory_service_directory.test.password
    username    = "Admin"
  }
}

resource "aws_fsx_windows_file_system" "test" {
  active_directory_id = aws_directory_service_directory.test.id
  security_group_ids  = [aws_security_group.test.id]
  skip_final_backup   = true
  storage_capacity    = 32
  subnet_ids          = [aws_subnet.test[0].id]
  throughput_capacity = 8
}

resource "aws_storagegateway_file_system_association" "fsx" {

  gateway_arn  = aws_storagegateway_gateway.test.arn
  location_arn = aws_fsx_windows_file_system.test.arn
  username     = "Admin"
  password     = aws_directory_service_directory.test.password
  cache_attributes {
    cache_stale_timeout_in_seconds = 400
  }
  audit_destination_arn = aws_cloudwatch_log_group.test.arn
}

Argument Reference

This resource supports the following arguments:

cache_attributes

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In Terraform v1.5.0 and later, use an import block to import aws_storagegateway_file_system_association using the FSx file system association Amazon Resource Name (ARN). For example:

import {
  to = aws_storagegateway_file_system_association.example
  id = "arn:aws:storagegateway:us-east-1:123456789012:fs-association/fsa-0DA347732FDB40125"
}

Using terraform import, import aws_storagegateway_file_system_association using the FSx file system association Amazon Resource Name (ARN). For example:

% terraform import aws_storagegateway_file_system_association.example arn:aws:storagegateway:us-east-1:123456789012:fs-association/fsa-0DA347732FDB40125