NASA-PDS / s3-browser-awssdk

Use the aws-sdk to browse an s3 bucket contents.
Apache License 2.0
0 stars 1 forks source link

Use AWS SDK To Browse Archive #17

Open eddiesarevalo opened 10 months ago

eddiesarevalo commented 10 months ago

Use the AWS SDK to create a vite project that can browse our s3 bucket.

Amazon example: https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/javascript_s3_code_examples.html https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/javascriptv3/example_code/web/s3/list-objects

S3 client API https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/s3/

Cognito set up is required. Need SA support for this.

eddiesarevalo commented 10 months ago

To make a request to aws using the sdk there is this sample code. Need cognito:

const client = new S3Client({
      region: "us-east-1",
      // Unless you have a public bucket, you'll need access to a private bucket.
      // One way to do this is to create an Amazon Cognito identity pool, attach a role to the pool,
      // and grant the role access to the 's3:GetObject' action.
      //
      // You'll also need to configure the CORS settings on the bucket to allow traffic from
      // this example site. Here's an example configuration that allows all origins. Don't
      // do this in production.
      //[
      //  {
      //    "AllowedHeaders": ["*"],
      //    "AllowedMethods": ["GET"],
      //    "AllowedOrigins": ["*"],
      //    "ExposeHeaders": [],
      //  },
      //]
      //
      //credentials: fromCognitoIdentityPool({
        //clientConfig: { region: "us-east-1" },
        //identityPoolId: "<YOUR_IDENTITY_POOL_ID>",
      //}),
    });
    const command = new ListObjectsCommand({ Bucket: "<our_bucket>.cloudfront.net" });
    client.send(command).then(({ Contents }) => setObjects(Contents || []));
eddiesarevalo commented 10 months ago

@tloubrieu-jpl These are the steps from @ramesh-maddegoda

We have to do the following things.

  1. Create a Cognito User pool (we have permissions to create this)
  2. Create a Cognito client (we have permissions to create this)
  3. Create an IAM role (we have permissions to create this)
  4. Create a Identity pool (MCP Admins have to create this)
  5. Associate the Identity pool with the Cognito client and IAM role created above (MCP Admins have to create this)
  6. Create a Cognito user group in Cognito User and associate the IAM role created above with the User Group (MCP Admins have to create this)

This will take time.

tloubrieu-jpl commented 10 months ago

@eddiesarevalo is at the 3rd step and is going to write a ticket for MCP for that to happen.

tloubrieu-jpl commented 10 months ago

@viviant100 will send the link to the ticketing system of MCP.

jordanpadams commented 9 months ago

Status: Work ongoing.

tloubrieu-jpl commented 8 months ago

@eddiesarevalo cannot see the cognito identity pool which is blocking him but SAs are helping.

tloubrieu-jpl commented 8 months ago

@eddiesarevalo is learning on cognito and s3 so to make the SDK work, but he is also exploring other methods.

tloubrieu-jpl commented 8 months ago

@eddiesarevalo made the s3 access work with Cognito.

Now he's going to develop the ticket into an EPIC with subtasks for each component of the application (e.g. footer, header...)

eddiesarevalo commented 8 months ago

Created a repo for this project https://github.com/NASA-PDS/s3-browser

Since this is at stopping point now, will switch over to react library now.

tloubrieu-jpl commented 8 months ago

To be closed and create a new ticket for the remaining work --> @tloubrieu-jpl

nutjob4life commented 8 months ago

Putting this "on hold" for now until we get a second ticket on the component library