aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
239 stars 79 forks source link

Issue with New-BAKBackupPlan and AdvancedBackupSetting #236

Closed candersonzna closed 2 years ago

candersonzna commented 2 years ago

Description

When creating a new backup plan with the -BackupPlan_AdvancedBackupSetting with the object Amazon.Backup.Model.AdvancedBackupSetting being used we getting the error:

"New-BAKBackupPlan: Invalid Resource Type : EC2"

Reproduction Steps

Code used

$VaultName= "Default"
$BackupLifeCycle = New-Object -TypeName Amazon.Backup.Model.Lifecycle
$BackupLifeCycle.DeleteAfterDays = 7
$BackupRule = New-Object -TypeName Amazon.Backup.Model.BackupRuleInput
$BackupRule.Lifecycle = $BackupLifeCycle
$BackupRule.StartWindowMinutes = 60
$BackupRule.CompletionWindowMinutes = 480
$BackupRule.TargetBackupVaultName = $VaultName
$BackupRule.RecoveryPointTags = $RecoveryTags
$BackupRule.RuleName = 'Daily_Backup'
$BackupRule.ScheduleExpression = 'cron(0 3 * * ? *)' 

$AdvancedBackup = New-Object -TypeName Amazon.Backup.Model.AdvancedBackupSetting
$AdvancedBackup.BackupOptions.Add("WindowsVSS","Enabled")
$AdvancedBackup.ResourceType = "EC2"
$backupplan = New-BAKBackupPlan -BackupPlan_BackupPlanName 'Daily_Backup' -BackupPlan_Rule $BackupRule -BackupPlanTag $ProjectTag -BackupPlan_AdvancedBackupSetting $AdvancedBackup

Output of $advancedbackup:
PS C:\> $AdvancedBackup

BackupOptions           ResourceType
-------------           ------------
{[WindowsVSS, Enabled]} EC2

> $AdvancedBackup | gm

   TypeName: Amazon.Backup.Model.AdvancedBackupSetting

Name          MemberType Definition
----          ---------- ----------
Equals        Method     bool Equals(System.Object obj)
GetHashCode   Method     int GetHashCode()
GetType       Method     type GetType()
ToString      Method     string ToString()
BackupOptions Property   System.Collections.Generic.Dictionary[string,string] BackupOptions {get;set;}
ResourceType  Property   string ResourceType {get;set;}

Environment


This is a :bug: bug-report

ashishdhingra commented 2 years ago

Hi @candersonzna,

Good afternoon.

Thanks for reporting the issue. Looks like the value for AdvancedBackupSetting.BackupOptions: WindowsVSS is case sensitive. In your code above you have used Enabled (notice the first letter in uppercase). I was able to successfully create a new backup plan with value as enabled (all in lowercase):

$AdvancedBackup.BackupOptions.Add("WindowsVSS","enabled");

Kindly refer AdvancedBackupSetting for more details.

Closing this issue as guidance.

Thanks, Ashish

github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.