github.com/bendemaree/terraform@v0.5.4-0.20150613200311-f50d97d6eee6/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 testTerraformApplyModuleDestroyOrderStr = ` 366 <no state> 367 module.child: 368 <no state> 369 ` 370 371 const testTerraformApplyMultiProviderStr = ` 372 aws_instance.bar: 373 ID = foo 374 foo = bar 375 type = aws_instance 376 do_instance.foo: 377 ID = foo 378 num = 2 379 type = do_instance 380 ` 381 382 const testTerraformApplyOutputOrphanStr = ` 383 <no state> 384 Outputs: 385 386 foo = bar 387 ` 388 389 const testTerraformApplyProvisionerStr = ` 390 aws_instance.bar: 391 ID = foo 392 393 Dependencies: 394 aws_instance.foo 395 aws_instance.foo: 396 ID = foo 397 dynamical = computed_dynamical 398 num = 2 399 type = aws_instance 400 ` 401 402 const testTerraformApplyProvisionerFailStr = ` 403 aws_instance.bar: (1 tainted) 404 ID = <not created> 405 Tainted ID 1 = foo 406 aws_instance.foo: 407 ID = foo 408 num = 2 409 type = aws_instance 410 ` 411 412 const testTerraformApplyProvisionerFailCreateStr = ` 413 aws_instance.bar: (1 tainted) 414 ID = <not created> 415 Tainted ID 1 = foo 416 ` 417 418 const testTerraformApplyProvisionerFailCreateNoIdStr = ` 419 <no state> 420 ` 421 422 const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = ` 423 aws_instance.bar: (1 tainted) 424 ID = bar 425 require_new = abc 426 Tainted ID 1 = foo 427 ` 428 429 const testTerraformApplyProvisionerResourceRefStr = ` 430 aws_instance.bar: 431 ID = foo 432 num = 2 433 type = aws_instance 434 ` 435 436 const testTerraformApplyProvisionerSelfRefStr = ` 437 aws_instance.foo: 438 ID = foo 439 foo = bar 440 type = aws_instance 441 ` 442 443 const testTerraformApplyProvisionerMultiSelfRefStr = ` 444 aws_instance.foo.0: 445 ID = foo 446 foo = number 0 447 type = aws_instance 448 aws_instance.foo.1: 449 ID = foo 450 foo = number 1 451 type = aws_instance 452 aws_instance.foo.2: 453 ID = foo 454 foo = number 2 455 type = aws_instance 456 ` 457 458 const testTerraformApplyProvisionerDiffStr = ` 459 aws_instance.bar: 460 ID = foo 461 foo = bar 462 type = aws_instance 463 ` 464 465 const testTerraformApplyDestroyStr = ` 466 <no state> 467 ` 468 469 const testTerraformApplyErrorStr = ` 470 aws_instance.bar: 471 ID = bar 472 473 Dependencies: 474 aws_instance.foo 475 aws_instance.foo: 476 ID = foo 477 num = 2 478 ` 479 480 const testTerraformApplyErrorCreateBeforeDestroyStr = ` 481 aws_instance.bar: 482 ID = bar 483 require_new = abc 484 ` 485 486 const testTerraformApplyErrorDestroyCreateBeforeDestroyStr = ` 487 aws_instance.bar: (1 deposed) 488 ID = foo 489 Deposed ID 1 = bar 490 ` 491 492 const testTerraformApplyErrorPartialStr = ` 493 aws_instance.bar: 494 ID = bar 495 496 Dependencies: 497 aws_instance.foo 498 aws_instance.foo: 499 ID = foo 500 num = 2 501 ` 502 503 const testTerraformApplyTaintStr = ` 504 aws_instance.bar: 505 ID = foo 506 num = 2 507 type = aws_instance 508 ` 509 510 const testTerraformApplyTaintDepStr = ` 511 aws_instance.bar: 512 ID = bar 513 foo = foo 514 num = 2 515 type = aws_instance 516 517 Dependencies: 518 aws_instance.foo 519 aws_instance.foo: 520 ID = foo 521 num = 2 522 type = aws_instance 523 ` 524 525 const testTerraformApplyTaintDepRequireNewStr = ` 526 aws_instance.bar: 527 ID = foo 528 foo = foo 529 require_new = yes 530 type = aws_instance 531 532 Dependencies: 533 aws_instance.foo 534 aws_instance.foo: 535 ID = foo 536 num = 2 537 type = aws_instance 538 ` 539 540 const testTerraformApplyOutputStr = ` 541 aws_instance.bar: 542 ID = foo 543 foo = bar 544 type = aws_instance 545 aws_instance.foo: 546 ID = foo 547 num = 2 548 type = aws_instance 549 550 Outputs: 551 552 foo_num = 2 553 ` 554 555 const testTerraformApplyOutputListStr = ` 556 aws_instance.bar.0: 557 ID = foo 558 foo = bar 559 type = aws_instance 560 aws_instance.bar.1: 561 ID = foo 562 foo = bar 563 type = aws_instance 564 aws_instance.bar.2: 565 ID = foo 566 foo = bar 567 type = aws_instance 568 aws_instance.foo: 569 ID = foo 570 num = 2 571 type = aws_instance 572 573 Outputs: 574 575 foo_num = bar,bar,bar 576 ` 577 578 const testTerraformApplyOutputMultiStr = ` 579 aws_instance.bar.0: 580 ID = foo 581 foo = bar 582 type = aws_instance 583 aws_instance.bar.1: 584 ID = foo 585 foo = bar 586 type = aws_instance 587 aws_instance.bar.2: 588 ID = foo 589 foo = bar 590 type = aws_instance 591 aws_instance.foo: 592 ID = foo 593 num = 2 594 type = aws_instance 595 596 Outputs: 597 598 foo_num = bar,bar,bar 599 ` 600 601 const testTerraformApplyOutputMultiIndexStr = ` 602 aws_instance.bar.0: 603 ID = foo 604 foo = bar 605 type = aws_instance 606 aws_instance.bar.1: 607 ID = foo 608 foo = bar 609 type = aws_instance 610 aws_instance.bar.2: 611 ID = foo 612 foo = bar 613 type = aws_instance 614 aws_instance.foo: 615 ID = foo 616 num = 2 617 type = aws_instance 618 619 Outputs: 620 621 foo_num = bar 622 ` 623 624 const testTerraformApplyUnknownAttrStr = ` 625 aws_instance.foo: 626 ID = foo 627 num = 2 628 type = aws_instance 629 ` 630 631 const testTerraformApplyVarsStr = ` 632 aws_instance.bar: 633 ID = foo 634 bar = foo 635 baz = override 636 foo = us-west-2 637 type = aws_instance 638 aws_instance.foo: 639 ID = foo 640 bar = baz 641 num = 2 642 type = aws_instance 643 ` 644 645 const testTerraformApplyVarsEnvStr = ` 646 aws_instance.bar: 647 ID = foo 648 foo = baz 649 type = aws_instance 650 ` 651 652 const testTerraformPlanStr = ` 653 DIFF: 654 655 CREATE: aws_instance.bar 656 foo: "" => "2" 657 type: "" => "aws_instance" 658 CREATE: aws_instance.foo 659 num: "" => "2" 660 type: "" => "aws_instance" 661 662 STATE: 663 664 <no state> 665 ` 666 667 const testTerraformPlanComputedStr = ` 668 DIFF: 669 670 CREATE: aws_instance.bar 671 foo: "" => "<computed>" 672 type: "" => "aws_instance" 673 CREATE: aws_instance.foo 674 foo: "" => "<computed>" 675 num: "" => "2" 676 type: "" => "aws_instance" 677 678 STATE: 679 680 <no state> 681 ` 682 683 const testTerraformPlanComputedIdStr = ` 684 DIFF: 685 686 CREATE: aws_instance.bar 687 foo: "" => "<computed>" 688 type: "" => "aws_instance" 689 CREATE: aws_instance.foo 690 foo: "" => "<computed>" 691 num: "" => "2" 692 type: "" => "aws_instance" 693 694 STATE: 695 696 <no state> 697 ` 698 699 const testTerraformPlanComputedListStr = ` 700 DIFF: 701 702 CREATE: aws_instance.bar 703 foo: "" => "<computed>" 704 type: "" => "aws_instance" 705 CREATE: aws_instance.foo 706 list.#: "" => "<computed>" 707 num: "" => "2" 708 type: "" => "aws_instance" 709 710 STATE: 711 712 <no state> 713 ` 714 715 const testTerraformPlanCountStr = ` 716 DIFF: 717 718 CREATE: aws_instance.bar 719 foo: "" => "foo,foo,foo,foo,foo" 720 type: "" => "aws_instance" 721 CREATE: aws_instance.foo.0 722 foo: "" => "foo" 723 type: "" => "aws_instance" 724 CREATE: aws_instance.foo.1 725 foo: "" => "foo" 726 type: "" => "aws_instance" 727 CREATE: aws_instance.foo.2 728 foo: "" => "foo" 729 type: "" => "aws_instance" 730 CREATE: aws_instance.foo.3 731 foo: "" => "foo" 732 type: "" => "aws_instance" 733 CREATE: aws_instance.foo.4 734 foo: "" => "foo" 735 type: "" => "aws_instance" 736 737 STATE: 738 739 <no state> 740 ` 741 742 const testTerraformPlanCountIndexStr = ` 743 DIFF: 744 745 CREATE: aws_instance.foo.0 746 foo: "" => "0" 747 type: "" => "aws_instance" 748 CREATE: aws_instance.foo.1 749 foo: "" => "1" 750 type: "" => "aws_instance" 751 752 STATE: 753 754 <no state> 755 ` 756 757 const testTerraformPlanCountIndexZeroStr = ` 758 DIFF: 759 760 CREATE: aws_instance.foo 761 foo: "" => "0" 762 type: "" => "aws_instance" 763 764 STATE: 765 766 <no state> 767 ` 768 769 const testTerraformPlanCountOneIndexStr = ` 770 DIFF: 771 772 CREATE: aws_instance.bar 773 foo: "" => "foo" 774 type: "" => "aws_instance" 775 CREATE: aws_instance.foo 776 foo: "" => "foo" 777 type: "" => "aws_instance" 778 779 STATE: 780 781 <no state> 782 ` 783 784 const testTerraformPlanCountZeroStr = ` 785 DIFF: 786 787 CREATE: aws_instance.bar 788 foo: "" => "" 789 type: "" => "aws_instance" 790 791 STATE: 792 793 <no state> 794 ` 795 796 const testTerraformPlanCountVarStr = ` 797 DIFF: 798 799 CREATE: aws_instance.bar 800 foo: "" => "foo,foo,foo" 801 type: "" => "aws_instance" 802 CREATE: aws_instance.foo.0 803 foo: "" => "foo" 804 type: "" => "aws_instance" 805 CREATE: aws_instance.foo.1 806 foo: "" => "foo" 807 type: "" => "aws_instance" 808 CREATE: aws_instance.foo.2 809 foo: "" => "foo" 810 type: "" => "aws_instance" 811 812 STATE: 813 814 <no state> 815 ` 816 817 const testTerraformPlanCountDecreaseStr = ` 818 DIFF: 819 820 CREATE: aws_instance.bar 821 foo: "" => "bar" 822 type: "" => "aws_instance" 823 DESTROY: aws_instance.foo.1 824 DESTROY: aws_instance.foo.2 825 826 STATE: 827 828 aws_instance.foo.0: 829 ID = bar 830 foo = foo 831 type = aws_instance 832 aws_instance.foo.1: 833 ID = bar 834 aws_instance.foo.2: 835 ID = bar 836 ` 837 838 const testTerraformPlanCountIncreaseStr = ` 839 DIFF: 840 841 CREATE: aws_instance.bar 842 foo: "" => "bar" 843 type: "" => "aws_instance" 844 CREATE: aws_instance.foo.1 845 foo: "" => "foo" 846 type: "" => "aws_instance" 847 CREATE: aws_instance.foo.2 848 foo: "" => "foo" 849 type: "" => "aws_instance" 850 851 STATE: 852 853 aws_instance.foo: 854 ID = bar 855 foo = foo 856 type = aws_instance 857 ` 858 859 const testTerraformPlanCountIncreaseFromOneStr = ` 860 DIFF: 861 862 CREATE: aws_instance.bar 863 foo: "" => "bar" 864 type: "" => "aws_instance" 865 CREATE: aws_instance.foo.1 866 foo: "" => "foo" 867 type: "" => "aws_instance" 868 CREATE: aws_instance.foo.2 869 foo: "" => "foo" 870 type: "" => "aws_instance" 871 872 STATE: 873 874 aws_instance.foo.0: 875 ID = bar 876 foo = foo 877 type = aws_instance 878 ` 879 880 const testTerraformPlanCountIncreaseFromOneCorruptedStr = ` 881 DIFF: 882 883 CREATE: aws_instance.bar 884 foo: "" => "bar" 885 type: "" => "aws_instance" 886 DESTROY: aws_instance.foo 887 CREATE: aws_instance.foo.1 888 foo: "" => "foo" 889 type: "" => "aws_instance" 890 CREATE: aws_instance.foo.2 891 foo: "" => "foo" 892 type: "" => "aws_instance" 893 894 STATE: 895 896 aws_instance.foo: 897 ID = bar 898 foo = foo 899 type = aws_instance 900 aws_instance.foo.0: 901 ID = bar 902 foo = foo 903 type = aws_instance 904 ` 905 906 const testTerraformPlanDestroyStr = ` 907 DIFF: 908 909 DESTROY: aws_instance.one 910 DESTROY: aws_instance.two 911 912 STATE: 913 914 aws_instance.one: 915 ID = bar 916 aws_instance.two: 917 ID = baz 918 ` 919 920 const testTerraformPlanDiffVarStr = ` 921 DIFF: 922 923 CREATE: aws_instance.bar 924 num: "" => "3" 925 type: "" => "aws_instance" 926 UPDATE: aws_instance.foo 927 num: "2" => "3" 928 929 STATE: 930 931 aws_instance.foo: 932 ID = bar 933 num = 2 934 ` 935 936 const testTerraformPlanEmptyStr = ` 937 DIFF: 938 939 CREATE: aws_instance.bar 940 CREATE: aws_instance.foo 941 942 STATE: 943 944 <no state> 945 ` 946 947 const testTerraformPlanModulesStr = ` 948 DIFF: 949 950 CREATE: aws_instance.bar 951 foo: "" => "2" 952 type: "" => "aws_instance" 953 CREATE: aws_instance.foo 954 num: "" => "2" 955 type: "" => "aws_instance" 956 957 module.child: 958 CREATE: aws_instance.foo 959 num: "" => "2" 960 type: "" => "aws_instance" 961 962 STATE: 963 964 <no state> 965 ` 966 967 const testTerraformPlanModuleCycleStr = ` 968 DIFF: 969 970 CREATE: aws_instance.b 971 CREATE: aws_instance.c 972 some_input: "" => "<computed>" 973 type: "" => "aws_instance" 974 975 STATE: 976 977 <no state> 978 ` 979 980 const testTerraformPlanModuleDestroyStr = ` 981 DIFF: 982 983 DESTROY: aws_instance.foo 984 985 module.child: 986 DESTROY MODULE 987 DESTROY: aws_instance.foo 988 989 STATE: 990 991 aws_instance.foo: 992 ID = bar 993 994 module.child: 995 aws_instance.foo: 996 ID = bar 997 ` 998 999 const testTerraformPlanModuleDestroyCycleStr = ` 1000 DIFF: 1001 1002 module.a_module: 1003 DESTROY MODULE 1004 DESTROY: aws_instance.a 1005 module.b_module: 1006 DESTROY MODULE 1007 DESTROY: aws_instance.b 1008 1009 STATE: 1010 1011 module.a_module: 1012 aws_instance.a: 1013 ID = a 1014 module.b_module: 1015 aws_instance.b: 1016 ID = b 1017 ` 1018 1019 const testTerraformPlanModuleDestroyMultivarStr = ` 1020 DIFF: 1021 1022 module.child: 1023 DESTROY MODULE 1024 DESTROY: aws_instance.foo.0 1025 DESTROY: aws_instance.foo.1 1026 1027 STATE: 1028 1029 <no state> 1030 module.child: 1031 aws_instance.foo.0: 1032 ID = bar0 1033 aws_instance.foo.1: 1034 ID = bar1 1035 ` 1036 1037 const testTerraformPlanModuleInputStr = ` 1038 DIFF: 1039 1040 CREATE: aws_instance.bar 1041 foo: "" => "2" 1042 type: "" => "aws_instance" 1043 1044 module.child: 1045 CREATE: aws_instance.foo 1046 foo: "" => "42" 1047 type: "" => "aws_instance" 1048 1049 STATE: 1050 1051 <no state> 1052 ` 1053 1054 const testTerraformPlanModuleInputComputedStr = ` 1055 DIFF: 1056 1057 CREATE: aws_instance.bar 1058 foo: "" => "<computed>" 1059 type: "" => "aws_instance" 1060 1061 module.child: 1062 CREATE: aws_instance.foo 1063 foo: "" => "<computed>" 1064 type: "" => "aws_instance" 1065 1066 STATE: 1067 1068 <no state> 1069 ` 1070 1071 const testTerraformPlanModuleInputVarStr = ` 1072 DIFF: 1073 1074 CREATE: aws_instance.bar 1075 foo: "" => "2" 1076 type: "" => "aws_instance" 1077 1078 module.child: 1079 CREATE: aws_instance.foo 1080 foo: "" => "52" 1081 type: "" => "aws_instance" 1082 1083 STATE: 1084 1085 <no state> 1086 ` 1087 1088 const testTerraformPlanModuleMultiVarStr = ` 1089 DIFF: 1090 1091 CREATE: aws_instance.parent.0 1092 CREATE: aws_instance.parent.1 1093 1094 module.child: 1095 CREATE: aws_instance.bar.0 1096 baz: "" => "baz" 1097 type: "" => "aws_instance" 1098 CREATE: aws_instance.bar.1 1099 baz: "" => "baz" 1100 type: "" => "aws_instance" 1101 CREATE: aws_instance.foo 1102 foo: "" => "baz,baz" 1103 type: "" => "aws_instance" 1104 1105 STATE: 1106 1107 <no state> 1108 ` 1109 1110 const testTerraformPlanModuleOrphansStr = ` 1111 DIFF: 1112 1113 CREATE: aws_instance.foo 1114 num: "" => "2" 1115 type: "" => "aws_instance" 1116 1117 module.child: 1118 DESTROY: aws_instance.foo 1119 1120 STATE: 1121 1122 module.child: 1123 aws_instance.foo: 1124 ID = baz 1125 ` 1126 1127 const testTerraformPlanModuleVarStr = ` 1128 DIFF: 1129 1130 CREATE: aws_instance.bar 1131 foo: "" => "2" 1132 type: "" => "aws_instance" 1133 1134 module.child: 1135 CREATE: aws_instance.foo 1136 num: "" => "2" 1137 type: "" => "aws_instance" 1138 1139 STATE: 1140 1141 <no state> 1142 ` 1143 1144 const testTerraformPlanModuleVarComputedStr = ` 1145 DIFF: 1146 1147 CREATE: aws_instance.bar 1148 foo: "" => "<computed>" 1149 type: "" => "aws_instance" 1150 1151 module.child: 1152 CREATE: aws_instance.foo 1153 foo: "" => "<computed>" 1154 type: "" => "aws_instance" 1155 1156 STATE: 1157 1158 <no state> 1159 ` 1160 1161 const testTerraformPlanModuleVarIntStr = ` 1162 DIFF: 1163 1164 module.child: 1165 CREATE: aws_instance.foo 1166 num: "" => "2" 1167 type: "" => "aws_instance" 1168 1169 STATE: 1170 1171 <no state> 1172 ` 1173 1174 const testTerraformPlanOrphanStr = ` 1175 DIFF: 1176 1177 DESTROY: aws_instance.baz 1178 CREATE: aws_instance.foo 1179 num: "" => "2" 1180 type: "" => "aws_instance" 1181 1182 STATE: 1183 1184 aws_instance.baz: 1185 ID = bar 1186 ` 1187 1188 const testTerraformPlanStateStr = ` 1189 DIFF: 1190 1191 CREATE: aws_instance.bar 1192 foo: "" => "2" 1193 type: "" => "aws_instance" 1194 UPDATE: aws_instance.foo 1195 num: "" => "2" 1196 type: "" => "aws_instance" 1197 1198 STATE: 1199 1200 aws_instance.foo: 1201 ID = bar 1202 ` 1203 1204 const testTerraformPlanTaintStr = ` 1205 DIFF: 1206 1207 DESTROY/CREATE: aws_instance.bar 1208 foo: "" => "2" 1209 type: "" => "aws_instance" 1210 1211 STATE: 1212 1213 aws_instance.bar: (1 tainted) 1214 ID = <not created> 1215 Tainted ID 1 = baz 1216 aws_instance.foo: 1217 ID = bar 1218 num = 2 1219 ` 1220 1221 const testTerraformPlanMultipleTaintStr = ` 1222 DIFF: 1223 1224 DESTROY/CREATE: aws_instance.bar 1225 foo: "" => "2" 1226 type: "" => "aws_instance" 1227 1228 STATE: 1229 1230 aws_instance.bar: (2 tainted) 1231 ID = <not created> 1232 Tainted ID 1 = baz 1233 Tainted ID 2 = zip 1234 aws_instance.foo: 1235 ID = bar 1236 num = 2 1237 ` 1238 1239 const testTerraformPlanVarMultiCountOneStr = ` 1240 DIFF: 1241 1242 CREATE: aws_instance.bar 1243 foo: "" => "2" 1244 type: "" => "aws_instance" 1245 CREATE: aws_instance.foo 1246 num: "" => "2" 1247 type: "" => "aws_instance" 1248 1249 STATE: 1250 1251 <no state> 1252 ` 1253 1254 const testTerraformPlanPathVarStr = ` 1255 DIFF: 1256 1257 CREATE: aws_instance.foo 1258 cwd: "" => "%s/barpath" 1259 module: "" => "%s/foopath" 1260 root: "" => "%s/barpath" 1261 type: "" => "aws_instance" 1262 1263 STATE: 1264 1265 <no state> 1266 `