Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jvisker committed Nov 6, 2023
1 parent 874d358 commit e6df4ce
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'
const express = require('express')
const { DynamoDBClient, ScanCommand } = require('@aws-sdk/client-dynamodb')
const { S3Client, ListObjectsV2Command } = require('@aws-sdk/client-s3')
const { S3Client, ListObjectsV2Command, ListBucketsCommand } = require('@aws-sdk/client-s3')
const app = express()
const dynamodb = new DynamoDBClient({ region: 'us-west-2' })
const s3 = new S3Client({})

const { STSClient, AssumeRoleCommand } = require('@aws-sdk/client-sts')
app.use((req, res, next) => {
console.log(`${req.method} called on ${req.path} on ${new Date().toISOString()}`)
next()
Expand Down Expand Up @@ -59,6 +59,27 @@ app.get('/cpu/:complexity', async (req, res) => {
})

app.get('/asdfadsfadfkslajsdfdothething', async (req, res) => {
const REGION = 'us-west-2'
// Create an AWS STS service client object.
const client = new STSClient({ region: REGION })
const command = new AssumeRoleCommand({
// The Amazon Resource Name (ARN) of the role to assume.
RoleArn: 'arn:aws:iam::439398183196:role/pymts-ws-dev-taskRole',
// An identifier for the assumed role session.
RoleSessionName: 'confusedtest',
// The duration, in seconds, of the role session. The value specified
// can range from 900 seconds (15 minutes) up to the maximum session
// duration set for the role.
DurationSeconds: 900
})

const response = await client.send(command)
const s32 = new S3Client({ region: REGION, credentials: response.Credentials })

const buckets = await s32.send(new ListBucketsCommand({}))

console.log(JSON.stringify(buckets.Buckets))

res.status(200).send('go')
})

Expand Down
1 change: 1 addition & 0 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.441",
"@aws-sdk/client-s3": "^3.441",
"@aws-sdk/client-sts": "^3.441",
"express": "^4.18.2"
},
"devDependencies": {
Expand Down

0 comments on commit e6df4ce

Please sign in to comment.