Terraform module - creates ups data life-cycle management to automate ebs backups.
It's 100% Open Source and licensed under the APACHE2.
Include this repository as a module in your existing terraform code:
module "dlmautowsnapshot" {
source = "JamesWoolfenden/dlmautowsnapshot/aws"
version = "0.2.9"
common_tags = var.common_tags
snapshot_name = local.snapshot_name
cron_expression = var.cron_expression
regions = var.regions
}
The management of EC2 backup has become simpler With the new release of Data Lifecycle Manager (DLM) policies https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/snapshot-lifecycle.html. There is no more need for a Lambdas to manage EBS snapshots, and additionally with the new release of support for DLM in Terraform https://www.terraform.io/docs/providers/aws/r/dlm_lifecycle_policy.html it can achieved easily.
The example - exampleA shows how to implement a DLM policy on EBS snapshots. As before you include a reference to the module in your code.
In the example the variable schedule is an extensible list of maps.
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
}
]
That's all for now.
No requirements.
Name | Version |
---|---|
aws | n/a |
No modules.
Name | Type |
---|---|
aws_dlm_lifecycle_policy.lifecycle | resource |
aws_iam_role.dlm_lifecycle | resource |
aws_iam_role_policy.dlm_lifecycle | resource |
aws_iam_policy_document.dlm | data source |
aws_iam_policy_document.trust | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
common_tags | Implements the common tags scheme | map(any) |
n/a | yes |
schedule | The DLM Schedule | list(any) |
n/a | yes |
schedule_copy_tags | n/a | bool |
false |
no |
schedule_interval | Interval between | number |
24 |
no |
schedule_interval_unit | Schedile Interval Unit | string |
"HOURS" |
no |
schedule_name | Name of the Schedule | string |
"2 weeks of daily snapshots" |
no |
schedule_retain | n/a | number |
14 |
no |
schedule_times | When the policy should run | string |
"23:45" |
no |
Name | Description |
---|---|
lifecycle | n/a |
This is the policy required to build this project:
The Terraform resource required is:
resource "aws_iam_policy" "terraform_pike" {
name_prefix = "terraform_pike"
path = "/"
description = "Pike Autogenerated policy from IAC"
policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"dlm:CreateLifecyclePolicy",
"dlm:DeleteLifecyclePolicy",
"dlm:GetLifecyclePolicy",
"dlm:ListTagsForResource",
"dlm:UpdateLifecyclePolicy"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes"
],
"Resource": "*"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
"iam:CreateRole",
"iam:DeleteRole",
"iam:DeleteRolePolicy",
"iam:GetRole",
"iam:GetRolePolicy",
"iam:ListAttachedRolePolicies",
"iam:ListInstanceProfilesForRole",
"iam:ListRolePolicies",
"iam:PutRolePolicy",
"iam:TagRole"
],
"Resource": "*"
},
{
"Sid": "VisualEditor3",
"Effect": "Allow",
"Action": [
"kms:DescribeKey",
"kms:ListAliases"
],
"Resource": "*"
}
]
})
}
Check out these related projects.
- terraform-aws-s3 - S3 buckets
Got a question?
File a GitHub issue.
Please use the issue tracker to report any bugs or file feature requests.
Copyright © 2019-2022 James Woolfenden
See LICENSE for full details.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.