Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic an 667 dest access rules #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions client/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ type Destination struct {
Labels []string `json:"labels"`
Attributes []Attribute `json:"attributes"`
Warehouse string `json:"warehouse,omitempty"`
AccessRules []AccessRule `json:"accessRules"`
}

// GCSStagingArea ...
Expand Down
25 changes: 25 additions & 0 deletions client/resource_destination.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ func ResourceDestination() *schema.Resource {
Description: "Attributes (key value pairs) to attach to the object",
Elem: attributeSchema(),
},
"access_rule": {
Type: schema.TypeList,
Optional: true,
Description: "Access rules to attach to the object",
Elem: accessRuleSchema(),
},
},
}
}
Expand Down Expand Up @@ -320,6 +326,9 @@ func resourceDestinationRead(d *schema.ResourceData, m interface{}) error {
if err := d.Set("attribute", flattenAttributes(destination.Attributes)); err != nil {
return err
}
if err := d.Set("access_rule", flattenAccessRules(destination.AccessRules)); err != nil {
return err
}
return err
}

Expand Down Expand Up @@ -570,6 +579,11 @@ func parseSnowflakeDestination(destination *Destination) ([]map[string]interface
}

func composeDestination(d *schema.ResourceData) (*Destination, error) {
accessRules, err := expandAccessRules(d.Get("access_rule").([]interface{}))
if err != nil {
return nil, err
}

if s3, _ := expandSingleMap(d.Get("s3")); s3 != nil {
fileFormat := composeFileFormat(s3)
destination := Destination{
Expand All @@ -581,6 +595,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
FileFormat: fileFormat,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -599,6 +614,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
FileFormat: fileFormat,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -623,6 +639,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
CredentialsProvider: credentialsProvider,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -635,6 +652,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
Database: hive["database"].(string),
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -653,6 +671,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
StagingArea: stagingArea,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -668,6 +687,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
FileFormat: fileFormat,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -682,6 +702,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
FileFormat: fileFormat,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -696,6 +717,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
FileFormat: fileFormat,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -720,6 +742,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
CredentialsProvider: credentialsProvider,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand Down Expand Up @@ -755,6 +778,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
KafkaProperties: sensitives,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand All @@ -781,6 +805,7 @@ func composeDestination(d *schema.ResourceData) (*Destination, error) {
CredentialsProvider: credentialsProvider,
Labels: expandStringList(d.Get("labels").([]interface{})),
Attributes: expandAttributes(d),
AccessRules: accessRules,
}
return &destination, nil
}
Expand Down
14 changes: 14 additions & 0 deletions example/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ resource "anaml-operations_feature_store" "household_daily" {
feature_set = anaml_feature_set.household.id
enabled = true
cluster = data.anaml-operations_cluster.local.id
principal = anaml-operations_user.john.id
destination {
destination = data.anaml-operations_destination.s3a.id
folder {
Expand All @@ -194,6 +195,7 @@ resource "anaml-operations_feature_store" "household_cron" {
feature_set = anaml_feature_set.household.id
enabled = true
cluster = data.anaml-operations_cluster.local.id
principal = anaml-operations_user.john.id
entity_population = anaml_entity_population.adults.id
destination {
destination = data.anaml-operations_destination.s3a.id
Expand All @@ -215,6 +217,7 @@ resource "anaml-operations_feature_store" "household_never" {
feature_set = anaml_feature_set.household.id
enabled = true
cluster = data.anaml-operations_cluster.local.id
principal = anaml-operations_user.john.id
destination {
destination = data.anaml-operations_destination.s3a.id
folder {
Expand All @@ -230,6 +233,7 @@ resource "anaml-operations_feature_store" "household_daily_retry" {
feature_set = anaml_feature_set.household.id
enabled = true
cluster = data.anaml-operations_cluster.local.id
principal = anaml-operations_user.john.id
destination {
destination = data.anaml-operations_destination.s3a.id
folder {
Expand All @@ -253,6 +257,7 @@ resource "anaml-operations_feature_store" "household_cron_retry" {
feature_set = anaml_feature_set.household.id
enabled = true
cluster = data.anaml-operations_cluster.local.id
principal = anaml-operations_user.john.id
destination {
destination = data.anaml-operations_destination.s3a.id
folder {
Expand Down Expand Up @@ -472,6 +477,15 @@ resource "anaml-operations_destination" "s3" {
file_format = "csv"
include_header = true
}
access_rule {
resource = "customers"

principals {
user_group {
id = anaml-operations_user_group.engineering.id
}
}
}
}

resource "anaml-operations_destination" "s3a" {
Expand Down