Skip to content

Commit

Permalink
Merge pull request #1763 from hashicorp/b-fix-1699
Browse files Browse the repository at this point in the history
core: fix targeting with non-word chars
  • Loading branch information
phinze committed Apr 30, 2015
2 parents bd7d737 + 9295e1e commit 430e00c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 2 additions & 2 deletions terraform/resource_address.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 9 additions & 0 deletions terraform/resource_address_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 430e00c

Please sign in to comment.