Attaching an IAM Role to a EC2 Instance

To configure access to the S3 bucket from your EC2 using IAM roles, attach an IAM role to your instance, to be used for authentication, as described in the link below. This step allows your EC2 instance to write and retrieve data from the S3 bucket:


Example for using IAM Role:

    "Version": "2008-10-17",
    "Id": "Policy1388257451238",
    "Statement": [
            "Sid": "1232343455",
            "Effect": "Allow",
            "Principal": {
                "AWS": "arn:aws:iam::432746435694:role/custom-role"
            "Action": [
            "Resource": "arn:aws:s3:::hybridtest/*"

the IAM role: "arn:aws:iam::432746435694:role/custom-role"
the S3 Bucket arn: "arn:aws:s3:::hybridtest/*"