DEV Community

Rodrigo Fernandes
Rodrigo Fernandes

Posted on

AWS KMS - Grants

Anotações sobre o AWS KMS - Grants para ajudar na preparação das certificações AWS.

Até o momento as anotações são para as certificações abaixo:

Image description


Definição do fornecedor

Grantsé um instrumento de Policy que permite que as entidades principais da AWS usem KMS Keys em operações de criptografia.


Anotações gerais

  • Grant user -> Gera o Grant // Key Administrator
  • Grantee -> Usuário que usa o Grant gerado pelo Grant user
  • Condição: Bool - kms:GrantsForAWSResource:true
  • Acesso temporário
  • Igual a um Secret Token
  • Cada Grant permite o acesso a exatamente uma KMS Key. Você pode criar uma Grant para uma KMS Key em uma Conta da AWS diferente.
  • Uma Grants pode permitir acesso a uma KMS Key, mas não pode negar acesso.
  • Cada Grants deve ter pelo menos uma entidade principal receptora. A entidade principal receptora da Grants pode ser uma identidade em uma Conta da AWS diferente.
  • Ele também pode permitir que eles visualizem uma KMS Key (DescribeKey) e criem e gerenciem Grant.
  • Ao autorizar o acesso a uma KMS Key, Grants são consideradas junto com as Key Policy e as IAM Policy.
  • Grants geralmente são usadas para permissões temporárias porque você pode criar uma, usar suas permissões e excluí-la sem alterar suas Key Policy ou IAM Policy.
  • Grants é uma alternativa à Key Policy.
  • Fornece controle de acesso programático

Permite ou nega permissão somente quando um serviço da AWS integrado ao AWS KMS

Documentação oficial

  • "Condition": { "Bool": { "kms:GrantIsForAWSResource": true }}
  • Permissões -- CreateGrant -- ListGrants -- RevokeGrant

Exemplo

{
  "Effect": "Allow",
  "Principal": {
    "AWS": "arn:aws:iam::111122223333:user/ExampleUser"
  },
  "Action": "kms:CreateGrant",
  "Resource": "*",
  "Condition": {
    "Bool": {
      "kms:GrantIsForAWSResource": true
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Exemplo

Image description


Comandos KMS Grant

Generating the Grant

aws kms create-grant /
--key-id [KEY-ID] /
--grantee-principal [GRANTE-PRINCIPLE-ARN] /
--operations "Encrypt"
Enter fullscreen mode Exit fullscreen mode

Using Grant to Perform Operation

aws kms encrypt --plaintext "hello world" 
--key-id [KEY-ID] /
--grant-tokens [GRANT TOKEN RECEIVED] 
Enter fullscreen mode Exit fullscreen mode

Revoking the Grant

aws kms revoke-grant --key-id [KEY-ID] --grant-id [GRANT-ID-HERE]
Enter fullscreen mode Exit fullscreen mode

Referências

AWS GenAI LIVE image

How is generative AI increasing efficiency?

Join AWS GenAI LIVE! to find out how gen AI is reshaping productivity, streamlining processes, and driving innovation.

Learn more

Top comments (0)

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay