Skip to content

Commit

Permalink
Feature/rds cluster resource id output (#31)
Browse files Browse the repository at this point in the history
* Added the Resource ID to outputs.

* Updated with information for using this_rds_cluster_resource_id output parameter.

* Updated the example with a sample policy using this new output parameter.
  • Loading branch information
melechi authored and antonbabenko committed Mar 22, 2019
1 parent 9cb2598 commit 868bd80
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ Terraform documentation is generated automatically using [pre-commit hooks](http
| this\_rds\_cluster\_database\_name | Name for an automatically created database on cluster creation |
| this\_rds\_cluster\_endpoint | The cluster endpoint |
| this\_rds\_cluster\_id | The ID of the cluster |
| this\_rds\_cluster\_resource\_id | The Resource ID of the cluster |
| this\_rds\_cluster\_instance\_endpoints | A list of all cluster instance endpoints |
| this\_rds\_cluster\_master\_password | The master password |
| this\_rds\_cluster\_master\_username | The master username |
Expand Down
21 changes: 21 additions & 0 deletions examples/mysql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,24 @@ module "vpc" {
"10.0.9.0/25",
]
}

# IAM Policy for use with iam_database_authentication = true
resource "aws_iam_policy" "aurora_mysql_policy_iam_auth" {
name = "test-aurora-db-57-policy-iam-auth"
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"rds-db:connect"
],
"Resource": [
"arn:aws:rds-db:us-east-1:123456789012:dbuser:${module.aurora.this_rds_cluster_resource_id}/jane_doe"
]
}
]
}
POLICY
}
5 changes: 5 additions & 0 deletions outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ output "this_rds_cluster_id" {
value = "${aws_rds_cluster.this.id}"
}

output "this_rds_cluster_resource_id" {
description = "The Resource ID of the cluster"
value = "${aws_rds_cluster.this.cluster_resource_id}"
}

output "this_rds_cluster_endpoint" {
description = "The cluster endpoint"
value = "${aws_rds_cluster.this.endpoint}"
Expand Down

0 comments on commit 868bd80

Please sign in to comment.