0

I am loading userdata script using AWC CDK typescript code as below.

let userDataScript = fs.readFileSync(path.resolve("./lib/helpers/bootstrap.sh"), "utf8");
  
instance.addUserData(userDataScript);

The script runs only partially and doesn't seem to run below statements as I see : No jq pacakage available message in logs.

echo "Installing epel release"  >>  /tmp/cfn-init.log 

yes | rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm  >>  /tmp/cfn-init.log 

echo "Finished Installing epel release"  >>  /tmp/cfn-init.log 


echo "Installing yum update"  >>  /tmp/cfn-init.log 
yum -y update   >>  /tmp/cfn-init.log 

echo "Finished Installing yum update"  >>  /tmp/cfn-init.log 


echo "Installing  jq"  >>  /tmp/cfn-init.log 
yum -y install jq   >>  /tmp/cfn-init.log 

Strange part being, if I run these commands from console using SSM session manager, everything works as expected. Any suggestions please?

Thanks for your help.

dossani
  • 1,892
  • 3
  • 14
  • 23

1 Answers1

0

Removing carriage return (\r) from the shell script helped to resolve the issue.

dossani
  • 1,892
  • 3
  • 14
  • 23