Skip to content

Commit 7a975be

Browse files
Merge remote-tracking branch 'origin/2.3.x' into master
2 parents 17ccc83 + d1aadd6 commit 7a975be

File tree

28 files changed

+1608
-9
lines changed

28 files changed

+1608
-9
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
name: "Test with ${{ matrix.version }}"
1414
strategy:
1515
matrix:
16-
version: [ 8.0.272.hs-adpt ]
16+
version: [ 8.0.275.hs-adpt ]
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v2

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Java CI with Maven
2+
3+
on:
4+
push:
5+
tags:
6+
- v2.3.*
7+
- v2.4.*
8+
- v3.0.*
9+
10+
jobs:
11+
build:
12+
name: "Release"
13+
strategy:
14+
matrix:
15+
version: [ 8.0.275.hs-adpt ]
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Cache local Maven repository
20+
uses: actions/cache@v2
21+
with:
22+
path: ~/.m2/repository
23+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24+
restore-keys: ${{ runner.os }}-maven-
25+
- name: Download ${{ matrix.version }}
26+
uses: sdkman/sdkman-action@master
27+
id: sdkman
28+
with:
29+
candidate: java
30+
version: ${{ matrix.version }}
31+
- name: Set up ${{ matrix.version }}
32+
uses: actions/setup-java@v1
33+
with:
34+
java-version: 8
35+
jdkFile: ${{ steps.sdkman.outputs.file }}
36+
server-id: bintray-awspring
37+
server-username: BINTRAY_USERNAME
38+
server-password: BINTRAY_PASSWORD
39+
- name: Build with Maven
40+
run: ./mvnw -V verify
41+
- name: Build with Maven
42+
run: ./mvnw -V deploy
43+
env:
44+
BINTRAY_USERNAME: awspring-releaser
45+
BINTRAY_PASSWORD: ${{ secrets.BINTRAY_PASSWORD }}

docs/src/main/asciidoc/_configprops.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,6 @@
5555
|cloud.aws.stack.auto | true | Enables the automatic stack name detection for the application.
5656
|cloud.aws.stack.enabled | true | Enables Stack integration.
5757
|cloud.aws.stack.name | | The name of the manually configured stack name that will be used to retrieve the resources.
58+
|spring.cloud.aws.ses.region || The specific region for SES integration.
5859

5960
|===

docs/src/main/asciidoc/cloudformation.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ template file and creates all resources with their _physical name_. The applicat
1515
with the _logical name_ defined in the template. Spring Cloud AWS resolves all _logical names_ into the respective
1616
_physical name_ for the application developer.
1717

18+
=== Dependencies
19+
20+
To enable CloudFormation support in Spring Cloud AWS you must add following dependency that will trigger `ContextStackAutoConfiguration`:
21+
22+
[source,xml,indent=0]
23+
----
24+
<dependency>
25+
<groupId>com.amazonaws</groupId>
26+
<artifactId>aws-java-sdk-cloudformation</artifactId>
27+
</dependency>
28+
----
29+
1830
=== Automatic CloudFormation configuration
1931
If the application runs inside a stack (because the underlying EC2 instance has been bootstrapped within the stack), then
2032
Spring Cloud AWS will automatically detect the stack and resolve all resources from the stack. Application developers

docs/src/main/asciidoc/ses.adoc

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ an SES service where the client is overridden to use a valid region (EU-WEST-1).
142142
</beans>
143143
----
144144

145+
Since 2.3, if using spring-boot, the existing auto-configuration offers a specific configuration property to set the
146+
region for the SES client.
147+
148+
[source,properties,indent=0]
149+
----
150+
cloud.aws.mail.region=eu-west-1
151+
----
152+
153+
Also, there is a new starter `spring-cloud-starter-aws-ses` and it offers a specific configuration property.
154+
155+
[source,properties,indent=0]
156+
----
157+
spring.cloud.aws.ses.region=eu-west-1
158+
----
159+
145160
=== Authenticating e-mails
146161
To avoid any spam attacks on the Amazon SES mail service, applications without production access must
147162
https://docs.aws.amazon.com/ses/latest/DeveloperGuide/verify-email-addresses.html[verify] each

pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,13 @@
6161
<module>spring-cloud-aws-autoconfigure</module>
6262
<module>spring-cloud-aws-parameter-store-config</module>
6363
<module>spring-cloud-aws-secrets-manager-config</module>
64+
<module>spring-cloud-aws-ses</module>
6465
<module>spring-cloud-starter-aws</module>
6566
<module>spring-cloud-starter-aws-jdbc</module>
6667
<module>spring-cloud-starter-aws-messaging</module>
6768
<module>spring-cloud-starter-aws-parameter-store-config</module>
6869
<module>spring-cloud-starter-aws-secrets-manager-config</module>
70+
<module>spring-cloud-starter-aws-ses</module>
6971
<module>spring-cloud-aws-integration-test</module>
7072
<module>docs</module>
7173
</modules>
@@ -291,4 +293,11 @@
291293
</profile>
292294
</profiles>
293295

296+
<distributionManagement>
297+
<repository>
298+
<id>bintray-awspring</id>
299+
<url>https://api.bintray.com/maven/awspring/releases/spring-cloud-aws/;publish=1</url>
300+
</repository>
301+
</distributionManagement>
302+
294303
</project>

spring-cloud-aws-autoconfigure/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@
4848
<artifactId>spring-cloud-aws-parameter-store-config</artifactId>
4949
<optional>true</optional>
5050
</dependency>
51+
<dependency>
52+
<groupId>org.springframework.cloud</groupId>
53+
<artifactId>spring-cloud-aws-ses</artifactId>
54+
<optional>true</optional>
55+
</dependency>
5156
<dependency>
5257
<groupId>org.springframework.boot</groupId>
5358
<artifactId>spring-boot-autoconfigure</artifactId>
@@ -57,6 +62,25 @@
5762
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
5863
<optional>true</optional>
5964
</dependency>
65+
66+
<dependency>
67+
<groupId>org.springframework.security</groupId>
68+
<artifactId>spring-security-config</artifactId>
69+
<optional>true</optional>
70+
</dependency>
71+
72+
<dependency>
73+
<groupId>org.springframework.security</groupId>
74+
<artifactId>spring-security-oauth2-jose</artifactId>
75+
<optional>true</optional>
76+
</dependency>
77+
78+
<dependency>
79+
<groupId>org.springframework.security</groupId>
80+
<artifactId>spring-security-oauth2-resource-server</artifactId>
81+
<optional>true</optional>
82+
</dependency>
83+
6084
<dependency>
6185
<groupId>io.micrometer</groupId>
6286
<artifactId>micrometer-registry-cloudwatch</artifactId>
@@ -87,6 +111,11 @@
87111
<artifactId>aws-java-sdk-ses</artifactId>
88112
<optional>true</optional>
89113
</dependency>
114+
<dependency>
115+
<groupId>com.amazonaws</groupId>
116+
<artifactId>aws-java-sdk-cloudformation</artifactId>
117+
<optional>true</optional>
118+
</dependency>
90119
<dependency>
91120
<groupId>com.amazonaws</groupId>
92121
<artifactId>aws-java-sdk-cloudwatch</artifactId>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright 2013-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.aws.autoconfigure.mail;
18+
19+
import javax.mail.Session;
20+
21+
import com.amazonaws.auth.AWSCredentialsProvider;
22+
import com.amazonaws.services.simpleemail.AmazonSimpleEmailService;
23+
import com.amazonaws.services.simpleemail.AmazonSimpleEmailServiceClient;
24+
25+
import org.springframework.beans.factory.ObjectProvider;
26+
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
27+
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
28+
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
29+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
30+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
31+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
32+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
33+
import org.springframework.boot.autoconfigure.mail.MailSenderAutoConfiguration;
34+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
35+
import org.springframework.cloud.aws.autoconfigure.context.ContextCredentialsAutoConfiguration;
36+
import org.springframework.cloud.aws.context.annotation.ConditionalOnMissingAmazonClient;
37+
import org.springframework.cloud.aws.core.config.AmazonWebserviceClientFactoryBean;
38+
import org.springframework.cloud.aws.core.region.RegionProvider;
39+
import org.springframework.cloud.aws.core.region.StaticRegionProvider;
40+
import org.springframework.cloud.aws.ses.SimpleEmailServiceJavaMailSender;
41+
import org.springframework.cloud.aws.ses.SimpleEmailServiceMailSender;
42+
import org.springframework.context.annotation.Bean;
43+
import org.springframework.context.annotation.Configuration;
44+
import org.springframework.context.annotation.Import;
45+
import org.springframework.mail.MailSender;
46+
import org.springframework.mail.javamail.JavaMailSender;
47+
48+
/**
49+
* {@link EnableAutoConfiguration Auto-configuration} for AWS Simple Email Service
50+
* support.
51+
*
52+
* @author Agim Emruli
53+
* @author Eddú Meléndez
54+
*/
55+
@Configuration(proxyBeanMethods = false)
56+
@AutoConfigureAfter(MailSenderAutoConfiguration.class)
57+
@AutoConfigureBefore(SimpleEmailAutoConfiguration.class)
58+
@ConditionalOnClass({ AmazonSimpleEmailService.class, MailSender.class })
59+
@ConditionalOnMissingBean(MailSender.class)
60+
@Import(ContextCredentialsAutoConfiguration.class)
61+
@EnableConfigurationProperties(SesProperties.class)
62+
@ConditionalOnProperty(name = "spring.cloud.aws.ses.enabled", havingValue = "true", matchIfMissing = true)
63+
public class SesAutoConfiguration {
64+
65+
private final AWSCredentialsProvider credentialsProvider;
66+
67+
private final RegionProvider regionProvider;
68+
69+
public SesAutoConfiguration(ObjectProvider<RegionProvider> regionProvider,
70+
ObjectProvider<AWSCredentialsProvider> credentialsProvider, SesProperties properties) {
71+
this.credentialsProvider = credentialsProvider.getIfAvailable();
72+
this.regionProvider = properties.getRegion() == null ? regionProvider.getIfAvailable()
73+
: new StaticRegionProvider(properties.getRegion());
74+
}
75+
76+
@Bean
77+
@ConditionalOnMissingAmazonClient(AmazonSimpleEmailService.class)
78+
public AmazonWebserviceClientFactoryBean<AmazonSimpleEmailServiceClient> amazonSimpleEmailService() {
79+
return new AmazonWebserviceClientFactoryBean<>(AmazonSimpleEmailServiceClient.class, this.credentialsProvider,
80+
this.regionProvider);
81+
}
82+
83+
@Bean
84+
@ConditionalOnMissingClass("javax.mail.Session")
85+
public MailSender simpleMailSender(AmazonSimpleEmailService amazonSimpleEmailService) {
86+
return new SimpleEmailServiceMailSender(amazonSimpleEmailService);
87+
}
88+
89+
@Bean
90+
@ConditionalOnClass(Session.class)
91+
public JavaMailSender javaMailSender(AmazonSimpleEmailService amazonSimpleEmailService) {
92+
return new SimpleEmailServiceJavaMailSender(amazonSimpleEmailService);
93+
}
94+
95+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2013-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.aws.autoconfigure.mail;
18+
19+
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
21+
/**
22+
* Configuration properties for AWS Simple Email Service.
23+
*
24+
* @author Eddú Meléndez
25+
*/
26+
@ConfigurationProperties(prefix = "spring.cloud.aws.ses")
27+
public class SesProperties {
28+
29+
/**
30+
* Overrides the default region.
31+
*/
32+
private String region;
33+
34+
public String getRegion() {
35+
return region;
36+
}
37+
38+
public void setRegion(String region) {
39+
this.region = region;
40+
}
41+
42+
}

0 commit comments

Comments
 (0)