github.com/alexissmirnov/terraform@v0.4.3-0.20150423153700-1ef9731a2f14/terraform/terraform_test.go (about) 1 package terraform 2 3 import ( 4 "bytes" 5 "crypto/sha1" 6 "encoding/gob" 7 "encoding/hex" 8 "fmt" 9 "io/ioutil" 10 "os" 11 "path/filepath" 12 "strings" 13 "sync" 14 "testing" 15 16 "github.com/hashicorp/terraform/config" 17 "github.com/hashicorp/terraform/config/module" 18 ) 19 20 // This is the directory where our test fixtures are. 21 const fixtureDir = "./test-fixtures" 22 23 func checksumStruct(t *testing.T, i interface{}) string { 24 // TODO(mitchellh): write a library to do this because gob is not 25 // deterministic in order 26 return "foo" 27 28 buf := new(bytes.Buffer) 29 enc := gob.NewEncoder(buf) 30 if err := enc.Encode(i); err != nil { 31 t.Fatalf("err: %s", err) 32 } 33 34 sum := sha1.Sum(buf.Bytes()) 35 return hex.EncodeToString(sum[:]) 36 } 37 38 func tempDir(t *testing.T) string { 39 dir, err := ioutil.TempDir("", "tf") 40 if err != nil { 41 t.Fatalf("err: %s", err) 42 } 43 if err := os.RemoveAll(dir); err != nil { 44 t.Fatalf("err: %s", err) 45 } 46 47 return dir 48 } 49 50 // tempEnv lets you temporarily set an environment variable. It returns 51 // the old value that should be set via a defer. 52 func tempEnv(t *testing.T, k string, v string) string { 53 old := os.Getenv(k) 54 os.Setenv(k, v) 55 return old 56 } 57 58 func testConfig(t *testing.T, name string) *config.Config { 59 c, err := config.Load(filepath.Join(fixtureDir, name, "main.tf")) 60 if err != nil { 61 t.Fatalf("err: %s", err) 62 } 63 64 return c 65 } 66 67 func testModule(t *testing.T, name string) *module.Tree { 68 mod, err := module.NewTreeModule("", filepath.Join(fixtureDir, name)) 69 if err != nil { 70 t.Fatalf("err: %s", err) 71 } 72 73 s := &module.FolderStorage{StorageDir: tempDir(t)} 74 if err := mod.Load(s, module.GetModeGet); err != nil { 75 t.Fatalf("err: %s", err) 76 } 77 78 return mod 79 } 80 81 func testStringMatch(t *testing.T, s fmt.Stringer, expected string) { 82 actual := strings.TrimSpace(s.String()) 83 expected = strings.TrimSpace(expected) 84 if actual != expected { 85 t.Fatalf("Actual\n\n%s\n\nExpected:\n\n%s", actual, expected) 86 } 87 } 88 89 func testProviderFuncFixed(rp ResourceProvider) ResourceProviderFactory { 90 return func() (ResourceProvider, error) { 91 return rp, nil 92 } 93 } 94 95 func testProvisionerFuncFixed(rp ResourceProvisioner) ResourceProvisionerFactory { 96 return func() (ResourceProvisioner, error) { 97 return rp, nil 98 } 99 } 100 101 // HookRecordApplyOrder is a test hook that records the order of applies 102 // by recording the PreApply event. 103 type HookRecordApplyOrder struct { 104 NilHook 105 106 Active bool 107 108 IDs []string 109 States []*InstanceState 110 Diffs []*InstanceDiff 111 112 l sync.Mutex 113 } 114 115 func (h *HookRecordApplyOrder) PreApply( 116 info *InstanceInfo, 117 s *InstanceState, 118 d *InstanceDiff) (HookAction, error) { 119 if h.Active { 120 h.l.Lock() 121 defer h.l.Unlock() 122 123 h.IDs = append(h.IDs, info.Id) 124 h.Diffs = append(h.Diffs, d) 125 h.States = append(h.States, s) 126 } 127 128 return HookActionContinue, nil 129 } 130 131 // Below are all the constant strings that are the expected output for 132 // various tests. 133 134 const testTerraformInputProviderStr = ` 135 aws_instance.bar: 136 ID = foo 137 bar = override 138 foo = us-east-1 139 type = aws_instance 140 aws_instance.foo: 141 ID = foo 142 bar = baz 143 num = 2 144 type = aws_instance 145 ` 146 147 const testTerraformInputProviderOnlyStr = ` 148 aws_instance.foo: 149 ID = foo 150 foo = us-west-2 151 type = aws_instance 152 ` 153 154 const testTerraformInputVarOnlyStr = ` 155 aws_instance.foo: 156 ID = foo 157 foo = us-east-1 158 type = aws_instance 159 ` 160 161 const testTerraformInputVarOnlyUnsetStr = ` 162 aws_instance.foo: 163 ID = foo 164 bar = baz 165 foo = foovalue 166 type = aws_instance 167 ` 168 169 const testTerraformInputVarsStr = ` 170 aws_instance.bar: 171 ID = foo 172 bar = override 173 foo = us-east-1 174 type = aws_instance 175 aws_instance.foo: 176 ID = foo 177 bar = baz 178 num = 2 179 type = aws_instance 180 ` 181 182 const testTerraformApplyStr = ` 183 aws_instance.bar: 184 ID = foo 185 foo = bar 186 type = aws_instance 187 aws_instance.foo: 188 ID = foo 189 num = 2 190 type = aws_instance 191 ` 192 193 const testTerraformApplyProviderAliasStr = ` 194 aws_instance.bar: 195 ID = foo 196 provider = aws.bar 197 foo = bar 198 type = aws_instance 199 aws_instance.foo: 200 ID = foo 201 num = 2 202 type = aws_instance 203 ` 204 205 const testTerraformApplyEmptyModuleStr = ` 206 <no state> 207 Outputs: 208 209 end = XXXX 210 211 module.child: 212 <no state> 213 Outputs: 214 215 aws_access_key = YYYYY 216 aws_route53_zone_id = XXXX 217 aws_secret_key = ZZZZ 218 ` 219 220 const testTerraformApplyDependsCreateBeforeStr = ` 221 aws_instance.lb: 222 ID = foo 223 instance = foo 224 type = aws_instance 225 226 Dependencies: 227 aws_instance.web 228 aws_instance.web: 229 ID = foo 230 require_new = ami-new 231 type = aws_instance 232 ` 233 234 const testTerraformApplyCreateBeforeStr = ` 235 aws_instance.bar: 236 ID = foo 237 require_new = xyz 238 type = aws_instance 239 ` 240 241 const testTerraformApplyCreateBeforeUpdateStr = ` 242 aws_instance.bar: 243 ID = foo 244 foo = baz 245 type = aws_instance 246 ` 247 248 const testTerraformApplyCancelStr = ` 249 aws_instance.foo: 250 ID = foo 251 num = 2 252 ` 253 254 const testTerraformApplyComputeStr = ` 255 aws_instance.bar: 256 ID = foo 257 foo = computed_dynamical 258 type = aws_instance 259 260 Dependencies: 261 aws_instance.foo 262 aws_instance.foo: 263 ID = foo 264 dynamical = computed_dynamical 265 num = 2 266 type = aws_instance 267 ` 268 269 const testTerraformApplyCountDecStr = ` 270 aws_instance.foo.0: 271 ID = bar 272 foo = foo 273 type = aws_instance 274 aws_instance.foo.1: 275 ID = bar 276 foo = foo 277 type = aws_instance 278 ` 279 280 const testTerraformApplyCountDecToOneStr = ` 281 aws_instance.foo: 282 ID = bar 283 foo = foo 284 type = aws_instance 285 ` 286 287 const testTerraformApplyCountDecToOneCorruptedStr = ` 288 aws_instance.foo: 289 ID = bar 290 foo = foo 291 type = aws_instance 292 ` 293 294 const testTerraformApplyCountDecToOneCorruptedPlanStr = ` 295 DIFF: 296 297 DESTROY: aws_instance.foo.0 298 299 STATE: 300 301 aws_instance.foo: 302 ID = bar 303 foo = foo 304 type = aws_instance 305 aws_instance.foo.0: 306 ID = baz 307 type = aws_instance 308 ` 309 310 const testTerraformApplyCountTaintedStr = ` 311 <no state> 312 ` 313 314 const testTerraformApplyCountVariableStr = ` 315 aws_instance.foo.0: 316 ID = foo 317 foo = foo 318 type = aws_instance 319 aws_instance.foo.1: 320 ID = foo 321 foo = foo 322 type = aws_instance 323 ` 324 325 const testTerraformApplyMinimalStr = ` 326 aws_instance.bar: 327 ID = foo 328 aws_instance.foo: 329 ID = foo 330 ` 331 332 const testTerraformApplyModuleStr = ` 333 aws_instance.bar: 334 ID = foo 335 foo = bar 336 type = aws_instance 337 aws_instance.foo: 338 ID = foo 339 num = 2 340 type = aws_instance 341 342 module.child: 343 aws_instance.baz: 344 ID = foo 345 foo = bar 346 type = aws_instance 347 ` 348 349 const testTerraformApplyModuleBoolStr = ` 350 aws_instance.bar: 351 ID = foo 352 foo = 1 353 type = aws_instance 354 355 Dependencies: 356 module.child 357 358 module.child: 359 <no state> 360 Outputs: 361 362 leader = 1 363 ` 364 365 const testTerraformApplyMultiProviderStr = ` 366 aws_instance.bar: 367 ID = foo 368 foo = bar 369 type = aws_instance 370 do_instance.foo: 371 ID = foo 372 num = 2 373 type = do_instance 374 ` 375 376 const testTerraformApplyProvisionerStr = ` 377 aws_instance.bar: 378 ID = foo 379 380 Dependencies: 381 aws_instance.foo 382 aws_instance.foo: 383 ID = foo 384 dynamical = computed_dynamical 385 num = 2 386 type = aws_instance 387 ` 388 389 const testTerraformApplyProvisionerFailStr = ` 390 aws_instance.bar: (1 tainted) 391 ID = <not created> 392 Tainted ID 1 = foo 393 aws_instance.foo: 394 ID = foo 395 num = 2 396 type = aws_instance 397 ` 398 399 const testTerraformApplyProvisionerFailCreateStr = ` 400 aws_instance.bar: (1 tainted) 401 ID = <not created> 402 Tainted ID 1 = foo 403 ` 404 405 const testTerraformApplyProvisionerFailCreateNoIdStr = ` 406 <no state> 407 ` 408 409 const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = ` 410 aws_instance.bar: (1 tainted) 411 ID = bar 412 require_new = abc 413 Tainted ID 1 = foo 414 ` 415 416 const testTerraformApplyProvisionerResourceRefStr = ` 417 aws_instance.bar: 418 ID = foo 419 num = 2 420 type = aws_instance 421 ` 422 423 const testTerraformApplyProvisionerSelfRefStr = ` 424 aws_instance.foo: 425 ID = foo 426 foo = bar 427 type = aws_instance 428 ` 429 430 const testTerraformApplyProvisionerMultiSelfRefStr = ` 431 aws_instance.foo.0: 432 ID = foo 433 foo = number 0 434 type = aws_instance 435 aws_instance.foo.1: 436 ID = foo 437 foo = number 1 438 type = aws_instance 439 aws_instance.foo.2: 440 ID = foo 441 foo = number 2 442 type = aws_instance 443 ` 444 445 const testTerraformApplyProvisionerDiffStr = ` 446 aws_instance.bar: 447 ID = foo 448 foo = bar 449 type = aws_instance 450 ` 451 452 const testTerraformApplyDestroyStr = ` 453 <no state> 454 ` 455 456 const testTerraformApplyErrorStr = ` 457 aws_instance.bar: 458 ID = bar 459 460 Dependencies: 461 aws_instance.foo 462 aws_instance.foo: 463 ID = foo 464 num = 2 465 ` 466 467 const testTerraformApplyErrorCreateBeforeDestroyStr = ` 468 aws_instance.bar: 469 ID = bar 470 require_new = abc 471 ` 472 473 const testTerraformApplyErrorDestroyCreateBeforeDestroyStr = ` 474 aws_instance.bar: (1 deposed) 475 ID = foo 476 Deposed ID 1 = bar 477 ` 478 479 const testTerraformApplyErrorPartialStr = ` 480 aws_instance.bar: 481 ID = bar 482 483 Dependencies: 484 aws_instance.foo 485 aws_instance.foo: 486 ID = foo 487 num = 2 488 ` 489 490 const testTerraformApplyTaintStr = ` 491 aws_instance.bar: 492 ID = foo 493 num = 2 494 type = aws_instance 495 ` 496 497 const testTerraformApplyTaintDepStr = ` 498 aws_instance.bar: 499 ID = bar 500 foo = foo 501 num = 2 502 type = aws_instance 503 504 Dependencies: 505 aws_instance.foo 506 aws_instance.foo: 507 ID = foo 508 num = 2 509 type = aws_instance 510 ` 511 512 const testTerraformApplyTaintDepRequireNewStr = ` 513 aws_instance.bar: 514 ID = foo 515 foo = foo 516 require_new = yes 517 type = aws_instance 518 519 Dependencies: 520 aws_instance.foo 521 aws_instance.foo: 522 ID = foo 523 num = 2 524 type = aws_instance 525 ` 526 527 const testTerraformApplyOutputStr = ` 528 aws_instance.bar: 529 ID = foo 530 foo = bar 531 type = aws_instance 532 aws_instance.foo: 533 ID = foo 534 num = 2 535 type = aws_instance 536 537 Outputs: 538 539 foo_num = 2 540 ` 541 542 const testTerraformApplyOutputListStr = ` 543 aws_instance.bar.0: 544 ID = foo 545 foo = bar 546 type = aws_instance 547 aws_instance.bar.1: 548 ID = foo 549 foo = bar 550 type = aws_instance 551 aws_instance.bar.2: 552 ID = foo 553 foo = bar 554 type = aws_instance 555 aws_instance.foo: 556 ID = foo 557 num = 2 558 type = aws_instance 559 560 Outputs: 561 562 foo_num = bar,bar,bar 563 ` 564 565 const testTerraformApplyOutputMultiStr = ` 566 aws_instance.bar.0: 567 ID = foo 568 foo = bar 569 type = aws_instance 570 aws_instance.bar.1: 571 ID = foo 572 foo = bar 573 type = aws_instance 574 aws_instance.bar.2: 575 ID = foo 576 foo = bar 577 type = aws_instance 578 aws_instance.foo: 579 ID = foo 580 num = 2 581 type = aws_instance 582 583 Outputs: 584 585 foo_num = bar,bar,bar 586 ` 587 588 const testTerraformApplyOutputMultiIndexStr = ` 589 aws_instance.bar.0: 590 ID = foo 591 foo = bar 592 type = aws_instance 593 aws_instance.bar.1: 594 ID = foo 595 foo = bar 596 type = aws_instance 597 aws_instance.bar.2: 598 ID = foo 599 foo = bar 600 type = aws_instance 601 aws_instance.foo: 602 ID = foo 603 num = 2 604 type = aws_instance 605 606 Outputs: 607 608 foo_num = bar 609 ` 610 611 const testTerraformApplyUnknownAttrStr = ` 612 aws_instance.foo: 613 ID = foo 614 num = 2 615 type = aws_instance 616 ` 617 618 const testTerraformApplyVarsStr = ` 619 aws_instance.bar: 620 ID = foo 621 bar = foo 622 baz = override 623 foo = us-west-2 624 type = aws_instance 625 aws_instance.foo: 626 ID = foo 627 bar = baz 628 num = 2 629 type = aws_instance 630 ` 631 632 const testTerraformApplyVarsEnvStr = ` 633 aws_instance.bar: 634 ID = foo 635 foo = baz 636 type = aws_instance 637 ` 638 639 const testTerraformPlanStr = ` 640 DIFF: 641 642 CREATE: aws_instance.bar 643 foo: "" => "2" 644 type: "" => "aws_instance" 645 CREATE: aws_instance.foo 646 num: "" => "2" 647 type: "" => "aws_instance" 648 649 STATE: 650 651 <no state> 652 ` 653 654 const testTerraformPlanComputedStr = ` 655 DIFF: 656 657 CREATE: aws_instance.bar 658 foo: "" => "<computed>" 659 type: "" => "aws_instance" 660 CREATE: aws_instance.foo 661 foo: "" => "<computed>" 662 num: "" => "2" 663 type: "" => "aws_instance" 664 665 STATE: 666 667 <no state> 668 ` 669 670 const testTerraformPlanComputedIdStr = ` 671 DIFF: 672 673 CREATE: aws_instance.bar 674 foo: "" => "<computed>" 675 type: "" => "aws_instance" 676 CREATE: aws_instance.foo 677 foo: "" => "<computed>" 678 num: "" => "2" 679 type: "" => "aws_instance" 680 681 STATE: 682 683 <no state> 684 ` 685 686 const testTerraformPlanComputedListStr = ` 687 DIFF: 688 689 CREATE: aws_instance.bar 690 foo: "" => "<computed>" 691 type: "" => "aws_instance" 692 CREATE: aws_instance.foo 693 list.#: "" => "<computed>" 694 num: "" => "2" 695 type: "" => "aws_instance" 696 697 STATE: 698 699 <no state> 700 ` 701 702 const testTerraformPlanCountStr = ` 703 DIFF: 704 705 CREATE: aws_instance.bar 706 foo: "" => "foo,foo,foo,foo,foo" 707 type: "" => "aws_instance" 708 CREATE: aws_instance.foo.0 709 foo: "" => "foo" 710 type: "" => "aws_instance" 711 CREATE: aws_instance.foo.1 712 foo: "" => "foo" 713 type: "" => "aws_instance" 714 CREATE: aws_instance.foo.2 715 foo: "" => "foo" 716 type: "" => "aws_instance" 717 CREATE: aws_instance.foo.3 718 foo: "" => "foo" 719 type: "" => "aws_instance" 720 CREATE: aws_instance.foo.4 721 foo: "" => "foo" 722 type: "" => "aws_instance" 723 724 STATE: 725 726 <no state> 727 ` 728 729 const testTerraformPlanCountIndexStr = ` 730 DIFF: 731 732 CREATE: aws_instance.foo.0 733 foo: "" => "0" 734 type: "" => "aws_instance" 735 CREATE: aws_instance.foo.1 736 foo: "" => "1" 737 type: "" => "aws_instance" 738 739 STATE: 740 741 <no state> 742 ` 743 744 const testTerraformPlanCountIndexZeroStr = ` 745 DIFF: 746 747 CREATE: aws_instance.foo 748 foo: "" => "0" 749 type: "" => "aws_instance" 750 751 STATE: 752 753 <no state> 754 ` 755 756 const testTerraformPlanCountOneIndexStr = ` 757 DIFF: 758 759 CREATE: aws_instance.bar 760 foo: "" => "foo" 761 type: "" => "aws_instance" 762 CREATE: aws_instance.foo 763 foo: "" => "foo" 764 type: "" => "aws_instance" 765 766 STATE: 767 768 <no state> 769 ` 770 771 const testTerraformPlanCountZeroStr = ` 772 DIFF: 773 774 CREATE: aws_instance.bar 775 foo: "" => "" 776 type: "" => "aws_instance" 777 778 STATE: 779 780 <no state> 781 ` 782 783 const testTerraformPlanCountVarStr = ` 784 DIFF: 785 786 CREATE: aws_instance.bar 787 foo: "" => "foo,foo,foo" 788 type: "" => "aws_instance" 789 CREATE: aws_instance.foo.0 790 foo: "" => "foo" 791 type: "" => "aws_instance" 792 CREATE: aws_instance.foo.1 793 foo: "" => "foo" 794 type: "" => "aws_instance" 795 CREATE: aws_instance.foo.2 796 foo: "" => "foo" 797 type: "" => "aws_instance" 798 799 STATE: 800 801 <no state> 802 ` 803 804 const testTerraformPlanCountDecreaseStr = ` 805 DIFF: 806 807 CREATE: aws_instance.bar 808 foo: "" => "bar" 809 type: "" => "aws_instance" 810 DESTROY: aws_instance.foo.1 811 DESTROY: aws_instance.foo.2 812 813 STATE: 814 815 aws_instance.foo.0: 816 ID = bar 817 foo = foo 818 type = aws_instance 819 aws_instance.foo.1: 820 ID = bar 821 aws_instance.foo.2: 822 ID = bar 823 ` 824 825 const testTerraformPlanCountIncreaseStr = ` 826 DIFF: 827 828 CREATE: aws_instance.bar 829 foo: "" => "bar" 830 type: "" => "aws_instance" 831 CREATE: aws_instance.foo.1 832 foo: "" => "foo" 833 type: "" => "aws_instance" 834 CREATE: aws_instance.foo.2 835 foo: "" => "foo" 836 type: "" => "aws_instance" 837 838 STATE: 839 840 aws_instance.foo: 841 ID = bar 842 foo = foo 843 type = aws_instance 844 ` 845 846 const testTerraformPlanCountIncreaseFromOneStr = ` 847 DIFF: 848 849 CREATE: aws_instance.bar 850 foo: "" => "bar" 851 type: "" => "aws_instance" 852 CREATE: aws_instance.foo.1 853 foo: "" => "foo" 854 type: "" => "aws_instance" 855 CREATE: aws_instance.foo.2 856 foo: "" => "foo" 857 type: "" => "aws_instance" 858 859 STATE: 860 861 aws_instance.foo.0: 862 ID = bar 863 foo = foo 864 type = aws_instance 865 ` 866 867 const testTerraformPlanCountIncreaseFromOneCorruptedStr = ` 868 DIFF: 869 870 CREATE: aws_instance.bar 871 foo: "" => "bar" 872 type: "" => "aws_instance" 873 DESTROY: aws_instance.foo 874 CREATE: aws_instance.foo.1 875 foo: "" => "foo" 876 type: "" => "aws_instance" 877 CREATE: aws_instance.foo.2 878 foo: "" => "foo" 879 type: "" => "aws_instance" 880 881 STATE: 882 883 aws_instance.foo: 884 ID = bar 885 foo = foo 886 type = aws_instance 887 aws_instance.foo.0: 888 ID = bar 889 foo = foo 890 type = aws_instance 891 ` 892 893 const testTerraformPlanDestroyStr = ` 894 DIFF: 895 896 DESTROY: aws_instance.one 897 DESTROY: aws_instance.two 898 899 STATE: 900 901 aws_instance.one: 902 ID = bar 903 aws_instance.two: 904 ID = baz 905 ` 906 907 const testTerraformPlanDiffVarStr = ` 908 DIFF: 909 910 CREATE: aws_instance.bar 911 num: "" => "3" 912 type: "" => "aws_instance" 913 UPDATE: aws_instance.foo 914 num: "2" => "3" 915 916 STATE: 917 918 aws_instance.foo: 919 ID = bar 920 num = 2 921 ` 922 923 const testTerraformPlanEmptyStr = ` 924 DIFF: 925 926 CREATE: aws_instance.bar 927 CREATE: aws_instance.foo 928 929 STATE: 930 931 <no state> 932 ` 933 934 const testTerraformPlanModulesStr = ` 935 DIFF: 936 937 CREATE: aws_instance.bar 938 foo: "" => "2" 939 type: "" => "aws_instance" 940 CREATE: aws_instance.foo 941 num: "" => "2" 942 type: "" => "aws_instance" 943 944 module.child: 945 CREATE: aws_instance.foo 946 num: "" => "2" 947 type: "" => "aws_instance" 948 949 STATE: 950 951 <no state> 952 ` 953 954 const testTerraformPlanModuleCycleStr = ` 955 DIFF: 956 957 CREATE: aws_instance.b 958 CREATE: aws_instance.c 959 some_input: "" => "<computed>" 960 type: "" => "aws_instance" 961 962 STATE: 963 964 <no state> 965 ` 966 967 const testTerraformPlanModuleDestroyStr = ` 968 DIFF: 969 970 DESTROY: aws_instance.foo 971 972 module.child: 973 DESTROY MODULE 974 DESTROY: aws_instance.foo 975 976 STATE: 977 978 aws_instance.foo: 979 ID = bar 980 981 module.child: 982 aws_instance.foo: 983 ID = bar 984 ` 985 986 const testTerraformPlanModuleDestroyMultivarStr = ` 987 DIFF: 988 989 module.child: 990 DESTROY MODULE 991 DESTROY: aws_instance.foo.0 992 DESTROY: aws_instance.foo.1 993 994 STATE: 995 996 <no state> 997 module.child: 998 aws_instance.foo.0: 999 ID = bar0 1000 aws_instance.foo.1: 1001 ID = bar1 1002 ` 1003 1004 const testTerraformPlanModuleInputStr = ` 1005 DIFF: 1006 1007 CREATE: aws_instance.bar 1008 foo: "" => "2" 1009 type: "" => "aws_instance" 1010 1011 module.child: 1012 CREATE: aws_instance.foo 1013 foo: "" => "42" 1014 type: "" => "aws_instance" 1015 1016 STATE: 1017 1018 <no state> 1019 ` 1020 1021 const testTerraformPlanModuleInputComputedStr = ` 1022 DIFF: 1023 1024 CREATE: aws_instance.bar 1025 foo: "" => "<computed>" 1026 type: "" => "aws_instance" 1027 1028 module.child: 1029 CREATE: aws_instance.foo 1030 foo: "" => "<computed>" 1031 type: "" => "aws_instance" 1032 1033 STATE: 1034 1035 <no state> 1036 ` 1037 1038 const testTerraformPlanModuleInputVarStr = ` 1039 DIFF: 1040 1041 CREATE: aws_instance.bar 1042 foo: "" => "2" 1043 type: "" => "aws_instance" 1044 1045 module.child: 1046 CREATE: aws_instance.foo 1047 foo: "" => "52" 1048 type: "" => "aws_instance" 1049 1050 STATE: 1051 1052 <no state> 1053 ` 1054 1055 const testTerraformPlanModuleMultiVarStr = ` 1056 DIFF: 1057 1058 CREATE: aws_instance.parent.0 1059 CREATE: aws_instance.parent.1 1060 1061 module.child: 1062 CREATE: aws_instance.bar.0 1063 baz: "" => "baz" 1064 type: "" => "aws_instance" 1065 CREATE: aws_instance.bar.1 1066 baz: "" => "baz" 1067 type: "" => "aws_instance" 1068 CREATE: aws_instance.foo 1069 foo: "" => "baz,baz" 1070 type: "" => "aws_instance" 1071 1072 STATE: 1073 1074 <no state> 1075 ` 1076 1077 const testTerraformPlanModuleOrphansStr = ` 1078 DIFF: 1079 1080 CREATE: aws_instance.foo 1081 num: "" => "2" 1082 type: "" => "aws_instance" 1083 1084 module.child: 1085 DESTROY: aws_instance.foo 1086 1087 STATE: 1088 1089 module.child: 1090 aws_instance.foo: 1091 ID = baz 1092 ` 1093 1094 const testTerraformPlanModuleVarStr = ` 1095 DIFF: 1096 1097 CREATE: aws_instance.bar 1098 foo: "" => "2" 1099 type: "" => "aws_instance" 1100 1101 module.child: 1102 CREATE: aws_instance.foo 1103 num: "" => "2" 1104 type: "" => "aws_instance" 1105 1106 STATE: 1107 1108 <no state> 1109 ` 1110 1111 const testTerraformPlanModuleVarComputedStr = ` 1112 DIFF: 1113 1114 CREATE: aws_instance.bar 1115 foo: "" => "<computed>" 1116 type: "" => "aws_instance" 1117 1118 module.child: 1119 CREATE: aws_instance.foo 1120 foo: "" => "<computed>" 1121 type: "" => "aws_instance" 1122 1123 STATE: 1124 1125 <no state> 1126 ` 1127 1128 const testTerraformPlanModuleVarIntStr = ` 1129 DIFF: 1130 1131 module.child: 1132 CREATE: aws_instance.foo 1133 num: "" => "2" 1134 type: "" => "aws_instance" 1135 1136 STATE: 1137 1138 <no state> 1139 ` 1140 1141 const testTerraformPlanOrphanStr = ` 1142 DIFF: 1143 1144 DESTROY: aws_instance.baz 1145 CREATE: aws_instance.foo 1146 num: "" => "2" 1147 type: "" => "aws_instance" 1148 1149 STATE: 1150 1151 aws_instance.baz: 1152 ID = bar 1153 ` 1154 1155 const testTerraformPlanStateStr = ` 1156 DIFF: 1157 1158 CREATE: aws_instance.bar 1159 foo: "" => "2" 1160 type: "" => "aws_instance" 1161 UPDATE: aws_instance.foo 1162 num: "" => "2" 1163 type: "" => "aws_instance" 1164 1165 STATE: 1166 1167 aws_instance.foo: 1168 ID = bar 1169 ` 1170 1171 const testTerraformPlanTaintStr = ` 1172 DIFF: 1173 1174 DESTROY/CREATE: aws_instance.bar 1175 foo: "" => "2" 1176 type: "" => "aws_instance" 1177 1178 STATE: 1179 1180 aws_instance.bar: (1 tainted) 1181 ID = <not created> 1182 Tainted ID 1 = baz 1183 aws_instance.foo: 1184 ID = bar 1185 num = 2 1186 ` 1187 1188 const testTerraformPlanMultipleTaintStr = ` 1189 DIFF: 1190 1191 DESTROY/CREATE: aws_instance.bar 1192 foo: "" => "2" 1193 type: "" => "aws_instance" 1194 1195 STATE: 1196 1197 aws_instance.bar: (2 tainted) 1198 ID = <not created> 1199 Tainted ID 1 = baz 1200 Tainted ID 2 = zip 1201 aws_instance.foo: 1202 ID = bar 1203 num = 2 1204 ` 1205 1206 const testTerraformPlanVarMultiCountOneStr = ` 1207 DIFF: 1208 1209 CREATE: aws_instance.bar 1210 foo: "" => "2" 1211 type: "" => "aws_instance" 1212 CREATE: aws_instance.foo 1213 num: "" => "2" 1214 type: "" => "aws_instance" 1215 1216 STATE: 1217 1218 <no state> 1219 ` 1220 1221 const testTerraformPlanPathVarStr = ` 1222 DIFF: 1223 1224 CREATE: aws_instance.foo 1225 cwd: "" => "%s/barpath" 1226 module: "" => "%s/foopath" 1227 root: "" => "%s/barpath" 1228 type: "" => "aws_instance" 1229 1230 STATE: 1231 1232 <no state> 1233 `