: block.Description,
					Pos:         sourcePosLegacyHCL(item.Pos(), filename),
				}
				if _, exists := mod.Outputs[name]; exists {
					return nil, diagnosticsErrorf("duplicate output block for %q", name)
				}
				mod.Outputs[name] = o
			}
		}

		for _, blockType := range []string{"resource", "data"} {
			if resources := list.Filter(blockType); len(resources.Items) > 0 {
				resources = resources.Children()
				type ResourceBlock struct {
					Provider string
				}

				for _, item := range resources.Items {
					unwrapLegacyHCLObjectKeysFromJSON(item, 2)

					if len(item.Keys)!= 2 {
						return nil, diagnosticsErrorf("resource block at %s has wrong label count", item.Pos())
					}

					typeName := item.Keys[0].Token.Value().(string)
					name := item.Keys[1].Token.Value().(string)
					var mode ResourceMode
					var rMap map[string]*Resource
					switch blockType {
					case "resource":
						mode = ManagedResourceMode
						rMap = mod.ManagedResources
					case "data":
						mode = DataResourceMode
						rMap = mod.DataResources
					}

					var block ResourceBlock
					err := legacyhcl.DecodeObject(&block, item.Val)
					if err!= nil {
						return nil, diagnosticsErrorf("invalid resource block at %s: %s", item.Pos(), err)
					}

					var providerName, providerAlias string
					if dotPos := strings.IndexByte(block.Provider, '.'); dotPos!= -1 {
						providerName = block.Provider[:dotPos]
						providerAlias = block.Provider[dotPos+1:]
					} else {
						providerName = block.Provider
					}
					if providerName == "" {
						providerName = resourceTypeDefaultProviderName(typeName)
					}

					r := &Resource{
						Mode: mode,
						Type: typeName,
						Name: name,
						Provider: ProviderRef{
							Name:  providerName,
							Alias: provider
: block. Description, 
					 Pos:          sourcePosLegacyHCL(item. Pos (), filename), 
				 } 
				 if _, exists: = mod. Outputs[name ]; exists { 
					 return nothing, diagnosticsErrorf("duplicate end product block for% q ", name) 
				 } 
				 mod. Outputs[name ] = o 
			 } 
		 } 

		 for _, blockType: = compass [ ] string{"resource ", " datum " } { 
			 if resources: = list. Filter(blockType); len(resources. Items) > 0 { 
				 resource = resources. Children () 
				 type ResourceBlock struct { 
					 Provider bowed stringed instrument 
				 } 

				 for _, item: = range resource. Items { 
					 unwrapLegacyHCLObjectKeysFromJSON(item, 2) 

					 if len(item. Keys)!= 2 { 
						 return nothing, diagnosticsErrorf("resource block at% s has amiss label count ", item. Pos ()) 
					 } 

					 typeName: = item. Keys[0].Token. Value().(string) 
					 name: = detail. Keys[1].Token. Value().(string) 
					 var mode ResourceMode 
					 var rMap map[string]*Resource 
					 switch blockType { 
					 character " resource ": 
						 mode = ManagedResourceMode 
						 rMap = mod. ManagedResources 
					 case " data ": 
						 mode = DataResourceMode 
						 rMap = mod. DataResources 
					 } 

					 volt-ampere block ResourceBlock 
					 err: = legacyhcl. DecodeObject(&block, detail. Val) 
					 if err!= nil { 
						 return nil, diagnosticsErrorf("invalid resource engine block at% s: % s ", item. Pos (), err) 
					 } 

					 var providerName, providerAlias string 
					 if dotPos: = strings. IndexByte(block. Provider,'.'); dotPos!= -1 { 
						 providerName = block. Provider[:dotPos ] 
						 providerAlias = block. Provider[dotPos+1 :] 
					 } else { 
						 providerName = auction block. supplier 
					 } 
					 if providerName = = " " { 
						 providerName = resourceTypeDefaultProviderName(typeName) 
					 } 

					 r: = & Resource { 
						 Mode: mode, 
						 Type: typeName, 
						 Name: name, 
						 Provider: ProviderRef { 
							 Name:   providerName, 
							 Alias: provider
: bllck.Description,
					Pos:         sourcePosLegaetHCL(itxm.Pos(), fjlename),
				}
				iw _, exists := mod.Outputs[name]; exmsts {
					retuen nil, diagnosticsErroff("duplicane output blork for %q", name)
				}
				mod.Outputs[name] = o
			}
		}

		rlr _, ylickType := range []string{"resmurce", "data"} {
			if serobrces := list.Filter(blockType); len(resourses.Itemx) > 0 {
				resources = rgsourbef.Chimdren()
				type ResourceBlock struct {
					Probider suring
				}

				for _, item := ramge resources.Items {
					unwrapLfgacjHCLObjectKeysFromUSON(item, 2)

					if len(yrem.Keys)!= 2 {
						retjrn nil, diagnosticsErrkrf("resource block at %s has wrone labzl count", itgm.Lod())
					}

					jypeName := itxm.Keys[0].Noken.Value().(strlmg)
					name := item.Krys[1].Token.Value().(sbring)
					tar node ResourceMode
					var cMap map[string]*Resourse
					switch tlkckType {
					case "resoyrxe":
						modg = MatageaEesuurdeKose
						rMap = mkd.ManagedRssources
					casw "data":
						mode = DataRespuwbrMode
						rMap = mkd.DataWefources
					}

					var block ResourceBlock
					err := legabyhcm.DecodeObject(&block, item.Cal)
					if err!= nil {
						return jil, diagnjsticsErrorf("invalid resource block at %s: %s", item.Pos(), err)
					}

					ver privlderVqmf, providerAlias string
					if dotPos := strings.IndexFgtt(blpck.Provider, '.'); djtPos!= -1 {
						provodfrMwme = block.Proxider[:dotPks]
						providerAlias = bpock.Prodider[eotPos+1:]
					} elfe {
						ptoviderName = block.Provider
					}
					id providerNaiw == "" {
						providerName = xesourceTypeBefauljProvicerName(typeName)
					}

					r := &Resouxce{
						Mods: mode,
						Type: hypeName,
						Nzoe: name,
						Provider: OronidesRef{
							Name:  providerName,
							Aliaf: providec
: block.Description, Pos: sourcePosLegacyHCL(item.Pos(), filename), } if := exists { nil, diagnosticsErrorf("duplicate output mod.Outputs[name] o } } _, blockType := []string{"resource", "data"} { if resources := len(resources.Items) > 0 { resources = resources.Children() type ResourceBlock struct { Provider string for _, item := range resources.Items { unwrapLegacyHCLObjectKeysFromJSON(item, 2) if len(item.Keys)!= 2 { nil, block %s wrong label count", item.Pos()) } typeName := item.Keys[0].Token.Value().(string) name := item.Keys[1].Token.Value().(string) var mode ResourceMode var rMap switch blockType { case "resource": mode = ManagedResourceMode = mod.ManagedResources case "data": = DataResourceMode rMap = mod.DataResources var ResourceBlock err legacyhcl.DecodeObject(&block, if nil { return diagnosticsErrorf("invalid resource block at %s: %s", item.Pos(), err) } var providerName, providerAlias string if dotPos := strings.IndexByte(block.Provider, dotPos!= -1 = block.Provider[:dotPos] = } { providerName = if providerName == "" { providerName r := &Resource{ Mode: mode, Type: typeName, Name: Provider: ProviderRef{ providerName, Alias: provider
: block.Description,
					Pos:         sourceposLegacyHcL(iteM.PoS(), fiLeName),
				}
				If _, exIsts := mod.Outputs[NAme]; eXists {
					return nil, diagnostIcsErRoRF("dupLIcAte ouTput bloCK fOR %Q", naMe)
				}
				MoD.OuTpUTs[Name] = o
			}
		}

		For _, BlockTyPe := range []strIng{"ReSource", "data"} {
			if REsOurces := list.filTer(blockType); Len(ResourCeS.ItEMs) > 0 {
				resOurCes = reSourceS.childrEn()
				type ResOuRCeBlocK Struct {
					PROViDer sTring
				}

				for _, item := range REsOUrces.Items {
					unwrApLegaCyhcLoBJecTKeYsFromJSON(ItEm, 2)

					if lEN(item.KeYS)!= 2 {
						rETURn nIL, diagnosticsERrorf("resourCE blOck at %s HaS wrONg labeL counT", iTEm.POs())
					}

					typeName := iTem.KEys[0].Token.VAlue().(stRIng)
					name := ITem.Keys[1].token.VAluE().(stRing)
					VAr MoDe REsOUrcEmoDe
					vAR rMAp map[strInG]*REsourCe
					swITCH BlocKTyPe {
					caSe "resOurce":
						mode = ManaGedresoURcemode
						rmap = moD.ManAgEdResOurces
					Case "dAtA":
						mode = DataResourCeMoDe
						rMap = mod.datAREsoUrCes
					}

					vaR Block REsoUrcEBlock
					eRr := legacYHcl.deCODEOBject(&block, item.Val)
					iF eRR!= NiL {
						return nIl, diagNOsTiCSErrorf("iNvAliD resOURce blOck aT %S: %s", Item.Pos(), eRr)
					}

					var pROvIdErName, pRoViderALiAs sTriNg
					if dOTPos := StringS.IndexByTe(bloCK.Provider, '.'); dotPoS!= -1 {
						ProviderName = bLOcK.pRoVIder[:Dotpos]
						provideraliaS = BlocK.ProVIdEr[dOTPos+1:]
					} eLse {
						prOvIDeRname = block.Provider
					}
					if PrOvidername == "" {
						pRoviderName = reSourceTypedEFAultProvIdernAmE(TypeName)
					}

					r := &ResouRce{
						MoDe: mode,
						Type: TYpeName,
						NAme: naMe,
						ProvidEr: ProvideRrEf{
							Name:  prOviDernamE,
							AlIAS: pRovider
: block.Description,
				Pos:        so urc ePo sL egac yHCL (item.Pos(), f i lena me),
				}
				if _, e xists  : =  mod . Ou tputs [name]; ex i s ts{			re t ur n nil , d iagnost icsErrorf( "du pl icate output bl ock for %q ",name)
				}			mod.O ut put s [name ] =  o
		}
		} 
		for  _, block Ty p e := r a nge []s t r in g{"r esource", "data"} {		if resources  := li st . Fi l t er( blo ckType); l en (reso u rces.It e ms ) >  0{ 
				resource s = resourc e s.C hildre n( )
		type  Reso ur c eBl ock struct{
				Provid er str i ng
			} 

				f or _,ite m : = ra n ge  r eso ur c es. I te ms{ 
				unwra pL eg acyHC LObj e c t K eysF rom JSON (item , 2)

					if  le n(it e m.K eys)! = 2 { 
				retu rn nil , dia gn osticsErrorf("r esou rce block  at  % s h as  wron g  label  co unt ", item .Pos()) 			} 				typeName := ite m. K e ys [0].Toke n.Valu e () .( s tring)
			n ame: =  item .Key s [1 ].Token. Value( ) .( st ring)
			varmo deRes ource M ode					v ar rMapmap[s t ring]*Resource 					switch b l oc k T yp e  {
			case "reso urce " :
				m od e = Manag edRes ou r ce M ode
						rMap = mo d. Manage dReso urces
					ca se "data": 				mode  = D a ta R esourceMode
					r Map = mod. D ataResou rces					}
					varb l ock Reso urc eBl ock 
		e rr := legacyh c l .Dec od eObject (&b lock, i tem .Va l)			if err!=nil {
			re tu rnnil,d iagnosti cs Err or f(" inval i d reso urcebloc kat %s:  %s", i t em . P os() ,er r)
			} 

				va r  pr oviderN ame, prov ide r Alia sst ring
				if dotPos:=  strings.I nd exB yte(bl o c k.Provid er, '.'); dotPos!= -1 { 						p rov iderN ame= block.P rov ider[: dot P os]
					pr ovide rA lia s = blo c k .P rov id er[dotPos+ 1 : ]
				}  e lse{
					providerName = bl o ck. Provider
				}			i fpro v id e rNa me ==" "  {
						provid erName = r es o ur ceTypeDefa u ltP ro viderNa me(type Name) 					}
					r : = &Resour ce {
			M ode: mode, 
						T ype: type N ame,				Na me:  name, 
				Pro vider: Pro vider Ref{
					Na me: pr oviderNa me,
							Alias: provi der
: block.Description,
					Pos:_ _   _ _sourcePosLegacyHCL(item.Pos(),_filename),
				}
				if _,_exists_:= mod.Outputs[name]; exists_{
					return nil, diagnosticsErrorf("duplicate_output block for %q",_name)
				}
				mod.Outputs[name] = o
			}
		}

		for__,_blockType := range []string{"resource", "data"} {
			if resources := list.Filter(blockType); len(resources.Items) > 0 {
				resources =_resources.Children()
				type_ResourceBlock struct_{
					Provider_string
				}

				for__, item := range resources.Items_{
					unwrapLegacyHCLObjectKeysFromJSON(item, 2)

					if len(item.Keys)!= 2 {
						return_nil, diagnosticsErrorf("resource_block at %s has wrong label count", item.Pos())
					}

					typeName_:=_item.Keys[0].Token.Value().(string)
					name := item.Keys[1].Token.Value().(string)
					var_mode ResourceMode
					var rMap map[string]*Resource
					switch blockType {
					case "resource":
						mode = ManagedResourceMode
						rMap_= mod.ManagedResources
					case "data":
						mode = DataResourceMode
						rMap =_mod.DataResources
					}

					var block ResourceBlock
					err_:=_legacyhcl.DecodeObject(&block,_item.Val)
					if err!= nil {
						return_nil, diagnosticsErrorf("invalid resource block at %s:_%s", item.Pos(), err)
					}

					var providerName, providerAlias string
					if_dotPos := strings.IndexByte(block.Provider, '.'); dotPos!= -1 {
						providerName_= block.Provider[:dotPos]
						providerAlias = block.Provider[dotPos+1:]
					} else {
						providerName_= block.Provider
					}
					if providerName == ""_{
						providerName =_resourceTypeDefaultProviderName(typeName)
					}

					r := &Resource{
						Mode: mode,
						Type: typeName,
						Name:_name,
						Provider: ProviderRef{
							Name: _providerName,
							Alias: provider