Reputation: 579
I'm trying to run a script after my application is deployed on AWS. But whenever I try to run the script after deployment it gives a permission error.
[RunAppDeployPostDeployHooks]. Stop running the command. Error: Command .platform/hooks/postdeploy/99_start_script.sh failed with error fork/exec .platform/hooks/postdeploy/99_start_script.sh: permission denied
I tried to include chmod +x command in my .config file but it gives no such directory error.
script.config
commands:
01_chmod:chmod +x .platform/hooks/postdeploy/99_start_script.sh
cfn.init
2020-11-28 14:13:17,374 [ERROR] -----------------------BUILD FAILED!------------------------ 2020-11-28 14:13:17,374 [ERROR] Unhandled exception during build: Command 01_chmod failed Traceback (most recent call last): File "/opt/aws/bin/cfn-init", line 171, in worklog.build(metadata, configSets) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 129, in build Contractor(metadata).build(configSets, self) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 530, in build self.run_config(config, worklog) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 542, in run_config CloudFormationCarpenter(config, self._auth_config).build(worklog) File "/usr/lib/python2.7/site-packages/cfnbootstrap/construction.py", line 260, in build changes['commands'] = CommandTool().apply(self._config.commands) File "/usr/lib/python2.7/site-packages/cfnbootstrap/command_tool.py", line 117, in apply raise ToolError(u"Command %s failed" % name) ToolError: Command 01_chmod failed
Upvotes: 2
Views: 2929
Reputation: 238747
Commands in commands run in root folder, not your application folder:
By default, commands run in the root directory. To run commands from another directory, use the cwd option.
Also:
The commands run before the application and web server are set up and the application version file is extracted.
Thus, even if you fix the execution folder, it will probably still not work because your application is not yet extracted. To run commands after extraction, use container_commands.
Upvotes: 1