User class

Provides a AWS Transfer User resource. Managing SSH keys can be accomplished with the aws.transfer.SshKey resource.

> NOTE: We suggest using jsonencode() or aws.iam.getPolicyDocument when assigning a value to policy. They seamlessly translate Terraform language into JSON, enabling you to maintain consistency within your configuration without the need for context switches. Also, you can sidestep potential complications arising from formatting discrepancies, whitespace inconsistencies, and other nuances inherent to JSON.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const fooServer = new aws.transfer.Server("foo", {
    identityProviderType: "SERVICE_MANAGED",
    tags: {
        NAME: "tf-acc-test-transfer-server",
    },
});
const assumeRole = aws.iam.getPolicyDocument({
    statements: [{
        principals: [{
            type: "Service",
            identifiers: ["transfer.amazonaws.com"],
        }],
        effect: "Allow",
        actions: ["sts:AssumeRole"],
    }],
});
const fooRole = new aws.iam.Role("foo", {
    name: "tf-test-transfer-user-iam-role",
    assumeRolePolicy: assumeRole.then(assumeRole => assumeRole.json),
});
const foo = aws.iam.getPolicyDocument({
    statements: [{
        sid: "AllowFullAccesstoS3",
        effect: "Allow",
        actions: ["s3:*"],
        resources: ["*"],
    }],
});
const fooRolePolicy = new aws.iam.RolePolicy("foo", {
    name: "tf-test-transfer-user-iam-policy",
    role: fooRole.id,
    policy: foo.then(foo => foo.json),
});
const fooUser = new aws.transfer.User("foo", {
    homeDirectoryMappings: [{
        entry: "/test.pdf",
        target: "/bucket3/test-path/tftestuser.pdf",
    }],
    serverId: fooServer.id,
    userName: "tftestuser",
    role: fooRole.arn,
    homeDirectoryType: "LOGICAL",
});
import pulumi
import pulumi_aws as aws

foo_server = aws.transfer.Server("foo",
    identity_provider_type="SERVICE_MANAGED",
    tags={
        "NAME": "tf-acc-test-transfer-server",
    })
assume_role = aws.iam.get_policy_document(statements=[{
    "principals": [{
        "type": "Service",
        "identifiers": ["transfer.amazonaws.com"],
    }],
    "effect": "Allow",
    "actions": ["sts:AssumeRole"],
}])
foo_role = aws.iam.Role("foo",
    name="tf-test-transfer-user-iam-role",
    assume_role_policy=assume_role.json)
foo = aws.iam.get_policy_document(statements=[{
    "sid": "AllowFullAccesstoS3",
    "effect": "Allow",
    "actions": ["s3:*"],
    "resources": ["*"],
}])
foo_role_policy = aws.iam.RolePolicy("foo",
    name="tf-test-transfer-user-iam-policy",
    role=foo_role.id,
    policy=foo.json)
foo_user = aws.transfer.User("foo",
    home_directory_mappings=[{
        "entry": "/test.pdf",
        "target": "/bucket3/test-path/tftestuser.pdf",
    }],
    server_id=foo_server.id,
    user_name="tftestuser",
    role=foo_role.arn,
    home_directory_type="LOGICAL")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var fooServer = new Aws.Transfer.Server("foo", new()
    {
        IdentityProviderType = "SERVICE_MANAGED",
        Tags =
        {
            { "NAME", "tf-acc-test-transfer-server" },
        },
    });

    var assumeRole = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Principals = new[]
                {
                    new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
                    {
                        Type = "Service",
                        Identifiers = new[]
                        {
                            "transfer.amazonaws.com",
                        },
                    },
                },
                Effect = "Allow",
                Actions = new[]
                {
                    "sts:AssumeRole",
                },
            },
        },
    });

    var fooRole = new Aws.Iam.Role("foo", new()
    {
        Name = "tf-test-transfer-user-iam-role",
        AssumeRolePolicy = assumeRole.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var foo = Aws.Iam.GetPolicyDocument.Invoke(new()
    {
        Statements = new[]
        {
            new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
            {
                Sid = "AllowFullAccesstoS3",
                Effect = "Allow",
                Actions = new[]
                {
                    "s3:*",
                },
                Resources = new[]
                {
                    "*",
                },
            },
        },
    });

    var fooRolePolicy = new Aws.Iam.RolePolicy("foo", new()
    {
        Name = "tf-test-transfer-user-iam-policy",
        Role = fooRole.Id,
        Policy = foo.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
    });

    var fooUser = new Aws.Transfer.User("foo", new()
    {
        HomeDirectoryMappings = new[]
        {
            new Aws.Transfer.Inputs.UserHomeDirectoryMappingArgs
            {
                Entry = "/test.pdf",
                Target = "/bucket3/test-path/tftestuser.pdf",
            },
        },
        ServerId = fooServer.Id,
        UserName = "tftestuser",
        Role = fooRole.Arn,
        HomeDirectoryType = "LOGICAL",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/transfer"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		fooServer, err := transfer.NewServer(ctx, "foo", &transfer.ServerArgs{
			IdentityProviderType: pulumi.String("SERVICE_MANAGED"),
			Tags: pulumi.StringMap{
				"NAME": pulumi.String("tf-acc-test-transfer-server"),
			},
		})
		if err != nil {
			return err
		}
		assumeRole, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"transfer.amazonaws.com",
							},
						},
					},
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"sts:AssumeRole",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		fooRole, err := iam.NewRole(ctx, "foo", &iam.RoleArgs{
			Name:             pulumi.String("tf-test-transfer-user-iam-role"),
			AssumeRolePolicy: pulumi.String(assumeRole.Json),
		})
		if err != nil {
			return err
		}
		foo, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Sid:    pulumi.StringRef("AllowFullAccesstoS3"),
					Effect: pulumi.StringRef("Allow"),
					Actions: []string{
						"s3:*",
					},
					Resources: []string{
						"*",
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		_, err = iam.NewRolePolicy(ctx, "foo", &iam.RolePolicyArgs{
			Name:   pulumi.String("tf-test-transfer-user-iam-policy"),
			Role:   fooRole.ID().ToIDOutput().ToStringOutput(),
			Policy: pulumi.String(foo.Json),
		})
		if err != nil {
			return err
		}
		_, err = transfer.NewUser(ctx, "foo", &transfer.UserArgs{
			HomeDirectoryMappings: transfer.UserHomeDirectoryMappingArray{
				&transfer.UserHomeDirectoryMappingArgs{
					Entry:  pulumi.String("/test.pdf"),
					Target: pulumi.String("/bucket3/test-path/tftestuser.pdf"),
				},
			},
			ServerId:          fooServer.ID().ToIDOutput().ToStringOutput(),
			UserName:          pulumi.String("tftestuser"),
			Role:              fooRole.Arn,
			HomeDirectoryType: pulumi.String("LOGICAL"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

data "aws_iam_getpolicydocument" "assumeRole" {
  statements {
    principals {
      type        = "Service"
      identifiers = ["transfer.amazonaws.com"]
    }
    effect  = "Allow"
    actions = ["sts:AssumeRole"]
  }
}
data "aws_iam_getpolicydocument" "foo" {
  statements {
    sid       = "AllowFullAccesstoS3"
    effect    = "Allow"
    actions   = ["s3:*"]
    resources = ["*"]
  }
}

resource "aws_transfer_server" "foo" {
  identity_provider_type = "SERVICE_MANAGED"
  tags = {
    "NAME" = "tf-acc-test-transfer-server"
  }
}
resource "aws_iam_role" "foo" {
  name               = "tf-test-transfer-user-iam-role"
  assume_role_policy = data.aws_iam_getpolicydocument.assumeRole.json
}
resource "aws_iam_rolepolicy" "foo" {
  name   = "tf-test-transfer-user-iam-policy"
  role   = aws_iam_role.foo.id
  policy = data.aws_iam_getpolicydocument.foo.json
}
resource "aws_transfer_user" "foo" {
  home_directory_mappings {
    entry  = "/test.pdf"
    target = "/bucket3/test-path/tftestuser.pdf"
  }
  server_id           = aws_transfer_server.foo.id
  user_name           = "tftestuser"
  role                = aws_iam_role.foo.arn
  home_directory_type = "LOGICAL"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.transfer.Server;
import com.pulumi.aws.transfer.ServerArgs;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.iam.Role;
import com.pulumi.aws.iam.RoleArgs;
import com.pulumi.aws.iam.RolePolicy;
import com.pulumi.aws.iam.RolePolicyArgs;
import com.pulumi.aws.transfer.User;
import com.pulumi.aws.transfer.UserArgs;
import com.pulumi.aws.transfer.inputs.UserHomeDirectoryMappingArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var fooServer = new Server("fooServer", ServerArgs.builder()
            .identityProviderType("SERVICE_MANAGED")
            .tags(Map.of("NAME", "tf-acc-test-transfer-server"))
            .build());

        final var assumeRole = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .principals(GetPolicyDocumentStatementPrincipalArgs.builder()
                    .type("Service")
                    .identifiers("transfer.amazonaws.com")
                    .build())
                .effect("Allow")
                .actions("sts:AssumeRole")
                .build())
            .build());

        var fooRole = new Role("fooRole", RoleArgs.builder()
            .name("tf-test-transfer-user-iam-role")
            .assumeRolePolicy(assumeRole.json())
            .build());

        final var foo = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
            .statements(GetPolicyDocumentStatementArgs.builder()
                .sid("AllowFullAccesstoS3")
                .effect("Allow")
                .actions("s3:*")
                .resources("*")
                .build())
            .build());

        var fooRolePolicy = new RolePolicy("fooRolePolicy", RolePolicyArgs.builder()
            .name("tf-test-transfer-user-iam-policy")
            .role(fooRole.id())
            .policy(foo.json())
            .build());

        var fooUser = new User("fooUser", UserArgs.builder()
            .homeDirectoryMappings(UserHomeDirectoryMappingArgs.builder()
                .entry("/test.pdf")
                .target("/bucket3/test-path/tftestuser.pdf")
                .build())
            .serverId(fooServer.id())
            .userName("tftestuser")
            .role(fooRole.arn())
            .homeDirectoryType("LOGICAL")
            .build());

    }
}
resources:
  fooServer:
    type: aws:transfer:Server
    name: foo
    properties:
      identityProviderType: SERVICE_MANAGED
      tags:
        NAME: tf-acc-test-transfer-server
  fooRole:
    type: aws:iam:Role
    name: foo
    properties:
      name: tf-test-transfer-user-iam-role
      assumeRolePolicy: ${assumeRole.json}
  fooRolePolicy:
    type: aws:iam:RolePolicy
    name: foo
    properties:
      name: tf-test-transfer-user-iam-policy
      role: ${fooRole.id}
      policy: ${foo.json}
  fooUser:
    type: aws:transfer:User
    name: foo
    properties:
      homeDirectoryMappings:
        - entry: /test.pdf
          target: /bucket3/test-path/tftestuser.pdf
      serverId: ${fooServer.id}
      userName: tftestuser
      role: ${fooRole.arn}
      homeDirectoryType: LOGICAL
variables:
  assumeRole:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - principals:
              - type: Service
                identifiers:
                  - transfer.amazonaws.com
            effect: Allow
            actions:
              - sts:AssumeRole
  foo:
    fn::invoke:
      function: aws:iam:getPolicyDocument
      arguments:
        statements:
          - sid: AllowFullAccesstoS3
            effect: Allow
            actions:
              - s3:*
            resources:
              - '*'

To restrict a user to their own home directory, use a homeDirectoryMappings block like the following:

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.transfer.User("example", {
    homeDirectoryMappings: [{
        entry: "/",
        target: `/${foo.id}/${Transfer:UserName}`,
    }],
    homeDirectoryType: "LOGICAL",
});
import pulumi
import pulumi_aws as aws

example = aws.transfer.User("example",
    home_directory_mappings=[{
        "entry": "/",
        "target": f"/{foo['id']}/${{Transfer:UserName}}",
    }],
    home_directory_type="LOGICAL")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.Transfer.User("example", new()
    {
        HomeDirectoryMappings = new[]
        {
            new Aws.Transfer.Inputs.UserHomeDirectoryMappingArgs
            {
                Entry = "/",
                Target = $"/{foo.Id}/${{Transfer:UserName}}",
            },
        },
        HomeDirectoryType = "LOGICAL",
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/transfer"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := transfer.NewUser(ctx, "example", &transfer.UserArgs{
			HomeDirectoryMappings: transfer.UserHomeDirectoryMappingArray{
				&transfer.UserHomeDirectoryMappingArgs{
					Entry:  pulumi.String("/"),
					Target: pulumi.Sprintf("/%v/${Transfer:UserName}", foo.Id),
				},
			},
			HomeDirectoryType: pulumi.String("LOGICAL"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_transfer_user" "example" {
  home_directory_mappings {
    entry  = "/"
    target ="/${foo.id}/${Transfer:UserName}"
  }
  home_directory_type = "LOGICAL"
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.transfer.User;
import com.pulumi.aws.transfer.UserArgs;
import com.pulumi.aws.transfer.inputs.UserHomeDirectoryMappingArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new User("example", UserArgs.builder()
            .homeDirectoryMappings(UserHomeDirectoryMappingArgs.builder()
                .entry("/")
                .target(String.format("/%s/${{Transfer:UserName}}", foo.id()))
                .build())
            .homeDirectoryType("LOGICAL")
            .build());

    }
}
resources:
  example:
    type: aws:transfer:User
    properties:
      homeDirectoryMappings:
        - entry: /
          target: /${foo.id}/$${Transfer:UserName}
      homeDirectoryType: LOGICAL

Import

Using pulumi import, import Transfer Users using the serverId and userName separated by /. For example:

$ pulumi import aws:transfer/user:User bar s-12345678/test-username

Constructors

User(String name, {UserArgs? args, CustomResourceOptions? options})
Creates a new User. name The Pulumi resource name. args Arguments used to configure this User. The set of arguments for User. options Resource options controlling this resource's behavior.
User.reference(String urn)
Creates a typed reference to an existing User resource.

Properties

arn ↔ Output<String>
ARN of Transfer User
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
hashCode → int
The hash code for this object.
no setterinherited
homeDirectory ↔ Output<String?>
Landing directory (folder) for a user when they log in to the server using their SFTP client. It should begin with a /. The first item in the path is the name of the home bucket (accessible as ${Transfer:HomeBucket} in the policy) and the rest is the home directory (accessible as ${Transfer:HomeDirectory} in the policy). For example, /example-bucket-1234/username would set the home bucket to example-bucket-1234 and the home directory to username.
latefinal
homeDirectoryMappings ↔ Output<List<UserHomeDirectoryMapping>?>
Logical directory mappings that specify what S3 paths and keys should be visible to your user and how you want to make them visible. See homeDirectoryMappings Block below.
latefinal
homeDirectoryType ↔ Output<String?>
Type of landing directory (folder) you mapped for your users' home directory. Valid values are PATH and LOGICAL.
latefinal
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
policy ↔ Output<String?>
IAM JSON policy document that scopes down user access to portions of their Amazon S3 bucket. IAM variables you can use inside this policy include ${Transfer:UserName}, ${Transfer:HomeDirectory}, and ${Transfer:HomeBucket}. Since the IAM variable syntax matches Terraform's interpolation syntax, they must be escaped inside Terraform configuration strings ($${Transfer:UserName}). These are evaluated on-the-fly when navigating the bucket.
latefinal
posixProfile ↔ Output<UserPosixProfile?>
Full POSIX identity, including user ID (Uid), group ID (Gid), and any secondary groups IDs (SecondaryGids), that controls your users' access to your Amazon EFS file systems. See posixProfile Block below.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
role ↔ Output<String>
ARN of an IAM role that allows the service to control your user’s access to your Amazon S3 bucket.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
serverId ↔ Output<String>
Server ID of the Transfer Server (e.g., s-12345678)
latefinal
tags ↔ Output<Map<String, String>?>
Map of tags to assign to the resource. If configured with a provider defaultTags configuration block present, tags with matching keys will overwrite those defined at the provider-level.
latefinal
tagsAll ↔ Output<Map<String, String>>
Map of tags assigned to the resource, including those inherited from the provider defaultTags configuration block.
latefinal
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited
userName ↔ Output<String>
Name used for log in to your SFTP server.
latefinal

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {UserState? state, CustomResourceOptions? options}) → User
Gets an existing User resource's state with the given name and id.