Custom AWS CLI Step Powershell import module error

This was working in some of the previous 2018 releases but is not working now under 2018.4
I have a custom step template based on the Octopus AWS CLI step that looks like this:

{
  "Id": "ActionTemplates-83",
  "Name": "AWS S3 Upload",
  "Description": "Uploads the the specified source to the target S3 path.\nEmits the package folder S3 url as an output variable of S3Url.",
  "ActionType": "Octopus.AwsRunScript",
  "Version": 7,
  "CommunityActionTemplateId": null,
  "Properties": {
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.Aws.AssumeRole": "True",
    "Octopus.Action.AwsAccount.UseInstanceRole": "False",
    "Octopus.Action.Script.ScriptBody": "$bucketPath = $OctopusParameters[\"UploadS3BucketPathRoot\"]\n$s3Bucket = $OctopusParameters[\"UploadS3BucketName\"]\n$sourceTarget = $OctopusParameters[\"UploadS3SourcePath\"]\n\n\nif (!(Test-Path $sourceTarget)) {\n    Write-Error \"Source target: $sourceTarget was not found.\"\n}\n\nif (!(Test-S3Bucket $s3Bucket)) {\n    Write-Error \"Target S3Bucket ($s3Bucket) does not exist.\"\n}\n\nif ((Get-Item $sourceTarget) -is [System.IO.DirectoryInfo]) { \n    $basePath = $sourceTarget\n} else {\n    $basePath = Split-Path $sourceTarget -Parent\n}\n\npushd\n# Make the relative paths resolve correctly.\nSet-Location $basePath\n\n# Gets a(ll) file(s) in the target\nforeach ($item in (Get-ChildItem $sourceTarget -File -Recurse)) {\n    # Key: Get the relative path from the $basePath, remove any \".\\/\" at the beginning of the path, join it with the given bucketPath, then flip the \\ to /\n    $key = (Join-Path $bucketPath ((Resolve-Path $item.FullName -Relative).TrimStart(\".\",\"/\",\"\\\"))).Replace('\\','/')\n    Write-S3Object -BucketName $s3Bucket -Key $key -File $item.FullName\n}\n\npopd",
    "Octopus.Action.Aws.Region": "#{UploadS3AwsRegion}",
    "Octopus.Action.AwsAccount.Variable": "#{UploadS3AwsAccount}",
    "Octopus.Action.Aws.AssumedRoleArn": "#{UploadS3AwsAssumedRoleArn}",
    "Octopus.Action.Aws.AssumedRoleSession": "#{Octopus.Action.Id}"
  },
  "Parameters": [
    {
      "Id": "e06d78cc-38ba-436d-a7ce-e401d3fb07fc",
      "Name": "UploadS3BucketName",
      "Label": "S3 Bucket Name",
      "HelpText": "The S3 bucket to use for this sync operation.",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    },
    {
      "Id": "101405b4-b6b2-4e77-b2f6-0e781831e1e9",
      "Name": "UploadS3BucketPathRoot",
      "Label": "Base S3 Bucket Path",
      "HelpText": "The base path within the S3 bucket to add to the relative path(s) of the source when uploading.",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    },
    {
      "Id": "b43114d6-baa7-4ce1-8dea-8e4d4846492f",
      "Name": "UploadS3AwsRegion",
      "Label": "AWSRegion",
      "HelpText": "e.g. us-east-2",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    },
    {
      "Id": "2e88d4f5-d4a9-48e4-a379-670c44776737",
      "Name": "UploadS3AwsAccount",
      "Label": "AWS Account",
      "HelpText": null,
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "AmazonWebServicesAccount"
      },
      "Links": {}
    },
    {
      "Id": "8bf11e30-5a60-4fd2-b871-d2f5edb5f9e0",
      "Name": "UploadS3AwsAssumedRoleArn",
      "Label": "AwsRoleArn",
      "HelpText": null,
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    },
    {
      "Id": "9446f340-0617-4f06-8933-c64a944a0126",
      "Name": "UploadS3SourcePath",
      "Label": "Source Path",
      "HelpText": "The path to the source file or folder to upload. \nNote: Folders are walked recursively.",
      "DefaultValue": "",
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      },
      "Links": {}
    }
  ],
  "$Meta": {
    "ExportedAt": "2018-04-18T21:18:04.295Z",
    "OctopusVersion": "2018.4.0",
    "Type": "ActionTemplate"
  }
}

When this is being executed it is now erroring with:

Import-Module : Cannot find drive. A drive with the name '${env' does not  exist. 
At D:\OctopusTentacle\Work\20180418205854-6918-426\Bootstrap.Script.ps1:329    char:11 
+ ...             Import-Module -Name $calamariModulePath.Replace("{{Tentac ... 
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo          : ObjectNotFound: (${env:String) [Import-Module],   
   DriveNotFoundException 
    + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.ImpotModuleCommand

Last time it worked for sure was:
Server: 2018.3.7+Branch.master.Sha.7766581fe17b3e083120307f03e6732e1f071441
Octopus Deploy: Calamari.Aws version 4.4.10

Fullversion it is broken on is:
Server: 2018.4.0+Branch.master.Sha.6ab8757698b1669934816cfe378f4727e5b86d59
Octopus Deploy: Calamari.Aws version 4.5.1

Hi,

Thanks for providing the details on the community slack. I’ve raised an issue https://github.com/OctopusDeploy/Issues/issues/4495 and a fix should be out soon.

Rob

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.