Advertisement
Javi

AWS: cli for attaching policies to roles

Aug 23rd, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. * Create the IAM permission policy
  2.  
  3. ```
  4. aws iam create-policy --policy-name kopsK8sEC2MasterPerms --policy-doc file://kopsK8sEC2MasterPerms.json
  5. ```
  6.  
  7. * Get policy's ARN
  8.  
  9. ```
  10. POLICY_ARN=$(aws iam list-policies | jq ".Policies[] | select(.PolicyName | contains(\"kopsK8sEC2MasterPerms\")) | .Arn" -r)
  11. ```
  12.  
  13. * Check for the name of the role attached to the master nodes
  14.  
  15. ```
  16. aws iam list-roles | jq ".Roles[] | select(.RoleName | contains(\"masters.$CLUSTER_NAME.$DOMAIN\"))"
  17. ```
  18.  
  19. * Link the new policy to the role
  20.  
  21. ```
  22. aws iam attach-role-policy --role-name masters.$CLUSTER_NAME.$DOMAIN --policy-arn $POLICY_ARN
  23. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement