aws-cloudformation / aws-cloudformation-resource-providers-logs

The CloudFormation Resource Provider Package For Amazon CloudWatch Logs
https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/WhatIsCloudWatchLogs.html
Apache License 2.0
33 stars 35 forks source link

Add resource type "metric filter" #33

Closed miparnisari closed 4 years ago

miparnisari commented 4 years ago

Issue #, if available: N/A

Description of changes: I resurrected part of this PR and applied some changes. Used the guided version of the CFN CLI.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

miparnisari commented 4 years ago

cfn test passes in the latest commit.

-            .done(this::constructResourceModelFromResponse);
+            .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder()
+                    .status(OperationStatus.SUCCESS)
+                    .resourceModel(Translator.translateFromReadResponse(awsResponse))
+                    .build());
-                .success();
+                .done(awsResponse -> ProgressEvent.<ResourceModel, CallbackContext>builder()
+                        .status(OperationStatus.SUCCESS)
+                        .resourceModel(model)
+                        .build());

I also noticed & fixed a problem in the Update handler. Theoretically, PutMetricFilter can throw ResourceNotFoundException. However in practice this doesn't happen. I had to add a call to Read before doing an Update to ensure that the resource actually exists before executing the update.

However, the integration tests are failing. I believe the Create handlers are being called twice for each test. The first call works & creates the resource but the second one fails because the resource already exists. Need to fix this now. Related to https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-cloudwatch/issues/5