Usa dependencias privadas con funciones de Cloud Run
Organiza tus páginas con colecciones
Guarda y categoriza el contenido según tus preferencias.
Puedes usar un paquete en un repositorio de npm o Python como dependencia para una función de Cloud Run.
Permisos necesarios
Cloud Run Functions usa la cuenta de servicio de Cloud Build en el
mismo Google Cloud proyecto para compilar e implementar tu función.
Si las funciones de Cloud Run y Artifact Registry están en el mismo Google Cloud
proyecto, la cuenta de servicio tiene los permisos necesarios para descargar desde
los repositorios.
Si las funciones de Cloud Run y Artifact Registry están en proyectos diferentes, debes otorgarle acceso al repositorio a la cuenta de servicio de Cloud Build.
Para proporcionar acceso de solo lectura para descargar dependencias, otorga el rol de lector de Artifact Registry.
Si también usas Cloud Build para subir artefactos a repositorios, otorga el rol de escritor de Artifact Registry.
Configura el acceso a las dependencias
Consulta la documentación de Cloud Run Functions para obtener instrucciones de configuración de npm y Python.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-09-04 (UTC)"],[[["\u003cp\u003eCloud Run functions can use packages from npm or Python repositories as dependencies.\u003c/p\u003e\n"],["\u003cp\u003eThe Cloud Build service account is used to build and deploy Cloud Run functions, requiring specific permissions.\u003c/p\u003e\n"],["\u003cp\u003eIf Cloud Run functions and Artifact Registry are in the same project, the service account automatically has the necessary download permissions.\u003c/p\u003e\n"],["\u003cp\u003eIf in separate projects, you must grant the Cloud Build service account either the Artifact Registry Reader role for downloading dependencies or the Artifact Registry Writer role for uploading and downloading.\u003c/p\u003e\n"],["\u003cp\u003eDetailed configuration instructions for npm and Python dependencies can be found in the Cloud Run functions documentation.\u003c/p\u003e\n"]]],[],null,["# Using private dependencies with Cloud Run functions\n\nYou can use a package in an npm or Python repository as a dependency for\na Cloud Run function.\n\nRequired permissions\n--------------------\n\nCloud Run functions uses the [Cloud Build service account](/build/docs/cloud-build-service-account) in the\nsame Google Cloud project to build and deploy your function.\n\n- If Cloud Run functions and Artifact Registry are in the same Google Cloud project, the service account has the necessary permissions to download from repositories.\n- If Cloud Run functions and Artifact Registry are in different projects, you must grant repository access to the Cloud Build service account.\n - To provide read-only access for downloading dependencies, [grant](/artifact-registry/docs/access-control#grant) the Artifact Registry Reader role.\n - If you also use Cloud Build to upload artifacts to repositories, [grant](/artifact-registry/docs/access-control#grant) the Artifact Registry Writer role.\n\nConfiguring access to dependencies\n----------------------------------\n\nSee the Cloud Run functions documentation for [npm](/functions/docs/writing/specifying-dependencies-nodejs#using_private_modules) and [Python](/functions/docs/writing/specifying-dependencies-python#using_private_dependencies)\nconfiguration instructions."]]