github.com/tarrant/terraform@v0.3.8-0.20150402012457-f68c9eee638e/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 testTerraformPlanModuleDestroyStr = ` 928 DIFF: 929 930 DESTROY: aws_instance.foo 931 932 module.child: 933 DESTROY MODULE 934 DESTROY: aws_instance.foo 935 936 STATE: 937 938 aws_instance.foo: 939 ID = bar 940 941 module.child: 942 aws_instance.foo: 943 ID = bar 944 ` 945 946 const testTerraformPlanModuleDestroyMultivarStr = ` 947 DIFF: 948 949 module.child: 950 DESTROY MODULE 951 DESTROY: aws_instance.foo.0 952 DESTROY: aws_instance.foo.1 953 954 STATE: 955 956 <no state> 957 module.child: 958 aws_instance.foo.0: 959 ID = bar0 960 aws_instance.foo.1: 961 ID = bar1 962 ` 963 964 const testTerraformPlanModuleInputStr = ` 965 DIFF: 966 967 CREATE: aws_instance.bar 968 foo: "" => "2" 969 type: "" => "aws_instance" 970 971 module.child: 972 CREATE: aws_instance.foo 973 foo: "" => "42" 974 type: "" => "aws_instance" 975 976 STATE: 977 978 <no state> 979 ` 980 981 const testTerraformPlanModuleInputComputedStr = ` 982 DIFF: 983 984 CREATE: aws_instance.bar 985 foo: "" => "<computed>" 986 type: "" => "aws_instance" 987 988 module.child: 989 CREATE: aws_instance.foo 990 foo: "" => "<computed>" 991 type: "" => "aws_instance" 992 993 STATE: 994 995 <no state> 996 ` 997 998 const testTerraformPlanModuleInputVarStr = ` 999 DIFF: 1000 1001 CREATE: aws_instance.bar 1002 foo: "" => "2" 1003 type: "" => "aws_instance" 1004 1005 module.child: 1006 CREATE: aws_instance.foo 1007 foo: "" => "52" 1008 type: "" => "aws_instance" 1009 1010 STATE: 1011 1012 <no state> 1013 ` 1014 1015 const testTerraformPlanModuleMultiVarStr = ` 1016 DIFF: 1017 1018 CREATE: aws_instance.parent.0 1019 CREATE: aws_instance.parent.1 1020 1021 module.child: 1022 CREATE: aws_instance.bar.0 1023 baz: "" => "baz" 1024 type: "" => "aws_instance" 1025 CREATE: aws_instance.bar.1 1026 baz: "" => "baz" 1027 type: "" => "aws_instance" 1028 CREATE: aws_instance.foo 1029 foo: "" => "baz,baz" 1030 type: "" => "aws_instance" 1031 1032 STATE: 1033 1034 <no state> 1035 ` 1036 1037 const testTerraformPlanModuleOrphansStr = ` 1038 DIFF: 1039 1040 CREATE: aws_instance.foo 1041 num: "" => "2" 1042 type: "" => "aws_instance" 1043 1044 module.child: 1045 DESTROY: aws_instance.foo 1046 1047 STATE: 1048 1049 module.child: 1050 aws_instance.foo: 1051 ID = baz 1052 ` 1053 1054 const testTerraformPlanModuleVarStr = ` 1055 DIFF: 1056 1057 CREATE: aws_instance.bar 1058 foo: "" => "2" 1059 type: "" => "aws_instance" 1060 1061 module.child: 1062 CREATE: aws_instance.foo 1063 num: "" => "2" 1064 type: "" => "aws_instance" 1065 1066 STATE: 1067 1068 <no state> 1069 ` 1070 1071 const testTerraformPlanModuleVarComputedStr = ` 1072 DIFF: 1073 1074 CREATE: aws_instance.bar 1075 foo: "" => "<computed>" 1076 type: "" => "aws_instance" 1077 1078 module.child: 1079 CREATE: aws_instance.foo 1080 foo: "" => "<computed>" 1081 type: "" => "aws_instance" 1082 1083 STATE: 1084 1085 <no state> 1086 ` 1087 1088 const testTerraformPlanModuleVarIntStr = ` 1089 DIFF: 1090 1091 module.child: 1092 CREATE: aws_instance.foo 1093 num: "" => "2" 1094 type: "" => "aws_instance" 1095 1096 STATE: 1097 1098 <no state> 1099 ` 1100 1101 const testTerraformPlanOrphanStr = ` 1102 DIFF: 1103 1104 DESTROY: aws_instance.baz 1105 CREATE: aws_instance.foo 1106 num: "" => "2" 1107 type: "" => "aws_instance" 1108 1109 STATE: 1110 1111 aws_instance.baz: 1112 ID = bar 1113 ` 1114 1115 const testTerraformPlanStateStr = ` 1116 DIFF: 1117 1118 CREATE: aws_instance.bar 1119 foo: "" => "2" 1120 type: "" => "aws_instance" 1121 UPDATE: aws_instance.foo 1122 num: "" => "2" 1123 type: "" => "aws_instance" 1124 1125 STATE: 1126 1127 aws_instance.foo: 1128 ID = bar 1129 ` 1130 1131 const testTerraformPlanTaintStr = ` 1132 DIFF: 1133 1134 DESTROY/CREATE: aws_instance.bar 1135 foo: "" => "2" 1136 type: "" => "aws_instance" 1137 1138 STATE: 1139 1140 aws_instance.bar: (1 tainted) 1141 ID = <not created> 1142 Tainted ID 1 = baz 1143 aws_instance.foo: 1144 ID = bar 1145 num = 2 1146 ` 1147 1148 const testTerraformPlanMultipleTaintStr = ` 1149 DIFF: 1150 1151 DESTROY/CREATE: aws_instance.bar 1152 foo: "" => "2" 1153 type: "" => "aws_instance" 1154 1155 STATE: 1156 1157 aws_instance.bar: (2 tainted) 1158 ID = <not created> 1159 Tainted ID 1 = baz 1160 Tainted ID 2 = zip 1161 aws_instance.foo: 1162 ID = bar 1163 num = 2 1164 ` 1165 1166 const testTerraformPlanVarMultiCountOneStr = ` 1167 DIFF: 1168 1169 CREATE: aws_instance.bar 1170 foo: "" => "2" 1171 type: "" => "aws_instance" 1172 CREATE: aws_instance.foo 1173 num: "" => "2" 1174 type: "" => "aws_instance" 1175 1176 STATE: 1177 1178 <no state> 1179 ` 1180 1181 const testTerraformPlanPathVarStr = ` 1182 DIFF: 1183 1184 CREATE: aws_instance.foo 1185 cwd: "" => "%s/barpath" 1186 module: "" => "%s/foopath" 1187 root: "" => "%s/barpath" 1188 type: "" => "aws_instance" 1189 1190 STATE: 1191 1192 <no state> 1193 `