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