Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Creating lambda function to invoke glue job

Through Terraform I created a lambda function to invoke glue job.
I am running terraform apply job using jenkins and I am getting syntax error when I test the lambda function after creating.

If I run terraform apply from local terminal it’s working good.

Lambda test also executed, but through jenkins terraform apply i am getting syntax error.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

invoke-glue-job.py:

from __future__ import print_function
import boto3
import urllib

print ('Loading function')

glue = boto3.client('glue')

def lambda_handler(event, context)
    gluejobname = "job1"

    try: 
        runId = glue.start_job_run(JobName=gluejobname)
        status = glue.get_job_run(JobName=gluejobname, RunId=runid['JobRunId'])
        print("Job Status : ", status['JobRun']['JobRunState'], "runId",runId)
    except Exception as e:
        raise e

I am getting below error when I run through jenkins job:

{
  "errorMessage": "Syntax error in module 'invoke-glue-job': invalid syntax (invoke-glue-job.py, line 9)",
  "errorType": "Runtime.UserCodeSyntaxError",
  "requestId": "46a194e6-410b-45ed-927e-3e752f5836cb",
  "stackTrace": [
    "  File \"/var/task/invoke-glue-job.py\" Line 9\n    def lambda_handler(event, context)\n"
  ]
}

I used handler = "invoke-glue-job.lambda_handler" in terraform configuration.
I am not sure what the error here. Any suggestions?

>Solution :

You forgot about :. So it should be:

def lambda_handler(event, context):
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading