access dynamodb from ec2 using iam role code example
Example: aws cli ec2 how to change IAM role
$aws ec2 replace-iam-instance-profile-association --association-id YourCurrentAssociation-id --iam-instance-profile Name=YourReplacementRole-Instance-Profile