Home > Enterprise >  ParamValidationError: Parameter validation failed: Bucket name must match the regex
ParamValidationError: Parameter validation failed: Bucket name must match the regex

Time:10-01

I'm trying to run a Glue job by calling it from lambda function. The glue job in itself is running perfectly fine but when I trigger it from lambda function, I get the below error:

[ERROR] ParamValidationError: Parameter validation failed: Bucket name must match the regex \"^[a-zA-Z0-9.\\-_]{1,255}$\" or be an ARN matching the regex \"^arn:(aws).*:(s3|s3-object-lambda):[a-z\\-0-9]*:[0-9]{12}:accesspoint[/:][a-zA-Z0-9\\-.]{1,63}$|^arn:(aws).*:s3-outposts:[a-z\\-0-9] :[0-9]{12}:outpost[/:][a-zA-Z0-9\\-]{1,63}[/:]accesspoint[/:][a-zA-Z0-9\\-]{1,63}$\""

There is no issue in my bucket name as I am able to do different actions with it and also my glue job is working fine when running it standalone.

Any help would be appreciated.

Thanks in advance.

CodePudding user response:

Maybe you are including the s3:// protocol when indicating the bucket name and it is not required.

CodePudding user response:

I was able to solve it by making a few changes.

My initial code was:

import json
import os
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
import boto3
client = boto3.client('glue')

glueJobName = "MyTestJob"


def lambda_handler(event, context):
    logger.info('## INITIATED BY EVENT: ')
    logger.info(event['detail'])
    response = client.start_job_run(JobName = glueJobName)
    logger.info('## STARTED GLUE JOB: '   glueJobName)
    logger.info('## GLUE JOB RUN ID: '   response['JobRunId'])
    return response

Once I removed the logging part (code below), it worked without any error:

from __future__ import print_function
import boto3
import urllib

print('Loading function')

glue = boto3.client('glue')

def lambda_handler(event, context):
    gluejobname="MyTestJob"

    
    runId = glue.start_job_run(JobName=gluejobname)
    status = glue.get_job_run(JobName=gluejobname, RunId=runId['JobRunId'])
    print("Job Status : ", status['JobRun']['JobRunState'])

What could be the issue here?

Thanks

  • Related