Skip to content

Commit 7a833ca

Browse files
author
Yuriy Bezsonov
committed
WIP: refactoring
1 parent 9b81024 commit 7a833ca

21 files changed

Lines changed: 956 additions & 1352 deletions

apps/unicorn-store-spring/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
<dependency>
6363
<groupId>io.micrometer</groupId>
6464
<artifactId>micrometer-registry-prometheus</artifactId>
65-
<version>1.14.7</version>
6665
</dependency>
6766
<!-- AWS SDK dependencies -->
6867
<dependency>

apps/unicorn-store-spring/src/main/resources/application.properties

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,12 @@ spring.datasource.hikari.data-source-properties.preparedStatementCacheQueries=0
1616
spring.threads.virtual.enabled=true
1717

1818
# Actuator config
19-
spring.jmx-enabled=true
19+
spring.jmx.enabled=true
2020
management.endpoints.web.exposure.include=threaddump,prometheus,health,info
2121
management.endpoint.health.probes.enabled=true
22-
management.endpoint.prometheus.enabled=true
22+
management.endpoint.prometheus.access=unrestricted
2323
management.endpoint.health.group.liveness.include=livenessState
2424
management.endpoint.health.group.readiness.include=readinessState
2525

2626
management.metrics.enable.all=true
2727
management.metrics.tags.application=otel-jmx-unicorn-store
28-
29-
server.port=8080
30-
server.address=0.0.0.0

infrastructure/cdk/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,5 @@
7575
<version>${junit.version}</version>
7676
<scope>test</scope>
7777
</dependency>
78-
<dependency>
79-
<groupId>software.constructs</groupId>
80-
<artifactId>constructs</artifactId>
81-
<version>10.3.0</version>
82-
</dependency>
8378
</dependencies>
8479
</project>

infrastructure/cdk/src/main/java/com/unicorn/UnicornStoreStack.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ public class UnicornStoreStack extends Stack {
3232
echo '=== Additional Setup ===\n'
3333
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/app.sh"
3434
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/eks.sh"
35+
3536
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/monitoring.sh"
37+
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/thread-dump-lambda/build-and-deploy.sh"
38+
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/monitoring-jvm.sh"
3639
""";
3740

3841
private final String buildspec = """
@@ -64,14 +67,9 @@ public UnicornStoreStack(final Construct scope, final String id) {
6467
// Create VPC
6568
var vpc = new WorkshopVpc(this, "UnicornStoreVpc", "unicornstore-vpc").getVpc();
6669

67-
String bootstrapScriptWithRegion = bootstrapScript + String.format(
68-
"sudo -H -i -u ec2-user bash -c \"cd ~/java-on-aws/infrastructure/lambda/ && ./build-and-deploy.sh --region %s\"",
69-
this.getRegion()
70-
);
71-
7270
// Create VSCode IDE
7371
var ideProps = new VSCodeIdeProps();
74-
ideProps.setBootstrapScript(bootstrapScriptWithRegion);
72+
ideProps.setBootstrapScript(bootstrapScript);
7573
ideProps.setVpc(vpc);
7674
ideProps.setInstanceName("unicornstore-ide");
7775
ideProps.setInstanceType(InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE));
@@ -99,11 +97,8 @@ public UnicornStoreStack(final Construct scope, final String id) {
9997
new InfrastructureContainers(this, "InfrastructureContainers", infrastructureCore);
10098
new InfrastructureEks(this, "InfrastructureEks", infrastructureCore);
10199

102-
// Create Lambda function to create thread dump (after InfrastructureEks)
103-
InfrastructureLambdaBedrock lambdaBedrock = new InfrastructureLambdaBedrock(this, "InfrastructureLambdaBedrock", this.getRegion(), infrastructureCore.getWorkshopBucket(), eksCluster, vpc);
104-
105-
// Create Prometheus and Grafana infrastructure. Create Grafana dashboards (after InfrastructureEks)
106-
MonitoringConstruct monitoring = new MonitoringConstruct(this, "Monitoring", vpc, eksCluster.getCluster(), lambdaBedrock.getThreadDumpFunction());
100+
// Create JVM monitoring infrastructure with Lambda thread dump
101+
new InfrastructureMonitoringJVM(this, "InfrastructureMonitoringJVM", infrastructureCore.getWorkshopBucket(), eksCluster, vpc);
107102

108103
// Execute Database setup
109104
var databaseSetup = new DatabaseSetup(this, "UnicornStoreDatabaseSetup", infrastructureCore);

infrastructure/cdk/src/main/java/com/unicorn/core/AnalysisBucketProps.java

Lines changed: 0 additions & 82 deletions
This file was deleted.

infrastructure/cdk/src/main/java/com/unicorn/core/GrafanaDashboardConstruct.java

Lines changed: 0 additions & 169 deletions
This file was deleted.

infrastructure/cdk/src/main/java/com/unicorn/core/InfrastructureCore.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import software.amazon.awscdk.RemovalPolicy;
2929
import software.amazon.awscdk.SecretValue;
3030
import software.amazon.awscdk.SecretsManagerSecretOptions;
31+
import software.amazon.awscdk.Stack;
3132
import software.constructs.Construct;
3233

3334
import java.util.List;
@@ -67,8 +68,18 @@ public InfrastructureCore(final Construct scope, final String id, final IVpc vpc
6768
}
6869

6970
private Bucket createWorkshopBucket() {
71+
String timestamp = java.time.LocalDateTime.now().format(
72+
java.time.format.DateTimeFormatter.ofPattern("yyyyMMddHHmmss")
73+
);
74+
String bucketName = String.format("workshop-%s-%s-%s",
75+
Stack.of(this).getAccount(),
76+
Stack.of(this).getRegion(),
77+
timestamp
78+
);
79+
7080
var workshopBucket = Bucket.Builder
7181
.create(this, "WorkshopBucket")
82+
.bucketName(bucketName)
7283
.blockPublicAccess(BlockPublicAccess.BLOCK_ALL)
7384
.enforceSsl(true)
7485
.removalPolicy(RemovalPolicy.DESTROY)

0 commit comments

Comments
 (0)