-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing permissions for sample AWS policy (#122)
* Migrate AWS policy to autovalue object This avoids embedding JSON in a Java constant, which is error prone. * Add missing permissions Added: - kinesis:ListStreams - logs:DescribeLogGroups * Define JSON policy field order that matches AWS examples * Return the policy JSON string to the UI as string This is consistent with how this was done before. The UI can then format and display this to the user on the Available Services page. This is the policy that the user will create the AWS user for the AWS integration with. * Specify the correct AWS policy version * Change AWS Policy to a list * Add missing permissions Based on this [sample KCL code](aws/aws-sdk-java-v2#1214 (comment)) * Update version to 3.1.0-beta.2-SNAPSHOT * Remove uneeded import * Add Available Services API response error documentation * Throw InternalServerErrorException instead of JSON exception This is a bit cleaner from the API consumption side. A nice short error message is now returned instead of an obscure JSON error.
- Loading branch information
Showing
5 changed files
with
154 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.graylog.integrations.aws; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.google.auto.value.AutoValue; | ||
import org.graylog.autovalue.WithBeanGetter; | ||
|
||
import java.util.List; | ||
|
||
@JsonAutoDetect | ||
@AutoValue | ||
@WithBeanGetter | ||
// Define a JSON field order matching AWS examples. This improves readability. | ||
@JsonPropertyOrder({AWSPolicy.VERSION, AWSPolicy.STATEMENT}) | ||
public abstract class AWSPolicy { | ||
|
||
public static final String VERSION = "Version"; | ||
public static final String STATEMENT = "Statement"; | ||
|
||
@JsonProperty(VERSION) | ||
public abstract String version(); | ||
|
||
@JsonProperty(STATEMENT) | ||
public abstract List<AWSPolicyStatement> statement(); | ||
|
||
public static AWSPolicy create(@JsonProperty(VERSION) String version, | ||
@JsonProperty(STATEMENT) List<AWSPolicyStatement> statement) { | ||
return new AutoValue_AWSPolicy(version, statement); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/org/graylog/integrations/aws/AWSPolicyStatement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.graylog.integrations.aws; | ||
|
||
import com.fasterxml.jackson.annotation.JsonAutoDetect; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.google.auto.value.AutoValue; | ||
import org.graylog.autovalue.WithBeanGetter; | ||
|
||
import java.util.List; | ||
|
||
@JsonAutoDetect | ||
@AutoValue | ||
@WithBeanGetter | ||
// Define a JSON field order matching AWS examples. This improves readability. | ||
@JsonPropertyOrder({AWSPolicyStatement.SID, AWSPolicyStatement.EFFECT, AWSPolicyStatement.ACTION, AWSPolicyStatement.RESOURCE}) | ||
public abstract class AWSPolicyStatement { | ||
|
||
static final String SID = "Sid"; | ||
static final String EFFECT = "Effect"; | ||
static final String ACTION = "Action"; | ||
static final String RESOURCE = "Resource"; | ||
|
||
@JsonProperty(SID) | ||
public abstract String sid(); | ||
|
||
@JsonProperty(EFFECT) | ||
public abstract String effect(); | ||
|
||
@JsonProperty(ACTION) | ||
public abstract List<String> action(); | ||
|
||
@JsonProperty(RESOURCE) | ||
public abstract String resource(); | ||
|
||
public static AWSPolicyStatement create(@JsonProperty(SID) String sid, | ||
@JsonProperty(EFFECT) String effect, | ||
@JsonProperty(ACTION) List<String> action, | ||
@JsonProperty(RESOURCE) String resource) { | ||
return new AutoValue_AWSPolicyStatement(sid, effect, action, resource); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters