Terraform module to create AWS EBS (Elastic Block Storage) volume with DLM policy for automated snapshots as optional This module support support volume encrypt with KMS key 🔑
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Source: <https://opensource.org/licenses/MIT>
See LICENSE for full details.
Name | Version |
---|---|
terraform | >= 1.0 |
aws | >= 4.9.0 |
random | >= 3.0 |
No modules.
Name | Type |
---|---|
aws_dlm_lifecycle_policy.backup | resource |
aws_ebs_volume.this | resource |
aws_iam_role.dlm_lifecycle_role | resource |
aws_iam_role_policy.dlm_lifecycle_policy | resource |
random_integer.hour | resource |
random_integer.minute | resource |
random_string.name_suffix | resource |
Name | Description | Type | Default | Required |
---|---|---|---|---|
availability_zone | Availability Zone where EBS volume will exist. | string |
n/a | yes |
backup_ebs_iam_role_name | The IAM role name for the DLM lifecyle policy | string |
"dlm-lifecycle-role" |
no |
backup_ebs_period | frequency of snapshot in hours (valid values are 1 , 2 , 3 , 4 , 6 , 8 , 12 , or 24 ) |
number |
24 |
no |
backup_ebs_policy_role_name | The role name for the DLM lifecyle policy | string |
"dlm-lifecycle-policy" |
no |
backup_ebs_retention | retention period in days | number |
7 |
no |
backup_ebs_start_time | start time in 24 hour format (default is a random time) | string |
"" |
no |
create_name_suffix | always add a random suffix in a resource name. | bool |
true |
no |
enable_backup | Flag to turn on backups. Backup is by default enabled. | bool |
true |
no |
encrypted | If true, the disk will be encrypted. | bool |
false |
no |
final_snapshot | If true, snapshot will be created before volume deletion. Any tags on the volume will be migrated to the snapshot. BE AWARE by default is set to false . |
bool |
false |
no |
iops | Amount of IOPS to provision for the disk. Only valid for type of io1 , io2 or gp3 . |
number |
0 |
no |
kms_key_id | The ARN for the KMS encryption key. When specifying kms_key_id , encrypted needs to be set to true.Note: Terraform must be running with credentials which have the GenerateDataKeyWithoutPlaintext permission on the specified KMS keyas required by the EBS KMS CMK volume provisioning process to prevent a volume from being created and almost immediately deleted. |
string |
"" |
no |
multi_attach_enabled | Specifies whether to enable Amazon EBS Multi-Attach. Multi-Attach is supported on io1 and io2 volumes. |
bool |
false |
no |
name | Name of ebs volume | string |
n/a | yes |
outpost_arn | The Amazon Resource Name (ARN) of the Outpost | string |
"" |
no |
size | The size of the drive in GiBs | number |
n/a | yes |
snapshot_id | A snapshot to base the EBS volume off of | string |
"" |
no |
tags | extra tags | map(string) |
{} |
no |
type | The type of EBS volume. Can be standard , gp2 , gp3 , io1 , io2 , sc1 or st1 (Default: gp2 ) |
string |
"gp2" |
no |
Name | Description |
---|---|
backup_hours | Time in %HH:%MM format when ebs snapshot is started |
dlm_policy_id | ID dlm lifecycle policy |
dlm_role_id | ID dlm lifecycle role |
ebs_volume_arn | Elastic block storage volume arn |
ebs_volume_id | Elastic block storage volume id |
module "app_prod_bastion_label" {
source = "cloudposse/label/null"
version = "v0.25.0"
namespace = "app"
stage = "prod"
name = "bastion"
attributes = ["public"]
delimiter = "-"
tags = {
"BusinessUnit" = "XYZ",
"Snapshot" = "true"
}
}
module "app_prod_bastion_ebs" {
source = "../../"
encrypted = true
name = join(module.app_prod_bastion_label.delimiter, [module.app_prod_bastion_label.stage, module.app_prod_bastion_label.name, var.name])
backup_ebs_iam_role_name = join(module.app_prod_bastion_label.delimiter, [module.app_prod_bastion_label.stage, module.app_prod_bastion_label.name, var.iam_role_name])
backup_ebs_policy_role_name = join(module.app_prod_bastion_label.delimiter, [module.app_prod_bastion_label.stage, module.app_prod_bastion_label.name, var.policy_role_name])
availability_zone = var.availability_zone
size = var.size
tags = module.app_prod_bastion_label.tags
}