Skip to content

Instantly share code, notes, and snippets.

@RagedUnicorn
Last active July 25, 2018 17:04
Show Gist options
  • Save RagedUnicorn/dedb8db636aee5d2b208099ebb3d87a7 to your computer and use it in GitHub Desktop.
Save RagedUnicorn/dedb8db636aee5d2b208099ebb3d87a7 to your computer and use it in GitHub Desktop.
Aws device farm retrieve logfiles from runs

AWS Device Farm

Make sure to configure aws cli. Currently device farm is only supported in the us-west-2 region. Make sure to configure the aws cli to use this region.

aws configure

List your device farm projects

aws devicefarm list-projects

Output:

{
    "projects": [
        {
            "arn": "arn:aws:devicefarm:us-west-2:*:project:*",
            "name": "name",
            "defaultJobTimeoutMinutes": ,
            "created": 
        }
    ]
}

The arn is needed for subsequent commands

Note: With tools like jq the arn can be read directly from the json output from awscli

/bin/bash -c 'aws devicefarm list-projects | jq ".projects[0].arn"'

To list all runs inside a project

aws devicefarm list-runs --arn arn:aws:devicefarm:us-west-2:*:project:*

A run once again has an arn identifier which needs to be retrieved

{
  "arn": "arn:aws:devicefarm:us-west-2:*:run:*",
  "name": "[name]",
  "type": "INSTRUMENTATION",
  "platform": "",
  "created": ,
  ...
}

Finally all the artifacts can be listed.

aws devicefarm list-artifacts --arn arn:aws:devicefarm:us-west-2:*:run:* --type FILE

An artifact has an assigned s3 url.

{
  "arn": "arn:aws:devicefarm:us-west-2:*:artifact:*",
  "name": "[filename]",
  "type": "[type]",
  "extension": "[file extension]",
  "url": "[S3 URL]"
}

The file itself can then be downloaded with a simple GET call to this url. The urls are already presigned and as of this don't require extra authentication.

curl "[url]" > log.txt

Note: Make sure to put the url in quotes for curl to correctly parse the command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment