@@ -52,9 +52,20 @@ func TestContextImport_basic(t *testing.T) {
5252 }
5353}
5454
55+ // import 1 of count instances in the configuration
5556func TestContextImport_countIndex (t * testing.T ) {
5657 p := testProvider ("aws" )
57- m := testModule (t , "import-provider" )
58+ m := testModuleInline (t , map [string ]string {
59+ "main.tf" : `
60+ provider "aws" {
61+ foo = "bar"
62+ }
63+
64+ resource "aws_instance" "foo" {
65+ count = 2
66+ }
67+ ` })
68+
5869 ctx := testContext2 (t , & ContextOpts {
5970 Providers : map [addrs.Provider ]providers.Factory {
6071 addrs .NewDefaultProvider ("aws" ): testProviderFuncFixed (p ),
@@ -779,7 +790,7 @@ func TestContextImport_multiStateSame(t *testing.T) {
779790 }
780791}
781792
782- func TestContextImport_noConfigModuleImport (t * testing.T ) {
793+ func TestContextImport_nestedModuleImport (t * testing.T ) {
783794 p := testProvider ("aws" )
784795 m := testModuleInline (t , map [string ]string {
785796 "main.tf" : `
@@ -797,6 +808,9 @@ module "b" {
797808 source = "./b"
798809 y = module.a[each.key].y
799810}
811+
812+ resource "test_resource" "test" {
813+ }
800814` ,
801815 "a/main.tf" : `
802816output "y" {
@@ -810,6 +824,7 @@ variable "y" {
810824
811825resource "test_resource" "unused" {
812826 value = var.y
827+ // missing required, but should not error
813828}
814829` ,
815830 })
@@ -823,7 +838,8 @@ resource "test_resource" "unused" {
823838 ResourceTypes : map [string ]* configschema.Block {
824839 "test_resource" : {
825840 Attributes : map [string ]* configschema.Attribute {
826- "id" : {Type : cty .String , Computed : true },
841+ "id" : {Type : cty .String , Computed : true },
842+ "required" : {Type : cty .String , Required : true },
827843 },
828844 },
829845 },
@@ -834,17 +850,8 @@ resource "test_resource" "unused" {
834850 {
835851 TypeName : "test_resource" ,
836852 State : cty .ObjectVal (map [string ]cty.Value {
837- "id" : cty .StringVal ("test" ),
838- }),
839- },
840- },
841- }
842- p .ImportResourceStateResponse = & providers.ImportResourceStateResponse {
843- ImportedResources : []providers.ImportedResource {
844- {
845- TypeName : "test_resource" ,
846- State : cty .ObjectVal (map [string ]cty.Value {
847- "id" : cty .StringVal ("test" ),
853+ "id" : cty .StringVal ("test" ),
854+ "required" : cty .StringVal ("value" ),
848855 }),
849856 },
850857 },
@@ -871,7 +878,7 @@ resource "test_resource" "unused" {
871878 }
872879
873880 ri := state .ResourceInstance (mustResourceInstanceAddr ("test_resource.test" ))
874- expected := `{"id":"test"}`
881+ expected := `{"id":"test","required":"value" }`
875882 if ri == nil || ri .Current == nil {
876883 t .Fatal ("no state is recorded for resource instance test_resource.test" )
877884 }
0 commit comments