Difficulty with using AWS Account parameter in a Step Template


I have created a Step Template using PowerShell taking a parameter of type AWS Account.

Within the script I was expecting to be able to dereference the SecretKey & AccessKey appropriately, as per the documentation.

My variable name is $aAWSAccount. I believe the following code in my Step Template should therefore work:

Write-Host ‘AWSAccount.Id=’ $aAWSAccount
Write-Host ‘AWSAccount.AccessKey=’ $aAWSAccount.AccessKey

When I use the Step in a Process for one of my projects, I am correctly prompted to choose a variable from my Project of type AWS Account.
When the deployment of that project runs, the first line of output gives me the name of the AWS Account that is passed as a parameter, as I expect.
However $aAWSAccount.AccessKey is null.

Is there a difference between how AWS Account variables are accessible in a regular step as opposed to as a parameter in a Step Template?

Any other advice please? This is frustrating me.



Hi Conor

Thanks for getting in touch!

Coincidentally, I found the same the other day and ended up fixing it while I was looking at something else. Keep an eye on this issue - it should be released in the next few days.

In the meantime, you can approach it like this:

$variableName = $aAWSAccount
$accessKey = $OctopusParameters["$aAWSAccount.AccessKey"]

Not ideal, and not the most obvious, but should get you going.

Hope that helps!


Excellent, thanks for that!

Does indeed work!

1 Like

Hoping you can help me with similar clarification for bash scripts please?

Have tried the following without success:

AWS_ACCESS_KEY_ID=$(get_octopusvariable "aAWSAccount.AccessKey")
AWS_ACCESS_KEY_ID=$(get_octopusvariable "$aAWSAccount.AccessKey")

Hi Conor

I’m a bit rusty with bash, but I think it should be something like:

variableName=$(get_octopusvariable "aAWSAccount")
accessKey = $(get_octopusvariable "$variableName.AccessKey")

Check out our docs around using variables in scripts for more details here.


Thanks Matt, appreciated, that does the trick.



1 Like