github.com/webonyx/up@v0.7.4-0.20180808230834-91b94e551323/docs/06-commands.md (about) 1 --- 2 title: Commands 3 --- 4 5 6 Up provides the `up` command-line program, used to deploy the app, and manage associated resources such as domains and SSL certificates, as well as operational tasks like viewing logs. 7 8 To view details for a command at any time use `up help`, `up help <command>`, for example `up help team members add`. 9 10 ``` 11 Usage: 12 13 up [<flags>] <command> [<args> ...] 14 15 Flags: 16 17 -h, --help Output usage information. 18 -C, --chdir="." Change working directory. 19 -v, --verbose Enable verbose log output. 20 --format="text" Output formatter. 21 --version Show application version. 22 23 Commands: 24 25 help Show help for a command. 26 build Build zip file. 27 config Show configuration after defaults and validation. 28 deploy Deploy the project. 29 deploys Show deployment history. 30 docs Open documentation website in the browser. 31 domains ls List purchased domains. 32 domains check Check availability of a domain. 33 domains buy Purchase a domain. 34 env add Add variables. 35 env get Get a variable value. 36 env ls List variables. 37 env rm Remove variables. 38 logs Show log output. 39 metrics Show project metrics. 40 prune Prune old S3 deployments of a stage. 41 rollback Rollback to a previous deployment. 42 run Run a hook. 43 stack plan Plan configuration changes. 44 stack apply Apply configuration changes. 45 stack delete Delete configured resources. 46 stack status Show status of resources. 47 start Start development server. 48 team status Status of your account. 49 team switch Switch active team. 50 team login Sign in to your account. 51 team logout Sign out of your account. 52 team members add Add invites a team member. 53 team members rm Remove a member or invite. 54 team members ls List team members and invites. 55 team subscribe Subscribe to the Pro plan. 56 team unsubscribe Unsubscribe from the Pro plan. 57 team card change Change the default card. 58 team ci Credentials for CI. 59 team add Add a new team. 60 upgrade Install the latest or specified version of Up. 61 url Show, open, or copy a stage endpoint. 62 version Show version. 63 64 Examples: 65 66 Deploy the project to the staging environment. 67 $ up 68 69 Deploy the project to the production stage. 70 $ up deploy production 71 72 Show the staging endpoint url. 73 $ up url 74 75 Tail project logs. 76 $ up logs -f 77 78 Show error or fatal level logs. 79 $ up logs 'error or fatal' 80 81 Run build command manually. 82 $ up run build 83 84 Show help and examples for a command. 85 $ up help team 86 87 Show help and examples for a sub-command. 88 $ up help team members 89 ``` 90 91 ## Deploy 92 93 Deploy the project, by default to the "staging" stage. Note that running `up` and `up deploy` are identical, as it is the default command. 94 95 ``` 96 Usage: 97 98 up deploy [<stage>] 99 100 Flags: 101 102 -h, --help Output usage information. 103 -C, --chdir="." Change working directory. 104 -v, --verbose Enable verbose log output. 105 --format="text" Output formatter. 106 --version Show application version. 107 108 Args: 109 110 [<stage>] Target stage name. 111 ``` 112 113 ### Examples 114 115 Deploy the project to the staging stage. 116 117 ``` 118 $ up 119 ``` 120 121 Deploy the project to the staging stage, this is the same as running `up` without arguments. 122 123 ``` 124 $ up deploy 125 ``` 126 127 Deploy the project to the production stage. 128 129 ``` 130 $ up deploy production 131 ``` 132 133 Note that since `deploy` is the default command the following is also valid: 134 135 ``` 136 $ up production 137 ``` 138 139 ## Rollback 140 141 [Up Pro](#guides.subscribing_to_up_pro) supports instant rollbacks to a previous deployment. A subsequent `up rollback` will revert the rollback, as it simply toggles the deployment versions. Note that rollbacks do not affect environment variables, as they are loaded at runtime. 142 143 ``` 144 Usage: 145 146 up rollback [<flags>] [<version>] 147 148 Flags: 149 150 -h, --help Output usage information. 151 -C, --chdir="." Change working directory. 152 -v, --verbose Enable verbose log output. 153 --format="text" Output formatter. 154 --version Show application version. 155 -s, --stage="staging" Target stage name. 156 157 Args: 158 159 [<version>] Target version for rollback. 160 ``` 161 162 ### Examples 163 164 Rollback to the previous staging version. 165 166 ``` 167 $ up rollback 168 ``` 169 170 Rollback to a specific git commit 171 172 ``` 173 $ up rollback 15c46ba 174 ``` 175 176 Rollback to a specific git tag 177 178 ``` 179 $ up rollback v1.7.2 180 ``` 181 182 Rollback to the previous production version. 183 184 ``` 185 $ up rollback -s production 186 ``` 187 188 Rollback to a specific git commit 189 190 ``` 191 $ up rollback -s production 15c46ba 192 ``` 193 194 Rollback to a specific git tag 195 196 ``` 197 $ up rollback -s production v1.7.2 198 ``` 199 200 ## Config 201 202 Validate and output configuration with defaults applied. 203 204 ``` 205 $ up config 206 ``` 207 208 ```json 209 { 210 "name": "app", 211 "description": "", 212 "type": "server", 213 "headers": null, 214 "redirects": null, 215 "hooks": { 216 "build": "GOOS=linux GOARCH=amd64 go build -o server *.go", 217 "clean": "rm server" 218 }, 219 "environment": null, 220 "regions": [ 221 "us-west-2" 222 ], 223 "inject": null, 224 "lambda": { 225 "role": "arn:aws:iam::ACCOUNT:role/lambda_function", 226 "memory": 128, 227 "timeout": 5 228 }, 229 "cors": null, 230 "error_pages": { 231 "dir": ".", 232 "variables": null 233 }, 234 "proxy": { 235 "command": "./server", 236 "backoff": { 237 "min": 100, 238 "max": 500, 239 "factor": 2, 240 "attempts": 3, 241 "jitter": false 242 } 243 }, 244 "static": { 245 "dir": "." 246 }, 247 "logs": { 248 "disable": false 249 }, 250 "dns": { 251 "zones": null 252 } 253 } 254 ... 255 ``` 256 257 ## Logs 258 259 Show or tail log output with optional query for filtering. When viewing or tailing logs, you are viewing them from _all_ stages, see the examples below to filter on a stage name. 260 261 ``` 262 Usage: 263 264 up logs [<flags>] [<query>] 265 266 Flags: 267 268 -h, --help Output usage information. 269 -C, --chdir="." Change working directory. 270 -v, --verbose Enable verbose log output. 271 --format="text" Output formatter. 272 --version Show application version. 273 -f, --follow Follow or tail the live logs. 274 -S, --since="1d" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M). 275 -e, --expand Show expanded logs. 276 277 Args: 278 279 [<query>] Query pattern for filtering logs. 280 ``` 281 282 ### Expanded Output 283 284 Use the `-e` or `--expand` flag to expand log fields: 285 286 ``` 287 $ up -e 'path = "/static/*"' 288 289 1:36:34pm INFO request 290 id: 8ff53267-c33a-11e7-9685-15d48d102ae9 291 ip: 70.66.179.182 292 method: GET 293 path: /static/3.jpg 294 stage: production 295 version: 5 296 297 1:36:34pm INFO response 298 duration: 1ms 299 id: 8ff53267-c33a-11e7-9685-15d48d102ae9 300 ip: 70.66.179.182 301 method: GET 302 path: /static/3.jpg 303 size: 0 B 304 stage: production 305 status: 304 306 version: 5 307 308 1:36:34pm INFO request 309 id: 8ff4bd57-c33a-11e7-bf4b-4f0d97c427c5 310 ip: 70.66.179.182 311 method: GET 312 path: /static/1.png 313 stage: production 314 version: 5 315 ``` 316 317 ### JSON Output 318 319 When stdout is not a terminal Up will output the logs as JSON, which can be useful for further processing with tools such as [jq](https://stedolan.github.io/jq/). 320 321 In this contrived example the last 5 hours of production errors are piped to `jq` to produce a CSV of HTTP methods to IP address. 322 323 ``` 324 $ up logs -s 5h 'production error' | jq -r '.|[.fields.method,.fields.ip]|@csv' 325 ``` 326 327 Yielding: 328 329 ``` 330 "GET","207.194.34.24" 331 "GET","207.194.34.24" 332 "GET","207.194.34.24" 333 ``` 334 335 ### Examples 336 337 Show logs from the past day. 338 339 ``` 340 $ up logs 341 ``` 342 343 Show logs from the past 45 minutes. 344 345 ``` 346 $ up -S 45m logs 347 ``` 348 349 Show logs from the past 12 hours. 350 351 ``` 352 $ up -S 12h logs 353 ``` 354 355 Show live log output. 356 357 ``` 358 $ up logs -f 359 ``` 360 361 Show live logs from production only. 362 363 ``` 364 $ up logs -f production 365 ``` 366 367 Show live error logs from production only. 368 369 ``` 370 $ up logs -f 'production error' 371 ``` 372 373 Show error logs, which include 5xx responses. 374 375 ``` 376 $ up logs error 377 ``` 378 379 Show error and warning logs, which include 4xx and 5xx responses. 380 381 ``` 382 $ up logs 'warn or error' 383 ``` 384 385 Show logs with a specific message. 386 387 ``` 388 $ up logs 'message = "user login" method = "GET"' 389 ``` 390 391 Show logs with a specific message with implicit `=`: 392 393 ``` 394 $ up logs '"user login" method = "GET"' 395 ``` 396 397 Show responses with latency above 15ms. 398 399 ``` 400 $ up logs 'duration > 15' 401 ``` 402 403 Show 4xx and 5xx responses in production 404 405 ``` 406 $ up logs 'production (warn or error)' 407 ``` 408 409 Show production 5xx responses with a POST, PUT, or DELETE method. 410 411 ``` 412 $ up logs 'production error method in ("POST", "PUT", "DELETE") 413 ``` 414 415 Show 200 responses with latency above 1500ms. 416 417 ``` 418 $ up logs 'status = 200 duration > 1.5s' 419 ``` 420 421 Show responses with bodies larger than 100kb. 422 423 ``` 424 $ up logs 'size > 100kb' 425 ``` 426 427 Show 4xx and 5xx responses. 428 429 ``` 430 $ up logs 'status >= 400' 431 ``` 432 433 Show emails containing @apex.sh. 434 435 ``` 436 $ up logs 'user.email contains "@apex.sh"' 437 ``` 438 439 Show emails ending with @apex.sh. 440 441 ``` 442 $ up logs 'user.email = "*@apex.sh"' 443 ``` 444 445 Show emails starting with tj@. 446 447 ``` 448 $ up logs 'user.email = "tj@*"' 449 ``` 450 451 Show logs with a more complex query. 452 453 ``` 454 $ up logs 'method in ("POST", "PUT") ip = "207.*" status = 200 duration >= 50' 455 ``` 456 457 ## URL 458 459 Show, open, or copy a stage endpoint. 460 461 ``` 462 Usage: 463 464 up url [<flags>] 465 466 Flags: 467 468 -h, --help Output usage information. 469 -C, --chdir="." Change working directory. 470 -v, --verbose Enable verbose log output. 471 --format="text" Output formatter. 472 --version Show application version. 473 -s, --stage="staging" Target stage name. 474 -o, --open Open endpoint in the browser. 475 -c, --copy Copy endpoint to the clipboard. 476 ``` 477 478 ### Examples 479 480 Show the development endpoint. 481 482 ``` 483 $ up url 484 ``` 485 486 Open the development endpoint in the browser. 487 488 ``` 489 $ up url --open 490 ``` 491 492 Copy the development endpoint to the clipboard. 493 494 ``` 495 $ up url --copy 496 ``` 497 498 Show the production endpoint. 499 500 ``` 501 $ up url -s production 502 ``` 503 504 Open the production endpoint in the browser. 505 506 ``` 507 $ up url -o -s production 508 ``` 509 510 Copy the production endpoint to the clipboard. 511 512 ``` 513 $ up url -c -s production 514 ``` 515 516 ## Metrics 517 518 Show project metrics and estimated cost breakdown for requests, invocation count and the time spent for Lambda invocations. 519 520 ``` 521 Usage: 522 523 up metrics [<flags>] 524 525 Flags: 526 527 -h, --help Output usage information. 528 -C, --chdir="." Change working directory. 529 -v, --verbose Enable verbose log output. 530 --format="text" Output formatter. 531 --version Show application version. 532 -s, --stage="staging" Target stage name. 533 -S, --since="1M" Show logs since duration (30s, 5m, 2h, 1h30m, 3d, 1M). 534 ``` 535 536 For example: 537 538 ``` 539 $ up metrics -s production -S 15d 540 541 Requests: 13,653 ($0.01) 542 Duration min: 0ms 543 Duration avg: 48ms 544 Duration max: 15329ms 545 Duration sum: 3m6.611s ($0.00) 546 Errors 4xx: 1,203 547 Errors 5xx: 2 548 Invocations: 12,787 ($0.00) 549 Errors: 0 550 Throttles: 0 551 ``` 552 553 ## Start 554 555 Start development server. The development server runs the same proxy that is used in production for serving, so you can test a static site or application locally with the same feature-set. 556 557 See [Stage Overrides](https://up.docs.apex.sh/#configuration.stage_overrides) for an example of overriding the proxy command per-stage, especially useful in development. 558 559 Up Pro supports environment variables, and these will be loaded with `up start`, and variables mapped to the "development" stage will take precedence. For example: 560 561 ``` 562 $ up env set NAME Tobi 563 $ up start 564 # NAME is available as "Tobi" 565 566 $ up env set NAME Loki -s development 567 $ up start 568 # NAME is available as "Loki" 569 570 $ NAME=Jane up start 571 # NAME is available as "Jane" 572 ``` 573 574 The `UP_STAGE` and `NODE_ENV` environment variables will be set to "development" automatically. 575 576 ``` 577 Usage: 578 579 up start [<flags>] 580 581 Flags: 582 583 -h, --help Output usage information. 584 -C, --chdir="." Change working directory. 585 -v, --verbose Enable verbose log output. 586 --format="text" Output formatter. 587 --version Show application version. 588 -c, --command=COMMAND Proxy command override 589 -o, --open Open endpoint in the browser. 590 --address=":3000" Address for server. 591 ``` 592 593 ### Examples 594 595 Start development server on port 3000. 596 597 ``` 598 $ up start 599 ``` 600 601 Start development server on port 5000. 602 603 ``` 604 $ up start --address :5000 605 ``` 606 607 Override proxy command. Note that the server created must listen on `PORT`, which is why `--port $PORT` is required for the [gin](https://github.com/codegangsta/gin) example. 608 609 ``` 610 $ up start -c 'go run main.go' 611 $ up start -c 'gin --port $PORT' 612 $ up start -c 'node --some-flag app.js' 613 $ up start -c 'parcel' 614 ``` 615 616 ## Domains 617 618 Manage domain names, and purchase them from AWS Route53 as the registrar. 619 620 ``` 621 Usage: 622 623 up domains <command> [<args> ...] 624 625 Flags: 626 627 -h, --help Output usage information. 628 -C, --chdir="." Change working directory. 629 -v, --verbose Enable verbose log output. 630 --version Show application version. 631 632 Subcommands: 633 634 domains list List purchased domains. 635 domains check Check availability of a domain. 636 domains buy Purchase a domain. 637 638 ``` 639 640 ### Examples 641 642 List purchased domains. 643 644 ``` 645 $ up domains 646 ``` 647 648 Check availability of a domain. 649 650 ``` 651 $ up domains check example.com 652 ``` 653 654 Purchase a domain (with interactive form). 655 656 ``` 657 $ up domains buy 658 ``` 659 660 ## Stack 661 662 Stack resource management. The stack is essentially all of the resources powering your app, which is configured by Up on the first deploy. 663 664 At any time if you'd like to delete the application simply run `$ up stack delete`. To view the status and potential errors use `$ up stack`. 665 666 ``` 667 Usage: 668 669 up stack <command> [<args> ...] 670 671 Flags: 672 673 -h, --help Output usage information. 674 -C, --chdir="." Change working directory. 675 -v, --verbose Enable verbose log output. 676 --version Show application version. 677 678 Subcommands: 679 680 stack plan Plan configuration changes. 681 stack apply Apply configuration changes. 682 stack delete Delete configured resources. 683 stack status Show status of resources. 684 ``` 685 686 ### Examples 687 688 Show status of the stack resources and nameservers. 689 690 ``` 691 $ up stack 692 ``` 693 694 Show resource changes. 695 696 ``` 697 $ up stack plan 698 ``` 699 700 Apply resource changes. 701 702 ``` 703 $ up stack apply 704 ``` 705 706 Delete the stack resources. 707 708 ``` 709 $ up stack delete 710 ``` 711 712 713 ## Build 714 715 Build zip file, typically only helpful for inspecting its contents. If you're interested in seeing what files are causing bloat, use the `--size` flag to list files by size descending. 716 717 ``` 718 Usage: 719 720 up build [<flags>] 721 722 Flags: 723 724 -h, --help Output usage information. 725 -C, --chdir="." Change working directory. 726 -v, --verbose Enable verbose log output. 727 --format="text" Output formatter. 728 --version Show application version. 729 -s, --stage="staging" Target stage name. 730 --size Show zip contents size information. 731 ``` 732 733 ### Examples 734 735 Build archive and save to ./out.zip 736 737 ``` 738 $ up build 739 ``` 740 741 Build archive and output to file via stdout. 742 743 ``` 744 $ up build > /tmp/out.zip 745 ``` 746 747 Build archive list files by size. 748 749 ``` 750 $ up build --size 751 ``` 752 753 Build archive and list size without creating out.zip. 754 755 ``` 756 $ up build --size > /dev/null 757 ``` 758 759 ## Team 760 761 Manage team members, plans, and billing. 762 763 ``` 764 Usage: 765 766 up team <command> [<args> ...] 767 768 Flags: 769 770 -h, --help Output usage information. 771 -C, --chdir="." Change working directory. 772 -v, --verbose Enable verbose log output. 773 --format="text" Output formatter. 774 --version Show application version. 775 776 Subcommands: 777 778 team status Status of your account. 779 team switch Switch active team. 780 team login Sign in to your account. 781 team logout Sign out of your account. 782 team members add Add invites a team member. 783 team members rm Remove a member or invite. 784 team members ls List team members and invites. 785 team subscribe Subscribe to the Pro plan. 786 team unsubscribe Unsubscribe from the Pro plan. 787 team card change Change the default card. 788 team ci Credentials for CI. 789 team add Add a new team. 790 ``` 791 792 ### Examples 793 794 Show active team and subscription status. 795 796 ``` 797 $ up team 798 ``` 799 800 Switch teams interactively. 801 802 ``` 803 $ up team switch 804 ``` 805 806 Sign in or create account with interactive prompt. 807 808 ``` 809 $ up team login 810 ``` 811 812 Sign in to a team. 813 814 ``` 815 $ up team login --email tj@example.com --team apex-software 816 ``` 817 818 Add a new team and automatically switch to the team. 819 820 ``` 821 $ up team add "Apex Software" 822 ``` 823 824 Subscribe to the Pro plan. 825 826 ``` 827 $ up team subscribe 828 ``` 829 830 Invite a team member to your active team. 831 832 ``` 833 $ up team members add asya@example.com 834 ``` 835 836 ## Upgrade 837 838 Install the latest or specified version of Up. The OSS and Pro versions have independent semver, as bugfixes and features for one may not be relevant to the other. 839 840 If you're an Up Pro subscriber, `up upgrade` will _always_ install Up Pro, even when `--target` is specified, there is no need to specify that you want the Pro version. 841 842 ``` 843 Usage: 844 845 up upgrade [<flags>] 846 847 Flags: 848 849 -h, --help Output usage information. 850 -C, --chdir="." Change working directory. 851 -v, --verbose Enable verbose log output. 852 --format="text" Output formatter. 853 --version Show application version. 854 -t, --target=TARGET Target version for upgrade. 855 ``` 856 857 ### Examples 858 859 Upgrade to the latest version available. 860 861 ``` 862 $ up upgrade 863 ``` 864 865 Upgrade to the specified version. 866 867 ``` 868 $ up upgrade -t 0.4.4 869 ``` 870 871 ## Prune 872 873 Prune old S3 deployments of a stage. 874 875 ``` 876 Usage: 877 878 up prune [<flags>] 879 880 Flags: 881 882 -h, --help Output usage information. 883 -C, --chdir="." Change working directory. 884 -v, --verbose Enable verbose log output. 885 --format="text" Output formatter. 886 --version Show application version. 887 -s, --stage="staging" Target stage name. 888 -r, --retain=30 Number of versions to retain. 889 ``` 890 891 ### Examples 892 893 Prune and retain the most recent 30 staging versions. 894 895 ``` 896 $ up prune 897 ``` 898 899 Prune and retain the most recent 30 production versions. 900 901 ``` 902 $ up prune -s production 903 ``` 904 905 Prune and retain the most recent 15 production versions. 906 907 ``` 908 $ up prune -s production -r 15 909 ``` 910 911 ## Env 912 913 Manage encrypted environment variables. Environment variables are scoped to all stages by default, with stage-level overrides. The `up env` command is available in the Pro plan. 914 915 ``` 916 Usage: 917 918 up env <command> [<args> ...] 919 920 Flags: 921 922 -h, --help Output usage information. 923 -C, --chdir="." Change working directory. 924 -v, --verbose Enable verbose log output. 925 --format="text" Output formatter. 926 --version Show application version. 927 928 Subcommands: 929 930 env add Add variables. 931 env get Get a variable value. 932 env ls List variables. 933 env rm Remove variables. 934 ``` 935 936 Here are some examples: 937 938 ``` 939 $ up env add DB_NAME users DB_USER sloth 940 $ up env add DB_NAME=users DB_USER=sloth 941 $ up env add DB_URL stage.mydb.hosted.com 942 $ up env add DB_PASS passforstage 943 $ up env add DB_CONN "host=localhost port=5432" 944 ``` 945 946 Overriding for a stage such as production can be specified with the `-s, --stage` flag. For example `DB_NAME` and `DB_USER` would likely remain the same in production, however the `DB_URL` and `DB_PASS` would not, so we should assign them as shown here: 947 948 ``` 949 $ up env add -s production DB_URL prod.mydb.hosted.com 950 $ up env add -s production DB_PASS passforprod 951 ``` 952 953 Environment variables may also be plain or "clear" text, using the `-c, --clear` flag, which may be viewed in the output. 954 955 ``` 956 $ up env add -c DB_NAME users 957 $ up env add -c DB_USER sloth 958 $ up env add DB_PASS amazingpass 959 ``` 960 961 Get environment variable values with: 962 963 ``` 964 $ up env get DB_NAME 965 $ up env get DB_NAME -s production 966 ``` 967 968 List the env vars with: 969 970 ``` 971 $ up env 972 973 all 974 975 DB_NAME users - Modified 34 seconds ago by tobi 976 DB_PASS - - Modified 22 seconds ago by tobi 977 DB_URL - - Modified 24 seconds ago by tobi 978 DB_USER sloth - Modified 30 seconds ago by tobi 979 980 production 981 982 DB_PASS - - Modified 2 seconds ago by tobi 983 DB_URL - - Modified 4 seconds ago by tobi 984 ``` 985 986 Note that you can also assign descriptions with the `-d, --desc` flag. Note that `-cd` is equivalent to `-c, -d` marking the first two variables as cleartext. 987 988 ``` 989 $ up env set -cd 'MongoDB collection name' DB_NAME users 990 $ up env set -cd 'MongoDB name' DB_NAME users 991 $ up env set -d 'MongoDB address' DB_URL bar 992 $ up env set -d 'MongoDB password' DB_PASS foo 993 ``` 994 995 Check the output and you'll see the descriptions: 996 997 ``` 998 $ up env 999 1000 all 1001 1002 DB_NAME users MongoDB collection name Modified 2 minutes ago by tobi 1003 DB_PASS - MongoDB password Modified 19 seconds ago by tobi 1004 DB_URL - MongoDB address Modified 1 second ago by tobi 1005 DB_USER sloth MongoDB username Modified 2 minutes ago by tobi 1006 ``` 1007 1008 Note that while changes made to the variables are effective immediately, AWS Lambda may retain idle containers with the previous values. Currently you must perform a deploy in order to receive the new values. This can be used to your advantage, as it allows you to change for example both `DB_USER` and `DB_PASS` at the same time. 1009 1010 Variables defined via `up env` are also available to the build hooks, as well as `up start`. The `UP_STAGE` and `NODE_ENV` are defined to the target stage name automatically, unless specified manually. See the [Env Static](https://github.com/apex/up-examples/tree/master/pro/env-static) example to see how it works with build hooks.