-
Notifications
You must be signed in to change notification settings - Fork 372
Feature/AppConfig as PropertySource #652
base: 2.3.x
Are you sure you want to change the base?
Conversation
Fix AwsSecretsManagerProperties.prefix javadoc
…S can use to create read replicas. Closes spring-atticgh-458
…bab case to enable Spring Boot relaxed binding. Fixes spring-atticgh-406 Closes spring-atticgh-407
Closes spring-atticgh-529 Fixes spring-atticgh-509 Fixes spring-atticgh-527 Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
… on application startup. Fixes spring-atticgh-556
…istener. This commit fixes this issue by delegating exception processing to AbstractMethodMessageHandler only when there is a configured handler. If there is none, exception is logged. Fixes spring-atticgh-394 Closes spring-atticgh-465 Co-authored-by: Maciej Walkowiak <walkowiak.maciej@yahoo.com>
…pertySourceLocator. Fixes spring-atticgh-472 Closes spring-atticgh-473
Spring Boot 2.4 has moved from providing automatic support for JUnit 4. For now we must declare it explicitly and in the future migrate to JUnit 5.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jarpz thank you! looks amazing! it is almost done :)
...pringframework/cloud/aws/autoconfigure/appconfig/AwsAppConfigBootstrapConfigurationTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add few comments in order to improve the code. Also, spring.cloud.aws.appconfig.enabled
should be added in spring-cloud-aws-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json
. You can take a look into #682
@@ -9,4 +9,5 @@ org.springframework.cloud.aws.autoconfigure.cache.ElastiCacheAutoConfiguration,\ | |||
org.springframework.cloud.aws.autoconfigure.messaging.SqsAutoConfiguration,\ | |||
org.springframework.cloud.aws.autoconfigure.messaging.SnsAutoConfiguration,\ | |||
org.springframework.cloud.aws.autoconfigure.jdbc.AmazonRdsDatabaseAutoConfiguration,\ | |||
org.springframework.cloud.aws.autoconfigure.metrics.CloudWatchExportAutoConfiguration | |||
org.springframework.cloud.aws.autoconfigure.metrics.CloudWatchExportAutoConfiguration,\ | |||
org.springframework.cloud.aws.autoconfigure.appconfig.AwsAppConfigBootstrapConfiguration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one should be in another property
org.springframework.cloud.bootstrap.BootstrapConfiguration=\
org.springframework.cloud.aws.autoconfigure.appconfig.AwsAppConfigBootstrapConfiguration
assertThat(errors.getAllErrors()).isEmpty(); | ||
} | ||
|
||
private static class AwsAppConfigPropertiesBuilder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
builder is not needed, objects can be created inside of invalidProperties
"aws.appconfig.environment=dev" }; | ||
|
||
@Test | ||
void testWithStaticRegion() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be like this
@Test
void testWithStaticRegion() {
this.contextRunner
.withPropertyValues("spring.cloud.aws.parameterstore.region:us-east-1")
.run(context -> {
AWSSimpleSystemsManagementClient client = context
.getBean(AWSSimpleSystemsManagementClient.class);
Object region = ReflectionTestUtils.getField(client, "signingRegion");
assertThat(region).isEqualTo("us-east-1");
});
}
@ConditionalOnClass({ AmazonAppConfigAsync.class, | ||
AwsAppConfigPropertySourceLocator.class }) | ||
@ConditionalOnProperty(prefix = "aws.appconfig", name = "enabled", matchIfMissing = true) | ||
public class AwsAppConfigBootstrapConfiguration { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a constructor, similar to this one
public AwsParameterStoreBootstrapConfiguration(ParameterStoreProperties properties,
ObjectProvider<RegionProvider> regionProvider) {
this.regionProvider = properties.getRegion() == null
? regionProvider.getIfAvailable()
: new StaticRegionProvider(properties.getRegion());
this.properties = properties;
}
|
||
@Bean | ||
@ConditionalOnMissingBean | ||
public AmazonAppConfig appConfigClient( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
client should look like this
@Bean
@ConditionalOnMissingBean
public AmazonWebserviceClientFactoryBean<AWSSimpleSystemsManagementClient> ssmClient() {
return new AmazonWebserviceClientFactoryBean<>(
AWSSimpleSystemsManagementClient.class, null, this.regionProvider);
}
/** | ||
* Configuration prefix. | ||
*/ | ||
public static final String CONFIG_PREFIX = "aws.appconfig"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove this
/** | ||
* @author jarpz | ||
*/ | ||
@ConfigurationProperties(AwsAppConfigProperties.CONFIG_PREFIX) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ConfigurationProperties(prefix = "spring.cloud.aws.appconfig")
@EnableConfigurationProperties(AwsAppConfigProperties.class) | ||
@ConditionalOnClass({ AmazonAppConfigAsync.class, | ||
AwsAppConfigPropertySourceLocator.class }) | ||
@ConditionalOnProperty(prefix = "aws.appconfig", name = "enabled", matchIfMissing = true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ConditionalOnProperty(prefix = ""spring.cloud.aws.appconfig"", name = "enabled", matchIfMissing = true)
… change spring.factories BootstrapConfiguration + improve tests
Hi @eddumelendez , I applied last comments you made. Have you seen them? |
@jarpz sorry for the delay and thanks for your patience. The code looks good to me but unfortunately we are still figuring out few things. there are also some prs in progress for new modules related to parameter store and secrets manager and since this is a new one we want to make it right. The issue is this |
I understand. It's ok. Anything else can I help with? Regards |
I would like to see this one for 2.3 since it has many sources such as s3, ssm document, ssm parameter. The only missing part is adding the support for the new Config Data API with prefix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just left questions to understand more now that I have read some docs. Changes are not needed.
@ConfigurationProperties(prefix = "spring.cloud.aws.appconfig") | ||
public class AwsAppConfigProperties implements Validator { | ||
|
||
private String accountId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the client-id right? By reading the docs this would be each instance? Saying that because says unique. So, if I have two VMs then client-id
for one should be my-app-1
and the other one my-app-2
. Is that right @jarpz ?
I don't think so it would be like that but let me know if I am wrong. I think that here we should use the spring.application.name
or application
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, well accountId do reference to the was account subscription id, this value es required by aws-sdk. The "application" you means yes is "configurationProfile", We could have 2 VM with same accountId and differents "configurationProfile" names which make reference by the spring.application.name
If you check the class: AwsAppConfigPropertySourceLocator
we check for null configurationProfile and use spring.application.name
in that case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this example and it is using random uuid https://github.com/aws-samples/aws-appconfig-java-sample/blob/main/src/main/java/com/amazonaws/samples/appconfig/movies/MoviesController.java#L65
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstand.. "clientId" could be any value.. You are right- but is a required field. I'm gonna to change it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, you are right.. we can use a random value for "clientId".. but is required, I'm gonna change it
|
||
private String accountId; | ||
|
||
private String application; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be by default the spring.application.name
or if the previous one is not defined just application
|
||
private String environment; | ||
|
||
private String configurationProfile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not using in the request to the api, why do we need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to create the GetConfigurationRequest we use:
new GetConfigurationRequest()
.withClientId(accountId) // aws client Id is required.. we can use a random value
.withApplication(application) // appConfig ApplicationName
.withConfiguration(name) // configurationProfile or "spring.application.name" when is null *
.withClientConfigurationVersion(configurationVersion) //last version if null
.withEnvironment(environment); //environment
I tried to use the same names which aws app-config use.
Regards
…dom clientId + use first profile name as environment if it is null
Hi, any idea on when this will get released? Have been waiting for something like this for a while! |
Hi, this will get released? Have been waiting for something like this for a while! |
Enable to use of AppConfig as PropertySource supporting Yaml & Json content-types.