-
Notifications
You must be signed in to change notification settings - Fork 79
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
feat(bigquery): add data_policy resource #668
base: main
Are you sure you want to change the base?
feat(bigquery): add data_policy resource #668
Conversation
Signed-off-by: nilan3 <[email protected]>
Signed-off-by: nilan3 <[email protected]>
Signed-off-by: nilan3 <[email protected]>
/test-examples="examples/bigquery/v1beta1/datapolicydatapolicy.yaml" |
Signed-off-by: nilan3 <[email protected]>
/test-examples="examples/bigquery/v1beta1/datapolicydatapolicyiambinding.yaml" |
/test-examples="examples/bigquery/v1beta1/datapolicydatapolicy.yaml" |
Signed-off-by: nilan3 <[email protected]>
/test-examples="examples/bigquery/v1beta1/datapolicydatapolicyiambinding.yaml" |
/test-examples="examples/bigquery/v1beta1/datapolicydatapolicy.yaml" |
@turkenf, could you help with reviewing this pls? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your efforts in this PR @nilan3, I left a few comments for you to consider.
p.AddResourceConfigurator("google_bigquery_datapolicy_data_policy_iam_binding", func(r *config.Resource) { | ||
r.References["data_policy_id"] = config.Reference{ | ||
TerraformName: "google_bigquery_datapolicy_data_policy", | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it is in the example in the terraform registry, the reference definition for data_policy_id should come automatically. If so, please remove the above configurations.
r.References["data_policy_id"] = config.Reference{ | ||
TerraformName: "google_bigquery_datapolicy_data_policy", | ||
} | ||
r.MarkAsRequired("location") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no need to mark the location field as required here since it comes from the data policy id.
@@ -827,6 +827,10 @@ var terraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{ | |||
"google_bigquery_table_iam_member": config.TemplatedStringAsIdentifier("", "projects/{{ .parameters.project }}/datasets/{{ .parameters.dataset_id }}/tables/{{ .parameters.table_id }} {{ .parameters.member }}"), | |||
// IAM policy imports use the identifier of the resource: projects/{{project}}/datasets/{{dataset_id}}/tables/{{table_id}} | |||
"google_bigquery_table_iam_policy": config.IdentifierFromProvider, | |||
// Imported with the following format: projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}} | |||
"google_bigquery_datapolicy_data_policy": config.TemplatedStringAsIdentifier("data_policy_id", "projects/{{ .parameters.project }}/locations/{{ .parameters.location }}/dataPolicies/{{ .external_name }}"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the project field is optional and to handle the cases where it is not given, it may be better to use the configuration below.
"google_bigquery_datapolicy_data_policy": config.TemplatedStringAsIdentifier("data_policy_id", "projects/{{ .parameters.project }}/locations/{{ .parameters.location }}/dataPolicies/{{ .external_name }}"), | |
"google_bigquery_datapolicy_data_policy": config.TemplatedStringAsIdentifier("data_policy_id", "projects/{{ if .parameters.project }}{{ .parameters.project }}{{ else }}{{ .setup.configuration.project }}{{ end }}/locations/{{ .parameters.location }}/dataPolicies/{{ .external_name }}"), |
// Imported with the following format: projects/{{project}}/locations/{{location}}/dataPolicies/{{data_policy_id}} | ||
"google_bigquery_datapolicy_data_policy": config.TemplatedStringAsIdentifier("data_policy_id", "projects/{{ .parameters.project }}/locations/{{ .parameters.location }}/dataPolicies/{{ .external_name }}"), | ||
// Binding resource can be imported using the data_policy_id and role: "projects/your-project-id/dataPolicies/data-policy-id roles/viewer" | ||
"google_bigquery_datapolicy_data_policy_iam_binding": config.TemplatedStringAsIdentifier("", "{{ .parameters.data_policy_id }} {{ .parameters.role }}"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see manual intervention in the resource's example. Could you please test this resource manually and provide logs/screenshots in the PR description showing that the create, delete, and import steps were successful?
Description of your changes
Add resources for the following terraform resources:
Fixes #
I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested