리소스는 상위 조직, 폴더, 프로젝트에서 태그 값을 상속합니다. 따라서 태그를 사용하여Google Cloud 리소스에 대한 액세스를 관리할 수 있습니다.
다음은 태그로 액세스를 관리하는 몇 가지 일반적인 사용 사례입니다.
개발, 스테이징, 프로덕션 환경. 예를 들어 개발 환경에 environment: dev 태그를 추가하고 environment: prod를 프로덕션 환경에 추가할 수 있습니다.
구성요소 유형. 예를 들어 프런트엔드 리소스에 component: frontend 태그를 추가하고 일괄 처리용 리소스에 component: batch를 추가할 수 있습니다.
프로젝트 이름. 예를 들어 팀이 코드명이 Atlas인 프로젝트에서 작업하는 경우 팀의 개발 리소스에 project: atlas 태그를 추가할 수 있습니다.
태그 정의 및 식별자
태그를 리소스에 연결하기 전에 태그의 키뿐만 아니라 태그가 허용하는 값을 정의해야 합니다. 이러한 정의는 조직 또는 프로젝트 수준에서 만들 수 있습니다. Resource Manager를 사용하여 태그 정의를 관리합니다. 자세한 내용은 새 태그 만들기 및 정의를 참조하세요.
각 태그 키 및 값은 다음과 같은 몇 가지 식별자를 가집니다.
영구 ID: 전역적으로 고유하며 재사용할 수 없습니다. 예를 들어 태그 키는 영구 ID tagKeys/123456789012, 태그 값은 영구 ID tagValues/567890123456를 가질 수 있습니다.
닉네임: 각 키의 닉네임은 키가 정의된 프로젝트나 조직 내에서 고유해야 하며 각 값의 닉네임은 연결된 키에 고유해야 합니다. 예를 들어 태그 키에는 닉네임 env가, 태그 값에는 닉네임 prod가 있을 수 있습니다.
네임스페이스화된 이름: 조직의 숫자 ID나 프로젝트 ID를 태그 키의 닉네임에 추가합니다. 예를 들어 조직에 만든 태그 키에는 네임스페이스화된 이름 123456789012/env가 있을 수 있습니다. 조직 ID를 가져오는 방법은 조직 리소스 ID 가져오기를 참조하세요. 프로젝트에 만든 태그 키에는 네임스페이스화된 이름 myproject/env가 있을 수 있습니다. 프로젝트 ID를 가져오는 방법은 프로젝트 식별을 참조하세요.
이 페이지에 설명된 대로 리소스에 태그를 연결한 후 태그를 기준으로 액세스 권한을 부여하는 조건을 작성할 수 있습니다. 조건을 작성하려면 조건에서 사용할 식별자 유형을 선택해야 합니다.
다음 가이드라인에 따라 다음 중 하나를 선택하세요.
태그를 실험하려면 네임스페이스화된 이름(키의 경우) 및 닉네임(값의 경우)을 사용하는 것이 좋습니다. 이러한 식별자는 특히 시작할 때 쉽게 이해하고 기억할 수 있습니다.
Terraform과 같은 도구를 사용하여 구성을 선언적으로 관리하는 경우 네임스페이스화된 이름(키의 경우) 및 닉네임(값의 경우)을 사용하는 것이 좋습니다. 시간이 지나면 이 식별자를 다시 사용할 수 있습니다. 즉, 선언적 도구가 식별자를 삭제하고 다시 생성할 수 있으며 조건은 계속 작동합니다.
이 접근법에는 단점이 있습니다. 태그 키 또는 값을 삭제한 후 이름이 같지만 의미가 다른 새 키 또는 값을 만든다고 가정해 보겠습니다.
조건이 네임스페이스화된 이름 또는 닉네임을 참조하는 경우 조건이 새 키 또는 값에 계속 적용됩니다.
경우에 따라 이 동작으로 인해 주 구성원에게 의도하지 않은 액세스 권한이 부여될 수도 있습니다.
위험을 최소화하려면 다시 사용할 수 없는 영구 ID를 사용하는 것이 좋습니다.
영구 ID가 위험을 최소화하는 데 도움이 되는 이유는 다음과 같습니다. 태그 키 또는 값을 삭제한 후 이름이 같지만 의미가 다른 새 키 또는 값을 만든다고 가정해 보겠습니다. 조건이 영구 ID를 참조하는 경우 새 키 또는 값에 조건이 적용되지 않습니다. 따라서 주 구성원에게 의도하지 않은 액세스 권한이 부여될 가능성이 낮아집니다.
한 가지 단점은 키와 값을 삭제하고 다시 만들고 주 구성원의 액세스 권한을 유지하려면 새 영구 ID를 참조하도록 허용 정책도 업데이트해야 한다는 점입니다.
태그가 지정된 리소스에 대한 액세스
IAM 조건이 있는 태그를 사용하여 리소스에 첨부되거나 상속된 태그를 기준으로 조건부 역할을 부여할 수 있습니다. 조건이 true로 평가되면 액세스가 부여됩니다. 그렇지 않으면 액세스 권한이 부여되지 않습니다. 자세한 내용은 IAM 조건 개요를 참조하세요.
Google Cloud 콘솔의 특정 영역에서는 태그 기반 조건이 있는 허용 정책 역할 바인딩을 인식하지 못합니다. 따라서 태그 기반 조건이 있는 역할이 있는 경우 Google Cloud 콘솔에서 특정 작업을 수행하지 못하도록 잘못 차단할 수 있습니다. 이 문제가 발생하면 gcloud CLI와 같은 대체 방법을 사용하여 작업을 수행하세요.
다음 섹션에서는 리소스의 태그를 확인하는 조건 표현식의 예시를 보여줍니다. 조건은 영구 ID 또는 닉네임을 확인하는지에 따라 다른 함수를 호출합니다. 이러한 함수에 대한 자세한 내용은 리소스 태그를 참조하세요.
영구 ID를 사용하는 조건
이 조건은 tagKeys/123456789012: tagValues/567890123456 태그가 있는 리소스에 역할을 부여합니다.
[[["이해하기 쉬움","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-09-10(UTC)"],[[["\u003cp\u003eTags, which are key-value pairs, can be attached to Google Cloud resources to control access through conditional granting or denying of IAM roles and permissions.\u003c/p\u003e\n"],["\u003cp\u003eResources inherit tag values from parent levels (organization, folders, project), allowing for centralized access management across various Google Cloud resources.\u003c/p\u003e\n"],["\u003cp\u003eTag identifiers include permanent IDs (unique and non-reusable), short names (unique within the project/organization), and namespaced names (short name plus organization/project ID), each offering different trade-offs in terms of manageability and risk.\u003c/p\u003e\n"],["\u003cp\u003eTags are commonly used for environment separation (e.g., development, production), categorizing component types (e.g., frontend, batch), and project identification to help organize access.\u003c/p\u003e\n"],["\u003cp\u003eIAM conditions can be configured to check resource tags using either permanent IDs or namespaced/short names, with permanent IDs preferred for minimizing risk of unintended access due to tag name reuse.\u003c/p\u003e\n"]]],[],null,["# Tags and conditional access\n\nThis page describes how to use tags with Identity and Access Management (IAM) to help you\ncontrol access to your Google Cloud resources.\n\nTo learn more about tags, see [Tags overview](/resource-manager/docs/tags/tags-overview).\n\nOverview of tags\n----------------\n\nA tag is a key-value pair that is attached to a\n[Google Cloud resource](/resource-manager/docs/tags/tags-supported-services#supported_service_resources). You can\n[conditionally grant IAM roles](/iam/docs/conditions-overview) or\n[conditionally deny IAM permissions](/iam/docs/deny-overview) based on\nwhether a resource has a specific tag.\n\nResources [inherit tag values](/resource-manager/docs/tags/tags-overview#inheritance) from their parent organization,\nfolders, and project. As a result, you can use tags to manage access to any\nGoogle Cloud resource.\n\nThese are some common use cases for managing access with tags:\n\n- **Development, staging, and production environments.** For example, you could add the tags `environment: dev` to your development environment and `environment: prod` to your production environment.\n- **Component types.** For example, you could add the tags `component: frontend` to front-end resources and `component: batch` to resources for batch processing.\n- **Project names.** For example, if your team is working on a project with the codename Atlas, you could add the tag `project: atlas` to the team's development resources.\n\n\n| **Important:** Do not include sensitive information in tags. Sensitive information includes personally identifiable information (PII), such as an individual's name or job title. Tags are not intended to contain sensitive information.\n\n\u003cbr /\u003e\n\nTag definitions and identifiers\n-------------------------------\n\nBefore you attach tags to resources, you must define the key for the tag, as\nwell as the values that the tag allows. You can create these definitions at\nthe organization or project level. You use [Resource Manager](/resource-manager/docs) to\nmanage tag definitions. To learn more, see\n[Creating and defining a new tag](/resource-manager/docs/tags/tags-creating-and-managing#creating).\n\nEach tag key and value has a few different identifiers:\n\n\n- A *permanent ID* , which is globally unique and can never be reused. For example, a tag key could have the permanent ID `tagKeys/123456789012`, and a tag value could have the permanent ID `tagValues/567890123456`.\n- A *short name* . The short name for each key must be unique within the project or organization under which the key is defined, and the short name for each value must be unique for its associated key. For example, a tag key could have the short name `env`, and a tag value could have the short name `prod`.\n- A *namespaced name* , which adds your organization's numeric ID or project's ID to the short name of a tag key. For example, a tag key created for an organization could have the namespaced name `123456789012/env`. To learn how to get your organization ID, see [Getting\n your organization resource ID](/resource-manager/docs/creating-managing-organization#retrieving_your_organization_id). A tag key created for a project could have the namespaced name `myproject/env`. To learn how to get your project ID, see [Identifying\n projects](/resource-manager/docs/creating-managing-projects#identifying_projects).\n\n\u003cbr /\u003e\n\nAs explained on this page, after you attach tags to a resource, you can\n[write conditions to grant access based on tags](#control-access). To write a\ncondition, you must choose which type of identifier to use in the condition.\nFollow these guidelines to choose between them:\n\n- **To experiment with tags,** consider using the namespaced name (for keys) and the short name (for values). These identifiers are easier to understand and remember, especially as you get started.\n- **If you manage your configuration declaratively,** using a tool such as\n Terraform, consider using the namespaced name (for keys) and the short name\n (for values). You can reuse these identifiers over time, which means that a\n declarative tool can delete and recreate them, and your conditions will\n continue to work.\n\n This approach comes with a tradeoff: Suppose you delete a tag key or value,\n then create a new key or value with the same name but a different meaning.\n If your condition refers to the namespaced name or short name, then the\n condition continues to apply to the new key or value.\n\n In some cases, this behavior might cause principals to get access that you\n did not intend for them to have.\n- **To help minimize risk,** consider using permanent IDs, which can never be\n reused.\n\n Here's why permanent IDs help minimize risk: Suppose you delete a tag key or\n value, then create a new key or value with the same name but a different\n meaning. If your condition refers to the permanent ID, then the condition\n does not apply to the new key or value. As a result, principals are less\n likely to get access that you did not intend for them to have.\n\n One drawback is that if you delete and recreate keys and values, and you\n want to preserve principals' access, you must also update your allow\n policies to refer to the new permanent IDs.\n\nAccess to tagged resources\n--------------------------\n\nYou can use tags with IAM Conditions to grant a role\nconditionally, depending on the tags that are attached to or inherited by a\nresource. If a condition evaluates to `true`, then access is granted; otherwise,\naccess is not granted. To learn more, see the\n[overview of IAM Conditions](/iam/docs/conditions-overview).\n\n\nCertain\nareas of the Google Cloud console don't recognize allow policy role bindings\nwith tag-based conditions. As a result, if you have a role with a tag-based\ncondition, then the Google Cloud console might incorrectly prevent you from\nperforming certain actions. If you encounter this issue, then use an alternate\nmethod, such as the gcloud CLI, to perform the action.\n\n\n| **Note:** Conditions that check the tags for a resource *and* other\n| attributes, such as the resource name or the timestamp of the request, are in preview.\n| Such conditions are subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1). For more information, see\n| the [launch stage descriptions](/products#product-launch-stages).\n|\n|\n| Conditions that check the tags for a resource and *don't* check any other attributes are\n| generally available.\n\n\u003cbr /\u003e\n\nThe following sections show examples of condition expressions that check the\ntags on a resource. The condition calls different functions depending on whether\nit checks the permanent ID or the short name. To learn more about these\nfunctions, see [Resource tags](/iam/docs/conditions-attribute-reference#resource-tags).\n\n### Conditions that use permanent IDs\n\nThis condition grants a role on resources with the tag\n`tagKeys/123456789012: tagValues/567890123456`: \n\n resource.matchTagId('tagKeys/123456789012', 'tagValues/567890123456')\n\nThis condition grants a role on resources that have any tag with the key\n`tagKeys/123456789012`, regardless of its value: \n\n resource.hasTagKeyId('tagKeys/123456789012')\n\nThis condition grants a role on resources that have both the tag\n`tagKeys/123456789012: tagValues/567890123456`, and any tag that uses the\nkey `tagKeys/987654321098`: \n\n resource.matchTagId('tagKeys/123456789012', 'tagValues/567890123456') &&\n resource.hasTagKeyId('tagKeys/987654321098')\n\n### Conditions that use namespaced names and short names\n\nThis condition grants a role on resources with the tag `env: prod`, indicating\nthat the resource is in a production environment: \n\n resource.matchTag('123456789012/env', 'prod')\n\nThis condition grants a role on resources that have any tag with the key `env`,\nregardless of its value: \n\n resource.hasTagKey('123456789012/env')\n\nThis condition grants a role on resources that have both the tag `env: prod` and\nany tag that uses the key `project`: \n\n resource.matchTag('123456789012/env', 'prod') &&\n resource.hasTagKey('123456789012/project')\n\nWhat's next\n-----------\n\n- Learn how to [manage tags and attach tags to resources](/resource-manager/docs/tags/tags-creating-and-managing).\n- Get details about [checking tags in a condition](/iam/docs/conditions-attribute-reference#resource-tags)."]]