I am able to retrieve the credentials to logon to AWS using the JSON file. I am able to Set the credentials as well. I am facing issues when i am trying to code for logon to AWS console using powershell
I tried this piece of code to retrieve credentials for AWS login
Import-Module -Name AWS.Tools.SecretsManager
#Get the json file
$jsonContent = Get-Content -Raw -Path "Path to json file"
#$jsonContent
#to convert to powershell object
$secrets = $jsonContent | ConvertFrom-Json
#retrieve the id and key
$secretId = $secrets.'ACCESS-KEY-ID'
$secretKey = $secrets.'ACCESS-KEY-SECRET'
$role = $secrets.'ROLE'
$region = $secrets.'REGION'
I have all the credentials and i can set the credentials as well
Set-AWSCredential -AccessKey $secretId -SecretKey $secretKey
$roleSessionName = "Role"
$roleArn = $role
$roleArn
#Set the assumed role credentials
Set-AWSCredential -AccessKey $secretId -SecretKey $secretKey -StoreAs sourceAccountProfile
Set-AWSCredential -SourceProfile $roleSessionName -RoleArn $roleArn -StoreAs myRoleProfile
I am getting error when i am setting the role ( $roleSessionName = "Role") as error in reading the source profile and after resolving this how can i login to AWS by setting the role to retrieve the secret ?