terraform.aws-baseline-infra/modules/security_identity_compliance/iam-user
2022-09-19 16:04:26 +08:00
..
main.tf UPD: adding iam-user-policy-name variable 2022-09-19 16:04:26 +08:00
outputs.tf UPD: added iam group support 2022-09-16 10:37:28 +08:00
README.md UPD: adding iam-user-policy-name variable 2022-09-19 16:04:26 +08:00
variables.tf UPD: adding iam-user-policy-name variable 2022-09-19 16:04:26 +08:00

iam-user module

Module for creating IAM user. Credentials, if any, will be stored in secretsmanager

Example

module iam-user {
  source = "../../modules/security_identity_compliance/iam-user"

  default-tags    = local.default-tags
  iam-user-name   = var.iam-user-name
  iam-user-policy = data.aws_iam_policy_document.user-policy.json
  iam-user-policy-name = "SelfServicePermissions"
  create-access-key = false
  create-password = false
  managed-policy-arns = ["arn:aws:iam::aws:policy/job-function/ViewOnlyAccess"]
  create-group = true
  iam-group-name = var.iam-group-name
}

data aws_iam_policy_document user-policy {
  statement {
    sid = "ManageOwnCredentials"

    actions = [
      "iam:ChangePassword",
      "iam:CreateAccessKey",
      "iam:DeleteAccessKey",
      "iam:ListAccessKey",
      "iam:CreateVirtualMFADevice",
      "iam:EnableMFADevice",
      "iam:ListMFA*",
      "iam:ListVirtualMFA*",
      "iam:ResyncMFADevice"
    ]

    effect = "Allow"
    resources = ["arn:aws:iam::account-id:user/${var.iam-user-name}"]
  }
}

output iam-user-arn {
  value = module.iam-user.iam-user-arn
}