Search code examples
amazon-web-servicesterraformterraform-provider-awsamazon-sagemakeraws-step-functions

How to append stepfunction execution id to SageMaker job names?


I have a step function statemachine which creates SageMaker batch transform job, the definition is written in Terraform, I wanted to add the stepfunction execution id to the batch transform job names:

in stepfunction terraform file:

  definition = templatefile("stepfuntion.json",
    {
      xxxx
)

in the "stepfuntion.json":

{...
          "TransformJobName": "jobname-$$.Execution.Id",
  
          }
      },
        "End": true
      }
    }
  }

But after terraform apply, it didn't generate the actual id, it gave me jobname-$$.Execution.Id, can anyone help with this please?

Resources: https://docs.aws.amazon.com/step-functions/latest/dg/input-output-contextobject.html "To access the context object, first specify the parameter name by appending .$ to the end, as you do when selecting state input with a path. Then, to access context object data instead of the input, prepend the path with $$.. This tells AWS Step Functions to use the path to select a node in the context object."

Can someone tell me what I'm missing please?


Solution

  • The var you are trying to use terraform doesn't know about it

    jobname-$$.Execution.Id.

    That's something specific to the Step function and available within state machine not available for terraform.