IoT create job template using document source option

0

I can create a job template using the --document option, like so:

$ aws iot create-job-template --job-template-id 'test-job-template' --description 'test job template' --document '{"version":"1.0","steps":[{"action":{"name":"Run-Command","type":"runCommand","input":{"command":"ls"},"runAsUser":"root"}}]}'

However, I get a "job document source ${aws:iot:s3-presigned-url:https://s3.amazonaws.com/jobsdocs/testDoc.json} is invalid (InvalidRequestException)" if I execute the following:

aws iot create-job-template --job-template-id 'test-job-template' --description 'test job template' --document-source '${aws:iot:s3-presigned-url:https://s3.amazonaws.com/jobsdocs/testDoc.json}'

Thanks Gary

gary
posta un anno fa257 visualizzazioni
1 Risposta
1
Risposta accettata

Hi Gary.

EDIT: I just realized you are wrapping the S3 object link to the job document in a pre-signed URL placeholder. This is not correct. To try to clarify:

  • Use --document when specifying the body of the job document inline in your CLI command.
  • Use --document-source when your job document is in an S3 bucket.
  • A pre-signed URL placeholder is only needed if the body of the job document refers to another S3 object. The placeholder should only appear in the body of the job document.
  • You do not need to use a pre-signed URL placeholder in your CLI command when using --document-source.

So your second command should be:

aws iot create-job-template --job-template-id 'test-job-template' --description 'test job template' --document-source https://s3.amazonaws.com/jobsdocs/testDoc.json'

If testDoc.json includes a pre-signed placeholder, then you need the --presigned-url-config as well.

profile pictureAWS
ESPERTO
Greg_B
con risposta un anno fa
  • Thanks Greg. I used --document and --presigned-url as you suggested, as follows but got a new error:

    $ aws iot create-job-template --job-template-id 'job-temp' --description 'job temp' --document '${aws:iot:s3-presigned-url:https://s3.amazonaws.com/alpha-numeric/jobs-documents/jobDoc.json}' --presigned-url-config 'roleArn="arn:aws:iam::myacc:role/dwnld-s3",expiresInSec=60'
    An error occurred (InvalidRequestException) when calling the CreateJobTemplate operation: Job document located at request input is an invalid JSON document.
    

    My JSON file has the same content as per my first cmd

  • Hi Greg, I'm not sure why with --document I'm passing a placeholder link (when this is not mentioned in the docs), and why I'm not using --document-source and passing the placeholder link together with --presigned-url-config (to give AWS CLI permission to get the jobs doc?) to convert a jobs document into a jobs template. It would be great if you could clarify, I must be missing something in the docs.

  • Hi Gary. I edited my answer. When I first answered, I thought you were passing in a job document, not a link to a job document in S3. I hope the answer is clearer now.

  • Hi Greg, that makes perfect sense. It was this section in the docs If the job document resides in an S3 bucket, you must use a placeholder link when specifying the document. The placeholder link is of the following form: ${aws:iot:s3-presigned-url:https://s3.amazonaws.com/ *bucket* / *key* } that tripped me - I did wonder why a placeholder link was needed when I had a simple job document in S3. Thanks again

  • Understood. I raised in issue internally yesterday to get that part of the documentation addressed.

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande