Skip to content

Commit 8c42c7b

Browse files
Merge branch 'main' into feat/temp-sqs
2 parents dc00eac + 87cff38 commit 8c42c7b

File tree

5 files changed

+70
-29
lines changed

5 files changed

+70
-29
lines changed

pom.xml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<parent>
77
<groupId>org.springframework.boot</groupId>
88
<artifactId>spring-boot-starter-parent</artifactId>
99
<version>3.1.0</version>
10-
<relativePath/> <!-- lookup parent from repository -->
10+
<relativePath /> <!-- lookup parent from repository -->
1111
</parent>
1212
<groupId>br.com.grupo63</groupId>
1313
<artifactId>serviceproduction</artifactId>
14-
<version>4.0.0</version>
14+
<version>5.0.0</version>
1515
<name>Service Production</name>
16-
<description>FIAP SOAT1 2023 - Group 63 - Phase 4</description>
16+
<description>FIAP SOAT1 2023 - Group 63 - Phase 5 - Production microservice </description>
1717
<properties>
1818
<java.version>17</java.version>
1919
<aws.sdk.version>1.12.674</aws.sdk.version>
20+
<sonar.coverage.exclusions>
21+
**/config/*,
22+
**/dto/*DTO.*,
23+
</sonar.coverage.exclusions>
2024
</properties>
2125
<repositories>
2226
<repository>
@@ -130,7 +134,6 @@
130134
</dependencies>
131135

132136
<build>
133-
<finalName>app</finalName>
134137
<plugins>
135138
<plugin>
136139
<groupId>org.springframework.boot</groupId>
@@ -143,6 +146,17 @@
143146
</exclude>
144147
</excludes>
145148
</configuration>
149+
<executions>
150+
<execution>
151+
<goals>
152+
<goal>build-info</goal>
153+
</goals>
154+
</execution>
155+
</executions>
156+
</plugin>
157+
<plugin>
158+
<groupId>io.github.git-commit-id</groupId>
159+
<artifactId>git-commit-id-maven-plugin</artifactId>
146160
</plugin>
147161
</plugins>
148162
<resources>
@@ -191,7 +205,8 @@
191205
</goals>
192206
<configuration>
193207
<excludes>
194-
<exclude>**/br/com/grupo63/serviceproduction/config/DynamoDBConfig.class</exclude>
208+
<exclude>**/dto/*DTO.*</exclude>
209+
<exclude>**/config/**</exclude>
195210
</excludes>
196211
<formats>
197212
<format>XML</format>

src/main/java/br/com/grupo63/serviceproduction/ServiceProductionApplication.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
@OpenAPIDefinition(
1313
info = @Info(title = "${info.name}", description = "${info.description}", version = "${info.version}"),
1414
servers ={
15-
@Server(url = "${server.servlet.context-path}", description = "Current URL"),
16-
@Server(url = "localhost:8080", description = "Local"),
17-
@Server(url = "${docs.api.url}", description = "API Gateway Invoke URL")
15+
@Server(url = "${server.servlet.context-path:}", description = "Current URL"),
16+
@Server(url = "localhost:${server.port:8080}${server.servlet.context-path:}", description = "Localhost"),
17+
@Server(url = "${app.docs-api-url:(no value)}${server.servlet.context-path:}", description = "Custom URL from env")
1818
})
1919
@SecurityScheme(
2020
name = "bearerAuth",

src/main/java/br/com/grupo63/serviceproduction/config/DynamoDBConfig.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.amazonaws.auth.AWSCredentials;
44
import com.amazonaws.auth.BasicAWSCredentials;
5+
import com.amazonaws.auth.BasicSessionCredentials;
56
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB;
67
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;
78
import org.socialsignin.spring.data.dynamodb.repository.config.EnableDynamoDBRepositories;
@@ -18,30 +19,36 @@
1819
@EnableDynamoDBRepositories
1920
(basePackages = "br.com.grupo63.serviceproduction.gateway")
2021
public class DynamoDBConfig {
21-
@Value("${amazon.dynamodb.endpoint}")
22-
private String amazonDynamoDBEndpoint;
22+
@Value("${app.aws.dynamodb.endpoint}")
23+
private String awsDynamoDBEndpoint;
2324

24-
@Value("${amazon.aws.accesskey}")
25-
private String amazonAWSAccessKey;
25+
@Value("${app.aws.access-key}")
26+
private String awsAccessKey;
2627

27-
@Value("${amazon.aws.secretkey}")
28-
private String amazonAWSSecretKey;
28+
@Value("${app.aws.secret-key}")
29+
private String awsSecretKey;
30+
31+
@Value("${app.aws.session-token}")
32+
private String awsSessionToken;
2933

3034
@Bean
3135
public AmazonDynamoDB amazonDynamoDB(AWSCredentials awsCredentials) {
3236
AmazonDynamoDB amazonDynamoDB
3337
= new AmazonDynamoDBClient(awsCredentials);
3438

35-
if (!StringUtils.isEmpty(amazonDynamoDBEndpoint)) {
36-
amazonDynamoDB.setEndpoint(amazonDynamoDBEndpoint);
39+
if (!StringUtils.isEmpty(awsDynamoDBEndpoint)) {
40+
amazonDynamoDB.setEndpoint(awsDynamoDBEndpoint);
3741
}
3842

3943
return amazonDynamoDB;
4044
}
4145

4246
@Bean
43-
public AWSCredentials amazonAWSCredentials() {
44-
return new BasicAWSCredentials(
45-
amazonAWSAccessKey, amazonAWSSecretKey);
47+
public AWSCredentials awsCredentials() {
48+
if (awsSessionToken == null || awsSessionToken.isBlank()) {
49+
return new BasicAWSCredentials(
50+
awsAccessKey, awsSecretKey);
51+
}
52+
return new BasicSessionCredentials(awsAccessKey, awsSecretKey, awsSessionToken);
4653
}
4754
}

src/main/resources/application.yml

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ spring:
1414
flyway:
1515
locations: classpath:db/migrations/{vendor}/
1616
enabled: true
17-
jwt:
18-
token:
19-
key:
20-
public: "${JWT_PUBLIC_KEY}"
2117

2218
springdoc:
2319
swagger-ui:
@@ -31,15 +27,37 @@ management:
3127
endpoint:
3228
health:
3329
show-components: always
30+
shutdown:
31+
enabled: true # For debugging
3432
endpoints:
3533
web:
3634
exposure:
37-
include: health, info
35+
include: health, info, metrics, shutdown
36+
37+
server:
38+
servlet:
39+
context-path: "/production"
40+
port: 8004
41+
42+
43+
# --- Custom keys ---
44+
3845
info:
3946
name: '@project.name@'
4047
description: '@project.description@'
4148
version: '@project.version@'
4249

43-
docs:
44-
api:
45-
url: "${DOCS_API_URL:https://9ah1j49vm1.execute-api.us-east-2.amazonaws.com}"
50+
51+
app:
52+
docs-api-url: "${DOCS_API_URL:(no value)}"
53+
aws:
54+
access-key: "${AWS_ACCESS_KEY:no_access_key}"
55+
secret-key: "${AWS_SECRET_KEY:no_secret_key}"
56+
session-token: "${AWS_SESSION_TOKEN:}"
57+
dynamodb:
58+
endpoint: "${AWS_DYNAMODB_ENDPOINT:dynamodb.us-east-1.amazonaws.com}"
59+
60+
jwt:
61+
token:
62+
key:
63+
public: "${JWT_PUBLIC_KEY}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Due to how Spring Boot autoconfiguration works, this file needs to exist for the locale files to be detected.

0 commit comments

Comments
 (0)