Home > database >  Load Parameter from Local File in AWS CLI
Load Parameter from Local File in AWS CLI

Time:05-02

I am trying to create a glue job from AWS CLI. It works when I use the actual Glue Job name in the --name field

aws glue create-job \
    --name my-first-glue-job-cli \
    --role arn:aws:iam::***:role/GlueRole \
    --command file://command.json \
    --region us-east-2 \
    --output json \
    --default-arguments file://arguments.json \
    --glue-version 3.0 \
    --profile ***

But I want the value attached in the --name parameter to be loaded from a file just like --default-arguments / --command

I understand the latter two options are structure/map type and --name is of string type. I have gone through the glue documentation

Also went through the cli documentation to load parameters from a file. They only mention json use-cases.

I tried loading the value from a local txt file I created and put the job-name inside that txt file.

aws glue create-job \
    --name file://gluejobname.txt \
    --role arn:aws:iam::***:role/GlueRole \
    --command file://command.json \
    --region us-east-2 \
    --output json \
    --default-arguments file://arguments.json \
    --glue-version 3.0 \
    --profile ***

Error being displayed is:

An error occurred (ValidationException) when calling the CreateJob operation: 1 validation error detected: Value 'my-first-glue-job-cli
' at 'name' failed to satisfy constraint: Member must satisfy regular expression pattern: [\u0020-\uD7FF\uE000-\uFFFD\uD800\uDC00-\uDBFF\uDFFF\t]*

CodePudding user response:

The cli will accept a scalar parameter from a file as file://gluejobname.txt. Use unquoted text, no newlines!

Alternatively, pass all params as a single JSON file using the --cli-input-json flag. For example:

# Generate a template (optional):
aws glue get-job --generate-cli-skeleton > params.json
// params.json
{ "JobName": "" }
# pass all params in one file
aws glue get-job --cli-input-json file://params.json
  • Related