Remove backup and ses

Due to academy restrictions :'(

Co-authored-by: Ezequiel Bellver <ebellver@itba.edu.ar>
This commit is contained in:
Santiago Lo Coco 2022-11-30 19:33:42 -03:00
parent 9746ae8533
commit d7cbbb2cf6
30 changed files with 31 additions and 281 deletions

5
.gitignore vendored
View File

@ -59,3 +59,8 @@ venv.bak/
terraform.tfstate* terraform.tfstate*
.terraform* .terraform*
.fleet .fleet
ses/
ses.tf
backup/
backup.tf

View File

@ -10,6 +10,5 @@ repos:
- id: terraform_tflint - id: terraform_tflint
- id: terraform_tfsec - id: terraform_tfsec
- id: terrascan - id: terrascan
- id: tfupdate
- id: terraform_validate - id: terraform_validate

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,34 +0,0 @@
# ------------------------------------------------------------------------------
# Amazon Backup
# ------------------------------------------------------------------------------
resource "aws_backup_vault" "this" {
name = var.vault_name
}
resource "aws_backup_plan" "this" {
name = var.plan_name
dynamic "rule" {
for_each = var.rules
content {
rule_name = lookup(rule.value, "name", null)
target_vault_name = lookup(rule.value, "target_vault_name", null)
schedule = lookup(rule.value, "schedule", null)
start_window = lookup(rule.value, "start_window", null)
completion_window = lookup(rule.value, "completion_window", null)
enable_continuous_backup = lookup(rule.value, "enable_continuous_backup", null)
dynamic "lifecycle" {
for_each = length(lookup(rule.value, "lifecycle", {})) == 0 ? [] : [lookup(rule.value, "lifecycle", {})]
content {
cold_storage_after = lookup(lifecycle.value, "cold_storage_after", 0)
delete_after = lookup(lifecycle.value, "delete_after", 90)
}
}
}
}
depends_on = [aws_backup_vault.this]
}

View File

@ -1,92 +0,0 @@
# ------------------------------------------------------------------------------
# Amazon Backup variables
# ------------------------------------------------------------------------------
variable "vault_name" {
description = "Name of the backup vault to create. If not given, AWS use default"
type = string
default = null
}
variable "plan_name" {
description = "The display name of a backup plan"
type = string
}
variable "rule_name" {
description = "An display name for a backup rule"
type = string
default = null
}
variable "rule_schedule" {
description = "A CRON expression specifying when AWS Backup initiates a backup job"
type = string
default = null
}
variable "rule_start_window" {
description = "The amount of time in minutes before beginning a backup"
type = number
default = null
}
variable "rule_completion_window" {
description = "The amount of time AWS Backup attempts a backup before canceling the job and returning an error"
type = number
default = null
}
# variable "rule_recovery_point_tags" {
# description = "Metadata that you can assign to help organize the resources that you create"
# type = map(string)
# default = {}
# }
variable "rule_lifecycle_cold_storage_after" {
description = "Specifies the number of days after creation that a recovery point is moved to cold storage"
type = number
default = null
}
variable "rule_lifecycle_delete_after" {
description = "Specifies the number of days after creation that a recovery point is deleted. Must be 90 days greater than `cold_storage_after`"
type = number
default = null
}
# variable "rule_copy_action_lifecycle" {
# description = "The lifecycle defines when a protected resource is copied over to a backup vault and when it expires."
# type = map(any)
# default = {}
# }
# variable "rule_copy_action_destination_vault_arn" {
# description = "An Amazon Resource Name (ARN) that uniquely identifies the destination backup vault for the copied backup."
# type = string
# default = null
# }
variable "rule_enable_continuous_backup" {
description = "Enable continuous backups for supported resources."
type = bool
default = false
}
variable "rules" {
description = "A list of rule maps"
type = any
default = []
}
variable "selections" {
description = "A list of selction maps"
type = any
default = []
}
variable "tags" {
description = "A mapping of tags to assign to the resource"
type = map(string)
default = {}
}

View File

@ -1,10 +0,0 @@
terraform {
required_version = "1.3.4"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.10.0"
}
}
}

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers
@ -26,6 +26,8 @@ No modules.
| Name | Description | Type | Default | Required | | Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:| |------|-------------|------|---------|:--------:|
| <a name="input_acm_certificate_arn"></a> [acm\_certificate\_arn](#input\_acm\_certificate\_arn) | ACM certificate. | `string` | n/a | yes |
| <a name="input_aliases"></a> [aliases](#input\_aliases) | Domain aliases. | `any` | n/a | yes |
| <a name="input_default_cache_behavior"></a> [default\_cache\_behavior](#input\_default\_cache\_behavior) | The default cache behavior for this distribution | `any` | n/a | yes | | <a name="input_default_cache_behavior"></a> [default\_cache\_behavior](#input\_default\_cache\_behavior) | The default cache behavior for this distribution | `any` | n/a | yes |
| <a name="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object) | The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL. | `string` | `null` | no | | <a name="input_default_root_object"></a> [default\_root\_object](#input\_default\_root\_object) | The object that you want CloudFront to return (for example, index.html) when an end user requests the root URL. | `string` | `null` | no |
| <a name="input_enabled"></a> [enabled](#input\_enabled) | Whether the distribution is enabled to accept end user requests for content. | `bool` | `true` | no | | <a name="input_enabled"></a> [enabled](#input\_enabled) | Whether the distribution is enabled to accept end user requests for content. | `bool` | `true` | no |
@ -35,5 +37,8 @@ No modules.
## Outputs ## Outputs
No outputs. | Name | Description |
|------|-------------|
| <a name="output_distribution_domain_name"></a> [distribution\_domain\_name](#output\_distribution\_domain\_name) | The domain name corresponding to the distribution. |
| <a name="output_distribution_hosted_zone_id"></a> [distribution\_hosted\_zone\_id](#output\_distribution\_hosted\_zone\_id) | The CloudFront Route 53 zone ID that can be used to route an Alias Resource Record Set to. |
<!-- END_TF_DOCS --> <!-- END_TF_DOCS -->

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,54 +0,0 @@
# ------------------------------------------------------------------------------
# Amazon SES
# ------------------------------------------------------------------------------
resource "aws_ses_domain_identity" "this" {
domain = var.domain
}
resource "aws_ses_domain_mail_from" "this" {
domain = aws_ses_domain_identity.this.domain
mail_from_domain = "mail.${var.domain}"
}
# hacer for_each
# resource "aws_route53_record" "amazonses_verification_record" {
# zone_id = data.aws_route53_zone.main.zone_id
# name = "_amazonses.${var.domain}"
# type = "TXT"
# ttl = "600"
# records = [join("", aws_ses_domain_identity.ses_domain.*.verification_token)]
# }
# resource "aws_ses_domain_dkim" "ses_domain_dkim" {
# domain = join("", aws_ses_domain_identity.ses_domain.*.domain)
# }
# resource "aws_route53_record" "amazonses_dkim_record" {
# count = 3
# zone_id = data.aws_route53_zone.main.zone_id
# name = "${element(aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens, count.index)}._domainkey.${var.domain}"
# type = "CNAME"
# ttl = "600"
# records = ["${element(aws_ses_domain_dkim.ses_domain_dkim.dkim_tokens, count.index)}.dkim.amazonses.com"]
# }
# resource "aws_route53_record" "spf_mail_from" {
# zone_id = data.aws_route53_zone.main.zone_id
# name = aws_ses_domain_mail_from.main.mail_from_domain
# type = "TXT"
# ttl = "600"
# records = ["v=spf1 include:amazonses.com -all"]
# }
# creo que solo con este spf estamos
resource "aws_route53_record" "this" {
# zone_id = data.aws_route53_zone.this.zone_id
zone_id = var.zone_id
name = var.domain
type = "TXT"
ttl = "600"
records = ["v=spf1 include:amazonses.com -all"]
}

View File

@ -1,13 +0,0 @@
# ------------------------------------------------------------------------------
# Amazon SES variables
# ------------------------------------------------------------------------------
variable "domain" {
description = "The domain to use."
type = string
}
variable "zone_id" {
description = "ID of DNS zone"
type = string
}

View File

@ -1,10 +0,0 @@
terraform {
required_version = "1.3.4"
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.10.0"
}
}
}

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -3,7 +3,7 @@
| Name | Version | | Name | Version |
|------|---------| |------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | 1.3.4 | | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 | | <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.10.0 |
## Providers ## Providers

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {

View File

@ -1,32 +0,0 @@
module "backup" {
source = "../modules/backup"
providers = {
aws = aws.aws
}
vault_name = "dynamodb-backup-vault"
plan_name = "dynamodb-backup-plan"
rules = [
{
name = "dynamodb-backup-rule"
schedule = "cron(0 12 * * ? *)"
target_vault_name = "dynamodb-backup-vault"
start_window = 120
completion_window = 360
enable_continuous_backup = true
lifecycle = {
cold_storage_after = 0
delete_after = 30
},
}
]
selections = [
{
name = "selection"
resources = ["arn:aws:dynamodb:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:table/${module.dynamodb.name}"]
}
]
}

View File

@ -1,14 +0,0 @@
module "ses" {
source = "../modules/ses"
providers = {
aws = aws.aws
}
depends_on = [
module.route53
]
domain = local.domain
zone_id = module.route53.zone_id
}

View File

@ -1,5 +1,5 @@
terraform { terraform {
required_version = "1.3.4" required_version = ">= 1.3.1"
required_providers { required_providers {
aws = { aws = {