Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jsonconfig: Add provider configs to module calls
Add provider alias map to the JSON config module call output, allowing consumers of this format to determine which provider configurations map to the module-local aliases.
- Loading branch information
Showing
5 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
internal/command/testdata/show-json/provider-aliasing/child/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_providers { | ||
test = { | ||
source = "hashicorp/test" | ||
configuration_aliases = [test, test.second] | ||
} | ||
} | ||
} | ||
|
||
resource "test_instance" "test_primary" { | ||
ami = "primary" | ||
provider = test | ||
} | ||
|
||
resource "test_instance" "test_secondary" { | ||
ami = "secondary" | ||
provider = test.second | ||
} |
16 changes: 16 additions & 0 deletions
16
internal/command/testdata/show-json/provider-aliasing/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
provider "test" { | ||
region = "somewhere" | ||
} | ||
|
||
provider "test" { | ||
alias = "backup" | ||
region = "elsewhere" | ||
} | ||
|
||
module "child" { | ||
source = "./child" | ||
providers = { | ||
test = test | ||
test.second = test.backup | ||
} | ||
} |
150 changes: 150 additions & 0 deletions
150
internal/command/testdata/show-json/provider-aliasing/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ | ||
"format_version": "1.0", | ||
"planned_values": { | ||
"root_module": { | ||
"child_modules": [ | ||
{ | ||
"resources": [ | ||
{ | ||
"address": "module.child.test_instance.test_primary", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_primary", | ||
"provider_name": "registry.terraform.io/hashicorp/test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "primary" | ||
}, | ||
"sensitive_values": {} | ||
}, | ||
{ | ||
"address": "module.child.test_instance.test_secondary", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_secondary", | ||
"provider_name": "registry.terraform.io/hashicorp/test", | ||
"schema_version": 0, | ||
"values": { | ||
"ami": "secondary" | ||
}, | ||
"sensitive_values": {} | ||
} | ||
], | ||
"address": "module.child" | ||
} | ||
] | ||
} | ||
}, | ||
"resource_changes": [ | ||
{ | ||
"address": "module.child.test_instance.test_primary", | ||
"module_address": "module.child", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_primary", | ||
"provider_name": "registry.terraform.io/hashicorp/test", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"ami": "primary" | ||
}, | ||
"after_unknown": { | ||
"id": true | ||
}, | ||
"before_sensitive": false, | ||
"after_sensitive": {} | ||
} | ||
}, | ||
{ | ||
"address": "module.child.test_instance.test_secondary", | ||
"module_address": "module.child", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_secondary", | ||
"provider_name": "registry.terraform.io/hashicorp/test", | ||
"change": { | ||
"actions": [ | ||
"create" | ||
], | ||
"before": null, | ||
"after": { | ||
"ami": "secondary" | ||
}, | ||
"after_unknown": { | ||
"id": true | ||
}, | ||
"before_sensitive": false, | ||
"after_sensitive": {} | ||
} | ||
} | ||
], | ||
"configuration": { | ||
"provider_config": { | ||
"module.child:test": { | ||
"name": "test", | ||
"module_address": "module.child" | ||
}, | ||
"test": { | ||
"name": "test", | ||
"expressions": { | ||
"region": { | ||
"constant_value": "somewhere" | ||
} | ||
} | ||
}, | ||
"test.backup": { | ||
"name": "test", | ||
"alias": "backup", | ||
"expressions": { | ||
"region": { | ||
"constant_value": "elsewhere" | ||
} | ||
} | ||
} | ||
}, | ||
"root_module": { | ||
"module_calls": { | ||
"child": { | ||
"source": "./child", | ||
"module": { | ||
"resources": [ | ||
{ | ||
"address": "test_instance.test_primary", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_primary", | ||
"provider_config_key": "child:test", | ||
"expressions": { | ||
"ami": { | ||
"constant_value": "primary" | ||
} | ||
}, | ||
"schema_version": 0 | ||
}, | ||
{ | ||
"address": "test_instance.test_secondary", | ||
"mode": "managed", | ||
"type": "test_instance", | ||
"name": "test_secondary", | ||
"provider_config_key": "child:test.second", | ||
"expressions": { | ||
"ami": { | ||
"constant_value": "secondary" | ||
} | ||
}, | ||
"schema_version": 0 | ||
} | ||
] | ||
}, | ||
"providers": { | ||
"test": "test", | ||
"test.second": "test.backup" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters