0
votes

I am looking forward to call \File.txt using below AWS CLI , if you have exp please share it.

aws ec2 describe-instances --filters Name=network-interface.group-name,Values='\file.txt' --query 'Reservations[].Instances[].[Placement.AvailabilityZone, State.Name, InstanceId,Tags[?Key==Name].Value|[0]]'

File.txt includes Security Group Names.

1

1 Answers

1
votes

Here is a way you can do it, I'm assuming Security Group Name is on a separate line.

Command:

$(cat file.txt|sed 'N;s/\n/,/')

Input: file.txt:

cat file.txt
security-group-name-1
security-group-name-2
security-group-name-3

Output:

security-group-name-1,security-group-name-2

Full command:

aws ec2 describe-instances --filters Name=network-interface.group-name,Values=$(cat file.txt|sed 'N;s/\n/,/') --query 'Reservations[].Instances[].[Placement.AvailabilityZone, State.Name, InstanceId,Tags[?Key==Name].Value|[0]]'