kms.tf 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # # Codebuild artifacts by rule must be encrypted by a KMS key
  2. # # using the default aws/s3 key doesn't work with cross-account access
  3. # resource "aws_kms_key" "s3_codebuild_artifacts" {
  4. # description = "Codebuild Artifacts S3 bucket"
  5. # enable_key_rotation = true
  6. # policy = data.aws_iam_policy_document.codebuild_kms_key_encryption_policy.json
  7. # }
  8. # resource "aws_kms_alias" "codebuilt-artifacts" {
  9. # name = "alias/codebuild-artifacts"
  10. # target_key_id = aws_kms_key.s3_codebuild_artifacts.key_id
  11. # }
  12. # data "aws_iam_policy_document" "codebuild_kms_key_encryption_policy" {
  13. # #policy_id = "key-consolepolicy-3"
  14. # statement {
  15. # sid = "Enable IAM User Permissions"
  16. # effect = "Allow"
  17. # principals {
  18. # type = "AWS"
  19. # identifiers = [
  20. # "arn:aws-us-gov:iam::${var.aws_account_id}:role/user/mdr_terraformer",
  21. # "arn:aws-us-gov:iam::${var.aws_account_id}:user/MDRAdmin"
  22. # ]
  23. # }
  24. # actions = [ "kms:*" ]
  25. # resources = [ "*" ]
  26. # }
  27. # statement {
  28. # sid = "Allow access for Key Administrators"
  29. # effect = "Allow"
  30. # principals {
  31. # type = "AWS"
  32. # identifiers = [
  33. # "arn:aws-us-gov:iam::${var.aws_account_id}:role/user/mdr_terraformer",
  34. # ]
  35. # }
  36. # actions = [
  37. # "kms:Create*",
  38. # "kms:Describe*",
  39. # "kms:Enable*",
  40. # "kms:List*",
  41. # "kms:Put*",
  42. # "kms:Update*",
  43. # "kms:Revoke*",
  44. # "kms:Disable*",
  45. # "kms:Get*",
  46. # "kms:Delete*",
  47. # "kms:TagResource",
  48. # "kms:UntagResource",
  49. # "kms:ScheduleKeyDeletion",
  50. # "kms:CancelKeyDeletion"
  51. # ]
  52. # resources = [ "*" ]
  53. # }
  54. # statement {
  55. # sid = "Allow use of the key"
  56. # effect = "Allow"
  57. # principals {
  58. # type = "AWS"
  59. # identifiers = [
  60. # "arn:aws-us-gov:iam::${var.aws_account_id}:role/msoc-default-instance-role"
  61. # ]
  62. # }
  63. # actions = [
  64. # "kms:Encrypt",
  65. # "kms:Decrypt",
  66. # "kms:ReEncrypt*",
  67. # "kms:GenerateDataKey*",
  68. # "kms:DescribeKey"
  69. # ]
  70. # resources = [ "*" ]
  71. # }
  72. # statement {
  73. # sid = "Allow access through Amazon S3 for all principals in the account that are authorized to use Amazon S3"
  74. # effect = "Allow"
  75. # principals {
  76. # type = "AWS"
  77. # identifiers = [ "*" ]
  78. # }
  79. # actions = [
  80. # "kms:Encrypt",
  81. # "kms:Decrypt",
  82. # "kms:ReEncrypt*",
  83. # "kms:GenerateDataKey*",
  84. # "kms:DescribeKey"
  85. # ]
  86. # resources = [ "*" ]
  87. # condition {
  88. # test = "StringEquals"
  89. # variable = "kms.ViaService"
  90. # values = [ "s3.us-gov-east-1.amazonaws.com" ]
  91. # }
  92. # condition {
  93. # test = "StringEquals"
  94. # variable = "kms.CallerAccount"
  95. # values = [ var.aws_account_id ]
  96. # }
  97. # }
  98. # statement {
  99. # sid = "Allow access from the codebuild role"
  100. # effect = "Allow"
  101. # principals {
  102. # type = "AWS"
  103. # # FIXME this needs to be a better role by far
  104. # identifiers = [ aws_iam_role.codebuild_role.arn ]
  105. # }
  106. # actions = [
  107. # "kms:Encrypt",
  108. # "kms:Decrypt",
  109. # "kms:ReEncrypt*",
  110. # "kms:GenerateDataKey*",
  111. # "kms:DescribeKey"
  112. # ]
  113. # resources = [ "*" ]
  114. # }
  115. # statement {
  116. # sid = "Allow attachment of persistent resources"
  117. # effect = "Allow"
  118. # principals {
  119. # type = "AWS"
  120. # identifiers = [
  121. # "arn:aws-us-gov:iam::${var.aws_account_id}:role/msoc-default-instance-role"
  122. # ]
  123. # }
  124. # actions = [
  125. # "kms:CreateGrant",
  126. # "kms:ListGrants",
  127. # "kms:RevokeGrant"
  128. # ]
  129. # resources = [ "*" ]
  130. # condition {
  131. # test = "Bool"
  132. # variable = "kms:GrantIsForAWSResource"
  133. # values = [ "true" ]
  134. # }
  135. # }
  136. # }