forked from f5devcentral/terraform-aws-bigip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiam.tf
49 lines (42 loc) · 1.01 KB
/
iam.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#
# Create IAM Role
#
data "aws_iam_policy_document" "bigip_role" {
version = "2012-10-17"
statement {
actions = [
"sts:AssumeRole"
]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
resource "aws_iam_role" "bigip_role" {
name = format("%s-bigip-role", var.prefix)
assume_role_policy = data.aws_iam_policy_document.bigip_role.json
tags = {
tag-key = "tag-value"
}
}
resource "aws_iam_instance_profile" "bigip_profile" {
name = format("%s-bigip-profile", var.prefix)
role = aws_iam_role.bigip_role.name
}
data "aws_iam_policy_document" "bigip_policy" {
version = "2012-10-17"
statement {
actions = [
"secretsmanager:GetSecretValue"
]
resources = [
data.aws_secretsmanager_secret.password.arn
]
}
}
resource "aws_iam_role_policy" "bigip_policy" {
name = format("%s-bigip-policy", var.prefix)
role = aws_iam_role.bigip_role.id
policy = data.aws_iam_policy_document.bigip_policy.json
}