diff --git a/terraform/resource_address.go b/terraform/resource_address.go index b54a923d8..01d7e0c02 100644 --- a/terraform/resource_address.go +++ b/terraform/resource_address.go @@ -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\w+)\.` + + `(?P[^.]+)\.` + // "web" - `(?P\w+)` + + `(?P[^.[]+)` + // "tainted" (optional, omission implies: "primary") `(?:\.(?P\w+))?` + // "1" (optional, omission implies: "0") diff --git a/terraform/resource_address_test.go b/terraform/resource_address_test.go index 2a8caa1f8..f6439b2e8 100644 --- a/terraform/resource_address_test.go +++ b/terraform/resource_address_test.go @@ -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 {