2

I have this lambda go code, which approves a code deploy manual action step at a certain stage.

If the preview stage was successful then lambda will auto-approve the action. If not, then someone will have to check and do it manually. As a starting point, I wrote this code to always auto-approve, before adding more complex logic.

I'm having a hard time with something so simple as entering PutApprovalResult documentation and ApprovalResult documentation. Been looking everywhere for examples but nothing. Can someone give me a hand here, please?

My code:

func auto_approve(pipeName, stageName, actionName, token string){

    cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("eu-central-1"))

    if err != nil {
        log.Fatal(err)
    }

    client := codepipeline.NewFromConfig(cfg)

    //approve := { Status: "Approved", Summary: "Approved by lambda" }

    client.PutApprovalResult(context.TODO(), &codepipeline.PutApprovalResultInput{
        ActionName: &actionName,
        StageName: &stageName,
        PipelineName: &pipeName,
        Token: &token,
        Result: { Status: "Approved", Summary: "Approved by lambda"}, \\Here is the problem
    })

    return
}
blackgreen
  • 34,072
  • 23
  • 111
  • 129
rek2
  • 101
  • 12

1 Answers1

1

OK after a LOT of trial and error and reading the actual main source code and not the document I was able to figure out I need to add types. As well…

 Result: &types.ApprovalResult{ Status: "Approved", Summary: &summsg },

Furthermore, the Summary part needs to point out to a string… If someone can comment and explain why, so I learn something, will be nice. :)

rek2
  • 101
  • 12