Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to execute AWS CLI commands on an EC2 instance without placing AWS credentials on the EC2?

I have an API server running on a docker container, and the docker container runs on an AWS ec2 instance.

Is it possible to make the server execute AWS CLI commands without putting my aws credentials on the docker container?

Because I think the aws credentials should only be placed on my local machine.

I don't think it is safe to place it on a remote machine which can be accessed by other people.

like image 774
Brian Avatar asked Aug 23 '17 16:08

Brian


People also ask

How does AWS CLI get credentials?

When you use a shared profile that specifies an AWS Identity and Access Management (IAM) role, the AWS CLI calls the AWS STS AssumeRole operation to retrieve temporary credentials. These credentials are then stored (in ~/.aws/cli/cache ).

Do EC2 instances have AWS CLI?

You can access the features of Amazon Elastic Compute Cloud (Amazon EC2) using the AWS Command Line Interface (AWS CLI).

What is required to use AWS CLI?

To access AWS services with the AWS CLI, you need an AWS account, IAM credentials, and an IAM access key pair. When running AWS CLI commands, the AWS CLI needs to have access to those AWS credentials. To increase the security of your AWS account, we recommend that you do not use your root account credentials.


1 Answers

Yes. Attach IAM role to your EC2 instance. No need to place the AWS credentials in the EC2 instance. Your application/CLI will get the credentials automatically.

IAM Roles for Amazon EC2

  • Create an IAM role with necessary privileges.
  • Specify the role when you launch your instance, or attach the role to a running or stopped instance.
like image 192
helloV Avatar answered Sep 17 '22 15:09

helloV