0

I am new to using AWS PowerShell and I am having issues with executing commands in PowerShell. Specifically, I am having issues running the below command. When I log into an AWS EC2 and execute the same command in CLI using the same account credentials it runs without failure. The error I receive states "Insufficient privileges to perform this action." I even went as far as using the admin account and I still receive the same error. I do not believe this matters, but I am running PowerShell on my local PC. Any guidance would be appreciated.

Command that generates the error

aws backup list-recovery-points-by-backup-vault --backup-vault-name Default --max-results 10000

PowerShell script I created for this purpose

Set-AWSCredential `
-AccessKey XXXXXXXXX `
-SecretKey XXXXXXXXX/XXXXXXX`
-StoreAs "MyProfile"

aws backup list-recovery-points-by-backup-vault --backup-vault-name Default --max-results 10000
Chris Lombardi
  • 861
  • 2
  • 14
  • 31

2 Answers2

0

Your Set-AWSCredential command is creating a profile named "MyProfile", But your aws command is not specifying which profile to use (aws backup --profile MyProfile ...) so its using one called "default"/ignoring the credentials hence you get an accessed denied.

It shouldnt work on Ec2... unless it has a role attached that already grants these same permissions or better (which gets assigned to the "default" profile as the instance starts)

MisterSmith
  • 2,884
  • 1
  • 10
  • 13
0

The error was misleading and I was able to get this working to obtain my ultimate goal to delete recovery points by using the below script. The command I was running was not the correct command to be running for this operation.

Set-AWSCredential `
                 -AccessKey XXXXXX `
                 -SecretKey XXXXXXX `
                 -StoreAs "<ProfileName>"

$backups = Get-BAKRecoveryPointsByBackupVaultList -BackupVaultName Default
foreach ($backup in $backups)
{
Remove-BAKRecoveryPoint -BackupVaultName Default -RecoveryPointArn $backup.RecoveryPointArn -Confirm -Force
}
Chris Lombardi
  • 861
  • 2
  • 14
  • 31