Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 056d102

Browse files
Magicloudketzacoatl
authored andcommitted
Refine DLM lifecycle modules.
The original design has implict dependencies between `dlm-lifecycle-iam-role` and `dlm-lifecycle-policy` on IAM role. But TF currently does not support module dependency, and it does not get the dependency when a module is depends on another resource's `name` output. So merged the two modules to avoid applying error that "the role does not exist".
1 parent 614ecfd commit 056d102

File tree

5 files changed

+4
-31
lines changed

5 files changed

+4
-31
lines changed

modules/dlm-lifecycle-iam-role/README.md

-15
This file was deleted.

modules/dlm-lifecycle-iam-role/versions.tf

-3
This file was deleted.

modules/dlm-lifecycle-iam-role/main.tf modules/dlm-lifecycle-policy/iam.tf

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
variable "iam_role_name" {
2-
description = "The IAM role name for the DLM lifecyle policy"
3-
type = string
4-
default = "dlm-lifecycle-role"
5-
}
6-
71
# Create the iam role
82
resource "aws_iam_role" "dlm_lifecycle_role" {
93
name = var.iam_role_name
@@ -54,3 +48,4 @@ resource "aws_iam_role_policy" "dlm_lifecycle_policy" {
5448
}
5549
EOF
5650
}
51+

modules/dlm-lifecycle-policy/main.tf

+1-6
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,10 @@
1111
*
1212
*/
1313

14-
# Get the data of role to pass the resource
15-
data "aws_iam_role" "dlm_lifecycle_role" {
16-
name = var.role_name
17-
}
18-
1914
# DLM lifecycle schedule
2015
resource "aws_dlm_lifecycle_policy" "ebs-lifecycle-policy" {
2116
description = var.description
22-
execution_role_arn = data.aws_iam_role.dlm_lifecycle_role.arn
17+
execution_role_arn = aws_iam_role.dlm_lifecycle_role.arn
2318
state = "ENABLED"
2419

2520
policy_details {

modules/dlm-lifecycle-policy/variables.tf

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ variable "policy_tags_to_add" {
6363
default = {"SnapshotCreator" = "DLM lifecycle"}
6464
}
6565

66-
variable "role_name" {
66+
variable "iam_role_name" {
6767
description = "The IAM role name for the DLM lifecyle policy"
6868
type = string
69+
default = "dlm-lifecycle-role"
6970
}

0 commit comments

Comments
 (0)