From ccc0210e18c9c00b4168706c37766fee63c97df0 Mon Sep 17 00:00:00 2001 From: "Luis M. Gallardo D" Date: Thu, 22 Apr 2021 18:49:38 -0300 Subject: [PATCH] Update README & fix formatting --- .gitignore | 29 ++++++ .pre-commit-config.yaml | 16 ++++ CHANGELOG.md | 11 ++- README.md | 94 ++++++++++--------- examples/complete_plan/README.md | 3 +- examples/complete_plan/provider.tf | 1 - examples/complete_plan/terraform.tfvars | 1 - .../terraform_destroy_aws_backup.sh | 4 +- examples/complete_plan/variables.tf | 1 - examples/selection_by_tags/README.md | 3 +- examples/selection_by_tags/provider.tf | 1 - examples/selection_by_tags/terraform.tfvars | 1 - .../terraform_destroy_aws_backup.sh | 4 +- examples/selection_by_tags/variables.tf | 1 - examples/simple_plan/README.md | 2 +- examples/simple_plan/provider.tf | 1 - examples/simple_plan/terraform.tfvars | 1 - .../terraform_destroy_aws_backup.sh | 4 +- examples/simple_plan/variables.tf | 1 - .../simple_plan_using_variables/README.md | 2 +- .../simple_plan_using_variables/provider.tf | 1 - .../terraform.tfvars | 1 - .../terraform_destroy_aws_backup.sh | 4 +- .../simple_plan_using_variables/variables.tf | 1 - main.tf | 2 +- versions.tf | 1 - 26 files changed, 117 insertions(+), 74 deletions(-) create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a3e2fd --- /dev/null +++ b/.gitignore @@ -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* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..9740b95 --- /dev/null +++ b/.pre-commit-config.yaml @@ -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 diff --git a/CHANGELOG.md b/CHANGELOG.md index 846d969..7f37c39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: @@ -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 diff --git a/README.md b/README.md index d4581b1..0b21480 100644 --- a/README.md +++ b/README.md @@ -100,76 +100,80 @@ module "aws_backup_example" { Terraform = true } } -``` + + ## Requirements | Name | Version | |------|---------| -| terraform | >= 0.12 | -| aws | >= 2.58.0 | +| [terraform](#requirement\_terraform) | >= 0.12 | +| [aws](#requirement\_aws) | >= 2.58.0 | ## Providers | Name | Version | |------|---------| -| aws | >= 2.58.0 | +| [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 | +| [enabled](#input\_enabled) | Change to false to avoid deploying any AWS Backup resources | `bool` | `true` | no | +| [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 | +| [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 | +| [plan\_name](#input\_plan\_name) | The display name of a backup plan | `string` | n/a | yes | +| [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 | +| [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 | +| [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 | +| [rule\_enable\_continuous\_backup](#input\_rule\_enable\_continuous\_backup) | Enable continuous backups for supported resources. | `bool` | `false` | no | +| [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 | +| [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 | +| [rule\_name](#input\_rule\_name) | An display name for a backup rule | `string` | `null` | no | +| [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 | +| [rule\_schedule](#input\_rule\_schedule) | A CRON expression specifying when AWS Backup initiates a backup job | `string` | `null` | no | +| [rule\_start\_window](#input\_rule\_start\_window) | The amount of time in minutes before beginning a backup | `number` | `null` | no | +| [rules](#input\_rules) | A list of rule maps | `any` | `[]` | no | +| [selection\_name](#input\_selection\_name) | The display name of a resource selection document | `string` | `null` | no | +| [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 | +| [selection\_tags](#input\_selection\_tags) | List of tags for `selection_name` var, when using variable definition. | `list` | `[]` | no | +| [selections](#input\_selections) | A list of selction maps | `any` | `[]` | no | +| [tags](#input\_tags) | A mapping of tags to assign to the resource | `map(string)` | `{}` | no | +| [vault\_kms\_key\_arn](#input\_vault\_kms\_key\_arn) | The server-side encryption key that is used to protect your backups | `string` | `null` | no | +| [vault\_name](#input\_vault\_name) | Name of the backup vault to create. If not given, AWS use default | `string` | `null` | no | +| [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 | +| [plan\_arn](#output\_plan\_arn) | The ARN of the backup plan | +| [plan\_id](#output\_plan\_id) | The id of the backup plan | +| [plan\_role](#output\_plan\_role) | The service role of the backup plan | +| [plan\_version](#output\_plan\_version) | Unique, randomly generated, Unicode, UTF-8 encoded string that serves as the version ID of the backup plan | +| [vault\_arn](#output\_vault\_arn) | The ARN of the vault | +| [vault\_id](#output\_vault\_id) | The name of the vault | + ## Known issues diff --git a/examples/complete_plan/README.md b/examples/complete_plan/README.md index 4f0b0ab..d0bf4ce 100644 --- a/examples/complete_plan/README.md +++ b/examples/complete_plan/README.md @@ -1,4 +1,4 @@ -# Complete Plan +# Complete Plan This example shows you how to create a complete plan, using several resources and options: @@ -82,4 +82,3 @@ module "aws_backup_example" { } } ``` - diff --git a/examples/complete_plan/provider.tf b/examples/complete_plan/provider.tf index 919f305..aa33683 100644 --- a/examples/complete_plan/provider.tf +++ b/examples/complete_plan/provider.tf @@ -11,4 +11,3 @@ provider "aws" { region = var.env["region"] profile = var.env["profile"] } - diff --git a/examples/complete_plan/terraform.tfvars b/examples/complete_plan/terraform.tfvars index e635d38..3cdaa9a 100644 --- a/examples/complete_plan/terraform.tfvars +++ b/examples/complete_plan/terraform.tfvars @@ -2,4 +2,3 @@ env = { region = "us-east-1" profile = "default" } - diff --git a/examples/complete_plan/terraform_destroy_aws_backup.sh b/examples/complete_plan/terraform_destroy_aws_backup.sh index 048aa2f..731280e 100755 --- a/examples/complete_plan/terraform_destroy_aws_backup.sh +++ b/examples/complete_plan/terraform_destroy_aws_backup.sh @@ -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 diff --git a/examples/complete_plan/variables.tf b/examples/complete_plan/variables.tf index 7f4c349..ff4005d 100644 --- a/examples/complete_plan/variables.tf +++ b/examples/complete_plan/variables.tf @@ -2,4 +2,3 @@ variable "env" { type = map default = {} } - diff --git a/examples/selection_by_tags/README.md b/examples/selection_by_tags/README.md index b06fbf9..27866b6 100644 --- a/examples/selection_by_tags/README.md +++ b/examples/selection_by_tags/README.md @@ -1,4 +1,4 @@ -# Selection by tags +# Selection by tags This example shows you how to define selection using tags, without `resource` definitions: @@ -69,4 +69,3 @@ module "aws_backup_example" { } ``` - diff --git a/examples/selection_by_tags/provider.tf b/examples/selection_by_tags/provider.tf index 978beab..634c762 100644 --- a/examples/selection_by_tags/provider.tf +++ b/examples/selection_by_tags/provider.tf @@ -2,4 +2,3 @@ provider "aws" { region = var.env["region"] profile = var.env["profile"] } - diff --git a/examples/selection_by_tags/terraform.tfvars b/examples/selection_by_tags/terraform.tfvars index e635d38..3cdaa9a 100644 --- a/examples/selection_by_tags/terraform.tfvars +++ b/examples/selection_by_tags/terraform.tfvars @@ -2,4 +2,3 @@ env = { region = "us-east-1" profile = "default" } - diff --git a/examples/selection_by_tags/terraform_destroy_aws_backup.sh b/examples/selection_by_tags/terraform_destroy_aws_backup.sh index 048aa2f..731280e 100755 --- a/examples/selection_by_tags/terraform_destroy_aws_backup.sh +++ b/examples/selection_by_tags/terraform_destroy_aws_backup.sh @@ -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 diff --git a/examples/selection_by_tags/variables.tf b/examples/selection_by_tags/variables.tf index 7f4c349..ff4005d 100644 --- a/examples/selection_by_tags/variables.tf +++ b/examples/selection_by_tags/variables.tf @@ -2,4 +2,3 @@ variable "env" { type = map default = {} } - diff --git a/examples/simple_plan/README.md b/examples/simple_plan/README.md index 7ad815a..c5d2973 100644 --- a/examples/simple_plan/README.md +++ b/examples/simple_plan/README.md @@ -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 diff --git a/examples/simple_plan/provider.tf b/examples/simple_plan/provider.tf index 919f305..aa33683 100644 --- a/examples/simple_plan/provider.tf +++ b/examples/simple_plan/provider.tf @@ -11,4 +11,3 @@ provider "aws" { region = var.env["region"] profile = var.env["profile"] } - diff --git a/examples/simple_plan/terraform.tfvars b/examples/simple_plan/terraform.tfvars index e635d38..3cdaa9a 100644 --- a/examples/simple_plan/terraform.tfvars +++ b/examples/simple_plan/terraform.tfvars @@ -2,4 +2,3 @@ env = { region = "us-east-1" profile = "default" } - diff --git a/examples/simple_plan/terraform_destroy_aws_backup.sh b/examples/simple_plan/terraform_destroy_aws_backup.sh index 048aa2f..731280e 100755 --- a/examples/simple_plan/terraform_destroy_aws_backup.sh +++ b/examples/simple_plan/terraform_destroy_aws_backup.sh @@ -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 diff --git a/examples/simple_plan/variables.tf b/examples/simple_plan/variables.tf index 7f4c349..ff4005d 100644 --- a/examples/simple_plan/variables.tf +++ b/examples/simple_plan/variables.tf @@ -2,4 +2,3 @@ variable "env" { type = map default = {} } - diff --git a/examples/simple_plan_using_variables/README.md b/examples/simple_plan_using_variables/README.md index 67037c7..c8bbac0 100644 --- a/examples/simple_plan_using_variables/README.md +++ b/examples/simple_plan_using_variables/README.md @@ -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 diff --git a/examples/simple_plan_using_variables/provider.tf b/examples/simple_plan_using_variables/provider.tf index 919f305..aa33683 100644 --- a/examples/simple_plan_using_variables/provider.tf +++ b/examples/simple_plan_using_variables/provider.tf @@ -11,4 +11,3 @@ provider "aws" { region = var.env["region"] profile = var.env["profile"] } - diff --git a/examples/simple_plan_using_variables/terraform.tfvars b/examples/simple_plan_using_variables/terraform.tfvars index e635d38..3cdaa9a 100644 --- a/examples/simple_plan_using_variables/terraform.tfvars +++ b/examples/simple_plan_using_variables/terraform.tfvars @@ -2,4 +2,3 @@ env = { region = "us-east-1" profile = "default" } - diff --git a/examples/simple_plan_using_variables/terraform_destroy_aws_backup.sh b/examples/simple_plan_using_variables/terraform_destroy_aws_backup.sh index 048aa2f..731280e 100755 --- a/examples/simple_plan_using_variables/terraform_destroy_aws_backup.sh +++ b/examples/simple_plan_using_variables/terraform_destroy_aws_backup.sh @@ -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 diff --git a/examples/simple_plan_using_variables/variables.tf b/examples/simple_plan_using_variables/variables.tf index 7f4c349..ff4005d 100644 --- a/examples/simple_plan_using_variables/variables.tf +++ b/examples/simple_plan_using_variables/variables.tf @@ -2,4 +2,3 @@ variable "env" { type = map default = {} } - diff --git a/main.tf b/main.tf index 9b47823..19c0792 100644 --- a/main.tf +++ b/main.tf @@ -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 { diff --git a/versions.tf b/versions.tf index dfaae96..5eef53f 100644 --- a/versions.tf +++ b/versions.tf @@ -5,4 +5,3 @@ terraform { aws = ">= 2.58.0" } } -