Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix(gcp): improve error handling for AWS credentials retrieval in GCP workload identity federation

Victor Hugo dos Santos034c11a9de1d
diff --git a/backend/src/services/app-connection/gcp/gcp-connection-fns.ts b/backend/src/services/app-connection/gcp/gcp-connection-fns.ts
index b6b81d2862..d570964f1d 100644
--- a/backend/src/services/app-connection/gcp/gcp-connection-fns.ts
+++ b/backend/src/services/app-connection/gcp/gcp-connection-fns.ts
@@ -59,7 +59,16 @@ const buildGcpAwsExternalAccountClient = (credJson: TGcpCredentialJson, scopes:
}
},
getAwsSecurityCredentials: async () => {
- const credentials = await stsClient.config.credentials();
+ let credentials;
+ try {
+ credentials = await stsClient.config.credentials();
+ } catch (error) {
+ logger.error({ err: error }, "Failed to resolve AWS credentials for GCP workload identity federation");
+ throw new InternalServerError({
+ message:
+ "Failed to resolve AWS credentials for GCP workload identity federation. Verify the instance has valid AWS credentials available (task role, instance profile, or environment variables)."
+ });
+ }
return {
accessKeyId: credentials.accessKeyId,
secretAccessKey: credentials.secretAccessKey,