main.tf 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. locals {
  2. #account_arns = sort(
  3. # concat(
  4. # [ for account in concat(var.customer_account_list,local.account_list):
  5. # "arn:${var.aws_partition}:iam::${account}:root" if account != "*"
  6. # ],
  7. # [ for account in concat(var.customer_account_list,local.account_list):
  8. # "*" if account == "*"
  9. # ]
  10. #))
  11. # LCP AMI Key should allow anyone and everyone to use it. Rationale:
  12. # * The AMIs themselves only get shared with specific AWS accounts
  13. # * Only two IAM Actions are permitted by the policy defined in the
  14. # submodule: kms:ReEncryptFrom and kms:DescribeKey.
  15. # *Giving these limited rights to "anyone" should be fine, given the only way
  16. # to see the volumes encrypted using this key is by launching the AMI
  17. # which you have to be whitelisted to
  18. #
  19. # It is, however, incumbent on us to not use this particular KMS for any
  20. # other purpose other than the LCP AMI(s) EBS volume(s).
  21. account_arns = ["*"]
  22. terraformer_arns = sort([
  23. for account in local.account_list :
  24. "arn:${var.aws_partition}:iam::${account}:role/user/mdr_terraformer"
  25. ])
  26. all_keys = concat([module.shared_ami_key.key_arn])
  27. }
  28. output "other" {
  29. value = local.account_arns
  30. }
  31. module "shared_ami_key" {
  32. source = "../../submodules/kms/ami-key"
  33. name = "lcp_ami_key"
  34. alias = "alias/lcp_ami_key"
  35. description = "Key for encrypting the LCP AMIs to be shared with external clients."
  36. tags = merge(local.standard_tags, var.tags)
  37. key_admin_arns = []
  38. key_user_arns = []
  39. #key_attacher_arns = local.account_arns
  40. key_attacher_arns = local.terraformer_arns
  41. #key_attacher_arns = [ ]
  42. standard_tags = local.standard_tags
  43. aws_account_id = var.aws_account_id
  44. aws_partition = var.aws_partition
  45. remote_account_arns = local.account_arns
  46. }