And, click Roles.
Click Create role button.
Select AWS service and check EC2. Then, click Next: Permissions.
Next, check AmazonS3FullAccess and click Next: Tags.
You can input tag if necessary. And click Next: Review button.
Input Role name as you like, and click Create role.
You can see that new role is created successfully !!
Firstly, access EC2 console by AWS management console.
Then, click EC2 instance.
Click Action > Security > Modify IAM role.
Then, select IAM role that you’ve created in the previous procedure.
And, click Save button.
After saving, please check the Security setting and new role is assigned to EC2 instance.
Let’s upload test file to S3 bucket from EC2 instance.
Firstly, awscli needs to be installed to your EC2 instance.
Execute curl command and download awscliv2.zip.
Then, unzip downloaded file.
If you cannot execute unzip command, please install it by yum -y install unzip command.
Then, install awscli by executing install command.
Finally, execute aws s3 cp command.
In this case, I uploaded test.txt file to S3 bucket.
OK. Let’s access S3 bucket console and check if test.txt exists.
If you can see uploaded file, it is succeeded !!