main.tf 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #----------------------------------------------------------------------------
  2. # Okta Auth
  3. #----------------------------------------------------------------------------
  4. resource "vault_okta_auth_backend" "okta" {
  5. description = "Terraform Okta auth backend"
  6. organization = "mdr-multipass"
  7. token = var.okta_api_token
  8. base_url = "okta.com"
  9. ttl = "1h"
  10. max_ttl = "8h"
  11. group {
  12. group_name = "mdr-admins"
  13. policies = [vault_policy.admins.name]
  14. }
  15. group {
  16. group_name = "mdr-engineers"
  17. policies = [vault_policy.engineers.name]
  18. }
  19. group {
  20. group_name = "phantom-role-administrator"
  21. policies = [vault_policy.phantom.name]
  22. }
  23. group {
  24. group_name = "vault-admins"
  25. policies = [vault_policy.admins.name]
  26. }
  27. group {
  28. group_name = "analyst-shift-lead"
  29. policies = [vault_policy.soc.name]
  30. }
  31. group {
  32. group_name = "analyst-tier-3"
  33. policies = [vault_policy.soc.name]
  34. }
  35. }
  36. #----------------------------------------------------------------------------
  37. # Okta OIDC Auth
  38. #----------------------------------------------------------------------------
  39. #NOTICE: Members of the default_role do not need to type in the role, like a boss.
  40. # If you are not a member of the default_role, then you must type in your role, like a peasent.
  41. resource "vault_jwt_auth_backend" "okta_oidc" {
  42. description = "Terraform Managed OIDC Auth"
  43. path = "oidc"
  44. type = "oidc"
  45. oidc_discovery_url = "https://mdr-multipass.okta.com"
  46. oidc_client_id = var.okta_oidc_client_id
  47. oidc_client_secret = var.okta_oidc_client_secret
  48. bound_issuer = "https://mdr-multipass.okta.com"
  49. default_role = "mdr-admins"
  50. tune {
  51. listing_visibility = "unauth"
  52. max_lease_ttl = "8h"
  53. default_lease_ttl = "1h"
  54. token_type = "default-service"
  55. }
  56. #the oidc_client_secret causes terraform to think it needs to apply changes.
  57. #lifecycle { ignore_changes = [oidc_client_secret,]}
  58. }
  59. #max token length of 28800 seconds ( 8 Hours )
  60. resource "vault_jwt_auth_backend_role" "okta_oidc" {
  61. for_each = var.roles
  62. backend = vault_jwt_auth_backend.okta_oidc.path
  63. role_name = each.key
  64. token_policies = each.value.token_policies
  65. user_claim = "email"
  66. role_type = "oidc"
  67. allowed_redirect_uris = ["https://vault.pvt.xdrtest.accenturefederalcyber.com/ui/vault/auth/oidc/oidc/callback" ]
  68. oidc_scopes = [ "profile", "email", "groups" ]
  69. bound_claims = { groups = join(",", each.value.bound_groups) }
  70. verbose_oidc_logging = false
  71. token_explicit_max_ttl = "28800"
  72. }
  73. #----------------------------------------------------------------------------
  74. # AWS Auth
  75. #----------------------------------------------------------------------------
  76. resource "vault_auth_backend" "aws" {
  77. type = "aws"
  78. }
  79. #vault write auth/aws/config/client sts_endpoint=https://sts.us-gov-east-1.amazonaws.com sts_region=us-gov-east-1
  80. #https://github.com/terraform-providers/terraform-provider-vault/pull/717
  81. #https://github.com/terraform-providers/terraform-provider-vault/issues/689
  82. resource "vault_aws_auth_backend_client" "aws" {
  83. backend = vault_auth_backend.aws.path
  84. sts_endpoint = "https://sts.us-gov-east-1.amazonaws.com"
  85. }
  86. #this role has not been created yet. BP - 11/6/2020
  87. # resource "vault_aws_auth_backend_role" "portal" {
  88. # backend = vault_auth_backend.aws.path
  89. # role = "portal"
  90. # auth_type = "iam"
  91. # bound_iam_principal_arns = ["arn:aws-us-gov:iam::738800754746:role/portal-instance-role"]
  92. # token_ttl = 60
  93. # token_max_ttl = 86400
  94. # token_policies = ["portal"]
  95. # }
  96. #this role has not been created yet. BP - 11/6/2020
  97. # resource "vault_aws_auth_backend_role" "portal-data-sync-lambda-role" {
  98. # backend = vault_auth_backend.aws.path
  99. # role = "portal-data-sync-lambda-role"
  100. # auth_type = "iam"
  101. # bound_iam_principal_arns = ["arn:aws-us-gov:iam::738800754746:role/portal-data-sync-lambda-role"]
  102. # token_ttl = 60
  103. # token_max_ttl = 86400
  104. # token_policies = ["portal"]
  105. # }
  106. #Legacy probably not used
  107. # resource "vault_aws_auth_backend_role" "clu" {
  108. # backend = vault_auth_backend.aws.path
  109. # role = "clu"
  110. # auth_type = "iam"
  111. # bound_iam_principal_arns = ["arn:aws-us-gov:iam::738800754746:role/clu-instance-role"]
  112. # token_ttl = 60
  113. # token_max_ttl = 86400
  114. # token_policies = ["clu"]
  115. # inferred_aws_region = "us-gov-east-1"
  116. # }
  117. #----------------------------------------------------------------------------
  118. # AppRole Auth
  119. #----------------------------------------------------------------------------
  120. resource "vault_auth_backend" "approle" {
  121. type = "approle"
  122. description = "approle"
  123. }
  124. #generate approle for salt-master authentication
  125. resource "vault_approle_auth_backend_role" "salt-master" {
  126. backend = vault_auth_backend.approle.path
  127. role_name = "salt-master"
  128. token_policies = ["salt-master"]
  129. token_max_ttl = "10800"
  130. }
  131. #----------------------------------------------------------------------------
  132. # File Audit
  133. #----------------------------------------------------------------------------
  134. resource "vault_audit" "file_audit" {
  135. type = "file"
  136. options = {
  137. file_path = "/var/log/vault.log"
  138. }
  139. }