403 error when making get request on bucket using IBM Cloud Object Storage CLI

783 Views Asked by At

I created a cloud object storage service and created a standard bucket. My goal is to upload files using a service id in CLI.

As step -1 I am testing I am following to run few commands on bucket I created from this link: https://cloud.ibm.com/docs/cloud-object-storage?topic=cloud-object-storage-cli-ic-cos-cli

Here are some outputs:

ibmcloud cos config list
Key                     Value   
Last Updated            Tuesday, December 17 2019 at 23:31:19   
Default Region          us-east   
Download Location       /Users/myname/Downloads   
CRN                     crn:v1:bluemix:public:cloud-object-storage:global:a/784492b2864521d53b6c4590e0f2bf34:f743cac0-6166-404f-abea-2e1d74c6a7ac:: f743cac0-6166-404f-abea-2e1d74c6a7ac   
AccessKeyID                
SecretAccessKey            
Authentication Method   IAM   
URL Style               VHost   
ibmcloud cos list-buckets --ibm-service-instance-id crn:v1:bluemix:public:cloud-object-storage:global:a/784492b2864521d53b6c4590e0f2bf34:f743cac0-6166-404f-abea-2e1d74c6a7ac::
OK
2 buckets found in your account:

Name                   Date Created   
hog-bucket2            Dec 18, 2019 at 05:43:28   
hog-test-bucket-name   Dec 17, 2019 at 16:59:41  
ibmcloud cos head-bucket --bucket hog-bucket2
FAILED
Forbidden: Forbidden
    status code: 403, request id: 2fba921d-a11c-4f45-b172-3937daeab633, host id: 

I tried it on other bucket and I see same 403.

I went into access policies for the bucket and created a policy to set myself as manager. But it didn't help.

Creating a bucket from cli worked fine:

ibmcloud cos create-bucket --bucket hog-cli-bucket-name --ibm-service-instance-id crn:v1:bluemix:public:cloud-object-storage:global:a/784492b2864521d53b6c4590e0f2bf34:f743cac0-6166-404f-abea-2e1d74c6a7ac::
OK
Details about bucket hog-cli-bucket-name:
Region: us-east
Class: Standard

Then I tried to do get list of buckets:

ibmcloud cos list-buckets --ibm-service-instance-id crn:v1:bluemix:public:cloud-object-storage:global:a/784492b2864521d53b6c4590e0f2bf34:f743cac0-6166-404f-abea-2e1d74c6a7ac::
OK
3 buckets found in your account:

Name                   Date Created   
hog-bucket2            Dec 18, 2019 at 05:43:28   
hog-cli-bucket-name    Dec 18, 2019 at 06:14:03   
hog-test-bucket-name   Dec 17, 2019 at 16:59:41   

which looked good but trying to retrieve class for hog-cli-bucket-name bucket didn't work. It is asking me to login.

ibmcloud cos get-bucket-class --bucket hog-cli-bucket-name
FAILED
Access to your IBM Cloud account was denied. Log in again by typing ibmcloud login --sso.

And after I login when I test get-bucket-class it keeps telling me to login again.

1

There are 1 best solutions below

0
On

I think your CRN looks wrong. I only used the last part of my CRN f743cac0-6166-404f-abea-2e1d74c6a7ac