From eea73dc11020315fed68cf9081a040739a2a0fb6 Mon Sep 17 00:00:00 2001 From: KF Date: Mon, 17 Oct 2022 13:18:59 +0800 Subject: [PATCH] NEW: Process credentials with gpg --- examples/iam.user.gpg/main.tf | 51 ++++++++++++++++++++++++++ examples/iam.user.gpg/terraform.tfvars | 44 ++++++++++++++++++++++ examples/iam.user.gpg/variables.tf | 28 ++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 examples/iam.user.gpg/main.tf create mode 100644 examples/iam.user.gpg/terraform.tfvars create mode 100644 examples/iam.user.gpg/variables.tf diff --git a/examples/iam.user.gpg/main.tf b/examples/iam.user.gpg/main.tf new file mode 100644 index 0000000..fc0a4cc --- /dev/null +++ b/examples/iam.user.gpg/main.tf @@ -0,0 +1,51 @@ +module iam-user { + source = "../../modules/security_identity_compliance/iam-user-gpg" + + 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 = true + managed-policy-arns = ["arn:aws:iam::aws:policy/job-function/ViewOnlyAccess"] + create-group = true + iam-group-name = var.iam-group-name + pgp-key = var.pgp-key +} + +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 +} + +output iam-user-pass { + value = module.iam-user.iam-user-pass +} + +output iam-user-access-key { + value = module.iam-user.iam-user-access-key +} + +output iam-user-secret-key { + value = module.iam-user.iam-user-secret-key +} \ No newline at end of file diff --git a/examples/iam.user.gpg/terraform.tfvars b/examples/iam.user.gpg/terraform.tfvars new file mode 100644 index 0000000..9e681df --- /dev/null +++ b/examples/iam.user.gpg/terraform.tfvars @@ -0,0 +1,44 @@ +aws-region = "ap-southeast-1" +customer-name = "ken2026" +environment = "dev" +project = "iac" +application = "terraform" +costcenter = "none" +DynamicAddressGroup = "" +owner = "Rackspace" + +iam-user-name = "TestUser1017" +iam-group-name = "TestGroup1017" +pgp-key = <