Install google mod- pagespeed on elastic beanstalk on every instance added

870 views Asked by At

I've installed google mod-pagespeed with the following code:

container_commands:
01-command:
    command:        rm -rf /pagespeed/ebextensions

02-command:
    command:        mkdir -p /pagespeed/ebextensions

03-command:
    command:        cp -R .ebextensions/* /pagespeed/ebextensions/

04-command:
    command:         rpm -U /pagespeed/ebextensions/mod-pagespeed.rpm

Thanks to this answer Is it possible to use AWS Beanstalk's .ebextensions config to install mod_pagespeed Apache module?

The problem is apache is running those commands every time I deploy, and make error from the second time (because mod-pagespeed already installed), so I had to remove those commands, but then, when a new instance was added, it made LOTS of bugs, because only 1 machine had mod-pagespeed. (not recomended!)

I need to upload a code that installs mod-pagespeed on every new instance, and wont give me errors every time I deploy a new applications. Any ideas?

1

There are 1 answers

0
Rohit Banga On

Can you make your commands idempotent? May be keep all your commands in a script then run the script on the instance through container commands. The script could create a lock file in the end so that the script does not do anything on subsequent runs. That should solve your problem.