Skip to content

Commit

Permalink
remove s3-properties, consolidate aws config, remove ssm bean
Browse files Browse the repository at this point in the history
Co-authored-by: Stefan Lier <[email protected]>
Co-authored-by: Micha Regel <[email protected]>
  • Loading branch information
micharegel1111 and Stefan Lier committed Aug 29, 2018
1 parent 14058ad commit f03c10c
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 422 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.otto.edison.aws.configuration;

import de.otto.edison.aws.s3.S3Service;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -11,8 +12,11 @@
import software.amazon.awssdk.auth.credentials.EnvironmentVariableCredentialsProvider;
import software.amazon.awssdk.auth.credentials.InstanceProfileCredentialsProvider;
import software.amazon.awssdk.auth.credentials.ProfileCredentialsProvider;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.ssm.SsmClient;

import static software.amazon.awssdk.regions.Region.of;

@Configuration
@EnableConfigurationProperties(AwsProperties.class)
public class AwsConfiguration {
Expand All @@ -35,10 +39,19 @@ public AwsCredentialsProvider awsCredentialsProvider(final AwsProperties awsProp
}

@Bean
public SsmClient ssmClient(final AwsCredentialsProvider awsCredentialsProvider) {
return SsmClient.builder()
@ConditionalOnMissingBean(S3Client.class)
public S3Client s3Client(final AwsProperties awsProperties,
final AwsCredentialsProvider awsCredentialsProvider) {
return S3Client
.builder()
.region(of(awsProperties.getRegion()))
.credentialsProvider(awsCredentialsProvider)
.build();
}

@Bean
@ConditionalOnMissingBean
public S3Service s3Service(final S3Client s3Client) {
return new S3Service(s3Client);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package de.otto.edison.aws.paramstore;

import de.otto.edison.aws.configuration.AwsConfiguration;
import de.otto.edison.aws.configuration.AwsProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
Expand All @@ -23,6 +24,7 @@

import static io.netty.util.internal.StringUtil.isNullOrEmpty;
import static java.util.Objects.requireNonNull;
import static software.amazon.awssdk.regions.Region.EU_CENTRAL_1;
import static software.amazon.awssdk.services.ssm.model.ParameterType.SECURE_STRING;

@Component
Expand All @@ -32,14 +34,9 @@ public class ParamStorePropertySourcePostProcessor implements BeanFactoryPostPro
private static final Logger LOG = LoggerFactory.getLogger(ParamStorePropertySourcePostProcessor.class);

private static final String PARAMETER_STORE_PROPERTY_SOURCE = "parameterStorePropertySource";
private final SsmClient ssmClient;
private SsmClient ssmClient;
private ParamStoreProperties properties;

@Autowired
public ParamStorePropertySourcePostProcessor(final SsmClient ssmClient) {
this.ssmClient = ssmClient;
}

@Override
public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException {
final Properties propertiesSource = new Properties();
Expand Down Expand Up @@ -91,6 +88,14 @@ public void setEnvironment(final Environment environment) {
properties.setAddWithLowestPrecedence(
Boolean.parseBoolean(environment.getProperty("edison.aws.config.paramstore.addWithLowestPrecedence", "false")));
properties.setPath(path);

final AwsProperties awsProperties = new AwsProperties();
awsProperties.setProfile(environment.getProperty("aws.profile", "default"));
awsProperties.setRegion(environment.getProperty("aws.region", EU_CENTRAL_1.id()));
final AwsConfiguration awsConfig = new AwsConfiguration();
this.ssmClient = SsmClient.builder()
.credentialsProvider(awsConfig.awsCredentialsProvider(awsProperties))
.build();
}

}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import de.otto.edison.aws.s3.configuration.S3TogglzProperties;
import org.togglz.core.Feature;
import org.togglz.core.repository.FeatureState;
import org.togglz.core.repository.StateRepository;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package de.otto.edison.aws.s3.configuration;
package de.otto.edison.aws.s3.togglz;

import de.otto.edison.aws.s3.togglz.PrefetchCachingStateRepository;
import de.otto.edison.aws.s3.togglz.S3StateRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.otto.edison.aws.s3.configuration;
package de.otto.edison.aws.s3.togglz;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
Expand Down
Loading

0 comments on commit f03c10c

Please sign in to comment.