Skip to content

Commit 6b844ad

Browse files
committed
fix: prepare cloud
1 parent 7eb302b commit 6b844ad

File tree

5 files changed

+69
-38
lines changed

5 files changed

+69
-38
lines changed

pom.xml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
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>
@@ -16,6 +16,10 @@
1616
<description>FIAP SOAT1 2023 - Group 63 - Phase 4</description>
1717
<properties>
1818
<java.version>17</java.version>
19+
<sonar.coverage.exclusions>
20+
**/config/*,
21+
**/dto/*DTO.*,
22+
</sonar.coverage.exclusions>
1923
</properties>
2024
<repositories>
2125
<repository>
@@ -105,7 +109,6 @@
105109
</dependencies>
106110

107111
<build>
108-
<finalName>app</finalName>
109112
<plugins>
110113
<plugin>
111114
<groupId>org.springframework.boot</groupId>
@@ -118,6 +121,17 @@
118121
</exclude>
119122
</excludes>
120123
</configuration>
124+
<executions>
125+
<execution>
126+
<goals>
127+
<goal>build-info</goal>
128+
</goals>
129+
</execution>
130+
</executions>
131+
</plugin>
132+
<plugin>
133+
<groupId>io.github.git-commit-id</groupId>
134+
<artifactId>git-commit-id-maven-plugin</artifactId>
121135
</plugin>
122136
</plugins>
123137
<resources>
@@ -166,7 +180,8 @@
166180
</goals>
167181
<configuration>
168182
<excludes>
169-
<exclude>**/br/com/grupo63/serviceproduction/config/DynamoDBConfig.class</exclude>
183+
<exclude>**/dto/*DTO.*</exclude>
184+
<exclude>**/config/**</exclude>
170185
</excludes>
171186
<formats>
172187
<format>XML</format>
@@ -179,4 +194,4 @@
179194
</build>
180195
</profile>
181196
</profiles>
182-
</project>
197+
</project>

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: 19 additions & 12 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() {
3236
AmazonDynamoDB amazonDynamoDB
33-
= new AmazonDynamoDBClient(amazonAWSCredentials());
37+
= 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-dev.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ jwt:
1717
token:
1818
key:
1919
public: "${JWT_PUBLIC_KEY:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqStd8n4SGNM0eZhV/hzU+urHA5/IMZPoP9YQ9ZcLKWiX33nI6bSuZMCrLZcJExf63xS+uxDpGxM8Mnk2zOdl+lPwANXLzP1us5P1PyA3YPycW9J7C5YTQW0GiEL3M93ZX7vMJiVoBYblP3JPlYnoYlBORuc0JPk33KtfEZP+78qXpPHM8imYrJLe8ceiDLLFDU/nh5KC2dWAy3ci1ahoJ1Q9ELhp3IZLvOTX57H/T2VKOYOya5+ST41h+JjzI+qGTVnLcKaW+k25YLlVnkSspvdx98+yQDi7kbOTS6yRZHUPD6wPk/nUozpD0nZKccoH4W+zMwmQVtsAA6JCA9gfGwIDAQAB}"
20-
amazon:
21-
dynamodb:
22-
endpoint: "${AMAZON_DYNAMODB_ENDPOINT:http://127.0.0.1:8080}"
23-
aws:
24-
accesskey: "${AMAZON_AWS_ACCESSKEY:accesskey}"
25-
secretkey: "${AMAZON_AWS_SECRETKEY:secretkey}"
26-
server:
27-
servlet:
28-
context-path: "/production"

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}"

0 commit comments

Comments
 (0)