Skip to content

Commit 8c09608

Browse files
committed
Initial commit
1 parent 8e0a30b commit 8c09608

File tree

7 files changed

+505
-61
lines changed

7 files changed

+505
-61
lines changed

.github/settings.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
# Upstream changes from _extends are only recognized when modifications are made to this file in the default branch.
22
_extends: .github
33
repository:
4-
name: template
5-
description: Template for Terraform Components
4+
name: aws-backup
5+
description: This component is responsible for provisioning an AWS Backup Plan
66
homepage: https://cloudposse.com/accelerate
77
topics: terraform, terraform-component
8-
9-
10-
11-

README.yaml

Lines changed: 345 additions & 47 deletions
Large diffs are not rendered by default.

src/main.tf

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
locals {
2-
enabled = module.this.enabled
3-
}
1+
module "backup" {
2+
source = "cloudposse/backup/aws"
3+
version = "1.0.0"
44

5+
plan_name_suffix = var.plan_name_suffix
6+
vault_enabled = var.vault_enabled
7+
iam_role_enabled = var.iam_role_enabled
8+
plan_enabled = var.plan_enabled
59

10+
backup_resources = var.backup_resources
11+
selection_tags = var.selection_tags
612

13+
kms_key_arn = var.kms_key_arn
714

15+
rules = var.rules
16+
advanced_backup_setting = var.advanced_backup_setting
17+
backup_vault_lock_configuration = var.backup_vault_lock_configuration
818

19+
context = module.this.context
20+
}

src/outputs.tf

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
1-
output "mock" {
2-
description = "Mock output example for the Cloud Posse Terraform component template"
3-
value = local.enabled ? "hello ${basename(abspath(path.module))}" : ""
1+
output "backup_vault_id" {
2+
value = module.backup.backup_vault_id
3+
description = "Backup Vault ID"
4+
}
5+
6+
output "backup_vault_arn" {
7+
value = module.backup.backup_vault_arn
8+
description = "Backup Vault ARN"
9+
}
10+
11+
output "backup_plan_arn" {
12+
value = module.backup.backup_plan_arn
13+
description = "Backup Plan ARN"
14+
}
15+
16+
output "backup_plan_version" {
17+
value = module.backup.backup_plan_version
18+
description = "Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan"
19+
}
20+
21+
output "backup_selection_id" {
22+
value = module.backup.backup_selection_id
23+
description = "Backup Selection ID"
424
}

src/providers.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
provider "aws" {
2+
region = var.region
3+
4+
# Profile is deprecated in favor of terraform_role_arn. When profiles are not in use, terraform_profile_name is null.
5+
profile = module.iam_roles.terraform_profile_name
6+
7+
dynamic "assume_role" {
8+
# module.iam_roles.terraform_role_arn may be null, in which case do not assume a role.
9+
for_each = compact([module.iam_roles.terraform_role_arn])
10+
content {
11+
role_arn = assume_role.value
12+
}
13+
}
14+
}
15+
16+
module "iam_roles" {
17+
source = "../account-map/modules/iam-roles"
18+
context = module.this.context
19+
}

src/variables.tf

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
variable "region" {
2+
type = string
3+
description = "AWS Region"
4+
}
5+
6+
variable "kms_key_arn" {
7+
type = string
8+
description = "The server-side encryption key that is used to protect your backups"
9+
default = null
10+
}
11+
12+
variable "backup_vault_lock_configuration" {
13+
type = object({
14+
changeable_for_days = optional(number)
15+
max_retention_days = optional(number)
16+
min_retention_days = optional(number)
17+
})
18+
description = <<-EOT
19+
The backup vault lock configuration, each vault can have one vault lock in place. This will enable Backup Vault Lock on an AWS Backup vault it prevents the deletion of backup data for the specified retention period. During this time, the backup data remains immutable and cannot be deleted or modified."
20+
`changeable_for_days` - The number of days before the lock date. If omitted creates a vault lock in `governance` mode, otherwise it will create a vault lock in `compliance` mode.
21+
EOT
22+
default = null
23+
}
24+
25+
variable "selection_tags" {
26+
type = list(map(string))
27+
description = "An array of tag condition objects used to filter resources based on tags for assigning to a backup plan"
28+
default = []
29+
}
30+
31+
variable "backup_resources" {
32+
type = list(string)
33+
description = "An array of strings that either contain Amazon Resource Names (ARNs) or match patterns of resources to assign to a backup plan"
34+
default = []
35+
}
36+
37+
variable "plan_name_suffix" {
38+
type = string
39+
description = "The string appended to the plan name"
40+
default = null
41+
}
42+
43+
variable "vault_enabled" {
44+
type = bool
45+
description = "Whether or not a new Vault should be created"
46+
default = true
47+
}
48+
49+
variable "plan_enabled" {
50+
type = bool
51+
description = "Whether or not to create a new Plan"
52+
default = true
53+
}
54+
55+
variable "iam_role_enabled" {
56+
type = bool
57+
description = "Whether or not to create a new IAM Role and Policy Attachment"
58+
default = true
59+
}
60+
61+
62+
variable "rules" {
63+
type = list(object({
64+
name = string
65+
schedule = optional(string)
66+
enable_continuous_backup = optional(bool)
67+
start_window = optional(number)
68+
completion_window = optional(number)
69+
lifecycle = optional(object({
70+
cold_storage_after = optional(number)
71+
delete_after = optional(number)
72+
opt_in_to_archive_for_supported_resources = optional(bool)
73+
}))
74+
copy_action = optional(object({
75+
destination_vault_arn = optional(string)
76+
lifecycle = optional(object({
77+
cold_storage_after = optional(number)
78+
delete_after = optional(number)
79+
opt_in_to_archive_for_supported_resources = optional(bool)
80+
}))
81+
}))
82+
}))
83+
description = "An array of rule maps used to define schedules in a backup plan"
84+
default = []
85+
}
86+
87+
variable "advanced_backup_setting" {
88+
type = object({
89+
backup_options = string
90+
resource_type = string
91+
})
92+
description = "An object that specifies backup options for each resource type."
93+
default = null
94+
}

src/versions.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
terraform {
2-
required_version = ">= 1.0.0"
2+
required_version = ">= 1.3.0"
33

4-
required_providers {}
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 4.9.0"
8+
}
9+
}
510
}

0 commit comments

Comments
 (0)