Merge pull request #1763 from hashicorp/b-fix-1699

core: fix targeting with non-word chars
This commit is contained in:
Paul Hinze 2015-04-30 16:34:19 -05:00
commit 430e00c55c
2 changed files with 11 additions and 2 deletions

View File

@ -77,9 +77,9 @@ func tokenizeResourceAddress(s string) (map[string]string, error) {
// string "aws_instance.web.tainted[1]"
re := regexp.MustCompile(`\A` +
// "aws_instance"
`(?P<type>\w+)\.` +
`(?P<type>[^.]+)\.` +
// "web"
`(?P<name>\w+)` +
`(?P<name>[^.[]+)` +
// "tainted" (optional, omission implies: "primary")
`(?:\.(?P<instance_type>\w+))?` +
// "1" (optional, omission implies: "0")

View File

@ -55,6 +55,15 @@ func TestParseResourceAddress(t *testing.T) {
Index: -1,
},
},
"with a hyphen": {
Input: "aws_instance.foo-bar",
Expected: &ResourceAddress{
Type: "aws_instance",
Name: "foo-bar",
InstanceType: TypePrimary,
Index: -1,
},
},
}
for tn, tc := range cases {