Skip to content

CloudWatch V2: Move tagging functionality into separate methods to enable their overriding in pro version#13748

Open
k-a-il wants to merge 2 commits intomainfrom
flc-280-rgta-integration-cloudwatch
Open

CloudWatch V2: Move tagging functionality into separate methods to enable their overriding in pro version#13748
k-a-il wants to merge 2 commits intomainfrom
flc-280-rgta-integration-cloudwatch

Conversation

@k-a-il
Copy link
Contributor

@k-a-il k-a-il commented Feb 12, 2026

Motivation

This PR moves tagging logic to separate methods on the CloudWatch V2 Provider class to enable their overriding in pro version and adds tagging logic to methods which create metric and composite alarms.

The separate methods will be overridden in the Pro version, where CloudWatch V2 will be integrated with the new ResourceGroupsTagging plugin. This integration will enable CloudWatch resources to be tagged and allow tags to be retrieved through the Resource Groups Tagging service.

Changes

  • Moves tagging logic into separate methods
  • Adds tagging logic to methods which create metric and composite alarms
  • Resolves an issue where tags were being stored in the model. Since tagging is already handled by TaggingService, tags should not be persisted in the model

Tests

Added integration tests to check tagging when resource is being created

Related

FLC-280

@k-a-il k-a-il added this to the 4.14 milestone Feb 12, 2026
@k-a-il k-a-il self-assigned this Feb 12, 2026
@k-a-il k-a-il added semver: patch Non-breaking changes which can be included in patch releases docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes labels Feb 12, 2026
@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results - Preflight, Unit

23 111 tests  +12   21 249 ✅ +12   6m 48s ⏱️ +34s
     1 suites ± 0    1 862 💤 ± 0 
     1 files   ± 0        0 ❌ ± 0 

Results for commit b187c4f. ± Comparison against base commit 2046dff.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results - Alternative Providers

186 tests   - 1 087    39 ✅  - 687   2m 30s ⏱️ - 28m 36s
  1 suites  -     3   146 💤  - 401 
  1 files    -     3     1 ❌ +  1 

For more details on these failures, see this check.

Results for commit b187c4f. ± Comparison against base commit 2046dff.

This pull request removes 1093 and adds 6 tests. Note that renamed tests count towards both.
tests.aws.services.cloudformation.api.test_changesets ‑ test_autoexpand_capability_requirement
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_remove_non_supported_resource_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_remove_supported_resource_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_update_refreshes_template_metadata
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_create_existing
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_invalid_params
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_missing_stackname
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_no_changes
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_nonexisting
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_without_parameters
…
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[smithy-rpc-v2-cbor]
This pull request removes 406 skipped tests and adds 5 skipped tests. Note that renamed tests count towards both.
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_and_then_update_refreshes_template_metadata
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_no_changes
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_change_set_update_without_parameters
tests.aws.services.cloudformation.api.test_changesets ‑ test_create_while_in_review
tests.aws.services.cloudformation.api.test_changesets ‑ test_describe_changeset_after_delete
tests.aws.services.cloudformation.api.test_changesets ‑ test_execute_change_set
tests.aws.services.cloudformation.api.test_changesets ‑ test_update_change_set_with_aws_novalue_repro
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[condition]
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[parameter]
tests.aws.services.cloudformation.api.test_changesets ‑ test_using_pseudoparameters_in_places[resource]
…
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[smithy-rpc-v2-cbor]

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results (amd64) - Acceptance

7 tests  ±0   5 ✅ ±0   3m 5s ⏱️ -1s
1 suites ±0   2 💤 ±0 
1 files   ±0   0 ❌ ±0 

Results for commit b187c4f. ± Comparison against base commit 2046dff.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

Test Results (amd64) - Integration, Bootstrap

    5 files  ±    0      5 suites  ±0   1h 5m 44s ⏱️ - 1h 30m 16s
1 272 tests  - 4 340  1 155 ✅  - 3 949  76 💤  - 432  41 ❌ +41 
1 278 runs   - 4 340  1 155 ✅  - 3 949  82 💤  - 432  41 ❌ +41 

For more details on these failures, see this check.

Results for commit b187c4f. ± Comparison against base commit 2046dff.

This pull request removes 4346 and adds 6 tests. Note that renamed tests count towards both.
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_lambda_dynamodb
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_opensearch_crud
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_search_books
tests.aws.scenario.bookstore.test_bookstore.TestBookstoreApplication ‑ test_setup
tests.aws.scenario.kinesis_firehose.test_kinesis_firehose.TestKinesisFirehoseScenario ‑ test_kinesis_firehose_s3
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_destination_sns
tests.aws.scenario.lambda_destination.test_lambda_destination_scenario.TestLambdaDestinationScenario ‑ test_infra
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_prefill_dynamodb_table
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input0-SUCCEEDED]
tests.aws.scenario.loan_broker.test_loan_broker.TestLoanBrokerScenario ‑ test_stepfunctions_input_recipient_list[step_function_input1-SUCCEEDED]
…
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_composite_alarm[smithy-rpc-v2-cbor]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[json]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[query]
tests.aws.services.cloudwatch.test_cloudwatch.TestCloudwatch ‑ test_tagging_metric_alarm[smithy-rpc-v2-cbor]

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

LocalStack Community integration with Pro

    2 files      2 suites   46m 6s ⏱️
1 248 tests 1 129 ✅ 78 💤 41 ❌
1 250 runs  1 129 ✅ 80 💤 41 ❌

For more details on these failures, see this check.

Results for commit b187c4f.

♻️ This comment has been updated with latest results.

@k-a-il k-a-il requested a review from aidehn February 13, 2026 07:26
@k-a-il k-a-il marked this pull request as ready for review February 13, 2026 08:32
@k-a-il k-a-il added semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases and removed semver: patch Non-breaking changes which can be included in patch releases labels Feb 13, 2026
alarm_arn = alarm["AlarmArn"]

list_tags_for_resource = aws_cloudwatch_client.list_tags_for_resource(ResourceARN=alarm_arn)
snapshot.match("list_tags_for_resource_empty ", list_tags_for_resource)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is list tags for resource meant to return empty tags here? Based on the snapshot name I assume it should be empty but from the test logic I would have thought it'd have {"Key": "Environment", "Value": "Production"} as it's value (It might just be missing an additional put request here like how the below test does it)

}
}
},
"tests/aws/services/cloudwatch/test_cloudwatch.py::TestCloudwatch::test_tagging_metric_alarm[query]": {
Copy link
Contributor

Choose a reason for hiding this comment

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

noticed that the test_tagging_metric_alarm test has been parametrized here but but doesn't have parametrization on the test itself, might be leftover?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this is a bit misleading. The parametrization is done in the aws_cloudwatch_client fixture

}
}
},
"tests/aws/services/cloudwatch/test_cloudwatch.py::TestCloudwatch::test_tagging_composite_alarm[query]": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question on parametrization here!

self.region = region
self.alarm = alarm
# Tags are already stored as part of Tagging Service or RGTA plugin
self.alarm.pop("Tags")
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the MetricAlarm model in CloudWatch I don't think it contains a Tags field which will raise here (same with the CompositeAlarm model) but it means we can likely remove this code and the code below 👍🏼

Comment on lines +411 to +435
def _get_resource_tags(
self, resource_arn: AmazonResourceName, account_id: str, region: str
) -> TagList:
store = self.get_store(account_id, region)
tags = store.TAGS.list_tags_for_resource(resource_arn).get("Tags", [])
return tags

def _set_resource_tags(
self, resource_arn: AmazonResourceName, account_id: str, region: str, tags: TagList
) -> None:
store = self.get_store(account_id, region)
store.TAGS.tag_resource(arn=resource_arn, tags=tags)

def _remove_resource_tags(
self, resource_arn: AmazonResourceName, account_id: str, region: str, tag_keys: TagKeyList
) -> None:
store = self.get_store(account_id, region)
store.TAGS.untag_resource(resource_arn, tag_keys)

def _remove_all_resource_tags(
self, resource_arn: AmazonResourceName, account_id: str, region: str
):
store = self.get_store(account_id, region)
store.TAGS.del_resource(resource_arn)

Copy link
Member

Choose a reason for hiding this comment

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

It could be worth it to look into the implementations of the Strategy pattern that we use in the ECS and IAM services. Where we:

  • Write a simple entity that handles the simple functionality
  • Instantiate that entity in the provider and make the provider use it in the operations
  • In pro we define a different entity with more advance functionality and the pro plugin puts it in the provider.

IMO this makes the substitution of the method implementation more transparent to the maintainer.

Here is a sample

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs: skip Pull request does not require documentation changes notes: skip Pull request does not have to be mentioned in the release notes semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants