User guide
If the program fails, ensure that you are using credentials that provide you with access to the bucket.
5. (Optional) Transfer the sample program to a running Windows instance on which you haven't set up
credentials. Run the program and verify that it fails because it can't locate credentials.
Create an IAM Role
Create an IAM role that has the appropriate permissions to access Amazon S3.
To create the IAM role
1. Open the IAM console.
2. In the navigation pane, click Roles, and then click Create New Role.
3. Enter a name for the role, and then click Next Step. Remember this name, as you'll need it when
you launch your EC2 instance.
4. Under AWS Service Roles, select Amazon EC2. Under Select Policy Template, select Amazon
S3 Read Only Access. Review the policy and then click Next Step.
5. Review the role information and then click Create Role.
Launch an EC2 Instance and Specify the IAM Role
You can launch an EC2 instance with an IAM role using the Amazon EC2 console or the SDK for .NET.
• To launch an EC2 instance using the console, follow the directions in Launching a Windows Instance
in the Amazon EC2 User Guide for Microsoft Windows Instances.When you reach the Review Instance
Launch page, click Edit instance details. In IAM role, specify the IAM role that you created previously.
Complete the procedure as directed. Notice that you'll need to create or use an existing security group
and key pair in order to connect to the instance.
• To launch an EC2 instance with an IAM role using the SDK for .NET, see Launch an EC2
Instance (p. 74).
Note that an IAM user can't launch an instance with an IAM role without the permissions granted by the
following policy.
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": [
"iam:PassRole",
"iam:ListInstanceProfiles",
"ec2:*"
],
"Resource": "*"
}]
}
Run the Sample Program on the EC2 Instance
To transfer the sample program to your EC2 instance, connect to the instance using the AWS Management
Console as described in the following procedure.
Version v2.0.0
110
AWS SDK for .NET Developer Guide
Tutorial: Using an IAM Role