Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Support SNS as a destination #348

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

lezzago
Copy link
Contributor

@lezzago lezzago commented Feb 8, 2021

Issue #, if available:
#91
Description of changes:
Support SNS as a destination

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov
Copy link

codecov bot commented Feb 8, 2021

Codecov Report

Merging #348 (558504a) into main (9f2f2cd) will increase coverage by 0.34%.
The diff coverage is 74.39%.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #348      +/-   ##
============================================
+ Coverage     79.63%   79.98%   +0.34%     
- Complexity      209      245      +36     
============================================
  Files           151      156       +5     
  Lines          5342     5490     +148     
  Branches        700      721      +21     
============================================
+ Hits           4254     4391     +137     
+ Misses          717      708       -9     
- Partials        371      391      +20     
Impacted Files Coverage Δ Complexity Δ
...ticsearch/alerting/elasticapi/ElasticExtensions.kt 50.90% <33.33%> (-1.02%) 0.00 <0.00> (ø)
...icsearch/alerting/model/destination/Destination.kt 74.59% <44.44%> (-3.39%) 0.00 <0.00> (ø)
...estination/factory/DestinationFactoryProvider.java 57.14% <50.00%> (-17.86%) 3.00 <1.00> (ø)
...endistroforelasticsearch/alerting/MonitorRunner.kt 78.43% <66.66%> (-0.15%) 0.00 <0.00> (ø)
...relasticsearch/alerting/destination/util/Util.java 71.42% <71.42%> (ø) 7.00 <7.00> (?)
...ing/destination/factory/SNSDestinationFactory.java 73.33% <73.33%> (ø) 6.00 <6.00> (?)
...arch/alerting/destination/util/PropertyHelper.java 73.68% <73.68%> (ø) 3.00 <3.00> (?)
...oforelasticsearch/alerting/settings/AWSSettings.kt 76.92% <76.92%> (ø) 0.00 <0.00> (?)
...forelasticsearch/alerting/model/destination/SNS.kt 77.41% <81.25%> (+77.41%) 0.00 <0.00> (ø)
...earch/alerting/destination/message/SNSMessage.java 85.41% <85.41%> (ø) 15.00 <15.00> (?)
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9f2f2cd...558504a. Read the comment docs.

Base automatically changed from master to main February 9, 2021 20:04
CUSTOM_WEBHOOK("custom_webhook"),
EMAIL("email"),
TEST_ACTION("test_action");

override fun toString(): String {
return value
}

companion object {
var snsUseIamRole = false
Copy link
Contributor

@qreshi qreshi Feb 11, 2021

Choose a reason for hiding this comment

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

This seems a little strange to me. I'm not sure if we should maintain state on using IAM role in the DestinationType enum class.

It looks like this is mostly used for null assertion in the SNS data class. Perhaps you can remove this variable and instead validate if either roleARN or access/secret is set somewhere. It looks like you do something like that in SNSMessage already, that might be sufficient.

And ideally, we should allow the access/secret settings to be changed using the reload API and if we support that then you can have scenarios where:

  1. access/secret settings are originally set
  2. SNS Destinations are created (allowing roleARN to be null since snsUseIamRole = false)
  3. The access/secret settings are removed, checking roleARN on any subsequent SNS Destination but now you have one that's already created with a null roleARN and no access/secret settings so it bypassed this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need this in case the customer uses the indexDestination API to create the SNS destination and we need some validation for the role arn.
Also I have updated the code such that snsUseIamRole can change whenever the settings are reloaded.

@lezzago
Copy link
Contributor Author

lezzago commented Mar 15, 2021

There are some problems discovered, will reopen PR once they have been resolved

@lezzago lezzago closed this Mar 15, 2021
@lezzago lezzago reopened this Mar 22, 2021

// needed because of problems in ClientConfiguration
// TODO: get these fixed in aws sdk
permission java.lang.RuntimePermission "accessDeclaredMembers";
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need accessDeclaredMembers? Could you please double check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is required. The AWS SDK uses jackson databind, which needs accessDeclaredMembers.

@kevinduke10
Copy link

Would love this merge!!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants