Skip to content

Commit

Permalink
Merge pull request #16605 from DrFaust92/r/backup_plan_remove_validation
Browse files Browse the repository at this point in the history
r/backup_plan - remove validation
  • Loading branch information
anGie44 authored Dec 9, 2020
2 parents 3893c44 + 6ca440c commit af5d6b3
Showing 1 changed file with 7 additions and 25 deletions.
32 changes: 7 additions & 25 deletions aws/resource_aws_backup_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,8 @@ func resourceAwsBackupPlan() *schema.Resource {
Optional: true,
},
"delete_after": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(90),
Type: schema.TypeInt,
Optional: true,
},
},
},
Expand All @@ -101,9 +100,8 @@ func resourceAwsBackupPlan() *schema.Resource {
Optional: true,
},
"delete_after": {
Type: schema.TypeInt,
Optional: true,
ValidateFunc: validation.IntAtLeast(90),
Type: schema.TypeInt,
Optional: true,
},
},
},
Expand Down Expand Up @@ -314,19 +312,8 @@ func expandBackupPlanRules(vRules *schema.Set) []*backup.RuleInput {
rule.RecoveryPointTags = keyvaluetags.New(vRecoveryPointTags).IgnoreAws().BackupTags()
}

if vLifecycle, ok := mRule["lifecycle"].([]interface{}); ok && len(vLifecycle) > 0 && vLifecycle[0] != nil {
lifecycle := &backup.Lifecycle{}

mLifecycle := vLifecycle[0].(map[string]interface{})

if vDeleteAfter, ok := mLifecycle["delete_after"].(int); ok && vDeleteAfter > 0 {
lifecycle.DeleteAfterDays = aws.Int64(int64(vDeleteAfter))
}
if vColdStorageAfter, ok := mLifecycle["cold_storage_after"].(int); ok && vColdStorageAfter > 0 {
lifecycle.MoveToColdStorageAfterDays = aws.Int64(int64(vColdStorageAfter))
}

rule.Lifecycle = lifecycle
if vLifecycle, ok := mRule["lifecycle"].([]interface{}); ok && len(vLifecycle) > 0 {
rule.Lifecycle = expandBackupPlanLifecycle(vLifecycle)
}

if vCopyActions := expandBackupPlanCopyActions(mRule["copy_action"].(*schema.Set).List()); len(vCopyActions) > 0 {
Expand Down Expand Up @@ -409,12 +396,7 @@ func flattenBackupPlanRules(rules []*backup.Rule) *schema.Set {
}

if lifecycle := rule.Lifecycle; lifecycle != nil {
mRule["lifecycle"] = []interface{}{
map[string]interface{}{
"delete_after": int(aws.Int64Value(lifecycle.DeleteAfterDays)),
"cold_storage_after": int(aws.Int64Value(lifecycle.MoveToColdStorageAfterDays)),
},
}
mRule["lifecycle"] = flattenBackupPlanCopyActionLifecycle(lifecycle)
}

mRule["copy_action"] = flattenBackupPlanCopyActions(rule.CopyActions)
Expand Down

0 comments on commit af5d6b3

Please sign in to comment.