Skip to content

Instantly share code, notes, and snippets.

@clstokes
Last active Dec 3, 2017
Embed
What would you like to do?
variable "role_name" {}
variable "role_policy_file" {}
resource "aws_iam_role" "role" {
name = "${var.role_name}"
assume_role_policy = "${file("${path.module}/policies/${var.role_policy_file}")}"
}
output "role_arn" {
value = "${aws_iam_role.role.arn}"
}
/*
* Directory structure
* .
* ├── main.tf
* ├── modules
* │   └── iam_role
* │   ├── iam.tf
* │   └── policies
* │   ├── differentname_policy.json
* │   └── exampleroles_policy.json
*/
module "role_exampleroles" {
source = "./modules/iam_role"
role_name = "exampleroles"
role_policy_file = "exampleroles_policy.json"
}
module "role_differentname" {
source = "./modules/iam_role"
role_name = "differentname"
role_policy_file = "differentname_policy.json"
}
output "role_exampleroles_arn" {
value = "${module.role_exampleroles.role_arn}"
}
output "role_differentname_arn" {
value = "${module.role_differentname.role_arn}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment