aws / amazon-ssm-agent

An agent to enable remote management of your EC2 instances, on-premises servers, or virtual machines (VMs).
https://aws.amazon.com/systems-manager/
Apache License 2.0
1.04k stars 323 forks source link

SSM Agent tries to execute runCommand in wrong dir #375

Closed slaffcheff closed 3 years ago

slaffcheff commented 3 years ago

I have EC2 image pipeline with pre-set workingDir (default tmp, changed to home).

When the ec2 instance is up and running and the agent process is running the pipeline hangs on Step 6: RunBuildScriptsWithLogging. After couple of minutes the output in SSM is:

/var/lib/amazon/ssm/instance-ID/document/orchestration/ID/awsrunShellScript/0.awsrunShellScript/_script.sh: line 49: /home/imagebuilder/TaskOrchestratorAndExecutor/bootstrap.sh: No such file or directory
{"failureMessage":"Unable to bootstrap TOE"}

----------ERROR-------
chmod: cannot access '/home/imagebuilder/TaskOrchestratorAndExecutor/bootstrap.sh': No such file or directory
failed to run commands: exit status 1

When I logged on the instance I can see the scripts are located in /var/lib/amazon/ssm and not in $workingDir/imagebuilder/TaskOrchestratorAndExecutor.

Is it possible to modify the sh or somehow fix where to look at?

The script is curl https://ec2imagebuilder-toe-us-east-2-prod.s3.us-east-2.amazonaws.com/bootstrap_scripts/bootstrap.sh -o ${TOE_DIR}/bootstrap.sh --silent --create-dirs

from install_package function.

VishnuKarthikRavindran commented 3 years ago

Hi @slaffcheff, We have passed on to the concerned team. Thanks

slaffcheff commented 3 years ago

So the issue was a networking one. I managed to catch it after some time but at first i thought it's a script issue. YOu can consider this closed.

drewpushlive commented 2 years ago

@slaffcheff - can I ask what the networking issue was? I've run into the same issue and am pulling my hair out trying to diagnose!