EC2 server - Writing permissions on server for Tomcat Java Spring application

I am deploying Tomcat EC2 instances through ElasticBeanStalk and would like to write a few files on the EC2 server (to add Spring search lucene files). However, this does not seem to be working.

I am trying to use .ebextensions configuration (.config) file as such :

files:
    "/home/ec2-user/script.sh" :
        mode: "000755"
        owner: root
        group: root
        content: |
            chmod o+x /home
            chmod o+x /home/ec2-user
            chown ec2-user /home
            chown ec2-user /home/ec2-user

container_commands:
    chmod_lucene_directory:
        command: sudo /home/ec2-user/script.sh
        ignoreErrors: false

What am i doing wrong ?