How do I set up the AWS CLI so that I can work with a DynamoDB table on Amazon EC2?
Last updated: 2020-06-18
How do I configure the AWS Command Line Interface (AWS CLI) for working with Amazon DynamoDB tables on Amazon Elastic Compute Cloud (Amazon EC2)?
Create an AWS Identity and Access Management (IAM) role
- For Select type of trusted entity, choose AWS service, and then choose EC2.
- For Attach permissions policies, choose AmazonDynamoDBFullAccess.
Attach the IAM role to an EC2 instance
- Launch an EC2 instance using an Amazon Linux Amazon Machine Image (AMI). Linux AMIs come with the AWS CLI installed.
- On the Configure Instance Details page, in the IAM role drop-down list, select the IAM role that you created earlier. Be sure that the subnet that you select is accessible from the internet.
- On the Configure Security Group page, be sure that you select a security group that allows SSH access from your IP address.
Connect to the instance using SSH
- Connect to the Linux instance using SSH.
- After you're connected, run the yum update command to be sure that the software packages on the instance are up to date.
Configure the AWS CLI
- Run the aws configure command.
- When prompted for an AWS Access Key ID and AWS Secret Access Key, press Enter. You don't need to provide keys because you're using an instance IAM role to connect with an AWS service.
- When prompted for Default region name, enter the Region where your DynamoDB tables are located. For example, ap-northeast-3. For a list of Region names, see Service endpoints.
- When prompted for Default output format, press Enter.
- Run the list-tables command to confirm that you can run DynamoDB commands on the AWS CLI.
Note: If you receive errors when running AWS CLI commands, make sure that you’re using the most recent version of the AWS CLI.