Search code examples
amazon-web-servicesboto3amazon-efs

Create a directory in EFS using boto3


I want to create a directory EFS using boto3, is it possible? Are there any possible workarounds for this using python scripts? Thanks for help in advance


Solution

  • I have used a lambda function with EFS mounted on it and used boto3 script from local system which invokes lambda and lambda function creates the directory. Solution for the future readers of this post. here is lambda code.

    You can change the path to your required path you mounted on lambda.

    import json
    import os
    
    def lambda_handler(event, context):
        user_name = event["user_name"]
        path = f"/mnt/home/{user_name}"
        try:
            os.mkdir(path)
        except FileExistsError:
            print(f"directory with user_name {user_name} already exists")
        print(os.listdir("/mnt/home/"))