How to encrypt web.config section AND deploy to multiple servers with Amazon Elastic Beanstalk
Following @kukido 's suggestion what you need to do is create an .ebextension file with the following content.
commands:
encryptConfig:
command: aspnet_regiis.exe -pe "connectionStrings" -app /
cwd: %windir%\\Microsoft.NET\\Framework64\\v4.0.30319