Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (7k points)

How can I implement an optional parameter to an AWS Glue Job?

I have a job which has a string parameter an ISO 8601 date string as an input which is used in the ETL job. I like to make this parameter as optional, so the job can use a default value if it is not provided (e.g. using datetime.now and datetime.isoformatin my case). I have tried using 

import sys

from awsglue.utils import getResolvedOptions

args = getResolvedOptions(sys.argv, ['ISO_8601_STRING'])

However, when I am not passing an --ISO_8601_STRING job parameter I see the following error:

awsglue.utils.GlueArgumentError: argument --ISO_8601_STRING is required 

 

1 Answer

0 votes
by (31.9k points)

You can try the following by porting to Python 

if ('--{}'.format('ISO_8601_STRING') in sys.argv):

    args = getResolvedOptions(sys.argv, ['ISO_8601_STRING'])

else:

    args = {'ISO_8601_STRING': datetime.datetime.now().isoformat()}

Are you interested in learning AWS? Then check out AWS Course Training. 

Related questions

0 votes
1 answer
asked Dec 17, 2020 in AWS by devin (5.6k points)

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
asked Dec 7, 2020 in AWS by devin (5.6k points)
0 votes
1 answer
0 votes
1 answer
asked Nov 17, 2020 in AWS by Amyra (12.9k points)

Browse Categories

...