Skip to content
3 changes: 3 additions & 0 deletions .changelog/45113.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_dlm_lifecycle_policy: Add `exclude_data_volume_tags` attributes to `policy_details` parameters configuration block
```
12 changes: 12 additions & 0 deletions internal/service/dlm/lifecycle_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ func resourceLifecyclePolicy() *schema.Resource {
Type: schema.TypeBool,
Optional: true,
},
"exclude_data_volume_tags": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"no_reboot": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -1506,6 +1511,10 @@ func expandParameters(tfList []any, policyType awstypes.PolicyTypeValues) *awsty
apiObject.ExcludeBootVolume = aws.Bool(v)
}

if v, ok := tfMap["exclude_data_volume_tags"].(map[string]any); ok && policyType == awstypes.PolicyTypeValuesEbsSnapshotManagement {
apiObject.ExcludeDataVolumeTags = expandTags(v)
}

if v, ok := tfMap["no_reboot"].(bool); ok && policyType == awstypes.PolicyTypeValuesImageManagement {
apiObject.NoReboot = aws.Bool(v)
}
Expand All @@ -1518,6 +1527,9 @@ func flattenParameters(apiObject *awstypes.Parameters) []any {
if apiObject.ExcludeBootVolume != nil {
tfMap["exclude_boot_volume"] = aws.ToBool(apiObject.ExcludeBootVolume)
}
if apiObject.ExcludeDataVolumeTags != nil {
tfMap["exclude_data_volume_tags"] = flattenTags(apiObject.ExcludeDataVolumeTags)
}
if apiObject.NoReboot != nil {
tfMap["no_reboot"] = aws.ToBool(apiObject.NoReboot)
}
Expand Down
4 changes: 4 additions & 0 deletions internal/service/dlm/lifecycle_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ func TestAccDLMLifecyclePolicy_parameters_volume(t *testing.T) {
checkLifecyclePolicyExists(ctx, t, resourceName),
resource.TestCheckResourceAttr(resourceName, "policy_details.0.parameters.#", "1"),
resource.TestCheckResourceAttr(resourceName, "policy_details.0.parameters.0.exclude_boot_volume", acctest.CtTrue),
resource.TestCheckResourceAttr(resourceName, "policy_details.0.parameters.0.exclude_data_volume_tags.test", "exclude"),
resource.TestCheckResourceAttr(resourceName, "policy_details.0.parameters.0.no_reboot", acctest.CtFalse),
),
},
Expand Down Expand Up @@ -1380,6 +1381,9 @@ resource "aws_dlm_lifecycle_policy" "test" {

parameters {
exclude_boot_volume = true
exclude_data_volume_tags = {
test = "exclude"
}
}

schedule {
Expand Down
42 changes: 42 additions & 0 deletions website/docs/r/dlm_lifecycle_policy.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,47 @@ resource "aws_dlm_lifecycle_policy" "example" {
}
}
}

# ...example policy to exclude data volumes through tags...
resource "aws_dlm_lifecycle_policy" "example" {
description = "example DLM lifecycle policy"
execution_role_arn = aws_iam_role.dlm_lifecycle_role.arn
state = "ENABLED"

policy_details {
resource_types = ["INSTANCE"]
parameters {
exclude_data_volume_tags = {
test = "exclude"
}

}

schedule {
name = "2 weeks of daily snapshots"

create_rule {
interval = 24
interval_unit = "HOURS"
times = ["23:45"]
}

retain_rule {
count = 14
}

tags_to_add = {
SnapshotCreator = "DLM"
}

copy_tags = false
}

target_tags = {
Snapshot = "true"
}
}
}
```

### Example Default Policy
Expand Down Expand Up @@ -351,6 +392,7 @@ This resource supports the following arguments:
#### Parameters arguments

* `exclude_boot_volume` - (Optional) Indicates whether to exclude the root volume from snapshots created using CreateSnapshots. The default is `false`.
* `exclude_data_volume_tags` - (Optional) Map specifies whether to exclude volumes that have specific tags.
* `no_reboot` - (Optional) Applies to AMI lifecycle policies only. Indicates whether targeted instances are rebooted when the lifecycle policy runs. `true` indicates that targeted instances are not rebooted when the policy runs. `false` indicates that target instances are rebooted when the policy runs. The default is `true` (instances are not rebooted).

#### Schedule arguments
Expand Down
Loading