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