config: validate that data sources don't have provisioners

This commit is contained in:
Mitchell Hashimoto 2016-11-23 08:46:13 -08:00
parent 758322a1f8
commit 3665fea2db
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 19 additions and 0 deletions

View File

@ -610,6 +610,15 @@ func (c *Config) Validate() error {
"%s: lifecycle ignore_changes cannot contain interpolations",
n))
}
// If it is a data source then it can't have provisioners
if r.Mode == DataResourceMode {
if _, ok := r.RawConfig.Raw["provisioner"]; ok {
errs = append(errs, fmt.Errorf(
"%s: data sources cannot have provisioners",
n))
}
}
}
for source, vs := range vars {

View File

@ -161,6 +161,13 @@ func TestConfigValidate_table(t *testing.T) {
true,
"non-existent module 'foo'",
},
{
"data source with provisioners",
"validate-data-provisioner",
true,
"data sources cannot have",
},
}
for i, tc := range cases {

View File

@ -0,0 +1,3 @@
data "foo" "bar" {
provisioner "local-exec" {}
}