2 Answers
- Newest
- Most votes
- Most comments
1
Hello.
I assume you are probably using PowerShell since you are using "ConvertFrom-Json".
So please try as follows.
$sgs = @("sg1", "sg2", "sg3")
aws ec2 describe-network-interfaces --filters Name=group-id,Values=$($sgs -join ',') --output json | ConvertFrom-Json
0
Try this
sgs=("sg1" "sg2" "sg3")
aws ec2 describe-network-interfaces --filters "Name=group-id,Values=${sgs[*]}" --output json | jq .
This is invalid powershell, see how you were trying to interpolate the array in a string.
Relevant content
- asked 7 months ago
- asked a year ago
- asked 9 months ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a month ago
Added "-join" to join "$sgs" passed in an array. By doing this, a string combined in the form "sg1,sg2,sg3" will be passed to "Values". https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-arrays?view=powershell-7.4
"Unknown options: -join, ',')" When I run with this command it seems there is a syntax error.
Managed to get this working thanks! --filters "Name=group-id,Values=$($sgs -join ',')"