cdk-ssm-documents icon indicating copy to clipboard operation
cdk-ssm-documents copied to clipboard

Add output field for `InvokeLambdaFunctionStep` step

Open andremmfaria opened this issue 1 year ago • 0 comments

I am trying to create a lambda function step using InvokeLambdaFunctionStep. However, there is no outputs parameter on InvokeLambdaFunctionStepProps.

This is the function i am trying to create:

export function defineAutomationDocument(
  stack: Stack,
  lambda: aws_lambda.Function,
): AutomationDocument {
  const document = new AutomationDocument(
    stack,
    `SampleDocumentRunbook`,
    {
      documentFormat: DocumentFormat.JSON,
      documentName: "SampleRunbook",
      description: "Sample runbook",
      updateMethod: "NewVersion",
    },
  );

  const lambdaStep = new InvokeLambdaFunctionStep(stack, `LambdaStep`, {
    name: "Lambda",
    description: "Run Lambda",
    functionName: new HardCodedString(lambda.functionName),
    isEnd: false,
    explicitNextStep: StepRef.fromName("NextStep"),
    // outputs: [{ Type: "String", Name: "output", Selector: "$.output" }]     <-------------  THIS DOES NOT EXIST
  });

  document.addStep(lambdaStep);

  return document;
}

That parameter exists on CfnDocument (doc) whenever you are defining a new step. The above would be translated to a Cfn construct like so:


export function defineAutomationDocument(
  stack: Stack,
  lambda: aws_lambda.Function,
) {
  const cfnDocument = new aws_ssm.CfnDocument(stack, `SampleDocumentRunbook`, {
    name: "SampleRunbook",
    documentFormat: "JSON",
    documentType: "Automation",
    updateMethod: "NewVersion",
    content: {
      schemaVersion: "0.3",
      description: "Sample runbook",
      parameters: {},
      mainSteps: [
        {
          description: "Run Lambda",
          name: "Lambda",
          action: "aws:invokeLambdaFunction",
          inputs: {
            FunctionName: Fn.ref(
              stack.getLogicalId(
                lambda.node.defaultChild as aws_lambda.CfnFunction,
              ),
            ),
          },
          nextStep: "NextStep",
          outputs: [{ Type: "String", Name: "output", Selector: "$.output" }],  <-------------  THIS EXISTS
        },
      ],
    },
  });

  return cfnDocument;
}

Can this be added? Thanks in advance.

andremmfaria avatar Mar 18 '24 15:03 andremmfaria