EC2 - Using Roles for a Service

Using Roles for a Service


So as we mentioned before, Role is important part of IAM since it supports security of service indirectly. Let's imagine the scenario we want EC2 instance to access our S3 bucket (object storage) and receive some files from it. Since we have to do it programmatically, need to use cli for that. But cli is not enough, we need some kind of credentials to authenticate ourselves into the service. We can use access credentials and Roles for that.  

  1. Let's list S3 buckets using the command below, but it will display and error. It couldn't find the credentials that will help it to authenticate. 







  2. Search IAM and navigate to the users page.





  3. Click to the "create access key" button.




  4. Choose "Command line interface" option.






  5. Copy the credentials and paste into the cli.






  6. Use aws-cli utility tool to add credentials.




  7. And then you will be able to list all the available buckets.





  8. The issue with this approach is that it is not recommended and secure way to store access credentials like that. Because if attacker has access to our instance this mean it will able to use this credential for further exploitation.





  9. Let me show you better approach. Let's create a role first.




  10. Since we will use this role for EC2 service. We must choose AWS service option and EC2 service.





  11. Don't forget to add permission to this role too, otherwise you will face with the error message.




  12. Let's attach this role to our EC2 instance.




  13. Select the role we want to attach.




  14. That is it, we now successfully attached our role to this instance.

Comments

Popular posts from this blog

Identity Access Management - How to create user in IAM ?!

AWS pricing fundamentals

IAM - Roles