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

Add Resources to Cloudflare Terraform Provider #2633

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,11 @@ type integrationCloudflareAccountResource struct {
}

type integrationCloudflareAccountModel struct {
ID types.String `tfsdk:"id"`
ApiKey types.String `tfsdk:"api_key"`
Email types.String `tfsdk:"email"`
Name types.String `tfsdk:"name"`
ID types.String `tfsdk:"id"`
ApiKey types.String `tfsdk:"api_key"`
Email types.String `tfsdk:"email"`
Name types.String `tfsdk:"name"`
Resources types.List `tfsdk:"resources"`
}

func NewIntegrationCloudflareAccountResource() resource.Resource {
Expand Down Expand Up @@ -67,6 +68,11 @@ func (r *integrationCloudflareAccountResource) Schema(_ context.Context, _ resou
},
},
"id": utils.ResourceIDAttribute(),
"resources": schema.ListAttribute{
apiazza-dd marked this conversation as resolved.
Show resolved Hide resolved
apiazza-dd marked this conversation as resolved.
Show resolved Hide resolved
ElementType: types.StringType,
Optional: true,
Description: "An allowlist of resources to restrict pulling metrics for including `web`, `dns`, `lb` (load balancer), `worker`)",
},
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ func TestAccIntegrationCloudflareAccountBasic(t *testing.T) {
"datadog_integration_cloudflare_account.foo", "email", "[email protected]"),
resource.TestCheckResourceAttr(
"datadog_integration_cloudflare_account.foo", "name", uniq),
resource.TestCheckResourceAttr(
"datadog_integration_cloudflare_account.foo", "resources.#", "2"),
resource.TestCheckResourceAttr(
"datadog_integration_cloudflare_account.foo", "resources.0", "lb"),
resource.TestCheckResourceAttr(
"datadog_integration_cloudflare_account.foo", "resources.1", "worker"),
),
},
},
Expand All @@ -46,6 +52,7 @@ resource "datadog_integration_cloudflare_account" "foo" {
api_key = "1234567891012331asdd"
email = "[email protected]"
name = "%s"
resources = ["lb", "worker"]
}`, uniq)
}

Expand Down
1 change: 1 addition & 0 deletions docs/resources/integration_cloudflare_account.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resource "datadog_integration_cloudflare_account" "foo" {
### Optional

- `email` (String) The email associated with the Cloudflare account. If an API key is provided (and not a token), this field is also required.
- `resources` (List of String) An allowlist of resources to restrict pulling metrics for including `web`, `dns`, `lb` (load balancer), `worker`)
Copy link
Contributor

@maycmlee maycmlee Oct 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `resources` (List of String) An allowlist of resources to restrict pulling metrics for including `web`, `dns`, `lb` (load balancer), `worker`)
- `resources` (List of String) An allowlist of resources, such as `web`, `dns`, `lb` (load balancer), `worker`, that restricts pulling metrics for those resources.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the restriction part is important here, by default, they're set to all, but if they want one turned off, then they use the resources list. Phrasing as an allow list makes it seem like if they specify one, they'll collect metrics for it, when it's the opposite.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apiazza-dd Ah okay, thanks for the clarification. I updated the suggestion, what do you think?

Copy link
Contributor

@maycmlee maycmlee Oct 31, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apiazza-dd actually rereading your comment, I might have misunderstood.

but if they want one turned off, then they use the resources list.

Is the allowlist of resources, the resources that users want to pull metrics for or the resources they don't want pulling metrics for? If it's the latter, i think i'm throw off by it being called an allowlist

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maycmlee These docs are autogenerated and have been updated to match our other repository. Does this look okay, or should I make a change in the other repo?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DM'd. Docs are autogenerated so the suggestion will be updated in the other repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


### Read-Only

Expand Down
Loading