Skip to content

Instantly share code, notes, and snippets.

@dannietjoh
Last active February 4, 2016 09:22
Show Gist options
  • Save dannietjoh/963161c17c67ddc1c69d to your computer and use it in GitHub Desktop.
Save dannietjoh/963161c17c67ddc1c69d to your computer and use it in GitHub Desktop.
variable "aws_account" { default = "" }
variable "aws_region" { default = "" }
variable "aws_access_key" { default = "" }
variable "aws_secret_key" { default = "" }
variable "development_l1" { default = "" }
variable "development_l2" { default = "" }
variable "operations_l1" { default = "" }
variable "operations_l2" { default = "" }
# setup AWS provider
provider "aws" {
alias = "${var.aws_account}"
region = "${var.aws_region}"
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
}
# create users
module "users" {
source = "module"
users = "${compact(concat(var.operations_l1,",",var.operations_l2,",",var.development_l1,",",var.development_l2))}"
}
variable "aws_account" { default = "" }
variable "aws_region" { default = "" }
variable "aws_access_key" { default = "" }
variable "aws_secret_key" { default = "" }
variable "users" { default = "" }
variable "name" { default = "" }
# setup AWS provider
provider "aws" {
alias = "${var.aws_account}"
region = "${var.aws_region}"
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
}
resource "aws_iam_user" "user" {
count = "${length(split(",", var.users))}"
name = "${element(split(",", var.users), count.index)}"
}
resource "aws_iam_access_key" "key" {
count = "${length(split(",", var.users))}"
user = "${element(aws_iam_user.user.*.name, count.index)}"
}
development_l1 = "devuser1,devuser2"
development_l2 = "devuser3,devuser4"
operations_l1 = "opsuser1"
operations_l2 = "opsuser2,opsuser3"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment