diff --git a/docs/resources/stage_grant.md b/docs/resources/stage_grant.md index 69ec681d29..c144f897ce 100644 --- a/docs/resources/stage_grant.md +++ b/docs/resources/stage_grant.md @@ -39,10 +39,9 @@ resource snowflake_stage_grant grant { ### Optional - **id** (String) The ID of this resource. -- **on_future** (Boolean) When this is set to true and a schema_name is provided, apply this grant on all future stages in the given schema. When this is true and no schema_name is provided apply this grant on all future stages in the given database. The stage_name and shares fields must be unset in order to use on_future. +- **on_future** (Boolean) When this is set to true and a schema_name is provided, apply this grant on all future stages in the given schema. When this is true and no schema_name is provided apply this grant on all future stages in the given database. The stage_name field must be unset in order to use on_future. - **privilege** (String) The privilege to grant on the stage. - **roles** (Set of String) Grants privilege to these roles. -- **shares** (Set of String) Grants privilege to these shares (only valid if on_future is false). - **stage_name** (String) The name of the stage on which to grant privilege (only valid if on_future is false). - **with_grant_option** (Boolean) When this is set to true, allows the recipient role to grant the privileges to other roles. diff --git a/pkg/resources/stage_grant.go b/pkg/resources/stage_grant.go index 23b569dab9..88b6d459a3 100644 --- a/pkg/resources/stage_grant.go +++ b/pkg/resources/stage_grant.go @@ -49,20 +49,13 @@ var stageGrantSchema = map[string]*schema.Schema{ Description: "Grants privilege to these roles.", ForceNew: true, }, - "shares": { - Type: schema.TypeSet, - Elem: &schema.Schema{Type: schema.TypeString}, - Optional: true, - Description: "Grants privilege to these shares (only valid if on_future is false).", - ForceNew: true, - }, "on_future": { Type: schema.TypeBool, Optional: true, - Description: "When this is set to true and a schema_name is provided, apply this grant on all future stages in the given schema. When this is true and no schema_name is provided apply this grant on all future stages in the given database. The stage_name and shares fields must be unset in order to use on_future.", + Description: "When this is set to true and a schema_name is provided, apply this grant on all future stages in the given schema. When this is true and no schema_name is provided apply this grant on all future stages in the given database. The stage_name field must be unset in order to use on_future.", Default: false, ForceNew: true, - ConflictsWith: []string{"stage_name", "shares"}, + ConflictsWith: []string{"stage_name"}, }, "with_grant_option": { Type: schema.TypeBool, diff --git a/pkg/resources/stage_grant_test.go b/pkg/resources/stage_grant_test.go index 3c92bc5b09..cd056d8772 100644 --- a/pkg/resources/stage_grant_test.go +++ b/pkg/resources/stage_grant_test.go @@ -30,7 +30,6 @@ func TestStageGrantCreate(t *testing.T) { "database_name": "test-db", "privilege": test_priv, "roles": []interface{}{"test-role-1", "test-role-2"}, - "shares": []interface{}{"test-share-1", "test-share-2"}, "with_grant_option": true, } d := schema.TestResourceDataRaw(t, resources.StageGrant().Resource.Schema, in) @@ -39,8 +38,6 @@ func TestStageGrantCreate(t *testing.T) { WithMockDb(t, func(db *sql.DB, mock sqlmock.Sqlmock) { mock.ExpectExec(fmt.Sprintf(`^GRANT %s ON STAGE "test-db"."test-schema"."test-stage" TO ROLE "test-role-1" WITH GRANT OPTION$`, test_priv)).WillReturnResult(sqlmock.NewResult(1, 1)) mock.ExpectExec(fmt.Sprintf(`^GRANT %s ON STAGE "test-db"."test-schema"."test-stage" TO ROLE "test-role-2" WITH GRANT OPTION$`, test_priv)).WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectExec(fmt.Sprintf(`^GRANT %s ON STAGE "test-db"."test-schema"."test-stage" TO SHARE "test-share-1" WITH GRANT OPTION$`, test_priv)).WillReturnResult(sqlmock.NewResult(1, 1)) - mock.ExpectExec(fmt.Sprintf(`^GRANT %s ON STAGE "test-db"."test-schema"."test-stage" TO SHARE "test-share-2" WITH GRANT OPTION$`, test_priv)).WillReturnResult(sqlmock.NewResult(1, 1)) expectReadStageGrant(mock, test_priv) err := resources.CreateStageGrant(d, db) r.NoError(err) @@ -57,7 +54,6 @@ func TestStageGrantRead(t *testing.T) { "database_name": "test-db", "privilege": "USAGE", "roles": []interface{}{}, - "shares": []interface{}{}, "with_grant_option": false, }) @@ -73,11 +69,6 @@ func TestStageGrantRead(t *testing.T) { r.True(roles.Contains("test-role-1")) r.True(roles.Contains("test-role-2")) r.Equal(roles.Len(), 2) - - shares := d.Get("shares").(*schema.Set) - r.True(shares.Contains("test-share-1")) - r.True(shares.Contains("test-share-2")) - r.Equal(shares.Len(), 2) } func expectReadStageGrant(mock sqlmock.Sqlmock, test_priv string) { @@ -87,10 +78,6 @@ func expectReadStageGrant(mock sqlmock.Sqlmock, test_priv string) { time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), test_priv, "STAGE", "test-stage", "ROLE", "test-role-1", false, "bob", ).AddRow( time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), test_priv, "STAGE", "test-stage", "ROLE", "test-role-2", false, "bob", - ).AddRow( - time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), test_priv, "STAGE", "test-stage", "SHARE", "test-share-1", false, "bob", - ).AddRow( - time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC), test_priv, "STAGE", "test-stage", "SHARE", "test-share-2", false, "bob", ) mock.ExpectQuery(`^SHOW GRANTS ON STAGE "test-db"."test-schema"."test-stage"$`).WillReturnRows(rows) }