How can i pass cognito email details($context.authorizer.claims.email) in an api gateway VTL mapping template to a synchronous express workflow

0

I have a rest api gateway with direct integration with aws step functions. I want to get the email of the logged in user and pass it on to the step functions workflow. How can i get the email details in the integration rrequest? I have the following cloudformation but i cannot get the details from $context.authorizer.claims.email being passed on to the step functions workflow despite the other params being passed on. RequestTemplates: application/json: !Sub - |- #set($inputRoot = $input.path('$')) { "params": [

            {
              "OrganisationName": $('$.OrganisationName')
              "OrgCreatedBy": "$context.authorizer.claims.email"
            }
            
            ]
          }
          {
              "input": "$params",
              "stateMachineArn": "${StateMachineArn}"
          }
        - { StateMachineArn: !Ref OrgAdminStateMachine }
1개 답변
1

Finally succeeded ! After trying harder, here is the api gateway body mapping template for any other person out there; The trick is to manipulate the object this way before.

#set($data = $input.path('$'))
#set($input = " { ""OrganisationName"" : ""$data.OrganisationName"", ""OrgStatus"" : ""$data.OrgStatus"", ""OrgCreatedBy"" : ""$context.authorizer.claims.email"" }")
{ 
    "input": "$util.escapeJavaScript($input).replaceAll("\\'", "'")",
    "stateMachineArn": "<put your step machine arn here>"
}

VTL not my cup of tea, there are few resources with examples especially AWS specific VTL. I wish more tutorials are made for this - maybe i will make one!. Lambda would be the go to for somethings but who doesnt want pure serverless and not to worry about compute. Long live AWS! The power this functionality enables for my use case is tremendous!

답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠