@@ -1745,3 +1745,42 @@ func TestTFVarsFileDoesNotExist(t *testing.T) {
1745
1745
_ , _ , err := parser .EvaluateAll (context .TODO ())
1746
1746
assert .ErrorContains (t , err , "file does not exist" )
1747
1747
}
1748
+
1749
+ func Test_AWSRegionNameDefined (t * testing.T ) {
1750
+
1751
+ fs := testutil .CreateFS (t , map [string ]string {
1752
+ "code/test.tf" : `
1753
+ data "aws_region" "current" {}
1754
+
1755
+ data "aws_region" "other" {
1756
+ name = "us-east-2"
1757
+ }
1758
+
1759
+ resource "something" "blah" {
1760
+ r1 = data.aws_region.current.name
1761
+ r2 = data.aws_region.other.name
1762
+ }
1763
+ ` ,
1764
+ })
1765
+
1766
+ parser := New (fs , "" , OptionStopOnHCLError (true ))
1767
+ require .NoError (t , parser .ParseFS (context .TODO (), "code" ))
1768
+ modules , _ , err := parser .EvaluateAll (context .TODO ())
1769
+ require .NoError (t , err )
1770
+ require .Len (t , modules , 1 )
1771
+ rootModule := modules [0 ]
1772
+
1773
+ blocks := rootModule .GetResourcesByType ("something" )
1774
+ require .Len (t , blocks , 1 )
1775
+ block := blocks [0 ]
1776
+
1777
+ r1 := block .GetAttribute ("r1" )
1778
+ require .NotNil (t , r1 )
1779
+ assert .True (t , r1 .IsResolvable ())
1780
+ assert .Equal (t , "current-region" , r1 .Value ().AsString ())
1781
+
1782
+ r2 := block .GetAttribute ("r2" )
1783
+ require .NotNil (t , r2 )
1784
+ assert .True (t , r2 .IsResolvable ())
1785
+ assert .Equal (t , "us-east-2" , r2 .Value ().AsString ())
1786
+ }
0 commit comments