Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[transfer] Can't create user separately from Server?

See original GitHub issue

I have an existing Transfer instance. I would like to automatically create users for it via cdk at later times as needed.

Reproduction Steps

def make_user(user_name, server_id, ssh_public_key):

    app = core.App()
              id='sftp-transfer-user-' + user_name,
              description='SFTP Transfer User for ' + user_name,

class UserStack(core.Stack):

    def __init__(self, scope: core.Construct, id: str,
                 settings: Settings, **kwargs) -> None:

        super().__init__(scope, id)
        env = settings.get_environment()

                home_directory_mappings=[self.MEP("/in", "/sftp-bucket/${Transfer:UserName}/in"),
                                         self.MEP("/out", "/sftp-bucket/${Transfer:UserName}/out"),
                                         self.MEP("/", "/sftp-bucket/${Transfer:UserName}")],

    def MEP(self, entry, target):
        return aws_transfer.CfnUser.HomeDirectoryMapEntryProperty(entry=entry, target=target)

Error mesage is:

  Error: CfnUser at 'sftp-user-foo-test' should be created in the scope of a Stack, but no Stack found
      at _lookup (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/stack.js:137:23)
      at _lookup (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/stack.js:139:20)
      at Function.of (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/stack.js:121:27)
      at new CfnElement (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/cfn-element.js:25:36)
      at new CfnRefElement (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/cfn-element.js:98:1)
      at new CfnResource (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/core/lib/cfn-resource.js:23:9)
      at new CfnUser (/private/var/folders/kf/031yw5wx3hnfj7by8xsjz4jc0000gn/T/jsii-kernel-Ari9yh/node_modules/@aws-cdk/aws-transfer/lib/transfer.generated.js:340:9)
      at /Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3137:49
      at Kernel._wrapSandboxCode (/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3621:16)
      at Kernel._create (/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_embedded/jsii/jsii-runtime.js:3137:26)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "", line 52, in <module>
    make_user(cust_name, server_id, ssh_pub_key)
  File "", line 30, in make_user
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/", line 69, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/joel/PycharmProjects/shift-ux-backend/.cfn/stacks/", line 28, in __init__
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/", line 69, in __call__
    inst = super().__call__(*args, **kwargs)
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/aws_cdk/aws_transfer/", line 608, in __init__
    jsii.create(CfnUser, self, [scope, id, props])
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_kernel/", line 250, in create
    response = self.provider.create(
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_kernel/providers/", line 347, in create
    return self._process.send(request, CreateResponse)
  File "/Users/joel/PycharmProjects/venvs/sftp/lib/python3.8/site-packages/jsii/_kernel/providers/", line 332, in send
    raise JSIIError(resp.error) from JavaScriptError(resp.stack)
jsii.errors.JSIIError: CfnUser at 'sftp-user-foo-test' should be created in the scope of a Stack, but no Stack found

What did you expect to happen?

I expected an SFTP user to be created on the given server_id.

What actually happened?

Stack cannot be found?

jsii.errors.JSIIError: CfnUser at 'sftp-user-foo-test' should be created in the scope of a Stack, but no Stack found


  • CLI Version : aws-cli/1.18.148 Python/3.5.3 Darwin/19.6.0 botocore/1.18.7
  • Framework Version:
  • Node.js Version: v15.01
  • OS : Darwin, OSX
  • Language (Version): Python 3.5.3


This is 🐛 Bug Report

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

jbremsoncommented, Nov 5, 2020

User error.

mimozellcommented, Feb 1, 2021

@kiturutin I added a similar issue with the fix here. Hope it helps! I can elaborate further if needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with service-managed users - AWS Transfer Family
To add an Amazon S3 service-managed user to your server. Open the AWS Transfer ... The user name can't start with a hyphen...
Read more >
Transfer Endpoint and Transfer Server Differences - IBM
Transfer Endpoint can be used to connect outbound as a client to an unlimited number of remote Aspera endpoints.
Read more >
How to Copy Files Between Different User Accounts on ...
A simple way around this problem is to share the files with all users rather than transfer them to each user separately. To...
Read more >
Fix a corrupted user profile in Windows - Microsoft Support
Type the appropriate information in the dialog box, and then select Create. When you are finished creating user accounts, select Close. Restart the...
Read more >
Add or update multiple users from a CSV file - Google Support
There might be unmanaged accounts—Check to see if anyone you plan to add already has a Google Account. Then follow steps to avoid...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found