[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[],[],null,["# Protecting projects with liens\n\nThis document is for [Project owners](/resource-manager/docs/access-control-proj#permissions_and_roles)\nand [Organization administrators](/resource-manager/docs/access-control-org#permissions_and_roles)\nlooking to add protections against project deletion.\n\nYou can place a lien upon a project to block the project's deletion until you\nremove the lien. This can be useful to protect projects of particular\nimportance.\n\nLiens can also be placed upon a project automatically. For example, if you allow\nIdentity and Access Management (IAM) service accounts from one project to be\n[attached to resources in other projects](/iam/docs/attach-service-accounts#attaching-different-project),\na lien is placed upon the project where the service accounts are located.\n\nBefore you begin\n----------------\n\nThe gcloud CLI is the easiest way to interact with project\nliens. If you don't have it installed, you can use\n[Google Cloud Shell](/shell/docs).\n\n### Required roles\n\n\nTo get the permissions that\nyou need to modify liens,\n\nask your administrator to grant you the\n\n\n[Project lien modifier](/iam/docs/roles-permissions/resourcemanager#resourcemanager.lienModifier) (`roles/resourcemanager.lienModifier`)\nIAM role on projects.\n\n\nFor more information about granting roles, see [Manage access to projects, folders, and organizations](/iam/docs/granting-changing-revoking-access).\n\n\nThis predefined role contains\n\nthe permissions required to modify liens. To see the exact permissions that are\nrequired, expand the **Required permissions** section:\n\n\n#### Required permissions\n\nThe following permissions are required to modify liens:\n\n- ` resourcemanager.projects.updateLiens`\n- List liens on a project: ` resourcemanager.projects.get`\n\n\nYou might also be able to get\nthese permissions\nwith [custom roles](/iam/docs/creating-custom-roles) or\nother [predefined roles](/iam/docs/roles-overview#predefined).\n\nPlacing a lien on a project\n---------------------------\n\nTo place a lien on a project, use the `alpha resource-manager liens create`\ncommand. \n\n```bash\ngcloud alpha resource-manager liens create \\\n --project=PROJECT_ID \\\n --restrictions=PERMISSION_RESTRICTION \\\n --reason=LIEN_REASON \\\n --origin=LIEN_ORIGIN\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: ID of the project the lien applies to.\n- \u003cvar translate=\"no\"\u003ePERMISSION_RESTRICTION\u003c/var\u003e: Comma-separated list of IAM permissions to block. The only valid restriction for a project is `resourcemanager.projects.delete`.\n- \u003cvar translate=\"no\"\u003eLIEN_REASON\u003c/var\u003e: Human-readable description of why this lien exists. Put this description within double quotation marks. Example: `\"This project is protected by a lien\"`.\n- \u003cvar translate=\"no\"\u003eLIEN_ORIGIN\u003c/var\u003e: String denoting the user or system which originated the lien. It is a required field, but is automatically populated with the user's email address if omitted.\n\nListing liens on a project\n--------------------------\n\nTo list all liens applied to a project, use the\n`alpha resource-manager liens list` command. \n\n gcloud alpha resource-manager liens list\n\nThe output is similar to the following: \n\n gcloud alpha resource-manager liens list\n NAME ORIGIN REASON\n p1061081023732-l3d8032b3-ea2c-4683-ad48-5ca23ddd00e7 user@example.com testing\n\nRemoving liens from a project\n-----------------------------\n\nTo remove a lien from a project, use the\n`alpha resource-manager liens delete` command. \n\n```bash\ngcloud alpha resource-manager liens delete LIEN_NAME\n```\n\nReplace \u003cvar translate=\"no\"\u003eLIEN_NAME\u003c/var\u003e with the name of the lien to be deleted,\nsuch as `p1061081023732-l3d8032b3-ea2c-4683-ad48-5ca23ddd00e7`.\n\nReferences\n----------\n\nAPI Reference: [REST Resource: liens](https://cloud.google.com/resource-manager/reference/rest/v1/liens)"]]