-
Notifications
You must be signed in to change notification settings - Fork 31
/
iam-policy-rds.tf
45 lines (41 loc) · 1.11 KB
/
iam-policy-rds.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
/**
* Copyright (C) 2018-2020 Expedia, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
*/
resource "aws_iam_role_policy" "rds_for_hms_readonly" {
count = var.external_database_host == "" ? 1 : 0
name = "rds"
role = aws_iam_role.apiary_hms_readonly.id
policy = <<EOF
{
"Version" : "2012-10-17",
"Statement" :
[
{
"Effect" : "Allow",
"Action" : ["rds-db:connect"],
"Resource" : ["arn:aws:rds-db:${var.aws_region}:${data.aws_caller_identity.current.account_id}:dbuser:${aws_rds_cluster.apiary_cluster[0].cluster_resource_id}/iamro"]
}
]
}
EOF
}
resource "aws_iam_role_policy" "rds_for_hms_readwrite" {
count = var.external_database_host == "" ? 1 : 0
name = "rds"
role = aws_iam_role.apiary_hms_readwrite.id
policy = <<EOF
{
"Version" : "2012-10-17",
"Statement" :
[
{
"Effect" : "Allow",
"Action" : ["rds-db:connect"],
"Resource" : ["arn:aws:rds-db:${var.aws_region}:${data.aws_caller_identity.current.account_id}:dbuser:${aws_rds_cluster.apiary_cluster[0].cluster_resource_id}/iamrw"]
}
]
}
EOF
}