Skip to content

Commit 6e90b0a

Browse files
authored
[resource_datadog_custom_allocation_rules] add the functionality to allow users decide custom allocation rule reorder behaviors (#3324)
add the functionality to allow users define the reorder behaviors refactor code add and record more tests add docs and exmaples remove extra format update docs record more tests add ui override for custom allocation rule add unit tests record tests update docs update example remove local provider merge from master refactor the code record tests update doc Update docs/resources/custom_allocation_rules.md Co-authored-by: Rosa Trieu <[email protected]> Update docs/resources/custom_allocation_rules.md Co-authored-by: Rosa Trieu <[email protected]> Update docs/resources/custom_allocation_rules.md Co-authored-by: Rosa Trieu <[email protected]> format doc Co-authored-by: cong.xie <[email protected]>
1 parent d12d516 commit 6e90b0a

22 files changed

+5839
-410
lines changed

datadog/fwprovider/resource_datadog_custom_allocation_rules.go

Lines changed: 474 additions & 53 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-08T14:50:03.319536-04:00
1+
2025-11-17T10:47:33.007998-05:00

datadog/tests/cassettes/TestAccDatadogCustomAllocationRuleOrder_Basic.yaml

Lines changed: 143 additions & 77 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-08T14:50:16.206357-04:00
1+
2025-11-17T10:51:40.095128-05:00

datadog/tests/cassettes/TestAccDatadogCustomAllocationRuleOrder_Import.yaml

Lines changed: 150 additions & 84 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-08T14:50:20.674837-04:00
1+
2025-11-17T10:51:50.272841-05:00

datadog/tests/cassettes/TestAccDatadogCustomAllocationRuleOrder_SingleRule.yaml

Lines changed: 104 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interactions:
1313
remote_addr: ""
1414
request_uri: ""
1515
body: |
16-
{"data":{"attributes":{"costs_to_allocate":[{"condition":"is","tag":"aws_product","value":"AmazonEC2"}],"enabled":true,"provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1759949420","strategy":{"allocated_by_tag_keys":["team"],"based_on_costs":[{"condition":"is","tag":"aws_product","value":"AmazonEC2"}],"granularity":"daily","method":"even"},"type":"shared"},"type":"upsert_arbitrary_rule"}}
16+
{"data":{"attributes":{"costs_to_allocate":[{"condition":"is","tag":"aws_product","value":"AmazonEC2"}],"enabled":true,"provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"allocated_by_tag_keys":["team"],"based_on_costs":[{"condition":"is","tag":"aws_product","value":"AmazonEC2"}],"granularity":"daily","method":"even"},"type":"shared"},"type":"upsert_arbitrary_rule"}}
1717
form: {}
1818
headers:
1919
Accept:
@@ -23,20 +23,20 @@ interactions:
2323
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
2424
method: POST
2525
response:
26-
proto: HTTP/2.0
27-
proto_major: 2
28-
proto_minor: 0
26+
proto: HTTP/1.1
27+
proto_major: 1
28+
proto_minor: 1
2929
transfer_encoding: []
3030
trailer: {}
31-
content_length: 663
31+
content_length: 664
3232
uncompressed: false
33-
body: '{"data":{"id":"930","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-10-08T18:50:21.171758507Z","enabled":true,"last_modified_user_uuid":"bc462b6c-b8dd-11eb-abf5-da7ad0900001","order_id":1,"provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1759949420","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-10-08T18:50:21.171758507Z","version":1}}}'
33+
body: '{"data":{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281043Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281043Z","version":1}}}'
3434
headers:
3535
Content-Type:
3636
- application/vnd.api+json
3737
status: 200 OK
3838
code: 200
39-
duration: 40.501417ms
39+
duration: 86.755041ms
4040
- id: 1
4141
request:
4242
proto: HTTP/1.1
@@ -56,33 +56,33 @@ interactions:
5656
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
5757
method: GET
5858
response:
59-
proto: HTTP/2.0
60-
proto_major: 2
61-
proto_minor: 0
59+
proto: HTTP/1.1
60+
proto_major: 1
61+
proto_minor: 1
6262
transfer_encoding: []
6363
trailer: {}
64-
content_length: 717
64+
content_length: 713
6565
uncompressed: false
66-
body: '{"data":[{"id":"930","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-10-08T18:50:21.171758Z","enabled":true,"last_modified_user_uuid":"bc462b6c-b8dd-11eb-abf5-da7ad0900001","order_id":1,"processing_status":"processing","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1759949420","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-10-08T18:50:21.171758Z","version":1}}],"meta":{"total_count":1}}'
66+
body: '{"data":[{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"processing_status":"error","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281Z","version":1}}],"meta":{"total_count":1}}'
6767
headers:
6868
Content-Type:
6969
- application/vnd.api+json
7070
status: 200 OK
7171
code: 200
72-
duration: 955.233542ms
72+
duration: 118.898292ms
7373
- id: 2
7474
request:
7575
proto: HTTP/1.1
7676
proto_major: 1
7777
proto_minor: 1
78-
content_length: 48
78+
content_length: 49
7979
transfer_encoding: []
8080
trailer: {}
8181
host: api.datadoghq.com
8282
remote_addr: ""
8383
request_uri: ""
8484
body: |
85-
{"data":[{"id":"930","type":"arbitrary_rule"}]}
85+
{"data":[{"id":"2344","type":"arbitrary_rule"}]}
8686
form: {}
8787
headers:
8888
Accept:
@@ -92,9 +92,9 @@ interactions:
9292
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule/reorder
9393
method: POST
9494
response:
95-
proto: HTTP/2.0
96-
proto_major: 2
97-
proto_minor: 0
95+
proto: HTTP/1.1
96+
proto_major: 1
97+
proto_minor: 1
9898
transfer_encoding: []
9999
trailer: {}
100100
content_length: 0
@@ -103,7 +103,7 @@ interactions:
103103
headers: {}
104104
status: 204 No Content
105105
code: 204
106-
duration: 34.651375ms
106+
duration: 42.676833ms
107107
- id: 3
108108
request:
109109
proto: HTTP/1.1
@@ -120,23 +120,23 @@ interactions:
120120
headers:
121121
Accept:
122122
- application/json
123-
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule/930
123+
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
124124
method: GET
125125
response:
126-
proto: HTTP/2.0
127-
proto_major: 2
128-
proto_minor: 0
126+
proto: HTTP/1.1
127+
proto_major: 1
128+
proto_minor: 1
129129
transfer_encoding: []
130130
trailer: {}
131-
content_length: 690
131+
content_length: 713
132132
uncompressed: false
133-
body: '{"data":{"id":"930","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-10-08T18:50:21.171758Z","enabled":true,"last_modified_user_uuid":"bc462b6c-b8dd-11eb-abf5-da7ad0900001","order_id":1,"processing_status":"processing","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1759949420","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-10-08T18:50:21.171758Z","version":1}}}'
133+
body: '{"data":[{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"processing_status":"error","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281Z","version":1}}],"meta":{"total_count":1}}'
134134
headers:
135135
Content-Type:
136136
- application/vnd.api+json
137137
status: 200 OK
138138
code: 200
139-
duration: 681.418459ms
139+
duration: 90.912875ms
140140
- id: 4
141141
request:
142142
proto: HTTP/1.1
@@ -153,24 +153,90 @@ interactions:
153153
headers:
154154
Accept:
155155
- application/json
156-
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
156+
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule/2344
157157
method: GET
158158
response:
159-
proto: HTTP/2.0
160-
proto_major: 2
161-
proto_minor: 0
159+
proto: HTTP/1.1
160+
proto_major: 1
161+
proto_minor: 1
162162
transfer_encoding: []
163163
trailer: {}
164-
content_length: 717
164+
content_length: 686
165165
uncompressed: false
166-
body: '{"data":[{"id":"930","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-10-08T18:50:21.171758Z","enabled":true,"last_modified_user_uuid":"bc462b6c-b8dd-11eb-abf5-da7ad0900001","order_id":1,"processing_status":"processing","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1759949420","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-10-08T18:50:21.171758Z","version":1}}],"meta":{"total_count":1}}'
166+
body: '{"data":{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"processing_status":"error","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281Z","version":1}}}'
167167
headers:
168168
Content-Type:
169169
- application/vnd.api+json
170170
status: 200 OK
171171
code: 200
172-
duration: 759.338167ms
172+
duration: 102.797334ms
173173
- id: 5
174+
request:
175+
proto: HTTP/1.1
176+
proto_major: 1
177+
proto_minor: 1
178+
content_length: 0
179+
transfer_encoding: []
180+
trailer: {}
181+
host: api.datadoghq.com
182+
remote_addr: ""
183+
request_uri: ""
184+
body: ""
185+
form: {}
186+
headers:
187+
Accept:
188+
- application/json
189+
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
190+
method: GET
191+
response:
192+
proto: HTTP/1.1
193+
proto_major: 1
194+
proto_minor: 1
195+
transfer_encoding: []
196+
trailer: {}
197+
content_length: 713
198+
uncompressed: false
199+
body: '{"data":[{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"processing_status":"error","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281Z","version":1}}],"meta":{"total_count":1}}'
200+
headers:
201+
Content-Type:
202+
- application/vnd.api+json
203+
status: 200 OK
204+
code: 200
205+
duration: 88.653958ms
206+
- id: 6
207+
request:
208+
proto: HTTP/1.1
209+
proto_major: 1
210+
proto_minor: 1
211+
content_length: 0
212+
transfer_encoding: []
213+
trailer: {}
214+
host: api.datadoghq.com
215+
remote_addr: ""
216+
request_uri: ""
217+
body: ""
218+
form: {}
219+
headers:
220+
Accept:
221+
- application/json
222+
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule
223+
method: GET
224+
response:
225+
proto: HTTP/1.1
226+
proto_major: 1
227+
proto_minor: 1
228+
transfer_encoding: []
229+
trailer: {}
230+
content_length: 713
231+
uncompressed: false
232+
body: '{"data":[{"id":"2344","type":"arbitrary_rule","attributes":{"costs_to_allocate":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"created":"2025-11-17T15:51:52.351281Z","enabled":true,"last_modified_user_uuid":"3ad549bf-eba0-11e9-a77a-0705486660d0","order_id":1,"processing_status":"error","provider":["aws"],"rule_name":"tf-test-order-single-tf-TestAccDatadogCustomAllocationRuleOrder_SingleRule-local-1763394710","strategy":{"method":"even","granularity":"daily","based_on_costs":[{"tag":"aws_product","condition":"is","value":"AmazonEC2","values":null}],"allocated_by_tag_keys":["team"]},"type":"shared","updated":"2025-11-17T15:51:52.351281Z","version":1}}],"meta":{"total_count":1}}'
233+
headers:
234+
Content-Type:
235+
- application/vnd.api+json
236+
status: 200 OK
237+
code: 200
238+
duration: 97.732042ms
239+
- id: 7
174240
request:
175241
proto: HTTP/1.1
176242
proto_major: 1
@@ -186,12 +252,12 @@ interactions:
186252
headers:
187253
Accept:
188254
- '*/*'
189-
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule/930
255+
url: https://api.datadoghq.com/api/v2/cost/arbitrary_rule/2344
190256
method: DELETE
191257
response:
192-
proto: HTTP/2.0
193-
proto_major: 2
194-
proto_minor: 0
258+
proto: HTTP/1.1
259+
proto_major: 1
260+
proto_minor: 1
195261
transfer_encoding: []
196262
trailer: {}
197263
content_length: 0
@@ -200,4 +266,4 @@ interactions:
200266
headers: {}
201267
status: 204 No Content
202268
code: 204
203-
duration: 42.138542ms
269+
duration: 46.437875ms
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2025-10-08T14:50:08.516724-04:00
1+
2025-11-17T10:51:29.16869-05:00

0 commit comments

Comments
 (0)