Skip to content

Commit 5fa6089

Browse files
authored
Revert stable 8 backports (#2462)
SUMMARY Reverts two backports for minor features that were intended to be released in 8.3.0, but were instead released in 9.0.0. As such, they are being removed from this branch to reflect what we actually did. Reviewed-by: Alina Buzachis Reviewed-by: Mike Graves <[email protected]> Reviewed-by: Mark Chappell
1 parent f468f20 commit 5fa6089

File tree

8 files changed

+136
-394
lines changed

8 files changed

+136
-394
lines changed

Diff for: changelogs/fragments/20240906-cloudwatch-log-metric-filter-unit-dimensions.yml

-3
This file was deleted.

Diff for: changelogs/fragments/20250114-revert-backports.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
trivial:
3+
- Revert backports that ended up being released in 9.0.0. (https://github.com/ansible-collections/amazon.aws/pull/2462)

Diff for: changelogs/fragments/ec2_vpc_rote_table_transit_gateway.yml

-3
This file was deleted.

Diff for: plugins/modules/cloudwatchlogs_log_group_metric_filter.py

+19-62
Original file line numberDiff line numberDiff line change
@@ -56,22 +56,7 @@
5656
default_value:
5757
description:
5858
- The value to emit when a filter pattern does not match a log event.
59-
- The I(default_value) and I(dimensions) options are mutually exclusive.
6059
type: float
61-
unit:
62-
description:
63-
- The unit of the value.
64-
- The various options are available `here <https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/API_MetricDatum.html>`.
65-
type: str
66-
version_added: 8.3.0
67-
dimensions:
68-
description:
69-
- A dimension is a name/value pair that is a part of the identity of a metric.
70-
- You can assign up to 3 dimensions to a metric.
71-
- Dimensions are only supported for JSON or space-delimited metric filters.
72-
- The I(default_value) and I(dimensions) options are mutually exclusive.
73-
type: dict
74-
version_added: 8.3.0
7560
extends_documentation_fragment:
7661
- amazon.aws.common.modules
7762
- amazon.aws.region.modules
@@ -89,26 +74,12 @@
8974
metric_name: box_free_space
9075
metric_namespace: fluentd_metrics
9176
metric_value: "$.value"
92-
unit: Bytes
9377
9478
- name: delete metric filter on log group /fluentd/testcase
9579
amazon.aws.cloudwatchlogs_log_group_metric_filter:
9680
log_group_name: /fluentd/testcase
9781
filter_name: BoxFreeStorage
9882
state: absent
99-
100-
- name: set metric filter on log group /fluentd/testcase with dimensions
101-
amazon.aws.cloudwatchlogs_log_group_metric_filter:
102-
log_group_name: /fluentd/testcase
103-
filter_name: BoxFreeStorage
104-
filter_pattern: '{($.value = *) && ($.hostname = *)}'
105-
state: present
106-
metric_transformation:
107-
metric_name: box_free_space
108-
metric_namespace: fluentd_metrics
109-
metric_value: "$.value"
110-
dimensions:
111-
hostname: $.hostname
11283
"""
11384

11485
RETURN = r"""
@@ -121,11 +92,7 @@
12192
"default_value": 3.1415,
12293
"metric_name": "box_free_space",
12394
"metric_namespace": "made_with_ansible",
124-
"metric_value": "$.value",
125-
"unit": "Bytes",
126-
"dimensions": {
127-
"hostname": "$.hostname"
128-
}
95+
"metric_value": "$.value"
12996
}
13097
]
13198
"""
@@ -139,32 +106,30 @@ def metricTransformationHandler(metricTransformations, originMetricTransformatio
139106
if originMetricTransformations:
140107
change = False
141108
originMetricTransformations = camel_dict_to_snake_dict(originMetricTransformations)
142-
for item in ["default_value", "metric_name", "metric_namespace", "metric_value", "unit", "dimensions"]:
109+
for item in ["default_value", "metric_name", "metric_namespace", "metric_value"]:
143110
if metricTransformations.get(item) != originMetricTransformations.get(item):
144111
change = True
145112
else:
146113
change = True
147114

148-
retval = [
149-
{
150-
"metricName": metricTransformations.get("metric_name"),
151-
"metricNamespace": metricTransformations.get("metric_namespace"),
152-
"metricValue": metricTransformations.get("metric_value"),
153-
}
154-
]
155-
156-
# Add optional values
157115
defaultValue = metricTransformations.get("default_value")
158-
if defaultValue is not None:
159-
retval[0]["defaultValue"] = defaultValue
160-
161-
dimensions = metricTransformations.get("dimensions")
162-
if dimensions is not None:
163-
retval[0]["dimensions"] = dimensions
164-
165-
unit = metricTransformations.get("unit")
166-
if unit is not None:
167-
retval[0]["unit"] = unit
116+
if isinstance(defaultValue, int) or isinstance(defaultValue, float):
117+
retval = [
118+
{
119+
"metricName": metricTransformations.get("metric_name"),
120+
"metricNamespace": metricTransformations.get("metric_namespace"),
121+
"metricValue": metricTransformations.get("metric_value"),
122+
"defaultValue": defaultValue,
123+
}
124+
]
125+
else:
126+
retval = [
127+
{
128+
"metricName": metricTransformations.get("metric_name"),
129+
"metricNamespace": metricTransformations.get("metric_namespace"),
130+
"metricValue": metricTransformations.get("metric_value"),
131+
}
132+
]
168133

169134
return retval, change
170135

@@ -182,8 +147,6 @@ def main():
182147
metric_namespace=dict(type="str"),
183148
metric_value=dict(type="str"),
184149
default_value=dict(type="float"),
185-
unit=dict(type="str"),
186-
dimensions=dict(type="dict"),
187150
),
188151
),
189152
)
@@ -221,12 +184,6 @@ def main():
221184
metricTransformation = [camel_dict_to_snake_dict(item) for item in [originMetricTransformations]]
222185

223186
elif state == "present":
224-
if (
225-
metric_transformation.get("default_value") is not None
226-
and metric_transformation.get("dimensions") is not None
227-
):
228-
module.fail_json(msg="default_value and dimensions are mutually exclusive.")
229-
230187
metricTransformation, change = metricTransformationHandler(
231188
metricTransformations=metric_transformation, originMetricTransformations=originMetricTransformations
232189
)

Diff for: plugins/modules/ec2_vpc_route_table.py

+2-11
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
description:
5858
- List of routes in the route table.
5959
- Routes are specified as dicts containing the keys V(dest) and one of V(gateway_id),
60-
V(instance_id), V(network_interface_id), V(transit_gateway_id), or V(vpc_peering_connection_id).
60+
V(instance_id), V(network_interface_id), or V(vpc_peering_connection_id).
6161
- The value of V(dest) is used for the destination match. It may be a IPv4 CIDR block
6262
or a IPv6 CIDR block.
6363
- If V(gateway_id) is specified, you can refer to the VPC's IGW by using the value V(igw).
@@ -108,8 +108,6 @@
108108
gateway_id: "{{ igw.gateway_id }}"
109109
- dest: ::/0
110110
gateway_id: "{{ igw.gateway_id }}"
111-
- dest: 0.0.0.0/0
112-
gateway_id: "{{ transit_gateway_id }}"
113111
register: public_route_table
114112
115113
- name: Create VPC gateway
@@ -268,12 +266,6 @@
268266
type: str
269267
sample: local
270268
version_added: 6.0.0
271-
transit_gateway_id:
272-
description: ID of the Transit gateway.
273-
returned: when the route is via a Transit gateway
274-
type: str
275-
sample: tgw-123456789012
276-
version_added: 8.3.0
277269
origin:
278270
description: mechanism through which the route is in the table.
279271
returned: always
@@ -752,8 +744,6 @@ def create_route_spec(connection, module, vpc_id):
752744
rename_key(route_spec, "gateway_id", "nat_gateway_id")
753745
if route_spec.get("gateway_id") and route_spec["gateway_id"].startswith("cagw-"):
754746
rename_key(route_spec, "gateway_id", "carrier_gateway_id")
755-
if route_spec.get("gateway_id") and route_spec["gateway_id"].startswith("tgw-"):
756-
rename_key(route_spec, "gateway_id", "transit_gateway_id")
757747

758748
return snake_dict_to_camel_dict(routes, capitalize_first=True)
759749

@@ -852,6 +842,7 @@ def ensure_route_table_present(connection, module):
852842
)
853843
else:
854844
gateway_changed = False
845+
855846
changed = changed or gateway_changed
856847

857848
if changed:

Diff for: plugins/modules/ec2_vpc_route_table_info.py

-6
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,6 @@
163163
returned: when the route is via a NAT gateway.
164164
type: str
165165
sample: local
166-
transit_gateway_id:
167-
description: ID of the Transit gateway.
168-
returned: when the route is via a Transit gateway.
169-
type: str
170-
sample: tgw-123456789012
171-
version_added: 8.3.0
172166
origin:
173167
description: mechanism through which the route is in the table.
174168
returned: always

Diff for: tests/integration/targets/cloudwatchlogs/tasks/cloudwatchlogs_tests.yml

-89
Original file line numberDiff line numberDiff line change
@@ -100,95 +100,6 @@
100100
- out is changed
101101
- out.metric_filters[0].metric_namespace == "made_with_ansible"
102102

103-
- name: Update metric transformation with dimensions on '{{ log_group_name }}'
104-
amazon.aws.cloudwatchlogs_log_group_metric_filter:
105-
log_group_name: "{{ log_group_name }}"
106-
filter_name: "{{ filter_name }}"
107-
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}'
108-
state: present
109-
metric_transformation:
110-
metric_name: box_free_space
111-
metric_namespace: made_with_ansible
112-
metric_value: $.value
113-
dimensions:
114-
hostname: $.hostname
115-
register: out
116-
117-
- name: Assert that metric_filter is configured with dimensions
118-
ansible.builtin.assert:
119-
that:
120-
- out is changed
121-
- out.metric_filters[0].metric_namespace == "made_with_ansible"
122-
- out.metric_filters[0].dimensions.hostname == "$.hostname"
123-
124-
- name: Update metric transformation with unit on '{{ log_group_name }}'
125-
amazon.aws.cloudwatchlogs_log_group_metric_filter:
126-
log_group_name: "{{ log_group_name }}"
127-
filter_name: "{{ filter_name }}"
128-
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}'
129-
state: present
130-
metric_transformation:
131-
metric_name: box_free_space
132-
metric_namespace: made_with_ansible
133-
metric_value: $.value
134-
unit: Bytes
135-
dimensions:
136-
hostname: $.hostname
137-
register: out
138-
139-
- name: Assert that metric_filter is configured with dimensions and unit
140-
ansible.builtin.assert:
141-
that:
142-
- out is changed
143-
- out.metric_filters[0].metric_namespace == "made_with_ansible"
144-
- out.metric_filters[0].dimensions.hostname == "$.hostname"
145-
- out.metric_filters[0].unit == "Bytes"
146-
147-
- name: Idempotency check on metric transformation on '{{ log_group_name }}'
148-
amazon.aws.cloudwatchlogs_log_group_metric_filter:
149-
log_group_name: "{{ log_group_name }}"
150-
filter_name: "{{ filter_name }}"
151-
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}'
152-
state: present
153-
metric_transformation:
154-
metric_name: box_free_space
155-
metric_namespace: made_with_ansible
156-
metric_value: $.value
157-
unit: Bytes
158-
dimensions:
159-
hostname: $.hostname
160-
register: out
161-
162-
- name: Assert that idempotent action with unit and dimensions does not register as changed
163-
ansible.builtin.assert:
164-
that:
165-
- out is not changed
166-
- out.metric_filters[0].metric_namespace == "made_with_ansible"
167-
- out.metric_filters[0].unit == "Bytes"
168-
- out.metric_filters[0].dimensions.hostname == "$.hostname"
169-
170-
- name: Update metric transformation with default_value and dimensions on '{{ log_group_name }}'
171-
amazon.aws.cloudwatchlogs_log_group_metric_filter:
172-
log_group_name: "{{ log_group_name }}"
173-
filter_name: "{{ filter_name }}"
174-
filter_pattern: '{ ($.value = *) && ($.hostname = "box")}'
175-
state: present
176-
metric_transformation:
177-
metric_name: box_free_space
178-
metric_namespace: made_with_ansible
179-
metric_value: $.value
180-
default_value: 3.1415
181-
dimensions:
182-
hostname: $.hostname
183-
register: out
184-
ignore_errors: true
185-
186-
- name: Update metric transformation with default_value and dimensions must fail
187-
ansible.builtin.assert:
188-
that:
189-
- out is failed
190-
- out.msg == "default_value and dimensions are mutually exclusive."
191-
192103
- name: checkmode delete metric filter on '{{ log_group_name }}'
193104
amazon.aws.cloudwatchlogs_log_group_metric_filter:
194105
log_group_name: "{{ log_group_name }}"

0 commit comments

Comments
 (0)