Merged in feature/cognito-shared-environments (pull request #211)
cognito and permit shared prod environment support * code complete * user creattion tool test harness
This commit is contained in:
+23
-1
@@ -31,9 +31,13 @@ import (
|
||||
"queryorchestration/internal/label"
|
||||
"queryorchestration/internal/server/api"
|
||||
"queryorchestration/internal/serviceconfig"
|
||||
awsc "queryorchestration/internal/serviceconfig/aws"
|
||||
"queryorchestration/internal/serviceconfig/build"
|
||||
"queryorchestration/internal/serviceconfig/objectstore"
|
||||
"queryorchestration/internal/serviceconfig/queue/clientsync"
|
||||
"queryorchestration/internal/usermanagement"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/cognitoidentityprovider"
|
||||
|
||||
queryapi "queryorchestration/api/queryAPI"
|
||||
documentbatch "queryorchestration/internal/document/batch"
|
||||
@@ -134,8 +138,26 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Create Cognito SDK client for environment attribute registration and middleware use.
|
||||
// This client is created once and reused for the lifetime of the process.
|
||||
awsCfg, err := awsc.GetAWSConfig(ctx)
|
||||
if err != nil {
|
||||
slog.Error("Failed to load AWS config for Cognito client", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cognitoClient := cognitoidentityprovider.NewFromConfig(awsCfg)
|
||||
|
||||
// Ensure the custom:environment_id attribute is registered on the Cognito user pool.
|
||||
// This is safe to call on every startup (idempotent). Failure is non-fatal because
|
||||
// the attribute may already exist or the environment may not support this API (e.g. LocalStack).
|
||||
if err := usermanagement.EnsureEnvironmentIDAttribute(ctx, cognitoClient, cfg.GetAuthUserPoolID(), cfg.GetLogger()); err != nil {
|
||||
cfg.GetLogger().Warn("Failed to ensure Cognito environment_id attribute", "error", err)
|
||||
} else {
|
||||
cfg.GetLogger().Info("Cognito custom attribute custom:environment_id is registered")
|
||||
}
|
||||
|
||||
// Initialize S3 client before creating the server (needed for background worker)
|
||||
err := cfg.SetStoreClient(ctx)
|
||||
err = cfg.SetStoreClient(ctx)
|
||||
if err != nil {
|
||||
slog.Error(err.Error())
|
||||
os.Exit(1)
|
||||
|
||||
Reference in New Issue
Block a user