Comment to 'Installation of Una on AWS Elastic Beanstalk'
  • Per AWS:

    To get to the point, it is possible to delete the directory after installation.

    You can reserve set of jobs to install, delete directories or other assets at various point of times.

    I recommend you to refer to ‘Platform hooks’ section in our document about ‘Extending Elastic Beanstalk Linux platforms’ [1].

    The document says:

    ‘Platform hooks are specifically designed to extend your environment's platform. These are custom scripts and other executable files that you deploy as part of your application's source code, and Elastic Beanstalk runs during various instance provisioning stages.’

    Platform hooks can operate at:

    1) before building your application (prebuild)

    2) before deployment (predeploy)

    3) after deployment (postdeploy)

    To utilize platform hooks, you have to place the platform hook files under the .platform/hooks directory in your environment.

    Like this:

    --------------------

    ~/your-app-directory/

    |— .platform

    | └-- hooks

    | |-- prebuild\t\t← Put files here if you want the jobs to be run before build

    | |-- predeploy\t \t← Put files here if you want the jobs to be run before deployment

    | └-- postdeploy\t← Put files here if you want the jobs to be run after deployment

    |

    └-- other application files or directories

    --------------------

    Platform hooks are *.sh files, so you can just write shell scripts to install and delete directories.

    And platform hook files need execute permission, so you have to grant x permission to your platform hooks.

    You can give permission to files with .ebextentions [2].

    If you want to learn more about .ebextensions, please check out ‘Configuration files’ section in our document [1].

    Here is an example of .ebextention file.

    ------example.config------

    add_x_permission_to_platform_hooks:

    command: “chmod +x .platform/hooks/postdeploy/delete_directory.sh”

    ----------------------------

    And .ebextensions files should be placed under the .ebextentions directory in your environment.

    Like this:

    --------------------

    ~/your-app-directory/

    |— .ebextensions

    | |-- example.config\t← Put files here

    | └-- other .config files

    |

    └-- other application files or directories

    --------------------