AWS——Part 04 (AWS Amazon S3 (Scalable Storage in the Cloud)-02——EC2 accesses S3 bucket)

1 Introduction

2. Create EC2 instance + S3 bucket

3. Create an IAM role

4. Modify EC2’s IAM role

  • as follows:
    Insert image description here
    Insert image description here
    Insert image description here
    Insert image description here

5. Connect to EC2 to view the effect

5.1 Connect to EC2

  • as follows:
    Insert image description here

5.2 Simple test

5.2.1 Check the storage status in the bucket

  • as follows:
    Insert image description here
    Insert image description here
    Insert image description here

5.2.2 Copy local files to bucket

  • as follows:
    Insert image description here
    Insert image description here

5.2.3 Copy the files in the bucket to the local EC2 service

  • as follows:
    aws s3 cp s3://susu-bucket/aa.txt ./
    
    Insert image description here

5.3 Commonly used simple commands

  • View bucket list
    aws s3 ls
    
  • Check the storage status in the bucket
    aws s3 ls s3://susu-bucket
    
  • Move/copy local files to the bucket
    aws s3 mv aa.txt s3://susu-bucket
    
    aws s3 cp bb.txt s3://susu-bucket
    
  • Copy the files in the bucket to local
    aws s3 cp s3://susu-bucket/aa.txt ./
    

6. Problems encountered

6.1 Access denied

6.6.1 Problem description

  • as follows:
    An error occurred (AccessDenied) when calling the ListBuckets operation: Access Denied
    
    Insert image description here

6.6.2 Solving problems

6.6.2.1 Try to solve problem 1

  • Restarting the EC2 instance, the problem is not solved

6.6.2.2 Try to solve problem 2

  • Start a new instance as follows:
    Insert image description here
    Insert image description here
    Insert image description here
  • Still not working, the problem is not solved!

6.6.2.3 Try to solve problem 3

  • Empty the bucket and recreate the bucket. The problem is not solved! ! !

6.6.2.4 Try to solve problem 4 - modify the trust relationship

  • Before modification, it was as follows:
    Insert image description here
  • After modification, it is as follows:
    Insert image description here
  • Still unresolved! ! !

6.6.2.5 Try to solve problem 5 - modify IAM permission policy (problem solution)

  • When creating IAM, the permission policy was selected incorrectly, as follows:
    Insert image description here
  • Try the command again aws s3 ls, as follows:
    Insert image description here

7.

Guess you like

Origin blog.csdn.net/suixinfeixiangfei/article/details/132181430