Following the indication from the aws_backup_plan, I have an error that I didn’t found when googling when I try to limit the backup selection to the only EC2 :
this works if I comment the block :
advanced_backup_setting {
resource_type = “EC2”
}
but the code presented here fails with the error at the bottom.
https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/backup_plan
provider "aws" {
profile = "default"
region = "us-east-1"
}
provider "aws" {
alias = "useast1"
profile = "default"
region = "us-east-1"
}
resource "aws_backup_vault" "vault_local_useast1" {
provider = aws.useast1
name = "ec2-us-east-1-vault"
# kms_key_arn = aws_kms_key.example.arn
}
resource "aws_backup_vault" "vault_copy_eucentral1" {
provider = aws.eucentral1
name = "ec2-dr-eu-central-1"
# kms_key_arn = aws_kms_key.example.arn
}
resource "aws_backup_plan" "plan" {
name = "example"
# name = format("backup_plan_with_dr_%s", var.name)
advanced_backup_setting {
resource_type = "EC2"
}
rule {
rule_name = "example rule"
target_vault_name = aws_backup_vault.vault_local_useast1.name
schedule = "cron(0 8 * * ? *)"
lifecycle {
delete_after = "7"
}
copy_action {
lifecycle {
delete_after = "7"
}
destination_vault_arn = aws_backup_vault.vault_copy_eucentral1.arn
}
}
# tags = {
# "environment" = "poc"
# }
}
resource "aws_backup_selection" "backup_selection" {
iam_role_arn = aws_iam_role.iam_role.arn
name = "backup-selection-name-example"
plan_id = aws_backup_plan.plan.id
selection_tag {
type = "STRINGEQUALS"
key = "Backup Policy"
value = "1-7-7"
}
}
Error when I run the terraform apply
(NB : plan
works fine) :
Error: error creating Backup Plan: MissingParameterValueException: Resource Type or Backup Options is null in Advanced Backup Settings
{
RespMetadata: {
StatusCode: 400,
RequestID: "b9995a41-aad4-40f6-aaae-f727365462c1"
},
Code_: "ERROR_4214",
Message_: "Resource Type or Backup Options is null in Advanced Backup Settings"
}
Version :
$ terraform --version
Terraform v0.13.5
+ provider registry.terraform.io/hashicorp/aws v3.12.0
I’m leaving it commented for now, but I wasn’t sure where/how to report this unexpected behavior.