Brian
Brian

Reputation: 13583

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.

Upvotes: 12

Views: 7832

Answers (1)

helloV
helloV

Reputation: 52393

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.

Upvotes: 17

Related Questions