AWS——Part 04 (AWS Amazon S3 (Scalable Storage in the Cloud)-02——EC2 accesses S3 bucket)
1 Introduction
- The first few introductory articles about AWS are as follows:
2. Create EC2 instance + S3 bucket
- What I use here are all those created previously. For how to create them, please refer to the following two articles, as follows:
3. Create an IAM role
-
Regarding the IAM role, refer to the official website documentation as follows:
https://docs.aws.amazon.com/zh_cn/IAM/latest/UserGuide/introduction.html?icmpid=docs_iam_console .
-
Create an IAM role as follows:
4. Modify EC2’s IAM role
- as follows:
5. Connect to EC2 to view the effect
5.1 Connect to EC2
- as follows:
5.2 Simple test
5.2.1 Check the storage status in the bucket
- as follows:
5.2.2 Copy local files to bucket
- as follows:
5.2.3 Copy the files in the bucket to the local EC2 service
- as follows:
aws s3 cp s3://susu-bucket/aa.txt ./
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
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:
- 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:
- After modification, it is as follows:
- 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:
- Try the command again
aws s3 ls
, as follows: