Hi,
I have added created a blobstore instance and bound it to my nodeJS service. When I try and connect to blobstore, I get error 403 Access Denied. Code is
var AWS = require('aws-sdk')
AWS.config.update({accessKeyId: 'My Key', secretAccessKey: 'My Secret Key', region: 'us-west-2'})
var s3 = new AWS.S3()
s3.listBuckets(function (error, data) { if (error) { console.log('Error:', error) } })
Please note that MyKey and MySecretKey are taken from ENV in the real code. My nodeJS server is running in Cloud Foundry
From AWS documentation, the above code is basically what is needed, and should work. Can anyone please tell me why I cannot list the buckets please? I haven't created any new buckets myself, but ENV does list a bucket that was created for me
Answer by Lee Hayward · Jul 04, 2016 at 01:58 AM
I have figured out the problem. I do not have permission to list buckets - however, I have managed to create an object in my default bucket, and also to list all created objects.
According to AWS documentation, it says that had I created the bucket in raw S3, I could log into the AWS Management console (http://docs.aws.amazon.com/AmazonS3/latest/UG/EditingBucketPermissions.html) and edit accordingly.
Does anyone know if there is a Predix equivalent please (from Basic environment)?
In both environments creating an instance correlates to one bucket and you only have access to perform object operations. To create another bucket you will need to create another instance.
Hi Beth
If I understand correctly, you are saying that the bucket created with the instance is the only bucket you can ever create in that instance? If so, why does the AWS-SDK have a function called listBuckets (pertaining to S3)?
If you can only create a single bucket in the instance, then this function seems moot
Lee
The AWS SDK is designed for use with a normal S3 instance you can create through the AWS console. In Predix, you're given access to just one bucket per instance, so the list bucket function is moot.
Perfect. That completes the answer to the original question
Thank-you
Answer by Lee Hayward · Jul 03, 2016 at 02:06 PM
Hi Brian
The only URL provided is to the default bucket created. The host is s3-us-west-2.amazonaws.com, which is what I should connect to by setting the region in AWS.config (see http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-examples.html)
Taken from ENV (edited):
"credentials": {
"access_key_id": "My Key",
"bucket_name": "bucket-abc123",
"host": "s3-us-west-2.amazonaws.com",
"secret_access_key": "My Secret KEY",
"url": "https://bucket-abc123.s3-us-west-2.amazonaws.com"
}
My code is hosted inside of Cloud Foundry
As far as I can tell, connecting to us-west-2, using the key and secret key should be enough to connect to my blobstore
Answer by Brian Henzelmann · Jul 03, 2016 at 12:16 PM
Are you specifying the url that's provided from the ENV variables? I think it's a 10.x IP, so you'll want to use that rather than point to the normal S3 url.
Otherwise, I wonder if the problem is because when you create a blobstore service, you're given one bucket to use. Maybe you don't have access to list buckets. Can you try listing objects in the bucket created?
Also, is this error while running locally or while in the Cloud Foundry environment? It won't work locally without a tunnel to the Predix network.
HOW to use BLOB to upload file 2 Answers
Unable to access Blobstore object 4 Answers
Accessing BlobStore from outside Predix 3 Answers
Blobstore access in Predix Select environment using AWS SDK 7 Answers