mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(eventbridge): sync EventBridge tags to ResourceGroupsTaggingService (#1347)
* fix(eventbridge): sync EventBridge tags to ResourceGroupsTaggingService EventBridge stored tags on rules, buses, and archives in its own stores but never propagated them to the central ResourceGroupsTaggingService. This caused GetResources with --resource-type-filters events:rule to return an empty list. Inject ResourceGroupsTaggingService into EventBridgeService (following the existing GlueService pattern) and sync tags during putRule, tagResource, untagResource, and deleteRule operations. Closes #1343 * fix(eventbridge): register tags on event bus creation and clear tags on deletion
This commit is contained in:
1 parent
a8fde26d06
commit
1c87c2aa47
1 file changed
+156
+156
@@ -355,4 +355,160 @@ class EventBridgeTagResourceIntegrationTest {
|
||||
.body("{\"Name\":\"my-event-bus\"}")
|
||||
.when().post("/").then().statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(9)
|
||||
void createEventBusWithTagsAndVerifyCentralTagging() {
|
||||
String busName = "tagged-at-creation-bus";
|
||||
String busArn = given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.CreateEventBus")
|
||||
.body("""
|
||||
{
|
||||
"Name": "%s",
|
||||
"Tags": [
|
||||
{"Key": "CreatedBy", "Value": "TestSuite"},
|
||||
{"Key": "Project", "Value": "Floci"}
|
||||
]
|
||||
}
|
||||
""".formatted(busName))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().jsonPath().getString("EventBusArn");
|
||||
|
||||
// Verify it is registered in central tagging service
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ResourceGroupsTaggingAPI_20170126.GetResources")
|
||||
.body("{\"ResourceARNList\": [\"" + busArn + "\"]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ResourceTagMappingList", hasSize(1))
|
||||
.body("ResourceTagMappingList[0].ResourceARN", equalTo(busArn))
|
||||
.body("ResourceTagMappingList[0].Tags", hasSize(2))
|
||||
.body("ResourceTagMappingList[0].Tags.find { it.Key == 'CreatedBy' }.Value", equalTo("TestSuite"))
|
||||
.body("ResourceTagMappingList[0].Tags.find { it.Key == 'Project' }.Value", equalTo("Floci"));
|
||||
|
||||
// Now delete it
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DeleteEventBus")
|
||||
.body("{\"Name\":\"" + busName + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Verify it is removed from central tagging service
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ResourceGroupsTaggingAPI_20170126.GetResources")
|
||||
.body("{\"ResourceARNList\": [\"" + busArn + "\"]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ResourceTagMappingList", hasSize(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void deleteArchiveClearsCentralTagging() {
|
||||
String busName = "archive-tag-bus";
|
||||
String busArn = given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.CreateEventBus")
|
||||
.body("{\"Name\":\"" + busName + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().jsonPath().getString("EventBusArn");
|
||||
|
||||
String archiveName = "tag-test-archive";
|
||||
String archiveArn = given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.CreateArchive")
|
||||
.body("""
|
||||
{
|
||||
"ArchiveName": "%s",
|
||||
"EventSourceArn": "%s",
|
||||
"Description": "Archive tag test",
|
||||
"RetentionDays": 5
|
||||
}
|
||||
""".formatted(archiveName, busArn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.extract().jsonPath().getString("ArchiveArn");
|
||||
|
||||
// Tag the archive
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.TagResource")
|
||||
.body("""
|
||||
{
|
||||
"ResourceARN": "%s",
|
||||
"Tags": [
|
||||
{"Key": "ArchiveType", "Value": "Testing"}
|
||||
]
|
||||
}
|
||||
""".formatted(archiveArn))
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Verify it is registered in central tagging service
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ResourceGroupsTaggingAPI_20170126.GetResources")
|
||||
.body("{\"ResourceARNList\": [\"" + archiveArn + "\"]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ResourceTagMappingList", hasSize(1))
|
||||
.body("ResourceTagMappingList[0].ResourceARN", equalTo(archiveArn))
|
||||
.body("ResourceTagMappingList[0].Tags", hasSize(1))
|
||||
.body("ResourceTagMappingList[0].Tags[0].Key", equalTo("ArchiveType"))
|
||||
.body("ResourceTagMappingList[0].Tags[0].Value", equalTo("Testing"));
|
||||
|
||||
// Delete the archive
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DeleteArchive")
|
||||
.body("{\"ArchiveName\":\"" + archiveName + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Verify it is removed from central tagging service
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "ResourceGroupsTaggingAPI_20170126.GetResources")
|
||||
.body("{\"ResourceARNList\": [\"" + archiveArn + "\"]}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("ResourceTagMappingList", hasSize(0));
|
||||
|
||||
// Cleanup the bus
|
||||
given()
|
||||
.contentType(EVENT_BRIDGE_CONTENT_TYPE)
|
||||
.header("X-Amz-Target", "AWSEvents.DeleteEventBus")
|
||||
.body("{\"Name\":\"" + busName + "\"}")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user