-
Notifications
You must be signed in to change notification settings - Fork 378
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
[resource_datadog_domain_allowlist] Domain allowlist provider support #2637
Conversation
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'm curious whether there's been any product interest in eventually having separate domain allowlists for different email types, or if we plan to have one overarching one? If we might have many different Domain Allowlists, could this provider be easily backwards-compatible? We don't need a full solution now -- just want to get a sense for how much effort it might be to introduce a Allowlist Split in the future.
Perhaps if we still had a "Default" allowlist, and then optional "Override" allowlists for different email types, this would be easy to support.
@@ -356,6 +357,14 @@ func (i *ApiInstances) GetCSMThreatsApiV2() *datadogV2.CSMThreatsApi { | |||
return i.csmThreatsApiV2 | |||
} | |||
|
|||
// GetDoomainAllowlittApiV2 get instance of DowntimesApi |
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.
// GetDoomainAllowlittApiV2 get instance of DowntimesApi | |
// GetDomainAllowlistApiV2 get instance of DowntimesApi |
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.
Corrected and found a few other typos.
@@ -0,0 +1,4 @@ | |||
resource "datadog_ip_allowlist" "example" { | |||
enabled = true |
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.
How would this work if a user tried to set
enabled = true | |
enabled = False |
In the API this would be an invalid input -- does Terraform give similar feedback?
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.
So that should be able to be replicated within the tests. I updated to set that in line 72 in the test file
The error message from the command is
=== RUN TestAccDatadogDomainAllowlist_CreateUpdate
resource_datadog_domain_allowlist_test.go:21: Step 1/2 error: Error running pre-apply refresh: exit status 1
Error: Invalid reference
on terraform_plugin_test.tf line 3, in resource "datadog_domain_allowlist" "foo":
3: enabled = False
A reference to a resource type must be followed by at least one attribute
access, specifying the resource name.
I'm not sure if that's the general command error we return when the input is invalid in the provider.
If you want to confirm the command to run it against backend instead of the saved cassette file is TESTARGS="-run TestAccDatadogDomainAllowlist_CreateUpdate" make cassettes
I have seen some product interest from the beta customers to manage different email types in the domain allowlist from each other. I'm not sure there is any specific customers who have expressed interest in multiple different domain allowlists but it is possible. I'm checking with the PM whether that has ever been asked for by the beta customers. What you're suggesting should be easier to make it backwards compatible and matches the overall requests we have so far. If we had multiple lists to manage, it would be much harder to make this backwards compatible. We could think about making this internally a list to start but that might be overkill if we don't know whether that will ever be wanted. |
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.
LGTM, with some qs and nits.
Description: "The domains within the domain allowlist.", | ||
ElementType: types.StringType, | ||
Required: true, | ||
Computed: false, |
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.
Out-of-curiosity, what does this param computed
mean?
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.
From the hashicorp terraform-provider-framework comment
// Computed indicates whether the provider may return its own value for
// this Attribute or not. Required and Computed cannot both be true. If
// Required and Optional are both false, Computed must be true, and the
// attribute will be considered "read only" for the practitioner, with
// only the provider able to set its value.
remote_addr: "" | ||
request_uri: "" | ||
body: | | ||
{"data":{"attributes":{"domains":["@test.com","@datadoghq.com"],"enabled":true},"type":"domain_allowlist"}} |
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.
nit: domains
and enabled
aren't consistently in the same order in this file, not sure if it's autogenerated?
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.
Yeah this is autogenerated from the response from the server. Should be fine that they're out of order.
} | ||
resp, httpResp, err := r.Api.PatchDomainAllowlist(r.Auth, *domainAllowlistReq) | ||
if err != nil { | ||
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, " error updating domain allowlist"), "")) |
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.
nit:
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, " error updating domain allowlist"), "")) | |
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, "error updating domain allowlist"), "")) |
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.
updated this and the other comment in a new commit
domainAllowlistReq, _ := buildDomainAllowlistUpdateRequest(state) | ||
resp, httpResp, err := r.Api.PatchDomainAllowlist(r.Auth, *domainAllowlistReq) | ||
if err != nil { | ||
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, ""), "error updating email domain allowlist")) |
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.
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, ""), "error updating email domain allowlist")) | |
response.Diagnostics.Append(utils.FrameworkErrorDiag(utils.TranslateClientError(err, httpResp, ""), "error creating email domain allowlist")) |
In this context this might make more sense? But I don't feel strongly about this change, whatever makes more sense for user experience when config.
For the general release of the domain allowlist feature we need to support enabling the domain allowlist via terraform.
When enabled, the domain allowlist blocks emails of certain types from being sent to email domains outside the set list.