IAM API
Using CMC IAM Client
Instructions
- Login as engineer1
Ensure Engineering is selected
User ID: engineer1
Password: @Engineer1
Instructions
- Select IAM
- Select IAM User
- Click + ADD NEW USER
Instructions
- Type reado in User Name
- Click SAVE
Instructions
- Click IAM Policy tab
- Click + Add new Policy
- Type read in Policy Name
- Type Grant all read permissions in Description
- Click in the Policy Document Area
Instructions
- A Visual Editor should appear
- Expand the List and Read sections
- Click Select all in each section
- Click Save
Instructions
The policy document has been populated as JSON from the Visual Editor On the manage IAM policy page, click ADD to add the policy
Instructions
- Click Back on IAM User Tab
- Click reado
Instructions
- Click + CREATE NEW KEY
Instructions
- A New Access Key ID will be created.
- Ensure you take a copy of the Secret Key.
Warning
Unlike HyperStore User Keys, Secret Access Keys for IAM users are NOT stored. You cannot go back later to get the Secret Key.
Instructions
- Click IAM POLICIES Tab
- Select readonly policy
- Ensure the Policy Document Area is populated with the policy details
- Click Add
Instructions
- Login to the Host Server
- Create new s3cmd profile using IAM user reado access key / secret key
s3cmd --configure -c reado
- Use the reado Access Key and Secret Key you copied when creating the reado user.
- Enter region1 for the Default Region
- Use the S3 Endpoint from the Student Assignment page
- Use %(buckets)s.your.S3Endpoint
- Select defaults for Encryption Password and Path to GPG
- Choose no for HTTPS protocol
- Choose default for HTTP Proxy
- Test Access (Y)
- Save config (Y)
Testing the IAM credentials
Instructions
- Test new profile and IAM policy for reado and see if reado can list buckets / items in a bucket
s3cmd -c reado ls s3://
s3cmd -c reado ls s3://engineerbucket
Instructions
- Test read access to objects by downloading the 5mb object as new5mb
s3cmd -c reado get s3://engineerbucket/5mb new5mb
Instructions
Ensure you cannot write any data to the bucket
s3cmd -c reado put new5mb s3://engineerbucket
Using CLI for IAM API
Instructions
- First set the IAM endpoint in the .bash_profile on the Host Server. Ensure that you replace
studentX, where X is your student number.
echo "export iam_endpoint=iam.studentX.cloudian.tech" >> ~/.bash_profile && source ~/.bash_profile
Instructions
- We will use the IAM API to create a second user and policy but need to use the AWS CLI for this, so lets setup a profile for the root aws account engineer1.
aws configure --profile engineer1
Note
Use the Access Key and Secret key for the engineer1 account.
Use region1 for the Default Region name
Type json as output format
Instructions
- Create a new IAM user awsuser using the aws command below:
aws --profile engineer1 iam create-user --user-name awsuser --endpoint-url http://$iam_endpoint:16080
- Create S3 Access Key and Secret Key for new awsuser user
aws --profile engineer1 iam create-access-key --user-name awsuser --endpoint-url http://$iam_endpoint:16080
Warning
Ensure you take a copy of the SecretAccessKey and AccessKeyID !!
Instructions
- Create a new JSON file to give full permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets",
"s3:HeadObject",
"s3:ListBucket",
"s3:GetBucketAcl",
"s3:GetBucketCORS",
"s3:GetBucketLocation",
"s3:GetBucketLogging",
"s3:GetBucketNotification",
"s3:GetBucketObjectLockConfiguration",
"s3:GetBucketPolicy",
"s3:GetBucketRequestPayment",
"s3:GetBucketTagging",
"s3:GetBucketVersioning",
"s3:GetBucketWebsite",
"s3:GetEncryptionConfiguration",
"s3:GetLifecycleConfiguration",
"s3:GetObject",
"s3:GetObjectAcl",
"s3:GetObjectLegalHold",
"s3:GetObjectRetention",
"s3:GetObjectTagging",
"s3:GetObjectTorrent",
"s3:GetObjectVersion",
"s3:GetObjectVersionAcl",
"s3:GetObjectVersionTagging",
"s3:GetReplicationConfiguration",
"s3:ListBucketMultipartUploads",
"s3:ListBucketVersions",
"s3:ListMultipartUploadParts",
"s3:AbortMultipartUpload",
"s3:CreateBucket",
"s3:DeleteBucket",
"s3:DeleteBucketWebsite",
"s3:DeleteObject",
"s3:DeleteObjectTagging",
"s3:DeleteObjectVersion",
"s3:DeleteObjectVersionTagging",
"s3:PutBucketCORS",
"s3:PutBucketLogging",
"s3:PutBucketNotification",
"s3:PutBucketObjectLockConfiguration",
"s3:PutBucketRequestPayment",
"s3:PutBucketTagging",
"s3:PutBucketVersioning",
"s3:PutBucketWebsite",
"s3:PutEncryptionConfiguration",
"s3:PutLifecycleConfiguration",
"s3:PutObject",
"s3:PutObjectLegalHold",
"s3:PutObjectRetention",
"s3:PutObjectTagging",
"s3:PutObjectVersionTagging",
"s3:PutReplicationConfiguration",
"s3:RestoreObject"
],
"Resource": "*"
}
]
}
Instructions
- Lets now create a new IAM Policy allowing read & write access to buckets and objects. The json policy is provided for you as file full_policy.json
aws --profile engineer1 iam create-policy --policy-name full --description "Full Access" --policy-document file://full_policy.json --endpoint-url http://$iam_endpoint:16080
Important
Copy the Arn: in the output / you will need this to attach the policy to the awsuser user.
Instrutions
- Attach the Full Access policy to the awsuser account. Paste the ARN you copied above in the --policy-arn parameter
aws --profile engineer1 iam attach-user-policy --policy-arn < ARN copied from previous step > --user-name awsuser --endpoint-url http://$iam_endpoint:16080
Instructions
- Login to the Host Server via SSH
- Create new s3cmd profile using IAM user awsuser access key / secret key
s3cmd --configure -c awsuser
- Use the awsuser Access Key and Secret Key you copied when creating the awsuser user.
- Use the region1 endpoint on your Student worksheet when asked for S3 Endpoint.
- Use %(buckets)s.your.S3Endpoint
- Select defaults for Encryption Password and Path to GPG
- Choose no for HTTPS protocol
- Choose default for HTTP Proxy
- Test Access (Y)
- Save config (Y)
Instructions
- Test new profile and IAM policy for awsuser
s3cmd ls s3:// -c awsuser
s3cmd ls s3://engineerbucket -c awsuser
Instructions
- Test read access to objects by downloading the 5mb object as new5mb
s3cmd get s3://engineerbucket/5mb aws5mb -c awsuser
Instructions
- Ensure you CAN write data to the bucket
s3cmd put new5mb s3://engineerbucket/aws5mb -c awsuser