I want to construct a command based upon the number of groups in the yaml file shown in the Example..
Example:
I have groups command as below which extracts the groups from the iamIdentityMappings yaml file,
groups=$(yq read -j generated/identity-mapping.yaml "iamIdentityMappings.[0].groups")
iamIdentityMappings yaml file:
iamIdentityMappings:
- groups:
- Appdeployer
- Moregroups
rolearn: arn:aws:iam::12345:role/eks-project-us-east-1-ppdeployer
username: user1
Since there are two groups in groups array,I need to add two groups in the below command,
eksctl create iamidentitymapping --cluster "$name" --region "$region" --arn "$rolearn" --group "Appdeployer" -group "Moregroups" --username "$username"
If there are 3 groups,then --group should be repeated 3 times in the command.
Please let me know how to do this in bash