Skip to content

Instantly share code, notes, and snippets.

@candostdagdeviren
Created December 2, 2020 21:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save candostdagdeviren/17b3bcde5b27d505ad523c62e59c65c6 to your computer and use it in GitHub Desktop.
Save candostdagdeviren/17b3bcde5b27d505ad523c62e59c65c6 to your computer and use it in GitHub Desktop.
IAM User Variable in Terraform
variable "iam_user" {
default = "candost"
description = "My AWS IAM user"
}
resource "aws_iam_user" "candost" {
name = "${var.iam_user}-${terraform.workspace}"
path = "/"
}
resource "aws_iam_user_policy" "candost_policy" {
name_prefix = "${var.iam_user}-${terraform.workspace}-"
user = "${aws_iam_user.candost.name}"
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "dynamodb:*",
"Resource": [
"arn:aws:dynamodb:eu-west-1:113608568902:table/MyTable"
]
}
]
}
EOF
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment