AWS SAM CLI in Octopus Cloud Hosted

Is it possible to use the AWS SAM CLI in a deployment step when using the Cloud Hosted version of Octopus?

I see support for AWS CloudFormation templates using the standard AWS CLI, but we have SAM templates that require the AWS SAM CLI to be installed on the Octopus server.


Hi Chris, thanks for reaching out.

If you need additional tools during a deployment, the recommended approach is to create a worker that has the required tools installed. You can find more information about workers at

Another approach is to use an additional package reference in your AWS script step that includes the AWS SAM CLI. So you would first install the AWS SAM CLI tools locally. Then you would add the files in C:\Program Files\Amazon\AWSSAMCLI to a package and upload it to the Octopus server. Using the Octopus CLI you can create this package with the commands:

cd "C:\Program Files\Amazon\AWSSAMCLI"
octo pack -id AwsSamCli -version 1.0.0 -format zip

In the screenshot below you can see an AWS script step that is calling the AWS SAM CLI from an additional package.

Matt C

I’ve zipped up my “AwsSamCli” folder and uploaded it as a package to Octopus.

I included the package in my step and I can verify via logs it’s downloading and unzipping the AWSSAMCLI package.

However, I’m still not able to invoke sam.cmd

When my script contains the below line, I receive the error:
& “AWSSAMCLI\bin\sam.cmd” --help

The module 'AWSSAMCLI' could not be loaded. For more information, run 'Import-Module AWSSAMCLI'.

I then tried the below command and received the error.
& “.\AWSSAMCLI\bin\sam.cmd” --help

The term '.\AWSSAMCLI\bin\sam.cmd' 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.

I’m using the Cloud Hosted version of Octopus Server. I can see from the logs that the AWSSAMCLI package is being unzipped and it exists. I’m confused why the PowerShell script isn’t recognizing sam.cmd.


Hi @cnelson,

It sounds like the file is not being extracted to the expected location. You can add something like this to your script:


to ensure that the files are created in the locations that you expect.

Matt C

Thanks Matt, I have it working.

I feel silly. I assumed I knew where the package was be extracted, but it was being extracted a level lower than I expected.

It works when I do the below command with my current setup:

& ".\AWSSAMCLI\AWSSAMCLI\bin\sam.cmd" --help

That is good news! Thanks for lettings us know.