Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Job won't recognize AWS CLI command

Hello I have a SQL Server Job with a CmdExec step that goes like this:

powershell.exe -file D:\Script\test.ps1

currently the PowerShell script is simply this:

aws s3 ls s3://backup-sql-day/

and curiously the job runs sucessesfully, and there's this message.

The term 'aws' is not recognized as the name of a cmdlet, function, script file,
or operable program. Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At D:\Script\teste.ps1:1 char:1
+ aws s3 ls s3://backup-sql-day/
+ ~~~
     + CategoryInfo          : ObjectNotFound: (aws:String) [], CommandNotFoundException
     + FullyQualifiedErrorId : CommandNotFoundException.Process

Exit Code 0.
The step succeeded.

So the script doesn't run, doesn't report me the error, the thing is I cannot seem to run any AWS script on the SQL Server Job, however I can run it normally with any user, does anybody have a clue on how to fix this?

like image 313
Gabriel Guimarães Avatar asked Jan 04 '16 12:01

Gabriel Guimarães


People also ask

Why aws command is not working?

If the aws command cannot be found after first installing or updating the AWS CLI, you might need to restart your terminal for it to recognize any PATH updates. If the aws command cannot be found after first installing or updating the AWS CLI, it might not have been fully installed.

How do you test if AWS CLI is working?

To validate a user's credentials with the AWS CLI, run the sts get-caller-identity command. The command returns details about the user's credentials if they are valid, otherwise it throws an error. Copied!

How do you check if AWS CLI is configured correctly?

Use the describe-configuration-recorder-status command to check that the AWS Config has started recording the configurations of the supported AWS resources existing in your account. The recorded configurations are delivered to the specified delivery channel.

How do you fix unable to locate credentials you can configure credentials by running aws configure?

An "Unable to locate credentials" error indicates that Amazon S3 can't find the credentials to authenticate AWS API calls. To resolve this issue, make sure that your AWS credentials are correctly configured in the AWS CLI.


1 Answers

The (unmangled) error message is actually rather self-explanatory. The script does run, but cannot find the aws commandline tool. Either the path to the AWS CLI installation isn't included in the PATH environment variable, or the SQL Server job ignores the system environment.

You can work around the issue by adding the path inside your script:

$env:Path += ';C:\Program Files\Amazon\AWSCLI'
aws s3 ls s3://backup-sql-day/

Replace C:\Program Files\Amazon\AWSCLI with whichever folder the tool was installed to.

like image 122
Ansgar Wiechers Avatar answered Oct 25 '22 16:10

Ansgar Wiechers