03-kms-and-ssh-keys.tf 786 B

1234567891011121314151617181920212223242526272829
  1. # Creating symmetric KMS Key
  2. resource "yandex_kms_symmetric_key" "kc-key" {
  3. name = "${var.kms_key_name}"
  4. description = "description for key"
  5. default_algorithm = "AES_256"
  6. }
  7. # SA role binding for KMS Key described in service-account.tf
  8. resource "yandex_kms_symmetric_key_iam_binding" "encrypterDecrypter" {
  9. symmetric_key_id = yandex_kms_symmetric_key.kc-key.id
  10. role = "kms.keys.encrypterDecrypter"
  11. members = [
  12. "serviceAccount:${yandex_iam_service_account.kc-sa.id}",
  13. ]
  14. }
  15. #Create ssh key for guest OS
  16. resource "tls_private_key" "ssh" {
  17. algorithm = "RSA"
  18. rsa_bits = "2048"
  19. }
  20. resource "local_file" "private_key" {
  21. content = tls_private_key.ssh.private_key_pem
  22. filename = "pt_key.pem"
  23. file_permission = "0600"
  24. }