Secret Manager는 API 키, 비밀번호, 인증서, 기타 민감한 정보를 위한 안전하고 편리한 스토리지 시스템입니다. Secret Manager는 Google Cloud에서 보안 비밀을 관리, 액세스, 감사하는 중앙의 단일 정보 소스를 제공합니다.
Workflows의 Secret Manager API용 커넥터를 사용하여 워크플로 내에서 Secret Manager에 액세스할 수 있습니다. 이렇게 하면 커넥터가 요청 형식을 처리하고 Secret Manager API의 세부정보를 알 필요가 없도록 메서드와 인수를 제공하므로 통합이 간소화됩니다. 커넥터에는 재시도 및 장기 실행 작업을 처리하기 위한 기본 제공 동작도 있습니다. Workflows 커넥터 사용에 대한 상세 설명은 커넥터 이해를 참조하세요.
Workflows 서비스 계정에 Secret Manager 액세스 권한 부여
Secret Manager는 액세스 제어에 Identity and Access Management(IAM)를 사용합니다. 보안 비밀 만들기, 관리, 나열, 액세스를 위해서는 프로젝트 수준 및 개별 리소스 수준에서 적절한 IAM 권한을 부여해야 합니다. 자세한 내용은 IAM으로 액세스 제어를 참조하세요.
Workflows는 서비스 계정을 사용하여 워크플로에Google Cloud 리소스에 대한 액세스 권한을 부여합니다. 보안 비밀 버전에 액세스하려면 서비스 계정에 보안 비밀, 프로젝트, 폴더 또는 조직에 대한 Secret Manager 보안 비밀 접근자 역할(roles/secretmanager.secretAccessor)을 부여해야 합니다. 사용자 관리 서비스 계정으로 워크플로 배포에 대해 자세히 알아보세요.
API 사용 설정
Secret Manager API에 대해 Workflows 커넥터를 사용하기 전에 Secret Manager 및 Workflows API를 사용 설정합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-18(UTC)"],[],[],null,["# Secure and store sensitive data using the Secret Manager connector\n\nSecret Manager is a secure and convenient storage system for\nAPI keys, passwords, certificates, and other sensitive data. Secret Manager\nprovides a central place and single source of truth to manage, access, and audit\nsecrets across Google Cloud.\n\nYou can use Workflows'\n[connector for the Secret Manager API](https://cloud.google.com/workflows/docs/reference/googleapis/secretmanager/Overview)\nto access Secret Manager within a workflow. This simplifies the\nintegration for you, because the connector handles the formatting of\nrequests, and provides methods and arguments so that you don't need to know\nthe details of the Secret Manager API. The connector also has\nbuilt-in behavior for handling retries and long-running operations. To learn\nmore about using Workflows connectors, see\n[Understand connectors](/workflows/docs/connectors).\n\nGrant the Workflows service account access to Secret Manager\n------------------------------------------------------------\n\nSecret Manager uses Identity and Access Management (IAM) for access\ncontrol. To create, manage, list, or access a secret, the appropriate\nIAM permissions must be granted at the project level and at the\nindividual resource level. For more information, see\n[Access control with IAM](/secret-manager/docs/access-control).\n\nWorkflows uses service accounts to give workflows access to\nGoogle Cloud resources. To\n[access a secret version](/secret-manager/docs/access-secret-version), you must\ngrant the Secret Manager Secret Accessor role\n(`roles/secretmanager.secretAccessor`) on the secret, project, folder, or\norganization to the service account. Learn more about\n[deploying a workflow with a user-managed service account](/workflows/docs/authentication).\n\nEnable the APIs\n---------------\n\nBefore using the Workflows' connector for the\nSecret Manager API, ensure that you enable the\nSecret Manager and Workflows APIs. \n\n### Console\n\n[Enable the APIs](https://console.cloud.google.com/flows/enableapi?apiid=secretmanager.googleapis.com,workflows.googleapis.com)\n\n### gcloud\n\n gcloud services enable secretmanager.googleapis.com workflows.googleapis.com\n\nInvoke a connector call\n-----------------------\n\nSimilar to invoking an HTTP endpoint, a connector call requires `call` and `args`\nfields. For more information, see\n[Invoke a connector call](/workflows/docs/reference/googleapis#invoke_a_connector_call).\n\nIn addition to using a call step, you can call the helper methods in an\nexpression like this: \n\n```genshi\n${googleapis.secretmanager.v1.projects.secrets.versions.accessString(secret_id, version, project_id)}\n```\n\nFor example, you can use the helper method `accessString` to retrieve the secret\ndata as a string. This is simpler than using the `access` API as the secret data\nis automatically decoded to a string format.\n\nYou can also use the helper method `addVersionString` to add a new secret value\nto an existing secret. This is simpler than using the `addVersion` API as the\nsecret data is automatically encoded to a base-64 string, which is required by\n`addVersion`.\n\nRetrieve a secret using the Secret Manager connector\n----------------------------------------------------\n\nThe following workflow demonstrates how to use the Secret Manager\nconnector to retrieve a secret.\n\n### YAML\n\n # This workflow demonstrates how to use the Secret Manager connector:\n # Retrieve a secret using three different methods\n # Expected output: the secret data (thrice)\n - init:\n assign:\n - project_id: ${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}\n - secret_id: \"test-secret\" # Make sure you have this secret and it has a version of 1.\n - version: \"1\"\n # Add data to an existing secret without base-64 encoding\n - add_version_string:\n call: googleapis.secretmanager.v1.projects.secrets.addVersionString\n args:\n secret_id: ${secret_id}\n project_id: ${project_id}\n data: \"a new secret\"\n # Retrieve the secret in string format without base-64 decoding and assume\n # that the secret data is a valid UTF-8 string; if not, raise an error\n - access_string_secret:\n call: googleapis.secretmanager.v1.projects.secrets.versions.accessString\n args:\n secret_id: ${secret_id}\n version: ${version} # if not set, \"latest\" is used\n project_id: ${project_id}\n result: str_secret\n # Retrieve the secret in string format without base-64 decoding\n - access_secret:\n call: googleapis.secretmanager.v1.projects.secrets.versions.access\n args:\n name: ${\"projects/\" + project_id + \"/secrets/\" + secret_id + \"/versions/\" + version}\n result: base64_encoded_secret\n # Retrieve the secret using positional arguments in an expression\n - expression:\n assign:\n - secret_str_from_exp: ${googleapis.secretmanager.v1.projects.secrets.versions.accessString(secret_id, version, project_id)}\n - the_end:\n return:\n - ${str_secret}\n - ${text.decode(base64.decode(base64_encoded_secret.payload.data))}\n - ${secret_str_from_exp}\n\n### JSON\n\n [\n {\n \"init\": {\n \"assign\": [\n {\n \"project_id\": \"${sys.get_env(\\\"GOOGLE_CLOUD_PROJECT_ID\\\")}\"\n },\n {\n \"secret_id\": \"test-secret\"\n },\n {\n \"version\": \"1\"\n }\n ]\n }\n },\n {\n \"add_version_string\": {\n \"call\": \"googleapis.secretmanager.v1.projects.secrets.addVersionString\",\n \"args\": {\n \"secret_id\": \"${secret_id}\",\n \"project_id\": \"${project_id}\",\n \"data\": \"a new secret\"\n }\n }\n },\n {\n \"access_string_secret\": {\n \"call\": \"googleapis.secretmanager.v1.projects.secrets.versions.accessString\",\n \"args\": {\n \"secret_id\": \"${secret_id}\",\n \"version\": \"${version}\",\n \"project_id\": \"${project_id}\"\n },\n \"result\": \"str_secret\"\n }\n },\n {\n \"access_secret\": {\n \"call\": \"googleapis.secretmanager.v1.projects.secrets.versions.access\",\n \"args\": {\n \"name\": \"${\\\"projects/\\\" + project_id + \\\"/secrets/\\\" + secret_id + \\\"/versions/\\\" + version}\"\n },\n \"result\": \"base64_encoded_secret\"\n }\n },\n {\n \"expression\": {\n \"assign\": [\n {\n \"secret_str_from_exp\": \"${googleapis.secretmanager.v1.projects.secrets.versions.accessString(secret_id, version, project_id)}\"\n }\n ]\n }\n },\n {\n \"the_end\": {\n \"return\": [\n \"${str_secret}\",\n \"${text.decode(base64.decode(base64_encoded_secret.payload.data))}\",\n \"${secret_str_from_exp}\"\n ]\n }\n }\n ]\n\nWhat's next\n-----------\n\n- [Learn more about Secret Manager](/secret-manager/docs/overview)"]]