Resource: aws_transfer_user

Provides a AWS Transfer User resource. Managing SSH keys can be accomplished with the aws_transfer_ssh_key resource.

Example Usage

resource "aws_transfer_server" "foo" {
  identity_provider_type = "SERVICE_MANAGED"

  tags = {
    NAME = "tf-acc-test-transfer-server"
  }
}

data "aws_iam_policy_document" "assume_role" {
  statement {
    effect = "Allow"

    principals {
      type        = "Service"
      identifiers = ["transfer.amazonaws.com"]
    }

    actions = ["sts:AssumeRole"]
  }
}

resource "aws_iam_role" "foo" {
  name               = "tf-test-transfer-user-iam-role"
  assume_role_policy = data.aws_iam_policy_document.assume_role.json
}

data "aws_iam_policy_document" "foo" {
  statement {
    sid       = "AllowFullAccesstoS3"
    effect    = "Allow"
    actions   = ["s3:*"]
    resources = ["*"]
  }
}

resource "aws_iam_role_policy" "foo" {
  name   = "tf-test-transfer-user-iam-policy"
  role   = aws_iam_role.foo.id
  policy = data.aws_iam_policy_document.foo.json
}

resource "aws_transfer_user" "foo" {
  server_id = aws_transfer_server.foo.id
  user_name = "tftestuser"
  role      = aws_iam_role.foo.arn

  home_directory_type = "LOGICAL"
  home_directory_mappings {
    entry  = "/test.pdf"
    target = "/bucket3/test-path/tftestuser.pdf"
  }
}

Argument Reference

This resource supports the following arguments:

Home Directory Mappings

The Restricted option is achieved using the following mapping:

home_directory_mappings {
    entry  = "/"
    target = "/${aws_s3_bucket.foo.id}/$${Transfer:UserName}"
}

Posix Profile

Attribute Reference

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

Timeouts

Configuration options:

Import

In Terraform v1.5.0 and later, use an import block to import Transfer Users using the server_id and user_name separated by /. For example:

import {
  to = aws_transfer_user.bar
  id = "s-12345678/test-username"
}

Using terraform import, import Transfer Users using the server_id and user_name separated by /. For example:

% terraform import aws_transfer_user.bar s-12345678/test-username