Class User


  • public class User
    extends com.pulumi.resources.CustomResource
    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
     
     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());
     
         }
     }
     
     
    To restrict a user to their own home directory, use a `homeDirectoryMappings` block like the following:
     
     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());
     
         }
     }
     
     
    ## Import Using `pulumi import`, import Transfer Users using the `serverId` and `userName` separated by `/`. For example: ```sh $ pulumi import aws:transfer/user:User bar s-12345678/test-username ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Constructor Summary

      Constructors 
      Constructor Description
      User​(java.lang.String name)  
      User​(java.lang.String name, UserArgs args)  
      User​(java.lang.String name, UserArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> arn()  
      static User get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, UserState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> homeDirectory()  
      com.pulumi.core.Output<java.util.Optional<java.util.List<UserHomeDirectoryMapping>>> homeDirectoryMappings()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> homeDirectoryType()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> policy()  
      com.pulumi.core.Output<java.util.Optional<UserPosixProfile>> posixProfile()  
      com.pulumi.core.Output<java.lang.String> region()  
      com.pulumi.core.Output<java.lang.String> role()  
      com.pulumi.core.Output<java.lang.String> serverId()  
      com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()  
      com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()  
      com.pulumi.core.Output<java.lang.String> userName()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • User

        public User​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • User

        public User​(java.lang.String name,
                    UserArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • User

        public User​(java.lang.String name,
                    UserArgs args,
                    @Nullable
                    com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • arn

        public com.pulumi.core.Output<java.lang.String> arn()
        Returns:
        ARN of Transfer User
      • homeDirectory

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> homeDirectory()
        Returns:
        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`.
      • homeDirectoryMappings

        public com.pulumi.core.Output<java.util.Optional<java.util.List<UserHomeDirectoryMapping>>> homeDirectoryMappings()
        Returns:
        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.
      • homeDirectoryType

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> homeDirectoryType()
        Returns:
        Type of landing directory (folder) you mapped for your users' home directory. Valid values are `PATH` and `LOGICAL`.
      • policy

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> policy()
        Returns:
        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.
      • posixProfile

        public com.pulumi.core.Output<java.util.Optional<UserPosixProfile>> posixProfile()
        Returns:
        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.
      • region

        public com.pulumi.core.Output<java.lang.String> region()
        Returns:
        Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
      • role

        public com.pulumi.core.Output<java.lang.String> role()
        Returns:
        ARN of an IAM role that allows the service to control your user’s access to your Amazon S3 bucket.
      • serverId

        public com.pulumi.core.Output<java.lang.String> serverId()
        Returns:
        Server ID of the Transfer Server (e.g., `s-12345678`)
      • tags

        public com.pulumi.core.Output<java.util.Optional<java.util.Map<java.lang.String,​java.lang.String>>> tags()
        Returns:
        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.
      • tagsAll

        public com.pulumi.core.Output<java.util.Map<java.lang.String,​java.lang.String>> tagsAll()
        Returns:
        Map of tags assigned to the resource, including those inherited from the provider `defaultTags` configuration block.
      • userName

        public com.pulumi.core.Output<java.lang.String> userName()
        Returns:
        Name used for log in to your SFTP server.
      • get

        public static User get​(java.lang.String name,
                               com.pulumi.core.Output<java.lang.String> id,
                               @Nullable
                               UserState state,
                               @Nullable
                               com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.