Skip to content

Commit

Permalink
Merge pull request #32 from lgallard/fix/formatting
Browse files Browse the repository at this point in the history
Update README & fix formatting
  • Loading branch information
lgallard authored Apr 22, 2021
2 parents d4c8bdb + ccc0210 commit 2645e2d
Show file tree
Hide file tree
Showing 26 changed files with 117 additions and 74 deletions.
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log

# Ignore any .tfvars files that are generated automatically for each Terraform run. Most
# .tfvars files are managed as part of configuration and so should be included in
# version control.
#
# example.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
#
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-added-large-files
- id: detect-aws-credentials
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.49.0 # Get the latest from: https://github.com/antonbabenko/pre-commit-terraform/releases
hooks:
- id: terraform_fmt
- id: terraform_validate
- id: terraform_docs
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.11.3 (April 22, 2021)

ENHANCEMENTS:

* Add pre-commit config file
* Add .gitignore file
* Update README


## 0.11.2 (April 10, 2021)

FIXES:
Expand Down Expand Up @@ -118,7 +127,7 @@ UPDATES:
ENHANCEMENTS:

* Add enabled flag which avoid deploying any AWS Backup resources when set to false

FIXES:

* Fix inputs formatting in README file
Expand Down
94 changes: 49 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,76 +100,80 @@ module "aws_backup_example" {
Terraform = true
}
}
```
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements
| Name | Version |
|------|---------|
| terraform | >= 0.12 |
| aws | >= 2.58.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.12 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 2.58.0 |
## Providers
| Name | Version |
|------|---------|
| aws | >= 2.58.0 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 2.58.0 |
## Modules
No Modules.
No modules.
## Resources
| Name |
|------|
| [aws_backup_plan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) |
| [aws_backup_selection](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_selection) |
| [aws_backup_vault](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault) |
| [aws_backup_vault_notifications](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault_notifications) |
| [aws_iam_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) |
| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) |
| [aws_iam_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) |
| [aws_iam_role_policy_attachment](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) |
| [aws_sns_topic_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_policy) |
| Name | Type |
|------|------|
| [aws_backup_plan.ab_plan](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan) | resource |
| [aws_backup_selection.ab_selection](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_selection) | resource |
| [aws_backup_vault.ab_vault](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault) | resource |
| [aws_backup_vault_notifications.backup_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_vault_notifications) | resource |
| [aws_iam_policy.ab_tag_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_role.ab_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role_policy_attachment.ab_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.ab_restores_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_iam_role_policy_attachment.ab_tag_policy_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |
| [aws_sns_topic_policy.backup_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic_policy) | resource |
| [aws_iam_policy_document.backup_events](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| enabled | Change to false to avoid deploying any AWS Backup resources | `bool` | `true` | no |
| iam\_role\_arn | If configured, the module will attach this role to selections, instead of creating IAM resources by itself | `string` | `null` | no |
| notifications | Notification block which defines backup vault events and the SNS Topic ARN to send AWS Backup notifications to. Leave it empty to disable notifications | `any` | `{}` | no |
| plan\_name | The display name of a backup plan | `string` | n/a | yes |
| rule\_completion\_window | The amount of time AWS Backup attempts a backup before canceling the job and returning an error | `number` | `null` | no |
| rule\_copy\_action\_destination\_vault\_arn | An Amazon Resource Name (ARN) that uniquely identifies the destination backup vault for the copied backup. | `string` | `null` | no |
| rule\_copy\_action\_lifecycle | The lifecycle defines when a protected resource is copied over to a backup vault and when it expires. | `map` | `{}` | no |
| rule\_enable\_continuous\_backup | Enable continuous backups for supported resources. | `bool` | `false` | no |
| rule\_lifecycle\_cold\_storage\_after | Specifies the number of days after creation that a recovery point is moved to cold storage | `number` | `null` | no |
| rule\_lifecycle\_delete\_after | Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after` | `number` | `null` | no |
| rule\_name | An display name for a backup rule | `string` | `null` | no |
| rule\_recovery\_point\_tags | Metadata that you can assign to help organize the resources that you create | `map(string)` | `{}` | no |
| rule\_schedule | A CRON expression specifying when AWS Backup initiates a backup job | `string` | `null` | no |
| rule\_start\_window | The amount of time in minutes before beginning a backup | `number` | `null` | no |
| rules | A list of rule maps | `any` | `[]` | no |
| selection\_name | The display name of a resource selection document | `string` | `null` | no |
| selection\_resources | An array of strings that either contain Amazon Resource Names (ARNs) or match patterns of resources to assign to a backup plan | `list` | `[]` | no |
| selection\_tags | List of tags for `selection_name` var, when using variable definition. | `list` | `[]` | no |
| selections | A list of selction maps | `any` | `[]` | no |
| tags | A mapping of tags to assign to the resource | `map(string)` | `{}` | no |
| vault\_kms\_key\_arn | The server-side encryption key that is used to protect your backups | `string` | `null` | no |
| vault\_name | Name of the backup vault to create. If not given, AWS use default | `string` | `null` | no |
| windows\_vss\_backup | Enable Windows VSS backup option and create a VSS Windows backup | `bool` | `false` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Change to false to avoid deploying any AWS Backup resources | `bool` | `true` | no |
| <a name="input_iam_role_arn"></a> [iam\_role\_arn](#input\_iam\_role\_arn) | If configured, the module will attach this role to selections, instead of creating IAM resources by itself | `string` | `null` | no |
| <a name="input_notifications"></a> [notifications](#input\_notifications) | Notification block which defines backup vault events and the SNS Topic ARN to send AWS Backup notifications to. Leave it empty to disable notifications | `any` | `{}` | no |
| <a name="input_plan_name"></a> [plan\_name](#input\_plan\_name) | The display name of a backup plan | `string` | n/a | yes |
| <a name="input_rule_completion_window"></a> [rule\_completion\_window](#input\_rule\_completion\_window) | The amount of time AWS Backup attempts a backup before canceling the job and returning an error | `number` | `null` | no |
| <a name="input_rule_copy_action_destination_vault_arn"></a> [rule\_copy\_action\_destination\_vault\_arn](#input\_rule\_copy\_action\_destination\_vault\_arn) | An Amazon Resource Name (ARN) that uniquely identifies the destination backup vault for the copied backup. | `string` | `null` | no |
| <a name="input_rule_copy_action_lifecycle"></a> [rule\_copy\_action\_lifecycle](#input\_rule\_copy\_action\_lifecycle) | The lifecycle defines when a protected resource is copied over to a backup vault and when it expires. | `map` | `{}` | no |
| <a name="input_rule_enable_continuous_backup"></a> [rule\_enable\_continuous\_backup](#input\_rule\_enable\_continuous\_backup) | Enable continuous backups for supported resources. | `bool` | `false` | no |
| <a name="input_rule_lifecycle_cold_storage_after"></a> [rule\_lifecycle\_cold\_storage\_after](#input\_rule\_lifecycle\_cold\_storage\_after) | Specifies the number of days after creation that a recovery point is moved to cold storage | `number` | `null` | no |
| <a name="input_rule_lifecycle_delete_after"></a> [rule\_lifecycle\_delete\_after](#input\_rule\_lifecycle\_delete\_after) | Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after` | `number` | `null` | no |
| <a name="input_rule_name"></a> [rule\_name](#input\_rule\_name) | An display name for a backup rule | `string` | `null` | no |
| <a name="input_rule_recovery_point_tags"></a> [rule\_recovery\_point\_tags](#input\_rule\_recovery\_point\_tags) | Metadata that you can assign to help organize the resources that you create | `map(string)` | `{}` | no |
| <a name="input_rule_schedule"></a> [rule\_schedule](#input\_rule\_schedule) | A CRON expression specifying when AWS Backup initiates a backup job | `string` | `null` | no |
| <a name="input_rule_start_window"></a> [rule\_start\_window](#input\_rule\_start\_window) | The amount of time in minutes before beginning a backup | `number` | `null` | no |
| <a name="input_rules"></a> [rules](#input\_rules) | A list of rule maps | `any` | `[]` | no |
| <a name="input_selection_name"></a> [selection\_name](#input\_selection\_name) | The display name of a resource selection document | `string` | `null` | no |
| <a name="input_selection_resources"></a> [selection\_resources](#input\_selection\_resources) | An array of strings that either contain Amazon Resource Names (ARNs) or match patterns of resources to assign to a backup plan | `list` | `[]` | no |
| <a name="input_selection_tags"></a> [selection\_tags](#input\_selection\_tags) | List of tags for `selection_name` var, when using variable definition. | `list` | `[]` | no |
| <a name="input_selections"></a> [selections](#input\_selections) | A list of selction maps | `any` | `[]` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no |
| <a name="input_vault_kms_key_arn"></a> [vault\_kms\_key\_arn](#input\_vault\_kms\_key\_arn) | The server-side encryption key that is used to protect your backups | `string` | `null` | no |
| <a name="input_vault_name"></a> [vault\_name](#input\_vault\_name) | Name of the backup vault to create. If not given, AWS use default | `string` | `null` | no |
| <a name="input_windows_vss_backup"></a> [windows\_vss\_backup](#input\_windows\_vss\_backup) | Enable Windows VSS backup option and create a VSS Windows backup | `bool` | `false` | no |
## Outputs
| Name | Description |
|------|-------------|
| plan\_arn | The ARN of the backup plan |
| plan\_id | The id of the backup plan |
| plan\_role | The service role of the backup plan |
| plan\_version | Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan |
| vault\_arn | The ARN of the vault |
| vault\_id | The name of the vault |
| <a name="output_plan_arn"></a> [plan\_arn](#output\_plan\_arn) | The ARN of the backup plan |
| <a name="output_plan_id"></a> [plan\_id](#output\_plan\_id) | The id of the backup plan |
| <a name="output_plan_role"></a> [plan\_role](#output\_plan\_role) | The service role of the backup plan |
| <a name="output_plan_version"></a> [plan\_version](#output\_plan\_version) | Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan |
| <a name="output_vault_arn"></a> [vault\_arn](#output\_vault\_arn) | The ARN of the vault |
| <a name="output_vault_id"></a> [vault\_id](#output\_vault\_id) | The name of the vault |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Known issues
Expand Down
3 changes: 1 addition & 2 deletions examples/complete_plan/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Complete Plan
# Complete Plan

This example shows you how to create a complete plan, using several resources and options:

Expand Down Expand Up @@ -82,4 +82,3 @@ module "aws_backup_example" {
}
}
```

1 change: 0 additions & 1 deletion examples/complete_plan/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ provider "aws" {
region = var.env["region"]
profile = var.env["profile"]
}

1 change: 0 additions & 1 deletion examples/complete_plan/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ env = {
region = "us-east-1"
profile = "default"
}

4 changes: 2 additions & 2 deletions examples/complete_plan/terraform_destroy_aws_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ targets=""
for i in `terraform state list | grep "selection"`; do targets="${targets} --target=${i}"; done

# Destroy selections
terraform destroy ${targets}
terraform destroy ${targets}

# Destroy all
terraform destroy
terraform destroy
1 change: 0 additions & 1 deletion examples/complete_plan/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ variable "env" {
type = map
default = {}
}

3 changes: 1 addition & 2 deletions examples/selection_by_tags/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Selection by tags
# Selection by tags

This example shows you how to define selection using tags, without `resource` definitions:

Expand Down Expand Up @@ -69,4 +69,3 @@ module "aws_backup_example" {
}
```

1 change: 0 additions & 1 deletion examples/selection_by_tags/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ provider "aws" {
region = var.env["region"]
profile = var.env["profile"]
}

1 change: 0 additions & 1 deletion examples/selection_by_tags/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ env = {
region = "us-east-1"
profile = "default"
}

4 changes: 2 additions & 2 deletions examples/selection_by_tags/terraform_destroy_aws_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ targets=""
for i in `terraform state list | grep "selection"`; do targets="${targets} --target=${i}"; done

# Destroy selections
terraform destroy ${targets}
terraform destroy ${targets}

# Destroy all
terraform destroy
terraform destroy
1 change: 0 additions & 1 deletion examples/selection_by_tags/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ variable "env" {
type = map
default = {}
}

2 changes: 1 addition & 1 deletion examples/simple_plan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example shows you how to create a simple plan using lists instead of variab

```
module "aws_backup_example" {
source = "lgallard/backup/aws"
# Vault
Expand Down
1 change: 0 additions & 1 deletion examples/simple_plan/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ provider "aws" {
region = var.env["region"]
profile = var.env["profile"]
}

1 change: 0 additions & 1 deletion examples/simple_plan/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ env = {
region = "us-east-1"
profile = "default"
}

4 changes: 2 additions & 2 deletions examples/simple_plan/terraform_destroy_aws_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ targets=""
for i in `terraform state list | grep "selection"`; do targets="${targets} --target=${i}"; done

# Destroy selections
terraform destroy ${targets}
terraform destroy ${targets}

# Destroy all
terraform destroy
terraform destroy
1 change: 0 additions & 1 deletion examples/simple_plan/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ variable "env" {
type = map
default = {}
}

2 changes: 1 addition & 1 deletion examples/simple_plan_using_variables/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This example shows you how to create a simple plan using variables:

```
module "aws_backup_example" {
source = "lgallard/backup/aws"
# Vault
Expand Down
1 change: 0 additions & 1 deletion examples/simple_plan_using_variables/provider.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ provider "aws" {
region = var.env["region"]
profile = var.env["profile"]
}

1 change: 0 additions & 1 deletion examples/simple_plan_using_variables/terraform.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ env = {
region = "us-east-1"
profile = "default"
}

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ targets=""
for i in `terraform state list | grep "selection"`; do targets="${targets} --target=${i}"; done

# Destroy selections
terraform destroy ${targets}
terraform destroy ${targets}

# Destroy all
terraform destroy
terraform destroy
1 change: 0 additions & 1 deletion examples/simple_plan_using_variables/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ variable "env" {
type = map
default = {}
}

2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ resource "aws_backup_plan" "ab_plan" {
enable_continuous_backup = lookup(rule.value, "enable_continuous_backup", null)
recovery_point_tags = length(lookup(rule.value, "recovery_point_tags")) == 0 ? var.tags : lookup(rule.value, "recovery_point_tags")

# Lifecycle
# Lifecycle
dynamic "lifecycle" {
for_each = length(lookup(rule.value, "lifecycle")) == 0 ? [] : [lookup(rule.value, "lifecycle", {})]
content {
Expand Down
1 change: 0 additions & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ terraform {
aws = ">= 2.58.0"
}
}

0 comments on commit 2645e2d

Please sign in to comment.