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