Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions data-prepper-plugins/aws-common/build.gradle

This file was deleted.

1 change: 0 additions & 1 deletion data-prepper-plugins/aws-plugin/build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
dependencies {
implementation project(':data-prepper-api')
implementation project(':data-prepper-plugins:aws-plugin-api')
implementation project(':data-prepper-plugins:aws-common')
implementation 'com.fasterxml.jackson.core:jackson-databind'
implementation 'io.micrometer:micrometer-core'
implementation 'software.amazon.awssdk:auth'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.opensearch.dataprepper.aws.api.AwsCredentialsSupplier;
import org.opensearch.dataprepper.model.plugin.ExtensionProvider;

import java.util.Optional;

public class AwsExtensionProvider implements ExtensionProvider<AwsCredentialsSupplier> {
class AwsExtensionProvider implements ExtensionProvider<AwsCredentialsSupplier> {
private final AwsCredentialsSupplier awsCredentialsSupplier;

public AwsExtensionProvider(final AwsCredentialsSupplier awsCredentialsSupplier) {
AwsExtensionProvider(final AwsCredentialsSupplier awsCredentialsSupplier) {
this.awsCredentialsSupplier = awsCredentialsSupplier;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
import org.opensearch.dataprepper.model.annotations.DataPrepperPluginConstructor;
import org.opensearch.dataprepper.model.plugin.ExtensionPlugin;
import org.opensearch.dataprepper.model.plugin.ExtensionPoints;
import org.opensearch.dataprepper.aws.common.AwsStsConfiguration;
import org.opensearch.dataprepper.aws.common.CredentialsProviderFactory;
import org.opensearch.dataprepper.aws.common.CredentialsCache;
import org.opensearch.dataprepper.aws.common.AwsExtensionProvider;

/**
* The {@link ExtensionPlugin} class which adds the AWS Plugin to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package org.opensearch.dataprepper.plugins.aws;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.opensearch.dataprepper.aws.common.AwsStsConfiguration;

public class AwsPluginConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import com.fasterxml.jackson.annotation.JsonProperty;
import jakarta.validation.constraints.Size;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.opensearch.dataprepper.aws.api.AwsCredentialsOptions;
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
Expand All @@ -12,14 +12,14 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Supplier;

public class CredentialsCache {
class CredentialsCache {
private final Map<CredentialsIdentifier, AwsCredentialsProvider> credentialsProviderMap;

public CredentialsCache() {
CredentialsCache() {
credentialsProviderMap = new ConcurrentHashMap<>();
}

public AwsCredentialsProvider getOrCreate(final AwsCredentialsOptions awsCredentialsOptions, final Supplier<AwsCredentialsProvider> providerSupplier) {
AwsCredentialsProvider getOrCreate(final AwsCredentialsOptions awsCredentialsOptions, final Supplier<AwsCredentialsProvider> providerSupplier) {
final CredentialsIdentifier identifier = CredentialsIdentifier.fromAwsCredentialsOption(awsCredentialsOptions);

return credentialsProviderMap.computeIfAbsent(identifier, i -> providerSupplier.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.opensearch.dataprepper.aws.api.AwsCredentialsOptions;
import software.amazon.awssdk.regions.Region;
Expand All @@ -12,16 +12,16 @@
import java.util.Objects;

/**
* Class to identify credentials. This is a distinct class from
* Internal class to identify credentials. This is a distinct class from
* {@link AwsCredentialsOptions} in order to ensure that the internal caching
* is distinct from the external model.
*/
public class CredentialsIdentifier {
class CredentialsIdentifier {
private final String stsRoleArn;
private final Region region;
private final Map<String, String> stsHeaderOverrides;

public CredentialsIdentifier(
private CredentialsIdentifier(
final String stsRoleArn,
final Region region,
final Map<String, String> stsHeaderOverrides) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.opensearch.dataprepper.aws.api.AwsCredentialsOptions;
import org.slf4j.Logger;
Expand All @@ -28,7 +28,7 @@
import java.util.Optional;
import java.util.UUID;

public class CredentialsProviderFactory {
class CredentialsProviderFactory {
private static final Logger LOG = LoggerFactory.getLogger(CredentialsProviderFactory.class);
private static final String AWS_IAM = "iam";
private static final String AWS_IAM_ROLE = "role";
Expand All @@ -43,15 +43,15 @@ public CredentialsProviderFactory(final AwsStsConfiguration defaultStsConfigurat
this.defaultStsConfiguration = defaultStsConfiguration;
}

public Region getDefaultRegion() {
Region getDefaultRegion() {
return defaultStsConfiguration.getAwsRegion();
}

public String getDefaultStsRoleArn() {
String getDefaultStsRoleArn() {
return defaultStsConfiguration.getAwsStsRoleArn();
}

public AwsCredentialsProvider providerFromOptions(final AwsCredentialsOptions credentialsOptions) {
AwsCredentialsProvider providerFromOptions(final AwsCredentialsOptions credentialsOptions) {
Objects.requireNonNull(credentialsOptions);

if (credentialsOptions.isUseDefaultCredentialsProvider()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
import software.amazon.awssdk.regions.Region;

import org.opensearch.dataprepper.aws.common.CredentialsProviderFactory;
import org.opensearch.dataprepper.aws.common.CredentialsCache;

import java.util.Optional;

class DefaultAwsCredentialsSupplier implements AwsCredentialsSupplier {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -50,4 +50,4 @@ void provideInstance_returns_the_AwsCredentialsSupplier_from_the_constructor() {
assertThat(anotherOptionalCredentialsSupplier.isPresent(), equalTo(true));
assertThat(anotherOptionalCredentialsSupplier.get(), sameInstance(optionalCredentialsSupplier.get()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.sts.auth.StsAssumeRoleCredentialsProvider;

import org.opensearch.dataprepper.aws.common.AwsStsConfiguration;

import java.util.Optional;
import java.util.UUID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import org.mockito.junit.jupiter.MockitoExtension;
import org.opensearch.dataprepper.model.plugin.ExtensionPoints;
import org.opensearch.dataprepper.model.plugin.ExtensionProvider;
import org.opensearch.dataprepper.aws.common.AwsStsConfiguration;
import org.opensearch.dataprepper.aws.common.AwsExtensionProvider;

import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -64,4 +62,4 @@ void null_aws_plugin_config_applies_extensions_correctly() {

assertThat(actualExtensionProvider, instanceOf(AwsExtensionProvider.class));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import software.amazon.awssdk.regions.Region;
Expand All @@ -22,15 +21,6 @@ public class AwsStsConfigurationTest {

private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();

@Test
void testStsConfigurationWithNullRegion() throws JsonProcessingException {
final String defaultConfigurationAsString = "{\"sts_role_arn\": \"arn:aws:iam::123456789012:role/test-role\"}";
final AwsStsConfiguration objectUnderTest = OBJECT_MAPPER.readValue(defaultConfigurationAsString, AwsStsConfiguration.class);
assertThat(objectUnderTest, notNullValue());
assertThat(objectUnderTest.getAwsStsRoleArn(), equalTo("arn:aws:iam::123456789012:role/test-role"));
assertThat(objectUnderTest.getAwsRegion(), equalTo(null));
}

@ParameterizedTest
@MethodSource("getRegions")
void testStsConfiguration(final Region region) throws JsonProcessingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -79,4 +79,4 @@ void getOrCreate_returns_value_from_supplier_as_expected_with_multiple_objects()
verify(existingCredentialsProviderSupplier).get();
verify(credentialsProviderSupplier).get();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.aws.common;
package org.opensearch.dataprepper.plugins.aws;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand Down Expand Up @@ -168,4 +168,4 @@ void equals_hashCode_on_non_equal_StsHeaderOverrides() {
assertThat(objectUnderTest.equals(other), equalTo(false));
assertThat(objectUnderTest.hashCode(), not(equalTo(other.hashCode())));
}
}
}
Loading
Loading