Skip to content

Commit f8ac96e

Browse files
committed
Lambda fix for CDK
1 parent 5a4f825 commit f8ac96e

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ public class UnicornStoreStack extends Stack {
3030
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/ide.sh"
3131
3232
echo '=== Additional Setup ===\n'
33-
echo '===== whoami =====\n'
34-
whoami
35-
echo '\n'
33+
3634
echo '=== Checking directory ===\n'
3735
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/app.sh"
3836
sudo -H -i -u ec2-user bash -c "~/java-on-aws/infrastructure/scripts/setup/eks.sh"
@@ -69,9 +67,14 @@ public UnicornStoreStack(final Construct scope, final String id) {
6967
// Create VPC
7068
var vpc = new WorkshopVpc(this, "UnicornStoreVpc", "unicornstore-vpc").getVpc();
7169

70+
String bootstrapScriptWithRegion = bootstrapScript + String.format(
71+
"sudo -H -i -u ec2-user bash -c \"cd ~/java-on-aws/infrastructure/lambda/ && ./build-and-deploy.sh --region %s\"",
72+
this.getRegion()
73+
);
74+
7275
// Create VSCode IDE
7376
var ideProps = new VSCodeIdeProps();
74-
ideProps.setBootstrapScript(bootstrapScript);
77+
ideProps.setBootstrapScript(bootstrapScriptWithRegion);
7578
ideProps.setVpc(vpc);
7679
ideProps.setInstanceName("unicornstore-ide");
7780
ideProps.setInstanceType(InstanceType.of(InstanceClass.M5, InstanceSize.XLARGE));

infrastructure/scripts/setup/monitoring.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ log() {
1010
NAMESPACE="monitoring"
1111
GRAFANA_SECRET_NAME="grafana-admin"
1212
GRAFANA_USER="admin"
13-
GRAFANA_PASSWORD="$(openssl rand -base64 16 | tr -d '\n')"
13+
14+
source /etc/profile.d/workshop.sh
15+
16+
# Use IDE_PASSWORD if set; otherwise generate random Grafana password
17+
if [ -z "$IDE_PASSWORD" ]; then
18+
echo "⚠️ Warning: GRAFANA_PASSWORD is not set via IDE_PASSWORD. A random password will be generated."
19+
GRAFANA_PASSWORD="$(openssl rand -base64 16 | tr -d '\n')"
20+
else
21+
GRAFANA_PASSWORD="$IDE_PASSWORD"
22+
fi
1423

1524
VALUES_FILE="prometheus-values.yaml"
1625
EXTRA_SCRAPE_FILE="extra-scrape-configs.yaml"

0 commit comments

Comments
 (0)