You can execute a [[k6 (tool)|k6]] load testing script from the CLI:
- locally, with local results
- locally, but sending a copy of the results to [[k6 Cloud]]
- on the Cloud
All three options involve triggering the request in the CLI on your local machine, but the third option will use k6's cloud load generator(s) instead.
## Logging into k6 Cloud
If you're either sending results to or running tests on k6 Cloud, you'll need to add your k6 Cloud credentials. You can do this by providing the username and password or your API token.
### Providing your username and password
`k6 login cloud`
Enter your username and password when prompted.
### Providing your API token
Get your API token [here](https://app.k6.io/account/api-token) and run:
`k6 login cloud --token <TOKEN>`
## Sending results to k6 Cloud
This is useful to do when you want the extra control of executing the test on your own infrastructure, but the convenience of seeing those results analyzed in k6 Cloud.
Run this command to run a test locally and pipe the results of the test to k6 Cloud for further analysis or sharing:
`k6 run test.js -o cloud`
## Running a test from the CLI on the cloud
To bypass your local machine entirely and run a k6 test on k6 Cloud, using [[AWS]] infrastructure, run this command:
`k6 cloud test.js`
### Cloud execution options
If you know you're going to run on the cloud, you can add options within your script that are specific to k6 Cloud executions:
```js
export let options = {
ext: {
loadimpact: {
name: 'Hello k6 cloud!',
projectID: 123456,
staticIPs: true,
distribution: {
distributionLabel1: { loadZone: 'amazon:us:ashburn', percent: 50 },
distributionLabel2: { loadZone: 'amazon:ie:dublin', percent: 50 },
},
note: 'Anything that may be worth noting about your test.',
},
},
};
```
[^docs]
[^docs]: _Creating and running a test: Cloud execution options_. k6. Retrieved from https://k6.io/docs/cloud/creating-and-running-a-test/cloud-tests-from-the-cli/#cloud-execution-options