-1

System specification -

node version - v10.15.0
npm version - 6.4.1
aws-cli version - aws-cli/1.16.81 Python/3.6.0 Windows/10 botocore/1.12.71
sam-cli version - SAM CLI, version 0.41.0

Running on a windows machine.

So I have a node project, which would be deployed to aws-sam. I have scripts for sam-validate, prepare, package. But when I run this script via npm run <package-name>, commands don't run. For example If I run npm run package, I get the following -

aws --region <region-name> s3api head-bucket --bucket <bucket-name>
Command not run
Command executed in 0 msec
aws --region <<region-name>> cloudformation package --template-file template.yaml --s3-bucket <bucket-name> --output-template-file template-deploy.yaml
Command not run
Command executed in 0 msec

But surprisingly If I run those commands from powershell individually, then it works fine. Which made me come to the realization that scripts are okay, as the generated commands do work when I run them individually.

I checked my environment variables. All the things(node path, aws cli path etc.) are there.

What am I missing here? Simply put the problem is - Do I need to do anything else to run aws-cli or sam-cli commands through node scripts?

Arnab Roy
  • 619
  • 5
  • 16

1 Answers1

0

There might be an issue with your scripts i think,

Consider writing the script in python like

import subprocesses
commandToBeExecutedOnShell='any command'
subprocess.check_call(commandToBeExecutedOnShell, shell=True)

You can then either run the scripts from python itself or

create a separate node app which calls python functions

Reference This

and then run that node app using npm run

Ali Khan
  • 114
  • 2
  • 4
  • 21