Skip to content

Commit

Permalink
Conditionally set admin env vars based on keycloak version
Browse files Browse the repository at this point in the history
  • Loading branch information
alukach committed Oct 31, 2024
1 parent 9760b09 commit fbfbcb2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions deploy/lib/KeycloakService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface KeycloakServiceProps extends StackInputProps {
vpc: ec2.IVpc;
databaseName: string;
databaseInstance: rds.DatabaseInstance;
version: string;
}

export class KeycloakService extends Construct {
Expand Down Expand Up @@ -91,8 +92,15 @@ export class KeycloakService extends Construct {
KC_DB_URL_PORT: ecsDbSecret("port"),

// Admin
KEYCLOAK_ADMIN: ecsAdminSecret("username"),
KEYCLOAK_ADMIN_PASSWORD: ecsAdminSecret("password"),
...(parseInt(props.version.split(".")[0]) >= 26
? {
KEYCLOAK_ADMIN: ecsAdminSecret("username"),
KEYCLOAK_ADMIN_PASSWORD: ecsAdminSecret("password"),
}
: {
KC_BOOTSTRAP_ADMIN_USERNAME: ecsAdminSecret("username"),
KC_BOOTSTRAP_ADMIN_PASSWORD: ecsAdminSecret("password"),
}),
},
},
}
Expand Down
1 change: 1 addition & 0 deletions deploy/lib/KeycloakStack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export class KeycloakStack extends cdk.Stack {
vpc,
databaseName,
databaseInstance: database,
version: props.keycloakVersion,
...props,
});

Expand Down

0 comments on commit fbfbcb2

Please sign in to comment.