2014-06-03 17:08:00 -05:00
|
|
|
package terraform
|
|
|
|
|
|
|
|
import (
|
2016-08-01 16:16:22 -05:00
|
|
|
"flag"
|
2016-07-06 08:56:29 -05:00
|
|
|
"io"
|
2014-09-22 18:48:18 -05:00
|
|
|
"io/ioutil"
|
|
|
|
"os"
|
2014-06-03 17:08:00 -05:00
|
|
|
"path/filepath"
|
2015-03-01 23:28:41 -06:00
|
|
|
"strings"
|
2014-06-30 13:14:03 -05:00
|
|
|
"sync"
|
2014-06-03 17:08:00 -05:00
|
|
|
"testing"
|
|
|
|
|
2018-09-10 18:32:11 -05:00
|
|
|
"github.com/davecgh/go-spew/spew"
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
"github.com/zclconf/go-cty/cty"
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
"github.com/hashicorp/terraform/addrs"
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
"github.com/hashicorp/terraform/configs"
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
"github.com/hashicorp/terraform/configs/configload"
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
"github.com/hashicorp/terraform/internal/initwd"
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
"github.com/hashicorp/terraform/plans"
|
2018-08-17 14:32:35 -05:00
|
|
|
"github.com/hashicorp/terraform/providers"
|
|
|
|
"github.com/hashicorp/terraform/provisioners"
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
"github.com/hashicorp/terraform/registry"
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
"github.com/hashicorp/terraform/states"
|
2020-10-18 09:01:48 -05:00
|
|
|
|
|
|
|
_ "github.com/hashicorp/terraform/internal/logging"
|
2014-06-03 17:08:00 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
// This is the directory where our test fixtures are.
|
2019-06-30 02:38:36 -05:00
|
|
|
const fixtureDir = "./testdata"
|
2014-06-03 17:08:00 -05:00
|
|
|
|
2016-08-01 16:16:22 -05:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
flag.Parse()
|
2016-10-01 18:51:00 -05:00
|
|
|
|
2018-09-10 18:32:11 -05:00
|
|
|
// We have fmt.Stringer implementations on lots of objects that hide
|
|
|
|
// details that we very often want to see in tests, so we just disable
|
|
|
|
// spew's use of String methods globally on the assumption that spew
|
|
|
|
// usage implies an intent to see the raw values and ignore any
|
|
|
|
// abstractions.
|
|
|
|
spew.Config.DisableMethods = true
|
|
|
|
|
2016-08-01 16:16:22 -05:00
|
|
|
os.Exit(m.Run())
|
|
|
|
}
|
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
func testModule(t *testing.T, name string) *configs.Config {
|
2017-08-25 18:23:47 -05:00
|
|
|
t.Helper()
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
c, _ := testModuleWithSnapshot(t, name)
|
|
|
|
return c
|
|
|
|
}
|
|
|
|
|
|
|
|
func testModuleWithSnapshot(t *testing.T, name string) (*configs.Config, *configload.Snapshot) {
|
|
|
|
t.Helper()
|
2017-08-25 18:23:47 -05:00
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
dir := filepath.Join(fixtureDir, name)
|
|
|
|
// FIXME: We're not dealing with the cleanup function here because
|
|
|
|
// this testModule function is used all over and so we don't want to
|
|
|
|
// change its interface at this late stage.
|
|
|
|
loader, _ := configload.NewLoaderForTests(t)
|
2014-06-05 04:32:10 -05:00
|
|
|
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
// Test modules usually do not refer to remote sources, and for local
|
|
|
|
// sources only this ultimately just records all of the module paths
|
|
|
|
// in a JSON file so that we can load them below.
|
2019-01-08 20:39:14 -06:00
|
|
|
inst := initwd.NewModuleInstaller(loader.ModulesDir(), registry.NewClient(nil, nil))
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
_, instDiags := inst.InstallModules(dir, true, initwd.ModuleInstallHooksImpl{})
|
2019-01-08 20:39:14 -06:00
|
|
|
if instDiags.HasErrors() {
|
|
|
|
t.Fatal(instDiags.Err())
|
2018-05-04 21:56:40 -05:00
|
|
|
}
|
2017-08-25 18:23:47 -05:00
|
|
|
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
// Since module installer has modified the module manifest on disk, we need
|
|
|
|
// to refresh the cache of it in the loader.
|
|
|
|
if err := loader.RefreshModules(); err != nil {
|
|
|
|
t.Fatalf("failed to refresh modules after installation: %s", err)
|
|
|
|
}
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
config, snap, diags := loader.LoadConfigWithSnapshot(dir)
|
terraform: ugly huge change to weave in new HCL2-oriented types
Due to how deeply the configuration types go into Terraform Core, there
isn't a great way to switch out to HCL2 gradually. As a consequence, this
huge commit gets us from the old state to a _compilable_ new state, but
does not yet attempt to fix any tests and has a number of known missing
parts and bugs. We will continue to iterate on this in forthcoming
commits, heading back towards passing tests and making Terraform
fully-functional again.
The three main goals here are:
- Use the configuration models from the "configs" package instead of the
older models in the "config" package, which is now deprecated and
preserved only to help us write our migration tool.
- Do expression inspection and evaluation using the functionality of the
new "lang" package, instead of the Interpolator type and related
functionality in the main "terraform" package.
- Represent addresses of various objects using types in the addrs package,
rather than hand-constructed strings. This is not critical to support
the above, but was a big help during the implementation of these other
points since it made it much more explicit what kind of address is
expected in each context.
Since our new packages are built to accommodate some future planned
features that are not yet implemented (e.g. the "for_each" argument on
resources, "count"/"for_each" on modules), and since there's still a fair
amount of functionality still using old-style APIs, there is a moderate
amount of shimming here to connect new assumptions with old, hopefully in
a way that makes it easier to find and eliminate these shims later.
I apologize in advance to the person who inevitably just found this huge
commit while spelunking through the commit history.
2018-04-30 12:33:53 -05:00
|
|
|
if diags.HasErrors() {
|
|
|
|
t.Fatal(diags.Error())
|
2014-09-22 18:48:18 -05:00
|
|
|
}
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
return config, snap
|
2014-09-22 17:37:29 -05:00
|
|
|
}
|
|
|
|
|
2016-07-06 08:56:29 -05:00
|
|
|
// testModuleInline takes a map of path -> config strings and yields a config
|
|
|
|
// structure with those files loaded from disk
|
2018-05-04 21:24:06 -05:00
|
|
|
func testModuleInline(t *testing.T, sources map[string]string) *configs.Config {
|
2017-08-25 18:23:47 -05:00
|
|
|
t.Helper()
|
|
|
|
|
2016-07-06 08:56:29 -05:00
|
|
|
cfgPath, err := ioutil.TempDir("", "tf-test")
|
|
|
|
if err != nil {
|
|
|
|
t.Errorf("Error creating temporary directory for config: %s", err)
|
|
|
|
}
|
|
|
|
defer os.RemoveAll(cfgPath)
|
|
|
|
|
2018-05-04 21:24:06 -05:00
|
|
|
for path, configStr := range sources {
|
2016-07-06 08:56:29 -05:00
|
|
|
dir := filepath.Dir(path)
|
|
|
|
if dir != "." {
|
|
|
|
err := os.MkdirAll(filepath.Join(cfgPath, dir), os.FileMode(0777))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error creating subdir: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Write the configuration
|
|
|
|
cfgF, err := os.Create(filepath.Join(cfgPath, path))
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error creating temporary file for config: %s", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = io.Copy(cfgF, strings.NewReader(configStr))
|
|
|
|
cfgF.Close()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatalf("Error creating temporary file for config: %s", err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
loader, cleanup := configload.NewLoaderForTests(t)
|
|
|
|
defer cleanup()
|
2016-07-06 08:56:29 -05:00
|
|
|
|
2018-05-04 21:24:06 -05:00
|
|
|
// Test modules usually do not refer to remote sources, and for local
|
|
|
|
// sources only this ultimately just records all of the module paths
|
|
|
|
// in a JSON file so that we can load them below.
|
2019-01-08 20:39:14 -06:00
|
|
|
inst := initwd.NewModuleInstaller(loader.ModulesDir(), registry.NewClient(nil, nil))
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
_, instDiags := inst.InstallModules(cfgPath, true, initwd.ModuleInstallHooksImpl{})
|
2019-01-08 20:39:14 -06:00
|
|
|
if instDiags.HasErrors() {
|
|
|
|
t.Fatal(instDiags.Err())
|
2018-05-21 13:32:43 -05:00
|
|
|
}
|
2018-05-04 21:24:06 -05:00
|
|
|
|
command: "terraform init" can partially initialize for 0.12upgrade
There are a few constructs from 0.11 and prior that cause 0.12 parsing to
fail altogether, which previously created a chicken/egg problem because
we need to install the providers in order to run "terraform 0.12upgrade"
and thus fix the problem.
This changes "terraform init" to use the new "early configuration" loader
for module and provider installation. This is built on the more permissive
parser in the terraform-config-inspect package, and so it allows us to
read out the top-level blocks from the configuration while accepting
legacy HCL syntax.
In the long run this will let us do version compatibility detection before
attempting a "real" config load, giving us better error messages for any
future syntax additions, but in the short term the key thing is that it
allows us to install the dependencies even if the configuration isn't
fully valid.
Because backend init still requires full configuration, this introduces a
new mode of terraform init where it detects heuristically if it seems like
we need to do a configuration upgrade and does a partial init if so,
before finally directing the user to run "terraform 0.12upgrade" before
running any other commands.
The heuristic here is based on two assumptions:
- If the "early" loader finds no errors but the normal loader does, the
configuration is likely to be valid for Terraform 0.11 but not 0.12.
- If there's already a version constraint in the configuration that
excludes Terraform versions prior to v0.12 then the configuration is
probably _already_ upgraded and so it's just a normal syntax error,
even if the early loader didn't detect it.
Once the upgrade process is removed in 0.13.0 (users will be required to
go stepwise 0.11 -> 0.12 -> 0.13 to upgrade after that), some of this can
be simplified to remove that special mode, but the idea of doing the
dependency version checks against the liberal parser will remain valuable
to increase our chances of reporting version-based incompatibilities
rather than syntax errors as we add new features in future.
2019-01-14 13:11:00 -06:00
|
|
|
// Since module installer has modified the module manifest on disk, we need
|
|
|
|
// to refresh the cache of it in the loader.
|
|
|
|
if err := loader.RefreshModules(); err != nil {
|
|
|
|
t.Fatalf("failed to refresh modules after installation: %s", err)
|
|
|
|
}
|
|
|
|
|
2018-05-04 21:24:06 -05:00
|
|
|
config, diags := loader.LoadConfig(cfgPath)
|
|
|
|
if diags.HasErrors() {
|
|
|
|
t.Fatal(diags.Error())
|
2016-07-06 08:56:29 -05:00
|
|
|
}
|
|
|
|
|
2018-05-04 21:24:06 -05:00
|
|
|
return config
|
2016-07-06 08:56:29 -05:00
|
|
|
}
|
|
|
|
|
2020-04-01 12:13:40 -05:00
|
|
|
// testSetResourceInstanceCurrent is a helper function for tests that sets a Current,
|
|
|
|
// Ready resource instance for the given module.
|
|
|
|
func testSetResourceInstanceCurrent(module *states.Module, resource, attrsJson, provider string) {
|
|
|
|
module.SetResourceInstanceCurrent(
|
|
|
|
mustResourceInstanceAddr(resource).Resource,
|
|
|
|
&states.ResourceInstanceObjectSrc{
|
|
|
|
Status: states.ObjectReady,
|
|
|
|
AttrsJSON: []byte(attrsJson),
|
|
|
|
},
|
|
|
|
mustProviderConfig(provider),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// testSetResourceInstanceTainted is a helper function for tests that sets a Current,
|
|
|
|
// Tainted resource instance for the given module.
|
|
|
|
func testSetResourceInstanceTainted(module *states.Module, resource, attrsJson, provider string) {
|
|
|
|
module.SetResourceInstanceCurrent(
|
|
|
|
mustResourceInstanceAddr(resource).Resource,
|
|
|
|
&states.ResourceInstanceObjectSrc{
|
|
|
|
Status: states.ObjectTainted,
|
|
|
|
AttrsJSON: []byte(attrsJson),
|
|
|
|
},
|
|
|
|
mustProviderConfig(provider),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2018-08-17 14:32:35 -05:00
|
|
|
func testProviderFuncFixed(rp providers.Interface) providers.Factory {
|
|
|
|
return func() (providers.Interface, error) {
|
2014-06-25 14:58:27 -05:00
|
|
|
return rp, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-13 11:43:28 -06:00
|
|
|
func testProvisionerFuncFixed(rp provisioners.Interface) provisioners.Factory {
|
2018-08-17 14:32:35 -05:00
|
|
|
return func() (provisioners.Interface, error) {
|
2014-07-08 14:42:50 -05:00
|
|
|
return rp, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
func mustResourceInstanceAddr(s string) addrs.AbsResourceInstance {
|
|
|
|
addr, diags := addrs.ParseAbsResourceInstanceStr(s)
|
|
|
|
if diags.HasErrors() {
|
|
|
|
panic(diags.Err())
|
|
|
|
}
|
|
|
|
return addr
|
|
|
|
}
|
|
|
|
|
2020-09-24 10:57:43 -05:00
|
|
|
func mustConfigResourceAddr(s string) addrs.ConfigResource {
|
2019-11-19 16:41:45 -06:00
|
|
|
addr, diags := addrs.ParseAbsResourceStr(s)
|
|
|
|
if diags.HasErrors() {
|
|
|
|
panic(diags.Err())
|
|
|
|
}
|
2020-03-23 14:26:18 -05:00
|
|
|
return addr.Config()
|
2019-11-19 16:41:45 -06:00
|
|
|
}
|
|
|
|
|
2020-09-24 10:57:43 -05:00
|
|
|
func mustAbsResourceAddr(s string) addrs.AbsResource {
|
|
|
|
addr, diags := addrs.ParseAbsResourceStr(s)
|
|
|
|
if diags.HasErrors() {
|
|
|
|
panic(diags.Err())
|
|
|
|
}
|
|
|
|
return addr
|
|
|
|
}
|
|
|
|
|
2019-11-19 16:41:45 -06:00
|
|
|
func mustProviderConfig(s string) addrs.AbsProviderConfig {
|
|
|
|
p, diags := addrs.ParseAbsProviderConfigStr(s)
|
|
|
|
if diags.HasErrors() {
|
|
|
|
panic(diags.Err())
|
|
|
|
}
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
2014-06-30 13:14:03 -05:00
|
|
|
// HookRecordApplyOrder is a test hook that records the order of applies
|
|
|
|
// by recording the PreApply event.
|
|
|
|
type HookRecordApplyOrder struct {
|
|
|
|
NilHook
|
|
|
|
|
|
|
|
Active bool
|
|
|
|
|
|
|
|
IDs []string
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
States []cty.Value
|
|
|
|
Diffs []*plans.Change
|
2014-06-30 13:14:03 -05:00
|
|
|
|
|
|
|
l sync.Mutex
|
|
|
|
}
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
func (h *HookRecordApplyOrder) PreApply(addr addrs.AbsResourceInstance, gen states.Generation, action plans.Action, priorState, plannedNewState cty.Value) (HookAction, error) {
|
|
|
|
if plannedNewState.RawEquals(priorState) {
|
2017-01-20 22:36:53 -06:00
|
|
|
return HookActionContinue, nil
|
|
|
|
}
|
|
|
|
|
2014-06-30 13:14:03 -05:00
|
|
|
if h.Active {
|
|
|
|
h.l.Lock()
|
|
|
|
defer h.l.Unlock()
|
|
|
|
|
terraform: Ugly huge change to weave in new State and Plan types
Due to how often the state and plan types are referenced throughout
Terraform, there isn't a great way to switch them out gradually. As a
consequence, this huge commit gets us from the old world to a _compilable_
new world, but still has a large number of known test failures due to
key functionality being stubbed out.
The stubs here are for anything that interacts with providers, since we
now need to do the follow-up work to similarly replace the old
terraform.ResourceProvider interface with its replacement in the new
"providers" package. That work, along with work to fix the remaining
failing tests, will follow in subsequent commits.
The aim here was to replace all references to terraform.State and its
downstream types with states.State, terraform.Plan with plans.Plan,
state.State with statemgr.State, and switch to the new implementations of
the state and plan file formats. However, due to the number of times those
types are used, this also ended up affecting numerous other parts of core
such as terraform.Hook, the backend.Backend interface, and most of the CLI
commands.
Just as with 5861dbf3fc49b19587a31816eb06f511ab861bb4 before, I apologize
in advance to the person who inevitably just found this huge commit while
spelunking through the commit history.
2018-08-14 16:24:45 -05:00
|
|
|
h.IDs = append(h.IDs, addr.String())
|
|
|
|
h.Diffs = append(h.Diffs, &plans.Change{
|
|
|
|
Action: action,
|
|
|
|
Before: priorState,
|
|
|
|
After: plannedNewState,
|
|
|
|
})
|
|
|
|
h.States = append(h.States, priorState)
|
2014-06-30 13:14:03 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
return HookActionContinue, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Below are all the constant strings that are the expected output for
|
|
|
|
// various tests.
|
|
|
|
|
2014-10-08 12:18:45 -05:00
|
|
|
const testTerraformInputProviderOnlyStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-08 12:18:45 -05:00
|
|
|
foo = us-west-2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-06-18 18:38:08 -05:00
|
|
|
const testTerraformApplyStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-06-18 18:38:08 -05:00
|
|
|
foo = bar
|
2014-07-01 12:28:42 -05:00
|
|
|
type = aws_instance
|
2014-06-18 18:38:08 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-06-18 18:38:08 -05:00
|
|
|
num = 2
|
2014-07-01 12:28:42 -05:00
|
|
|
type = aws_instance
|
2014-06-18 18:38:08 -05:00
|
|
|
`
|
|
|
|
|
2016-10-20 23:53:35 -05:00
|
|
|
const testTerraformApplyDataBasicStr = `
|
|
|
|
data.null_data_source.testing:
|
|
|
|
ID = yo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/null"]
|
2016-10-20 23:53:35 -05:00
|
|
|
`
|
|
|
|
|
2016-08-31 13:49:25 -05:00
|
|
|
const testTerraformApplyRefCountStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-08-31 13:49:25 -05:00
|
|
|
foo = 3
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-08-31 13:49:25 -05:00
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-08-31 13:49:25 -05:00
|
|
|
aws_instance.foo.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-08-31 13:49:25 -05:00
|
|
|
`
|
|
|
|
|
2015-03-23 17:36:53 -05:00
|
|
|
const testTerraformApplyProviderAliasStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"].bar
|
2015-03-23 17:36:53 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-03-23 17:36:53 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2016-11-04 18:35:48 -05:00
|
|
|
const testTerraformApplyProviderAliasConfigStr = `
|
|
|
|
another_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/another"].two
|
2020-10-08 07:56:03 -05:00
|
|
|
type = another_instance
|
2016-11-04 18:35:48 -05:00
|
|
|
another_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/another"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = another_instance
|
2016-11-04 18:35:48 -05:00
|
|
|
`
|
|
|
|
|
2014-11-24 21:18:52 -06:00
|
|
|
const testTerraformApplyEmptyModuleStr = `
|
|
|
|
<no state>
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
end = XXXX
|
|
|
|
`
|
|
|
|
|
2014-09-29 19:00:45 -05:00
|
|
|
const testTerraformApplyDependsCreateBeforeStr = `
|
|
|
|
aws_instance.lb:
|
2018-05-30 11:08:46 -05:00
|
|
|
ID = baz
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-29 19:00:45 -05:00
|
|
|
instance = foo
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.web
|
|
|
|
aws_instance.web:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-29 19:00:45 -05:00
|
|
|
require_new = ami-new
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-09-23 13:13:50 -05:00
|
|
|
const testTerraformApplyCreateBeforeStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-23 13:13:50 -05:00
|
|
|
require_new = xyz
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-02-16 23:06:09 -06:00
|
|
|
const testTerraformApplyCreateBeforeUpdateStr = `
|
|
|
|
aws_instance.bar:
|
2018-06-01 08:24:45 -05:00
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-16 23:06:09 -06:00
|
|
|
foo = baz
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-07-02 18:16:38 -05:00
|
|
|
const testTerraformApplyCancelStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2018-05-25 11:13:22 -05:00
|
|
|
value = 2
|
2014-07-02 18:16:38 -05:00
|
|
|
`
|
|
|
|
|
2014-06-23 14:19:41 -05:00
|
|
|
const testTerraformApplyComputeStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-05-30 12:03:05 -05:00
|
|
|
foo = computed_value
|
2014-07-01 12:28:42 -05:00
|
|
|
type = aws_instance
|
2014-09-17 19:40:59 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
2014-06-23 14:19:41 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-02-11 19:05:24 -06:00
|
|
|
compute = value
|
|
|
|
compute_value = 1
|
2014-07-01 12:28:42 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
2018-05-30 12:03:05 -05:00
|
|
|
value = computed_value
|
2014-06-23 14:19:41 -05:00
|
|
|
`
|
|
|
|
|
2014-10-10 01:15:42 -05:00
|
|
|
const testTerraformApplyCountDecStr = `
|
2018-09-18 16:50:19 -05:00
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-18 16:50:19 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
2014-10-10 01:15:42 -05:00
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-10 01:15:42 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-10 01:15:42 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
|
|
|
const testTerraformApplyCountDecToOneStr = `
|
2015-02-12 22:06:42 -06:00
|
|
|
aws_instance.foo:
|
2014-10-10 01:15:42 -05:00
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-10 01:15:42 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-03-01 23:28:41 -06:00
|
|
|
const testTerraformApplyCountDecToOneCorruptedStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-03-01 23:28:41 -06:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
|
|
|
const testTerraformApplyCountDecToOneCorruptedPlanStr = `
|
|
|
|
DIFF:
|
|
|
|
|
2018-09-18 17:37:04 -05:00
|
|
|
DESTROY: aws_instance.foo[0]
|
2018-09-25 18:15:49 -05:00
|
|
|
id: "baz" => ""
|
|
|
|
type: "aws_instance" => ""
|
2018-09-18 17:37:04 -05:00
|
|
|
|
|
|
|
|
2015-03-01 23:28:41 -06:00
|
|
|
|
|
|
|
STATE:
|
|
|
|
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-03-01 23:28:41 -06:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = baz
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-03-01 23:28:41 -06:00
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-10-17 20:03:30 -05:00
|
|
|
const testTerraformApplyCountVariableStr = `
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-17 20:03:30 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-10-17 20:03:30 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2016-08-31 13:54:14 -05:00
|
|
|
const testTerraformApplyCountVariableRefStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-08-31 13:54:14 -05:00
|
|
|
foo = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-08-31 13:54:14 -05:00
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-08-31 13:54:14 -05:00
|
|
|
`
|
2019-08-26 12:27:33 -05:00
|
|
|
const testTerraformApplyForEachVariableStr = `
|
|
|
|
aws_instance.foo["b15c6d616d6143248c575900dff57325eb1de498"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-08-26 12:27:33 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo["c3de47d34b0a9f13918dd705c141d579dd6555fd"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-08-26 12:27:33 -05:00
|
|
|
foo = foo
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo["e30a7edcc42a846684f2a4eea5f3cd261d33c46d"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-08-26 12:27:33 -05:00
|
|
|
foo = foo
|
2019-08-28 13:02:11 -05:00
|
|
|
type = aws_instance
|
|
|
|
aws_instance.one["a"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2019-08-28 13:02:11 -05:00
|
|
|
aws_instance.one["b"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2019-08-28 13:02:11 -05:00
|
|
|
aws_instance.two["a"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2019-08-28 13:02:11 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.one
|
|
|
|
aws_instance.two["b"]:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2019-08-28 13:02:11 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.one`
|
2014-07-08 18:12:14 -05:00
|
|
|
const testTerraformApplyMinimalStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-07-08 18:12:14 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-07-08 18:12:14 -05:00
|
|
|
`
|
|
|
|
|
2014-09-23 19:13:50 -05:00
|
|
|
const testTerraformApplyModuleStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-23 19:13:50 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-23 19:13:50 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
module.child:
|
|
|
|
aws_instance.baz:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-23 19:13:50 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-02-20 11:40:41 -06:00
|
|
|
const testTerraformApplyModuleBoolStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-05-23 12:39:36 -05:00
|
|
|
foo = true
|
2015-02-20 11:40:41 -06:00
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-05-02 20:21:00 -05:00
|
|
|
const testTerraformApplyModuleDestroyOrderStr = `
|
|
|
|
<no state>
|
|
|
|
`
|
|
|
|
|
2015-02-16 21:04:05 -06:00
|
|
|
const testTerraformApplyMultiProviderStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-16 21:04:05 -06:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
do_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/do"]
|
2015-02-16 21:04:05 -06:00
|
|
|
num = 2
|
|
|
|
type = do_instance
|
|
|
|
`
|
|
|
|
|
2015-06-26 14:00:02 -05:00
|
|
|
const testTerraformApplyModuleOnlyProviderStr = `
|
|
|
|
<no state>
|
|
|
|
module.child:
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2015-06-26 14:00:02 -05:00
|
|
|
test_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/test"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = test_instance
|
2015-06-26 14:00:02 -05:00
|
|
|
`
|
|
|
|
|
2015-06-24 22:58:52 -05:00
|
|
|
const testTerraformApplyModuleProviderAliasStr = `
|
|
|
|
<no state>
|
|
|
|
module.child:
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = module.child.provider["registry.terraform.io/hashicorp/aws"].eu
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2015-06-24 22:58:52 -05:00
|
|
|
`
|
|
|
|
|
2016-11-04 19:47:20 -05:00
|
|
|
const testTerraformApplyModuleVarRefExistingStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-11-04 19:47:20 -05:00
|
|
|
foo = bar
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-11-04 19:47:20 -05:00
|
|
|
|
|
|
|
module.child:
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-11-04 19:47:20 -05:00
|
|
|
type = aws_instance
|
|
|
|
value = bar
|
2019-10-17 15:05:27 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
2016-11-04 19:47:20 -05:00
|
|
|
`
|
|
|
|
|
2015-04-29 13:27:12 -05:00
|
|
|
const testTerraformApplyOutputOrphanStr = `
|
|
|
|
<no state>
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
foo = bar
|
|
|
|
`
|
|
|
|
|
2016-11-02 00:42:41 -05:00
|
|
|
const testTerraformApplyOutputOrphanModuleStr = `
|
2018-09-25 19:12:24 -05:00
|
|
|
<no state>
|
2016-11-02 00:42:41 -05:00
|
|
|
`
|
|
|
|
|
2014-07-09 12:36:49 -05:00
|
|
|
const testTerraformApplyProvisionerStr = `
|
2014-07-22 11:56:39 -05:00
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-09-17 19:42:43 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
2014-07-22 11:56:39 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-02-11 19:05:24 -06:00
|
|
|
compute = value
|
|
|
|
compute_value = 1
|
2014-07-22 11:56:39 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
2018-05-29 14:03:04 -05:00
|
|
|
value = computed_value
|
2014-07-22 11:56:39 -05:00
|
|
|
`
|
|
|
|
|
2016-11-03 12:25:11 -05:00
|
|
|
const testTerraformApplyProvisionerModuleStr = `
|
|
|
|
<no state>
|
|
|
|
module.child:
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2016-11-03 12:25:11 -05:00
|
|
|
`
|
|
|
|
|
2014-07-22 11:56:39 -05:00
|
|
|
const testTerraformApplyProvisionerFailStr = `
|
2016-04-21 14:59:10 -05:00
|
|
|
aws_instance.bar: (tainted)
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-07-09 12:36:49 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-09 12:36:49 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-10-17 01:19:07 -05:00
|
|
|
const testTerraformApplyProvisionerFailCreateStr = `
|
2016-04-21 14:59:10 -05:00
|
|
|
aws_instance.bar: (tainted)
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-10-17 01:19:07 -05:00
|
|
|
`
|
|
|
|
|
2014-10-17 01:20:46 -05:00
|
|
|
const testTerraformApplyProvisionerFailCreateNoIdStr = `
|
|
|
|
<no state>
|
|
|
|
`
|
|
|
|
|
2014-09-22 19:18:51 -05:00
|
|
|
const testTerraformApplyProvisionerFailCreateBeforeDestroyStr = `
|
2018-03-15 13:50:58 -05:00
|
|
|
aws_instance.bar: (tainted) (1 deposed)
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-03-15 13:50:58 -05:00
|
|
|
require_new = xyz
|
|
|
|
type = aws_instance
|
|
|
|
Deposed ID 1 = bar
|
2014-09-22 19:18:51 -05:00
|
|
|
`
|
|
|
|
|
2014-07-24 09:58:45 -05:00
|
|
|
const testTerraformApplyProvisionerResourceRefStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-24 09:58:45 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-02-23 16:56:02 -06:00
|
|
|
const testTerraformApplyProvisionerSelfRefStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-23 16:56:02 -06:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-02-23 17:02:26 -06:00
|
|
|
const testTerraformApplyProvisionerMultiSelfRefStr = `
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-23 17:02:26 -06:00
|
|
|
foo = number 0
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-23 17:02:26 -06:00
|
|
|
foo = number 1
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-23 17:02:26 -06:00
|
|
|
foo = number 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2016-11-23 11:25:20 -06:00
|
|
|
const testTerraformApplyProvisionerMultiSelfRefSingleStr = `
|
|
|
|
aws_instance.foo.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-11-23 11:25:20 -06:00
|
|
|
foo = number 0
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-11-23 11:25:20 -06:00
|
|
|
foo = number 1
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2016-11-23 11:25:20 -06:00
|
|
|
foo = number 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-09-22 13:15:22 -05:00
|
|
|
const testTerraformApplyProvisionerDiffStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-22 13:15:22 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2020-10-16 13:52:31 -05:00
|
|
|
const testTerraformApplyProvisionerSensitiveStr = `
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-06-30 13:14:03 -05:00
|
|
|
const testTerraformApplyDestroyStr = `
|
2014-07-02 21:56:29 -05:00
|
|
|
<no state>
|
2014-06-30 13:14:03 -05:00
|
|
|
`
|
|
|
|
|
2014-07-02 19:26:39 -05:00
|
|
|
const testTerraformApplyErrorStr = `
|
2018-09-17 18:59:28 -05:00
|
|
|
aws_instance.bar: (tainted)
|
2020-10-08 07:56:03 -05:00
|
|
|
ID =
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
foo = 2
|
2014-09-17 19:45:38 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
2014-07-02 19:26:39 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2018-05-23 12:39:36 -05:00
|
|
|
value = 2
|
2014-07-02 19:26:39 -05:00
|
|
|
`
|
|
|
|
|
2014-09-23 12:53:29 -05:00
|
|
|
const testTerraformApplyErrorCreateBeforeDestroyStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-09-23 12:53:29 -05:00
|
|
|
require_new = abc
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-09-23 12:53:29 -05:00
|
|
|
`
|
|
|
|
|
2014-09-23 13:10:23 -05:00
|
|
|
const testTerraformApplyErrorDestroyCreateBeforeDestroyStr = `
|
2015-03-04 12:15:53 -06:00
|
|
|
aws_instance.bar: (1 deposed)
|
2014-09-23 13:10:23 -05:00
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2019-02-05 18:45:44 -06:00
|
|
|
require_new = xyz
|
|
|
|
type = aws_instance
|
2015-03-04 12:15:53 -06:00
|
|
|
Deposed ID 1 = bar
|
2014-09-23 13:10:23 -05:00
|
|
|
`
|
|
|
|
|
2014-07-02 19:26:39 -05:00
|
|
|
const testTerraformApplyErrorPartialStr = `
|
2015-02-13 14:50:13 -06:00
|
|
|
aws_instance.bar:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2014-09-17 19:45:38 -05:00
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
2014-07-02 19:26:39 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2020-10-08 07:56:03 -05:00
|
|
|
type = aws_instance
|
2018-05-23 12:39:36 -05:00
|
|
|
value = 2
|
2014-07-02 19:26:39 -05:00
|
|
|
`
|
|
|
|
|
2016-11-11 20:54:37 -06:00
|
|
|
const testTerraformApplyResourceDependsOnModuleStr = `
|
|
|
|
aws_instance.a:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 12:43:58 -05:00
|
|
|
ami = parent
|
|
|
|
type = aws_instance
|
2016-11-11 20:54:37 -06:00
|
|
|
|
|
|
|
Dependencies:
|
2019-10-17 15:05:27 -05:00
|
|
|
module.child.aws_instance.child
|
2016-11-11 20:54:37 -06:00
|
|
|
|
|
|
|
module.child:
|
|
|
|
aws_instance.child:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 12:43:58 -05:00
|
|
|
ami = child
|
|
|
|
type = aws_instance
|
2016-11-11 20:54:37 -06:00
|
|
|
`
|
|
|
|
|
2016-11-12 17:38:28 -06:00
|
|
|
const testTerraformApplyResourceDependsOnModuleDeepStr = `
|
|
|
|
aws_instance.a:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 13:49:16 -05:00
|
|
|
ami = parent
|
|
|
|
type = aws_instance
|
2016-11-12 17:38:28 -06:00
|
|
|
|
|
|
|
Dependencies:
|
2019-10-17 15:05:27 -05:00
|
|
|
module.child.module.grandchild.aws_instance.c
|
2016-11-12 17:38:28 -06:00
|
|
|
|
|
|
|
module.child.grandchild:
|
|
|
|
aws_instance.c:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 13:49:16 -05:00
|
|
|
ami = grandchild
|
|
|
|
type = aws_instance
|
2016-11-12 17:38:28 -06:00
|
|
|
`
|
|
|
|
|
|
|
|
const testTerraformApplyResourceDependsOnModuleInModuleStr = `
|
|
|
|
<no state>
|
|
|
|
module.child:
|
|
|
|
aws_instance.b:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 16:59:27 -05:00
|
|
|
ami = child
|
|
|
|
type = aws_instance
|
2016-11-12 17:38:28 -06:00
|
|
|
|
|
|
|
Dependencies:
|
2019-10-17 15:05:27 -05:00
|
|
|
module.child.module.grandchild.aws_instance.c
|
2016-11-12 17:38:28 -06:00
|
|
|
module.child.grandchild:
|
|
|
|
aws_instance.c:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-09-12 16:59:27 -05:00
|
|
|
ami = grandchild
|
|
|
|
type = aws_instance
|
2016-11-12 17:38:28 -06:00
|
|
|
`
|
|
|
|
|
2014-07-26 23:02:34 -05:00
|
|
|
const testTerraformApplyTaintStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-26 23:02:34 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2015-02-26 11:50:18 -06:00
|
|
|
const testTerraformApplyTaintDepStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = bar
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-26 11:50:18 -06:00
|
|
|
foo = foo
|
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-26 11:50:18 -06:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
|
|
|
const testTerraformApplyTaintDepRequireNewStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-26 11:50:18 -06:00
|
|
|
foo = foo
|
|
|
|
require_new = yes
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Dependencies:
|
|
|
|
aws_instance.foo
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-26 11:50:18 -06:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2014-07-04 17:36:28 -05:00
|
|
|
const testTerraformApplyOutputStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-04 17:36:28 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-04 17:36:28 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
foo_num = 2
|
|
|
|
`
|
|
|
|
|
2015-11-09 14:15:25 -06:00
|
|
|
const testTerraformApplyOutputAddStr = `
|
|
|
|
aws_instance.test.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-11-09 14:15:25 -06:00
|
|
|
foo = foo0
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.test.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-11-09 14:15:25 -06:00
|
|
|
foo = foo1
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
firstOutput = foo0
|
|
|
|
secondOutput = foo1
|
|
|
|
`
|
|
|
|
|
2014-11-24 18:49:38 -06:00
|
|
|
const testTerraformApplyOutputListStr = `
|
|
|
|
aws_instance.bar.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-11-24 18:49:38 -06:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-11-24 18:49:38 -06:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-11-24 18:49:38 -06:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-11-24 18:49:38 -06:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Outputs:
|
|
|
|
|
2016-04-11 12:40:06 -05:00
|
|
|
foo_num = [bar,bar,bar]
|
2014-11-24 18:49:38 -06:00
|
|
|
`
|
|
|
|
|
2014-07-05 12:48:47 -05:00
|
|
|
const testTerraformApplyOutputMultiStr = `
|
|
|
|
aws_instance.bar.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-05 12:48:47 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-05 12:48:47 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-05 12:48:47 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-05 12:48:47 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
foo_num = bar,bar,bar
|
|
|
|
`
|
|
|
|
|
2014-07-06 16:09:44 -05:00
|
|
|
const testTerraformApplyOutputMultiIndexStr = `
|
|
|
|
aws_instance.bar.0:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-06 16:09:44 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.1:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-06 16:09:44 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.bar.2:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-06 16:09:44 -05:00
|
|
|
foo = bar
|
|
|
|
type = aws_instance
|
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-06 16:09:44 -05:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
|
|
|
|
|
|
|
Outputs:
|
|
|
|
|
|
|
|
foo_num = bar
|
|
|
|
`
|
|
|
|
|
2014-06-23 15:08:25 -05:00
|
|
|
const testTerraformApplyUnknownAttrStr = `
|
2018-09-17 18:04:45 -05:00
|
|
|
aws_instance.foo: (tainted)
|
2015-02-13 14:50:13 -06:00
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2015-02-13 14:50:13 -06:00
|
|
|
num = 2
|
|
|
|
type = aws_instance
|
2014-06-23 15:08:25 -05:00
|
|
|
`
|
|
|
|
|
2014-06-23 14:28:02 -05:00
|
|
|
const testTerraformApplyVarsStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-05-11 16:40:40 -05:00
|
|
|
bar = override
|
2014-07-22 10:18:53 -05:00
|
|
|
baz = override
|
2018-05-11 16:40:40 -05:00
|
|
|
foo = us-east-1
|
2014-06-23 14:28:02 -05:00
|
|
|
aws_instance.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2014-07-22 10:14:20 -05:00
|
|
|
bar = baz
|
2018-05-11 16:40:40 -05:00
|
|
|
list.# = 2
|
|
|
|
list.0 = Hello
|
|
|
|
list.1 = World
|
|
|
|
map.Baz = Foo
|
|
|
|
map.Foo = Bar
|
|
|
|
map.Hello = World
|
2014-06-23 14:28:02 -05:00
|
|
|
num = 2
|
|
|
|
`
|
|
|
|
|
2015-04-21 23:31:53 -05:00
|
|
|
const testTerraformApplyVarsEnvStr = `
|
|
|
|
aws_instance.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/aws"]
|
2018-05-11 16:40:40 -05:00
|
|
|
list.# = 2
|
|
|
|
list.0 = Hello
|
|
|
|
list.1 = World
|
|
|
|
map.Baz = Foo
|
|
|
|
map.Foo = Bar
|
|
|
|
map.Hello = World
|
|
|
|
string = baz
|
2015-04-21 23:31:53 -05:00
|
|
|
type = aws_instance
|
|
|
|
`
|
|
|
|
|
2016-10-23 20:53:00 -05:00
|
|
|
const testTerraformRefreshDataRefDataStr = `
|
|
|
|
data.null_data_source.bar:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/null"]
|
2016-10-23 20:53:00 -05:00
|
|
|
bar = yes
|
|
|
|
data.null_data_source.foo:
|
|
|
|
ID = foo
|
2020-03-31 13:03:33 -05:00
|
|
|
provider = provider["registry.terraform.io/hashicorp/null"]
|
2016-10-23 20:53:00 -05:00
|
|
|
foo = yes
|
|
|
|
`
|