I have a Bamboo task that invokes a batch file on a remote EC2. That batch file executes a test, then calls a PowerShell script to parse the test.
Finally I grab the instance Id of our bamboo server and send the results of the test back via ssm.
My problem exists in the PowerShell script when I attempt to send my results. I use "describe-instances" to retrieve the Bamboo Server ID:
Set-AWSCredential -StoreAs default -AccessKey <key> -SecretKey <key>
$instanceid = aws ec2 describe-instances --profile default --region "us-east-1" --filters 'Name=tag:Name,Values=Bamboo Server' --query 'Reservations[*].Instances[*].InstanceId' --output text
Send-SSMCommand -InstanceId $instanceId -DocumentName AWS-RunPowerShellScript -Parameter -Comment
*NOTE: my Bamboo Server resides on a different EC2 than my tests.
So, if I invoke the batch file from my Bamboo Build Plan. The "describe-instances" command does not run correctly.
But, if I run the batch file locally on that remote EC2, the process runs smoothly.
I've tried:
- multiple variations of the "describe-instances" including the Get-EC2Instance and others.
- I believe my permissions are being set correctly. But maybe the "describe-instances" does not catch it. I have tried many variations of setting the creds including aws configure, manually loading from environment variables and from a file.
- I put Start-Sleeps in to ensure I am not having async issues.
It is like the command refuses to run when I invoke it from the Bamboo Task.
I noticed that the tests run in the foreground locally, and in the background when invoked from Bamboo.
Could my problem be a security issue? Like running from Bamboo doesn't allow the commands to run the same? I cannot find any documentation explaining that from AWS or Bamboo.
Any ideas?