Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Restringir novas implantações por versão do produto
O Cloud Run Functions oferece duas versões do produto:
funções do Cloud Run (1ª geração) e funções do Cloud Run criadas usando as
APIs do Google Cloud Functions v2. Para aplicar uma restrição especificando que apenas uma das versões pode ser usada para implantar novas funções, defina uma nova política da organização com a restriçãoconstraints/cloudfunctions.restrictAllowedGenerations. Essa restrição é usada para especificar a geração (versão) que você quer permitir ou negar na pasta ou no projeto em que a política é aplicada.
A restrição se aplica apenas a novas funções que estão sendo implantadas pela primeira vez. Você ainda poderá reimplantar as funções atuais, mesmo que elas não estejam em conformidade com a política.
Usar uma política para definir e aplicar restrições
É possível usar a CLI do Google Cloud ou o console do Google Cloud para criar uma política que
restrinja novas funções do Cloud Run implantadas pela primeira vez
em uma determinada organização no ambiente especificado.
A definição de uma política não se aplica a funções existentes. Todas as funções que foram implantadas antes da política podem ser reimplantadas, atualizadas ou excluídas sem restrições.
Selecione o projeto, a pasta ou a organização à qual você quer adicionar a nova política.
A página "Políticas da organização" exibe uma lista das restrições de políticas da organização disponíveis.
Encontre a política Gerações permitidas do Cloud Functions na lista. Use o campo Filtro na parte superior da lista.
Clique no nome da política. Como alternativa, selecione Editar política no menu de contexto.
Clique em Gerenciar política.
Selecione Personalizar em Aplicável a.
Selecione Substituir em Aplicação da política.
Clique em Adicionar regra em Regras.
Selecione Personalizado para Valores da política.
Selecione Permitir em Tipo de política.
Em Valor personalizado, especifique o ambiente que você quer aplicar na organização. Valores aceitos:
1stGen: permite o uso apenas de funções do Cloud Run (primeira geração).
2ndGen: permite o uso somente das funções do Cloud Run (segunda geração).
Para permitir explicitamente os dois ambientes, especifique 1stGen e 2ndGen
juntos. Por padrão, os dois ambientes são permitidos quando nenhuma política é definida.
Clique em Concluído.
Clique em Salvar.
As alterações entrarão em vigor em breve, e a política impedirá a implantação das funções do Cloud Run no ambiente especificado.
em que ORGANIZATION_NUMBER é o número da
organização à qual você quer aplicar a política e
VERSION é a versão das funções do Cloud Run que precisa ser
usada para novas implantações. VERSION pode ser:
1stGen: permite o uso apenas de funções do Cloud Run (primeira geração).
2ndGen: permite o uso somente das funções do Cloud Run (segunda geração).
Para permitir explicitamente os dois ambientes, especifique 1stGen e 2ndGen
juntos. Por padrão, os dois ambientes são permitidos quando nenhuma política é definida.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-12-22 UTC."],[[["\u003cp\u003eCloud Run functions have two versions, 1st gen and 2nd gen, and organizations can restrict new deployments to a specific version using organization policies.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003econstraints/cloudfunctions.restrictAllowedGenerations\u003c/code\u003e constraint allows specifying which Cloud Run function version (1stGen or 2ndGen) can be used for new deployments within a folder or project.\u003c/p\u003e\n"],["\u003cp\u003eSetting this restriction only applies to new function deployments; existing functions can still be redeployed regardless of the policy.\u003c/p\u003e\n"],["\u003cp\u003eTo create or modify organization policies, the account must have the \u003ccode\u003eroles/orgpolicy.policyAdmin\u003c/code\u003e role.\u003c/p\u003e\n"],["\u003cp\u003eYou can use the Google Cloud CLI to enforce these restrictions by using the \u003ccode\u003egcloud resource-manager org-policies allow cloudfunctions.restrictAllowedGenerations\u003c/code\u003e command.\u003c/p\u003e\n"]]],[],null,["# Restrict new deployments by product version\n===========================================\n\n| **Note:** In this document, \"Cloud Run functions (2nd gen)\" refers to Cloud Run functions created with the Google Cloud Functions v2 APIs.\n\nCloud Run functions offers two product versions:\nCloud Run functions (1st gen) and Cloud Run functions created through the\nGoogle Cloud Functions v2 APIs. If your organization wants to enforce a\nrestriction specifying that only one of the versions can be used to deploy new\nfunctions, you can define a new\n[organization policy](/resource-manager/docs/organization-policy/overview)\nwith the\n[constraint](/resource-manager/docs/organization-policy/overview#constraints)\n`constraints/cloudfunctions.restrictAllowedGenerations`. You use this constraint\nto specify the generation (version) you want to allow or deny in the folder or\nproject the policy is applied to.\n\nThe restriction will only apply to new functions being deployed for the first\ntime. You will still be able to redeploy existing functions even if they\ndon't comply with the policy.\n\nBefore you begin\n----------------\n\nTo create or change organization policies, your account must have the\nrole\n[`roles/orgpolicy.policyAdmin`](/resource-manager/docs/organization-policy/using-constraints#required-roles).\n\nUse a policy to set and enforce restrictions\n--------------------------------------------\n\nYou can use Google Cloud CLI to create a policy restricting new\nCloud Run functions from being deployed for the first time within a given\norganization to the specified environment.\n\nNote that setting a policy does not apply to existing functions. All functions\nthat were deployed before the policy can be redeployed, updated, or deleted\nwithout restriction.\n\nTo create a policy that restricts new Cloud Run functions, run the following command: \n\n```bash\ngcloud resource-manager org-policies \\\n allow cloudfunctions.restrictAllowedGenerations \\\n --organization=ORGANIZATION_NUMBER VERSION\n```\n\nwhere \u003cvar translate=\"no\"\u003eORGANIZATION_NUMBER\u003c/var\u003e is the number of the\norganization to which you want to apply the policy, and\n\u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e is the Cloud Run functions version that must be\nused for new deployments. \u003cvar translate=\"no\"\u003eVERSION\u003c/var\u003e can be one of the\nfollowing:\n\n- `1stGen`: Allow the use of Cloud Run functions (1st gen) only.\n- `2ndGen`: Allow the use of Cloud Run functions (2nd gen) only.\n- To explicitly allow both environments, specify `1stGen` and `2ndGen` together. By default, both environments are allowed when no policy is set.\n\n| **Note:** you can also set the policy on a project or folder by replacing the `--organization` flag with `--project=\u003cPROJECT_ID\u003e` or \\`--folder= respectively."]]