title: Access s3 bucket from different aws account
body: <p>I am trying to restore a database as a part of our testing. The backups exists on the prod s3 account. My database is running as ec2 instance in dev account. </p>
  
  <p>Can anyone tell me how can i access the prod s3 from dev account.</p>
  
  <p>Steps:
   - i created a role on prod account and with trusted relationship with the dev account
   - i added a policy to the role.</p>
  
  <p>{</p>
  
  <pre><code>    "Version": "2012-10-17",
      "Statement": [
          {
              "Effect": "Allow",
              "Action": "s3:ListAllMyBuckets",
              "Resource": "*"
          },
          {
              "Effect": "Allow",
              "Action": [
                  "s3:ListBucket",
                  "s3:GetBucketLocation"
              ],
              "Resource": "arn:aws:s3:::prod"
          },
          {
              "Effect": "Allow",
              "Action": [
                  "s3:GetObject",
                  "s3:PutObject",
                  "s3:DeleteObject"
              ],
              "Resource": "arn:aws:s3:::prod/*"
          }
      ]
  }
  </code></pre>
  
  <p>on dev account i created a role and with assume policy</p>
  
  <pre><code>&gt; {   "Version": "2012-10-17",   "Statement": [
  &gt;     {
  &gt;       "Effect": "Allow",
  &gt;       "Action": "sts:AssumeRole",
  &gt;       "Resource": "arn:aws:iam::xxxxxxxxx:role/prod-role"
  &gt;     }   ] }
  </code></pre>
  
  <p>But i am unable to access the s3 bucket, can someone point me where i am wrong.
  Also i added the above policy to an existing role. so does that mean its not working because of my instance profile ( inconsistent error)</p>
  
  <p>Please help and correct me if i am wrong anywhere. I am looking for a solution in terms of a role and not as a user.
  Thanks in advance!</p>