diff --git a/Makefile b/Makefile index 6d42604..29c1da3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,25 @@ -install: +BUILD_DIR = ./dist +SRC_DIR = ./src +NODE_MODULES = ./node_modules +SRC_FILES := $(shell find $(SRC_DIR) -type f) + +.PHONY: all install build run + +all: build + +$(NODE_MODULES): pnpm install +install: $(NODE_MODULES) + +$(BUILD_DIR): $(SRC_FILES) $(NODE_MODULES) + pnpm build + +build: $(BUILD_DIR) + +run: build + node ./bin/index.js --profile "${AWS_PROFILE}" --access-key "${ACCESS_KEY}" --secret-key "${SECRET_KEY}" --role-arn "${ROLE_ARN}" --region "${AWS_REGION}" -S $(SLACK_TOKEN_AWS_COST_CLI) -C $(SLACK_CHANNEL_ID) + test: pnpm test diff --git a/jest.config.cjs b/jest.config.cjs index 5e06f95..63e27fa 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -9,6 +9,7 @@ var esmModules = [ 'ansi-regex', 'is-interactive', 'stdin-discarder', + 'aws-sdk-client-mock', ]; module.exports = { diff --git a/package.json b/package.json index e55ab43..43168e1 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ }, "homepage": "https://github.com/kamranahmedse/aws-cost-cli#readme", "dependencies": { + "@aws-sdk/client-sts": "^3.521.0", "@aws-sdk/shared-ini-file-loader": "^3.254.0", "aws-sdk": "^2.1299.0", "chalk": "^5.2.0", @@ -66,11 +67,14 @@ "@babel/preset-env": "^7.24.6", "@babel/preset-typescript": "^7.24.6", "@eslint/js": "^9.4.0", + "@smithy/types": "^3.0.0", "@types/eslint__js": "^8.42.3", "@types/jest": "^29.5.12", "@types/node": "^18.11.18", "@typescript-eslint/eslint-plugin": "^7.11.0", "@typescript-eslint/parser": "^7.11.0", + "aws-sdk-client-mock": "^2.2.0", + "aws-sdk-client-mock-jest": "^4.0.0", "babel-jest": "^29.7.0", "eslint": "^9.4.0", "jest": "^29.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 83a7947..cf154ac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,12 +8,15 @@ importers: .: dependencies: + '@aws-sdk/client-sts': + specifier: ^3.521.0 + version: 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) '@aws-sdk/shared-ini-file-loader': specifier: ^3.254.0 version: 3.374.0 aws-sdk: specifier: ^2.1299.0 - version: 2.1631.0 + version: 2.1632.0 chalk: specifier: ^5.2.0 version: 5.3.0 @@ -45,6 +48,9 @@ importers: '@eslint/js': specifier: ^9.4.0 version: 9.4.0 + '@smithy/types': + specifier: ^3.0.0 + version: 3.0.0 '@types/eslint__js': specifier: ^8.42.3 version: 8.42.3 @@ -60,6 +66,12 @@ importers: '@typescript-eslint/parser': specifier: ^7.11.0 version: 7.11.0(eslint@9.4.0)(typescript@4.9.5) + aws-sdk-client-mock: + specifier: ^2.2.0 + version: 2.2.0 + aws-sdk-client-mock-jest: + specifier: ^4.0.0 + version: 4.0.0(aws-sdk-client-mock@2.2.0) babel-jest: specifier: ^29.7.0 version: 29.7.0(@babel/core@7.24.6) @@ -100,11 +112,127 @@ packages: resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} engines: {node: '>=6.0.0'} + '@aws-crypto/ie11-detection@3.0.0': + resolution: {integrity: sha512-341lBBkiY1DfDNKai/wXM3aujNBkXR7tq1URPQDL9wi3AUbI80NR74uF1TXHMm7po1AcnFk8iu2S2IeU/+/A+Q==} + + '@aws-crypto/sha256-browser@3.0.0': + resolution: {integrity: sha512-8VLmW2B+gjFbU5uMeqtQM6Nj0/F1bro80xQXCW6CQBWgosFWXTx77aeOF5CAIAmbOK64SdMBJdNr6J41yP5mvQ==} + + '@aws-crypto/sha256-js@3.0.0': + resolution: {integrity: sha512-PnNN7os0+yd1XvXAy23CFOmTbMaDxgxXtTKHybrJ39Y8kGzBATgBFibWJKH6BhytLI/Zyszs87xCOBNyBig6vQ==} + + '@aws-crypto/supports-web-crypto@3.0.0': + resolution: {integrity: sha512-06hBdMwUAb2WFTuGG73LSC0wfPu93xWwo5vL2et9eymgmu3Id5vFAHBbajVWiGhPO37qcsdCap/FqXvJGJWPIg==} + + '@aws-crypto/util@3.0.0': + resolution: {integrity: sha512-2OJlpeJpCR48CC8r+uKVChzs9Iungj9wkZrl8Z041DWEWvyIHILYKCPNzJghKsivj+S3mLo6BVc7mBNzdxA46w==} + + '@aws-sdk/client-sso-oidc@3.588.0': + resolution: {integrity: sha512-CTbgtLSg0y2jIOtESuQKkRIqRe/FQmKuyzFWc+Qy6yGcbk1Pyusfz2BC+GGwpYU+1BlBBSNnLQHpx3XY87+aSA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/client-sso@3.588.0': + resolution: {integrity: sha512-zKS+xUkBLfwjbh77ZjtRUoG/vR/fyDteSE6rOAzwlmHQL8p+QUX+zNUNvCInvPi62zGBhEwXOvzs8zvnT4NzfQ==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/client-sts@3.588.0': + resolution: {integrity: sha512-UIMjcUikgG9NIENQxSyJNTHMD8TaTfK6Jjf1iuZSyQRyTrcGy0/xcDxrmwZQFAPkOPUf6w9KqydLkMLcYOBdPQ==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/core@3.588.0': + resolution: {integrity: sha512-O1c2+9ce46Z+iiid+W3iC1IvPbfIo5ev9CBi54GdNB9SaI8/3+f8MJcux0D6c9toCF0ArMersN/gp8ek57e9uQ==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-env@3.587.0': + resolution: {integrity: sha512-Hyg/5KFECIk2k5o8wnVEiniV86yVkhn5kzITUydmNGCkXdBFHMHRx6hleQ1bqwJHbBskyu8nbYamzcwymmGwmw==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-http@3.587.0': + resolution: {integrity: sha512-Su1SRWVRCuR1e32oxX3C1V4c5hpPN20WYcRfdcr2wXwHqSvys5DrnmuCC+JoEnS/zt3adUJhPliTqpfKgSdMrA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-ini@3.588.0': + resolution: {integrity: sha512-tP/YmEKvYpmp7pCR2OuhoOhAOtm6BbZ1hbeG9Sw9RFZi55dbGPHqMmfvvzHFAGsJ20z4/oDS+UnHaWVhRnV82w==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@aws-sdk/client-sts': ^3.588.0 + + '@aws-sdk/credential-provider-node@3.588.0': + resolution: {integrity: sha512-8s4Ruo6q1YIrj8AZKBiUQG42051ytochDMSqdVOEZGxskfvmt2XALyi5SsWd0Ve3zR95zi+EtRBNPn2EU8sQpA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-process@3.587.0': + resolution: {integrity: sha512-V4xT3iCqkF8uL6QC4gqBJg/2asd/damswP1h9HCfqTllmPWzImS+8WD3VjgTLw5b0KbTy+ZdUhKc0wDnyzkzxg==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-sso@3.588.0': + resolution: {integrity: sha512-1GstMCyFzenVeppK7hWazMvo3P1DXKP70XkXAjH8H2ELBVg5X8Zt043cnQ7CMt4XjCV+ettHAtc9kz/gJTkDNQ==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/credential-provider-web-identity@3.587.0': + resolution: {integrity: sha512-XqIx/I2PG7kyuw3WjAP9wKlxy8IvFJwB8asOFT1xPFoVfZYKIogjG9oLP5YiRtfvDkWIztHmg5MlVv3HdJDGRw==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@aws-sdk/client-sts': ^3.587.0 + + '@aws-sdk/middleware-host-header@3.577.0': + resolution: {integrity: sha512-9ca5MJz455CODIVXs0/sWmJm7t3QO4EUa1zf8pE8grLpzf0J94bz/skDWm37Pli13T3WaAQBHCTiH2gUVfCsWg==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/middleware-logger@3.577.0': + resolution: {integrity: sha512-aPFGpGjTZcJYk+24bg7jT4XdIp42mFXSuPt49lw5KygefLyJM/sB0bKKqPYYivW0rcuZ9brQ58eZUNthrzYAvg==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/middleware-recursion-detection@3.577.0': + resolution: {integrity: sha512-pn3ZVEd2iobKJlR3H+bDilHjgRnNrQ6HMmK9ZzZw89Ckn3Dcbv48xOv4RJvu0aU8SDLl/SNCxppKjeLDTPGBNA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/middleware-user-agent@3.587.0': + resolution: {integrity: sha512-SyDomN+IOrygLucziG7/nOHkjUXES5oH5T7p8AboO8oakMQJdnudNXiYWTicQWO52R51U6CR27rcMPTGeMedYA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/region-config-resolver@3.587.0': + resolution: {integrity: sha512-93I7IPZtulZQoRK+O20IJ4a1syWwYPzoO2gc3v+/GNZflZPV3QJXuVbIm0pxBsu0n/mzKGUKqSOLPIaN098HcQ==} + engines: {node: '>=16.0.0'} + '@aws-sdk/shared-ini-file-loader@3.374.0': resolution: {integrity: sha512-r3mNf+GAsnJQGh2nssPIXdOMKSn/6v1vPPWEHC2Dy0uxVdeBRxlJLVGPt4QtlwX2dT2hnIttUh/vY9yuJRP4kg==} engines: {node: '>=14.0.0'} deprecated: This package has moved to @smithy/shared-ini-file-loader + '@aws-sdk/token-providers@3.587.0': + resolution: {integrity: sha512-ULqhbnLy1hmJNRcukANBWJmum3BbjXnurLPSFXoGdV0llXYlG55SzIla2VYqdveQEEjmsBuTZdFvXAtNpmS5Zg==} + engines: {node: '>=16.0.0'} + peerDependencies: + '@aws-sdk/client-sso-oidc': ^3.587.0 + + '@aws-sdk/types@3.577.0': + resolution: {integrity: sha512-FT2JZES3wBKN/alfmhlo+3ZOq/XJ0C7QOZcDNrpKjB0kqYoKjhVKZ/Hx6ArR0czkKfHzBBEs6y40ebIHx2nSmA==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/util-endpoints@3.587.0': + resolution: {integrity: sha512-8I1HG6Em8wQWqKcRW6m358mqebRVNpL8XrrEoT4In7xqkKkmYtHRNVYP6lcmiQh5pZ/c/FXu8dSchuFIWyEtqQ==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/util-locate-window@3.568.0': + resolution: {integrity: sha512-3nh4TINkXYr+H41QaPelCceEB2FXP3fxp93YZXB/kqJvX0U9j0N0Uk45gvsjmEPzG8XxkPEeLIfT2I1M7A6Lig==} + engines: {node: '>=16.0.0'} + + '@aws-sdk/util-user-agent-browser@3.577.0': + resolution: {integrity: sha512-zEAzHgR6HWpZOH7xFgeJLc6/CzMcx4nxeQolZxVZoB5pPaJd3CjyRhZN0xXeZB0XIRCWmb4yJBgyiugXLNMkLA==} + + '@aws-sdk/util-user-agent-node@3.587.0': + resolution: {integrity: sha512-Pnl+DUe/bvnbEEDHP3iVJrOtE3HbFJBPgsD6vJ+ml/+IYk1Eq49jEG+EHZdNTPz3SDG0kbp2+7u41MKYJHR/iQ==} + engines: {node: '>=16.0.0'} + peerDependencies: + aws-crt: '>=1.0.0' + peerDependenciesMeta: + aws-crt: + optional: true + + '@aws-sdk/util-utf8-browser@3.259.0': + resolution: {integrity: sha512-UvFa/vR+e19XookZF8RzFZBrw2EUkQWxiBW0yYQAhvk3C+QVGl0H3ouca8LDBlBfQKXwmW3huo/59H8rwb1wJw==} + '@babel/code-frame@7.24.6': resolution: {integrity: sha512-ZJhac6FkEd1yhG2AHOmfcXG4ceoLltoCVJjN5XsWN9BifBQr+cHJbWi0h68HZuSORq+3WtJ2z0hwF2NG1b5kcA==} engines: {node: '>=6.9.0'} @@ -1001,20 +1129,190 @@ packages: '@sinclair/typebox@0.27.8': resolution: {integrity: sha512-+Fj43pSMwJs4KRrH/938Uf+uAELIgVBmQzg/q1YG10djyfA3TnrU8N8XzqCh/okZdszqBQTZf96idMfE5lnwTA==} + '@sinonjs/commons@1.8.6': + resolution: {integrity: sha512-Ky+XkAkqPZSm3NLBeUng77EBQl3cmeJhITaGHdYH8kjVB+aun3S4XBRti2zt17mtt0mIUDiNxYeoJm6drVvBJQ==} + + '@sinonjs/commons@2.0.0': + resolution: {integrity: sha512-uLa0j859mMrg2slwQYdO/AkrOfmH+X6LTVmNTS9CqexuE2IvVORIkSpJLqePAbEnKJ77aMmCwr1NUZ57120Xcg==} + '@sinonjs/commons@3.0.1': resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} '@sinonjs/fake-timers@10.3.0': resolution: {integrity: sha512-V4BG07kuYSUkTCSBHG8G8TNhM+F19jXFWnQtzj+we8DrkpSBCee9Z3Ms8yiGer/dlmhe35/Xdgyo3/0rQKg7YA==} + '@sinonjs/fake-timers@11.2.2': + resolution: {integrity: sha512-G2piCSxQ7oWOxwGSAyFHfPIsyeJGXYtc6mFbnFA+kRXkiEnTl8c/8jul2S329iFBnDI9HGoeWWAZvuvOkZccgw==} + + '@sinonjs/fake-timers@9.1.2': + resolution: {integrity: sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==} + + '@sinonjs/samsam@7.0.1': + resolution: {integrity: sha512-zsAk2Jkiq89mhZovB2LLOdTCxJF4hqqTToGP0ASWlhp4I1hqOjcfmZGafXntCN7MDC6yySH0mFHrYtHceOeLmw==} + + '@sinonjs/text-encoding@0.7.2': + resolution: {integrity: sha512-sXXKG+uL9IrKqViTtao2Ws6dy0znu9sOaP1di/jKGW1M6VssO8vlpXCQcpZ+jisQ1tTFAC5Jo/EOzFbggBagFQ==} + + '@smithy/abort-controller@3.0.0': + resolution: {integrity: sha512-p6GlFGBt9K4MYLu72YuJ523NVR4A8oHlC5M2JO6OmQqN8kAc/uh1JqLE+FizTokrSJGg0CSvC+BrsmGzKtsZKA==} + engines: {node: '>=16.0.0'} + + '@smithy/config-resolver@3.0.1': + resolution: {integrity: sha512-hbkYJc20SBDz2qqLzttjI/EqXemtmWk0ooRznLsiXp3066KQRTvuKHa7U4jCZCJq6Dozqvy0R1/vNESC9inPJg==} + engines: {node: '>=16.0.0'} + + '@smithy/core@2.1.1': + resolution: {integrity: sha512-0vbIwwUcg0FMhTVJgMhbsRSAFL0rwduy/OQz7Xq1pJXJOyaGv+PGjj1iGawRlzBUPA5BkJv7S6q+YU2U8gk/WA==} + engines: {node: '>=16.0.0'} + + '@smithy/credential-provider-imds@3.1.0': + resolution: {integrity: sha512-q4A4d38v8pYYmseu/jTS3Z5I3zXlEOe5Obi+EJreVKgSVyWUHOd7/yaVCinC60QG4MRyCs98tcxBH1IMC0bu7Q==} + engines: {node: '>=16.0.0'} + + '@smithy/fetch-http-handler@3.0.1': + resolution: {integrity: sha512-uaH74i5BDj+rBwoQaXioKpI0SHBJFtOVwzrCpxZxphOW0ki5jhj7dXvDMYM2IJem8TpdFvS2iC08sjOblfFGFg==} + + '@smithy/hash-node@3.0.0': + resolution: {integrity: sha512-84qXstNemP3XS5jcof0el6+bDfjzuvhJPQTEfro3lgtbCtKgzPm3MgiS6ehXVPjeQ5+JS0HqmTz8f/RYfzHVxw==} + engines: {node: '>=16.0.0'} + + '@smithy/invalid-dependency@3.0.0': + resolution: {integrity: sha512-F6wBBaEFgJzj0s4KUlliIGPmqXemwP6EavgvDqYwCH40O5Xr2iMHvS8todmGVZtuJCorBkXsYLyTu4PuizVq5g==} + + '@smithy/is-array-buffer@3.0.0': + resolution: {integrity: sha512-+Fsu6Q6C4RSJiy81Y8eApjEB5gVtM+oFKTffg+jSuwtvomJJrhUJBu2zS8wjXSgH/g1MKEWrzyChTBe6clb5FQ==} + engines: {node: '>=16.0.0'} + + '@smithy/middleware-content-length@3.0.0': + resolution: {integrity: sha512-3C4s4d/iGobgCtk2tnWW6+zSTOBg1PRAm2vtWZLdriwTroFbbWNSr3lcyzHdrQHnEXYCC5K52EbpfodaIUY8sg==} + engines: {node: '>=16.0.0'} + + '@smithy/middleware-endpoint@3.0.1': + resolution: {integrity: sha512-lQ/UOdGD4KM5kLZiAl0q8Qy3dPbynvAXKAdXnYlrA1OpaUwr+neSsVokDZpY6ZVb5Yx8jnus29uv6XWpM9P4SQ==} + engines: {node: '>=16.0.0'} + + '@smithy/middleware-retry@3.0.3': + resolution: {integrity: sha512-Wve1qzJb83VEU/6q+/I0cQdAkDnuzELC6IvIBwDzUEiGpKqXgX1v10FUuZGbRS6Ov/P+HHthcAoHOJZQvZNAkA==} + engines: {node: '>=16.0.0'} + + '@smithy/middleware-serde@3.0.0': + resolution: {integrity: sha512-I1vKG1foI+oPgG9r7IMY1S+xBnmAn1ISqployvqkwHoSb8VPsngHDTOgYGYBonuOKndaWRUGJZrKYYLB+Ane6w==} + engines: {node: '>=16.0.0'} + + '@smithy/middleware-stack@3.0.0': + resolution: {integrity: sha512-+H0jmyfAyHRFXm6wunskuNAqtj7yfmwFB6Fp37enytp2q047/Od9xetEaUbluyImOlGnGpaVGaVfjwawSr+i6Q==} + engines: {node: '>=16.0.0'} + + '@smithy/node-config-provider@3.1.0': + resolution: {integrity: sha512-ngfB8QItUfTFTfHMvKuc2g1W60V1urIgZHqD1JNFZC2tTWXahqf2XvKXqcBS7yZqR7GqkQQZy11y/lNOUWzq7Q==} + engines: {node: '>=16.0.0'} + + '@smithy/node-http-handler@3.0.0': + resolution: {integrity: sha512-3trD4r7NOMygwLbUJo4eodyQuypAWr7uvPnebNJ9a70dQhVn+US8j/lCnvoJS6BXfZeF7PkkkI0DemVJw+n+eQ==} + engines: {node: '>=16.0.0'} + + '@smithy/property-provider@3.1.0': + resolution: {integrity: sha512-Tj3+oVhqdZgemjCiWjFlADfhvLF4C/uKDuKo7/tlEsRQ9+3emCreR2xndj970QSRSsiCEU8hZW3/8JQu+n5w4Q==} + engines: {node: '>=16.0.0'} + + '@smithy/protocol-http@4.0.0': + resolution: {integrity: sha512-qOQZOEI2XLWRWBO9AgIYuHuqjZ2csyr8/IlgFDHDNuIgLAMRx2Bl8ck5U5D6Vh9DPdoaVpuzwWMa0xcdL4O/AQ==} + engines: {node: '>=16.0.0'} + + '@smithy/querystring-builder@3.0.0': + resolution: {integrity: sha512-bW8Fi0NzyfkE0TmQphDXr1AmBDbK01cA4C1Z7ggwMAU5RDz5AAv/KmoRwzQAS0kxXNf/D2ALTEgwK0U2c4LtRg==} + engines: {node: '>=16.0.0'} + + '@smithy/querystring-parser@3.0.0': + resolution: {integrity: sha512-UzHwthk0UEccV4dHzPySnBy34AWw3V9lIqUTxmozQ+wPDAO9csCWMfOLe7V9A2agNYy7xE+Pb0S6K/J23JSzfQ==} + engines: {node: '>=16.0.0'} + + '@smithy/service-error-classification@3.0.0': + resolution: {integrity: sha512-3BsBtOUt2Gsnc3X23ew+r2M71WwtpHfEDGhHYHSDg6q1t8FrWh15jT25DLajFV1H+PpxAJ6gqe9yYeRUsmSdFA==} + engines: {node: '>=16.0.0'} + '@smithy/shared-ini-file-loader@1.1.0': resolution: {integrity: sha512-S/v33zvCWzFyGZGlsEF0XsZtNNR281UhR7byk3nRfsgw5lGpg51rK/zjMgulM+h6NSuXaFILaYrw1I1v4kMcuA==} engines: {node: '>=14.0.0'} + '@smithy/shared-ini-file-loader@3.1.0': + resolution: {integrity: sha512-dAM7wSX0NR3qTNyGVN/nwwpEDzfV9T/3AN2eABExWmda5VqZKSsjlINqomO5hjQWGv+IIkoXfs3u2vGSNz8+Rg==} + engines: {node: '>=16.0.0'} + + '@smithy/signature-v4@3.0.0': + resolution: {integrity: sha512-kXFOkNX+BQHe2qnLxpMEaCRGap9J6tUGLzc3A9jdn+nD4JdMwCKTJ+zFwQ20GkY+mAXGatyTw3HcoUlR39HwmA==} + engines: {node: '>=16.0.0'} + + '@smithy/smithy-client@3.1.1': + resolution: {integrity: sha512-tj4Ku7MpzZR8cmVuPcSbrLFVxmptWktmJMwST/uIEq4sarabEdF8CbmQdYB7uJ/X51Qq2EYwnRsoS7hdR4B7rA==} + engines: {node: '>=16.0.0'} + '@smithy/types@1.2.0': resolution: {integrity: sha512-z1r00TvBqF3dh4aHhya7nz1HhvCg4TRmw51fjMrh5do3h+ngSstt/yKlNbHeb9QxJmFbmN8KEVSWgb1bRvfEoA==} engines: {node: '>=14.0.0'} + '@smithy/types@3.0.0': + resolution: {integrity: sha512-VvWuQk2RKFuOr98gFhjca7fkBS+xLLURT8bUjk5XQoV0ZLm7WPwWPPY3/AwzTLuUBDeoKDCthfe1AsTUWaSEhw==} + engines: {node: '>=16.0.0'} + + '@smithy/url-parser@3.0.0': + resolution: {integrity: sha512-2XLazFgUu+YOGHtWihB3FSLAfCUajVfNBXGGYjOaVKjLAuAxx3pSBY3hBgLzIgB17haf59gOG3imKqTy8mcrjw==} + + '@smithy/util-base64@3.0.0': + resolution: {integrity: sha512-Kxvoh5Qtt0CDsfajiZOCpJxgtPHXOKwmM+Zy4waD43UoEMA+qPxxa98aE/7ZhdnBFZFXMOiBR5xbcaMhLtznQQ==} + engines: {node: '>=16.0.0'} + + '@smithy/util-body-length-browser@3.0.0': + resolution: {integrity: sha512-cbjJs2A1mLYmqmyVl80uoLTJhAcfzMOyPgjwAYusWKMdLeNtzmMz9YxNl3/jRLoxSS3wkqkf0jwNdtXWtyEBaQ==} + + '@smithy/util-body-length-node@3.0.0': + resolution: {integrity: sha512-Tj7pZ4bUloNUP6PzwhN7K386tmSmEET9QtQg0TgdNOnxhZvCssHji+oZTUIuzxECRfG8rdm2PMw2WCFs6eIYkA==} + engines: {node: '>=16.0.0'} + + '@smithy/util-buffer-from@3.0.0': + resolution: {integrity: sha512-aEOHCgq5RWFbP+UDPvPot26EJHjOC+bRgse5A8V3FSShqd5E5UN4qc7zkwsvJPPAVsf73QwYcHN1/gt/rtLwQA==} + engines: {node: '>=16.0.0'} + + '@smithy/util-config-provider@3.0.0': + resolution: {integrity: sha512-pbjk4s0fwq3Di/ANL+rCvJMKM5bzAQdE5S/6RL5NXgMExFAi6UgQMPOm5yPaIWPpr+EOXKXRonJ3FoxKf4mCJQ==} + engines: {node: '>=16.0.0'} + + '@smithy/util-defaults-mode-browser@3.0.3': + resolution: {integrity: sha512-3DFON2bvXJAukJe+qFgPV/rorG7ZD3m4gjCXHD1V5z/tgKQp5MCTCLntrd686tX6tj8Uli3lefWXJudNg5WmCA==} + engines: {node: '>= 10.0.0'} + + '@smithy/util-defaults-mode-node@3.0.3': + resolution: {integrity: sha512-D0b8GJXecT00baoSQ3Iieu3k3mZ7GY8w1zmg8pdogYrGvWJeLcIclqk2gbkG4K0DaBGWrO6v6r20iwIFfDYrmA==} + engines: {node: '>= 10.0.0'} + + '@smithy/util-endpoints@2.0.1': + resolution: {integrity: sha512-ZRT0VCOnKlVohfoABMc8lWeQo/JEFuPWctfNRXgTHbyOVssMOLYFUNWukxxiHRGVAhV+n3c0kPW+zUqckjVPEA==} + engines: {node: '>=16.0.0'} + + '@smithy/util-hex-encoding@3.0.0': + resolution: {integrity: sha512-eFndh1WEK5YMUYvy3lPlVmYY/fZcQE1D8oSf41Id2vCeIkKJXPcYDCZD+4+xViI6b1XSd7tE+s5AmXzz5ilabQ==} + engines: {node: '>=16.0.0'} + + '@smithy/util-middleware@3.0.0': + resolution: {integrity: sha512-q5ITdOnV2pXHSVDnKWrwgSNTDBAMHLptFE07ua/5Ty5WJ11bvr0vk2a7agu7qRhrCFRQlno5u3CneU5EELK+DQ==} + engines: {node: '>=16.0.0'} + + '@smithy/util-retry@3.0.0': + resolution: {integrity: sha512-nK99bvJiziGv/UOKJlDvFF45F00WgPLKVIGUfAK+mDhzVN2hb/S33uW2Tlhg5PVBoqY7tDVqL0zmu4OxAHgo9g==} + engines: {node: '>=16.0.0'} + + '@smithy/util-stream@3.0.1': + resolution: {integrity: sha512-7F7VNNhAsfMRA8I986YdOY5fE0/T1/ZjFF6OLsqkvQVNP3vZ/szYDfGCyphb7ioA09r32K/0qbSFfNFU68aSzA==} + engines: {node: '>=16.0.0'} + + '@smithy/util-uri-escape@3.0.0': + resolution: {integrity: sha512-LqR7qYLgZTD7nWLBecUi4aqolw8Mhza9ArpNEQ881MJJIU2sE5iHCK6TdyqqzcDLy0OPe10IY4T8ctVdtynubg==} + engines: {node: '>=16.0.0'} + + '@smithy/util-utf8@3.0.0': + resolution: {integrity: sha512-rUeT12bxFnplYDe815GXbq/oixEGHfRFFtcTF3YdDi/JaENIM6aSYYLJydG83UNzLXeRI5K8abYd/8Sp/QM0kA==} + engines: {node: '>=16.0.0'} + '@tsconfig/node10@1.0.11': resolution: {integrity: sha512-DcRjDCujK/kCk/cUe8Xz8ZSpm8mS3mNNpta+jGCA6USEDfktlNvm1+IuZ9eTcDbNk41BHwpHHeW+N1lKCz4zOw==} @@ -1069,6 +1367,12 @@ packages: '@types/node@18.19.33': resolution: {integrity: sha512-NR9+KrpSajr2qBVp/Yt5TU/rp+b5Mayi3+OlMlcg2cVCfRmcG5PWZ7S4+MG9PZ5gWBoc9Pd0BKSRViuBCRPu0A==} + '@types/sinon@10.0.20': + resolution: {integrity: sha512-2APKKruFNCAZgx3daAyACGzWuJ028VVCUDk6o2rw/Z4PXT0ogwdV4KUegW0MwVs0Zu59auPXbbuBJHF12Sx1Eg==} + + '@types/sinonjs__fake-timers@8.1.5': + resolution: {integrity: sha512-mQkU2jY8jJEF7YHjHvsQO8+3ughTL1mcnn96igfhONmR+fUPSKIkefQYpSe8bsly2Ep7oQbn/6VG5/9/0qcArQ==} + '@types/stack-utils@2.0.3': resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} @@ -1213,8 +1517,16 @@ packages: resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} engines: {node: '>= 0.4'} - aws-sdk@2.1631.0: - resolution: {integrity: sha512-QG1A1bsgy9jKyY20LVxEeB16zEbn3dPIZmVeh/7vk6ukb2+5Vjh0s+E5bVlNHFFXVu6rsviayqGmjr16fJ5I1g==} + aws-sdk-client-mock-jest@4.0.0: + resolution: {integrity: sha512-Q8WWWYpcEZK8m0OA42Lm2LaJgStAfqvmMYVtEs2Ibz+nwjZDZSK/xlsYbdsFz93RO9cUPXbQMeyKUXeqdjh49g==} + peerDependencies: + aws-sdk-client-mock: 4.0.0 + + aws-sdk-client-mock@2.2.0: + resolution: {integrity: sha512-Kq2N+6gHRDedbrgTA0NMMfyN1XDWEA5Kbpm9/M/cenSxoNjfvQBOtBawI1lQe5h4UziLl///E7u17K9PBoHEKA==} + + aws-sdk@2.1632.0: + resolution: {integrity: sha512-doNHUxto00r7r9qWb5RcIsQHUTHdGiPPyJoXxmsmQW6aOr69BqYeuFl8SicNS1YzP6s5sFFnDNKq9KB7jA2fyA==} engines: {node: '>= 10.0.0'} babel-jest@29.7.0: @@ -1270,6 +1582,9 @@ packages: bl@5.1.0: resolution: {integrity: sha512-tv1ZJHLfTDnXE6tMHv73YgSJaWR2AFuPwMntBe7XL/GBFHnT0CLnsHMogfk5+GzCDC5ZWarSCYaIGATZt9dNsQ==} + bowser@2.11.0: + resolution: {integrity: sha512-AlcaJBi/pqqJBIQ8U9Mcpc9i8Aqxn88Skv5d+xBX006BY5u8N3mGLHa5Lgppa7L/HfwgwLgZ6NYs+Ag6uUmJRA==} + brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -1492,6 +1807,10 @@ packages: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} + diff@5.2.0: + resolution: {integrity: sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==} + engines: {node: '>=0.3.1'} + dir-glob@3.0.1: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} @@ -1635,6 +1954,10 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + fast-xml-parser@4.2.5: + resolution: {integrity: sha512-B9/wizE4WngqQftFPmdaMYlXoJlJOYxGQOanC77fq9k8+Z0v5dDSVh+3glErdIROP//s/jgb7ZuxKfB8nVyo0g==} + hasBin: true + fastq@1.17.1: resolution: {integrity: sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==} @@ -2159,6 +2482,9 @@ packages: engines: {node: '>=6'} hasBin: true + just-extend@6.2.0: + resolution: {integrity: sha512-cYofQu2Xpom82S6qD778jBDpwvvy39s1l/hrYij2u9AMdQcGRpaBu6kY4mVhuno5kJVi1DAz4aiphA2WI1/OAw==} + keyv@4.5.4: resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==} @@ -2200,6 +2526,9 @@ packages: lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} + lodash.get@4.4.2: + resolution: {integrity: sha512-z+Uw/vLuy6gQe8cfaFWD7p0wVv8fJl3mbzXh33RS+0oW2wvUqiRXiQ69gLWSLpgB5/6sU+r6BlQR0MBILadqTQ==} + lodash.memoize@4.1.2: resolution: {integrity: sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==} @@ -2272,6 +2601,9 @@ packages: nice-try@1.0.5: resolution: {integrity: sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==} + nise@5.1.9: + resolution: {integrity: sha512-qOnoujW4SV6e40dYxJOb3uvuoPHtmLzIk4TFo+j0jPJoC+5Z9xja5qH5JZobEPsa8+YYphMrOSwnrshEhG2qww==} + node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} @@ -2387,6 +2719,9 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-to-regexp@6.2.2: + resolution: {integrity: sha512-GQX3SSMokngb36+whdpRXE+3f9V8UzyAorlYvOGx87ufGHehNTn5lCxrKtLyZ4Yl/wEKnNnr98ZzOwwDZV5ogw==} + path-type@3.0.0: resolution: {integrity: sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==} engines: {node: '>=4'} @@ -2615,6 +2950,10 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} + sinon@14.0.2: + resolution: {integrity: sha512-PDpV0ZI3ZCS3pEqx0vpNp6kzPhHrLx72wA0G+ZLaaJjLIYeE0n8INlgaohKuGy7hP0as5tbUd23QWu5U233t+w==} + deprecated: 16.1.1 + sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} @@ -2710,6 +3049,9 @@ packages: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} + strnum@1.0.5: + resolution: {integrity: sha512-J8bbNyKKXl5qYcR36TIO8W3mVGVHrmmxsd5PAItGkmyzwJvybiw2IVq5nqd0i4LSNSkB/sx9VHllbfFdr9k1JA==} + sucrase@3.35.0: resolution: {integrity: sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==} engines: {node: '>=16 || 14 >=14.17'} @@ -2810,6 +3152,9 @@ packages: '@swc/wasm': optional: true + tslib@1.14.1: + resolution: {integrity: sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==} + tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} @@ -2916,6 +3261,10 @@ packages: resolution: {integrity: sha512-jOXGuXZAWdsTH7eZLtyXMqUb9EcWMGZNbL9YcGBJl4MH4nrxHmZJhEHvyLFrkxo+28uLb/NYRcStH48fnD0Vzw==} hasBin: true + uuid@9.0.1: + resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==} + hasBin: true + v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -3019,11 +3368,351 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 + '@aws-crypto/ie11-detection@3.0.0': + dependencies: + tslib: 1.14.1 + + '@aws-crypto/sha256-browser@3.0.0': + dependencies: + '@aws-crypto/ie11-detection': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-crypto/supports-web-crypto': 3.0.0 + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-locate-window': 3.568.0 + '@aws-sdk/util-utf8-browser': 3.259.0 + tslib: 1.14.1 + + '@aws-crypto/sha256-js@3.0.0': + dependencies: + '@aws-crypto/util': 3.0.0 + '@aws-sdk/types': 3.577.0 + tslib: 1.14.1 + + '@aws-crypto/supports-web-crypto@3.0.0': + dependencies: + tslib: 1.14.1 + + '@aws-crypto/util@3.0.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-utf8-browser': 3.259.0 + tslib: 1.14.1 + + '@aws-sdk/client-sso-oidc@3.588.0': + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sts': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/core': 3.588.0 + '@aws-sdk/credential-provider-node': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0)(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)) + '@aws-sdk/middleware-host-header': 3.577.0 + '@aws-sdk/middleware-logger': 3.577.0 + '@aws-sdk/middleware-recursion-detection': 3.577.0 + '@aws-sdk/middleware-user-agent': 3.587.0 + '@aws-sdk/region-config-resolver': 3.587.0 + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-endpoints': 3.587.0 + '@aws-sdk/util-user-agent-browser': 3.577.0 + '@aws-sdk/util-user-agent-node': 3.587.0 + '@smithy/config-resolver': 3.0.1 + '@smithy/core': 2.1.1 + '@smithy/fetch-http-handler': 3.0.1 + '@smithy/hash-node': 3.0.0 + '@smithy/invalid-dependency': 3.0.0 + '@smithy/middleware-content-length': 3.0.0 + '@smithy/middleware-endpoint': 3.0.1 + '@smithy/middleware-retry': 3.0.3 + '@smithy/middleware-serde': 3.0.0 + '@smithy/middleware-stack': 3.0.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/node-http-handler': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/url-parser': 3.0.0 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.3 + '@smithy/util-defaults-mode-node': 3.0.3 + '@smithy/util-endpoints': 2.0.1 + '@smithy/util-middleware': 3.0.0 + '@smithy/util-retry': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - aws-crt + + '@aws-sdk/client-sso@3.588.0': + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/core': 3.588.0 + '@aws-sdk/middleware-host-header': 3.577.0 + '@aws-sdk/middleware-logger': 3.577.0 + '@aws-sdk/middleware-recursion-detection': 3.577.0 + '@aws-sdk/middleware-user-agent': 3.587.0 + '@aws-sdk/region-config-resolver': 3.587.0 + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-endpoints': 3.587.0 + '@aws-sdk/util-user-agent-browser': 3.577.0 + '@aws-sdk/util-user-agent-node': 3.587.0 + '@smithy/config-resolver': 3.0.1 + '@smithy/core': 2.1.1 + '@smithy/fetch-http-handler': 3.0.1 + '@smithy/hash-node': 3.0.0 + '@smithy/invalid-dependency': 3.0.0 + '@smithy/middleware-content-length': 3.0.0 + '@smithy/middleware-endpoint': 3.0.1 + '@smithy/middleware-retry': 3.0.3 + '@smithy/middleware-serde': 3.0.0 + '@smithy/middleware-stack': 3.0.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/node-http-handler': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/url-parser': 3.0.0 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.3 + '@smithy/util-defaults-mode-node': 3.0.3 + '@smithy/util-endpoints': 2.0.1 + '@smithy/util-middleware': 3.0.0 + '@smithy/util-retry': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - aws-crt + + '@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)': + dependencies: + '@aws-crypto/sha256-browser': 3.0.0 + '@aws-crypto/sha256-js': 3.0.0 + '@aws-sdk/client-sso-oidc': 3.588.0 + '@aws-sdk/core': 3.588.0 + '@aws-sdk/credential-provider-node': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0)(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)) + '@aws-sdk/middleware-host-header': 3.577.0 + '@aws-sdk/middleware-logger': 3.577.0 + '@aws-sdk/middleware-recursion-detection': 3.577.0 + '@aws-sdk/middleware-user-agent': 3.587.0 + '@aws-sdk/region-config-resolver': 3.587.0 + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-endpoints': 3.587.0 + '@aws-sdk/util-user-agent-browser': 3.577.0 + '@aws-sdk/util-user-agent-node': 3.587.0 + '@smithy/config-resolver': 3.0.1 + '@smithy/core': 2.1.1 + '@smithy/fetch-http-handler': 3.0.1 + '@smithy/hash-node': 3.0.0 + '@smithy/invalid-dependency': 3.0.0 + '@smithy/middleware-content-length': 3.0.0 + '@smithy/middleware-endpoint': 3.0.1 + '@smithy/middleware-retry': 3.0.3 + '@smithy/middleware-serde': 3.0.0 + '@smithy/middleware-stack': 3.0.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/node-http-handler': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/url-parser': 3.0.0 + '@smithy/util-base64': 3.0.0 + '@smithy/util-body-length-browser': 3.0.0 + '@smithy/util-body-length-node': 3.0.0 + '@smithy/util-defaults-mode-browser': 3.0.3 + '@smithy/util-defaults-mode-node': 3.0.3 + '@smithy/util-endpoints': 2.0.1 + '@smithy/util-middleware': 3.0.0 + '@smithy/util-retry': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + + '@aws-sdk/core@3.588.0': + dependencies: + '@smithy/core': 2.1.1 + '@smithy/protocol-http': 4.0.0 + '@smithy/signature-v4': 3.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + fast-xml-parser: 4.2.5 + tslib: 2.6.2 + + '@aws-sdk/credential-provider-env@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/credential-provider-http@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/fetch-http-handler': 3.0.1 + '@smithy/node-http-handler': 3.0.0 + '@smithy/property-provider': 3.1.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/util-stream': 3.0.1 + tslib: 2.6.2 + + '@aws-sdk/credential-provider-ini@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0))': + dependencies: + '@aws-sdk/client-sts': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/credential-provider-env': 3.587.0 + '@aws-sdk/credential-provider-http': 3.587.0 + '@aws-sdk/credential-provider-process': 3.587.0 + '@aws-sdk/credential-provider-sso': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/credential-provider-web-identity': 3.587.0(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)) + '@aws-sdk/types': 3.577.0 + '@smithy/credential-provider-imds': 3.1.0 + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + + '@aws-sdk/credential-provider-node@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0))': + dependencies: + '@aws-sdk/credential-provider-env': 3.587.0 + '@aws-sdk/credential-provider-http': 3.587.0 + '@aws-sdk/credential-provider-ini': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0)(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)) + '@aws-sdk/credential-provider-process': 3.587.0 + '@aws-sdk/credential-provider-sso': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/credential-provider-web-identity': 3.587.0(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)) + '@aws-sdk/types': 3.577.0 + '@smithy/credential-provider-imds': 3.1.0 + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - '@aws-sdk/client-sts' + - aws-crt + + '@aws-sdk/credential-provider-process@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/credential-provider-sso@3.588.0(@aws-sdk/client-sso-oidc@3.588.0)': + dependencies: + '@aws-sdk/client-sso': 3.588.0 + '@aws-sdk/token-providers': 3.587.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + transitivePeerDependencies: + - '@aws-sdk/client-sso-oidc' + - aws-crt + + '@aws-sdk/credential-provider-web-identity@3.587.0(@aws-sdk/client-sts@3.588.0(@aws-sdk/client-sso-oidc@3.588.0))': + dependencies: + '@aws-sdk/client-sts': 3.588.0(@aws-sdk/client-sso-oidc@3.588.0) + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/middleware-host-header@3.577.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/middleware-logger@3.577.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/middleware-recursion-detection@3.577.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/middleware-user-agent@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@aws-sdk/util-endpoints': 3.587.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/region-config-resolver@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/types': 3.0.0 + '@smithy/util-config-provider': 3.0.0 + '@smithy/util-middleware': 3.0.0 + tslib: 2.6.2 + '@aws-sdk/shared-ini-file-loader@3.374.0': dependencies: '@smithy/shared-ini-file-loader': 1.1.0 tslib: 2.6.2 + '@aws-sdk/token-providers@3.587.0(@aws-sdk/client-sso-oidc@3.588.0)': + dependencies: + '@aws-sdk/client-sso-oidc': 3.588.0 + '@aws-sdk/types': 3.577.0 + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/types@3.577.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/util-endpoints@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/types': 3.0.0 + '@smithy/util-endpoints': 2.0.1 + tslib: 2.6.2 + + '@aws-sdk/util-locate-window@3.568.0': + dependencies: + tslib: 2.6.2 + + '@aws-sdk/util-user-agent-browser@3.577.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/types': 3.0.0 + bowser: 2.11.0 + tslib: 2.6.2 + + '@aws-sdk/util-user-agent-node@3.587.0': + dependencies: + '@aws-sdk/types': 3.577.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@aws-sdk/util-utf8-browser@3.259.0': + dependencies: + tslib: 2.6.2 + '@babel/code-frame@7.24.6': dependencies: '@babel/highlight': 7.24.6 @@ -4091,6 +4780,14 @@ snapshots: '@sinclair/typebox@0.27.8': {} + '@sinonjs/commons@1.8.6': + dependencies: + type-detect: 4.0.8 + + '@sinonjs/commons@2.0.0': + dependencies: + type-detect: 4.0.8 + '@sinonjs/commons@3.0.1': dependencies: type-detect: 4.0.8 @@ -4099,15 +4796,281 @@ snapshots: dependencies: '@sinonjs/commons': 3.0.1 + '@sinonjs/fake-timers@11.2.2': + dependencies: + '@sinonjs/commons': 3.0.1 + + '@sinonjs/fake-timers@9.1.2': + dependencies: + '@sinonjs/commons': 1.8.6 + + '@sinonjs/samsam@7.0.1': + dependencies: + '@sinonjs/commons': 2.0.0 + lodash.get: 4.4.2 + type-detect: 4.0.8 + + '@sinonjs/text-encoding@0.7.2': {} + + '@smithy/abort-controller@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/config-resolver@3.0.1': + dependencies: + '@smithy/node-config-provider': 3.1.0 + '@smithy/types': 3.0.0 + '@smithy/util-config-provider': 3.0.0 + '@smithy/util-middleware': 3.0.0 + tslib: 2.6.2 + + '@smithy/core@2.1.1': + dependencies: + '@smithy/middleware-endpoint': 3.0.1 + '@smithy/middleware-retry': 3.0.3 + '@smithy/middleware-serde': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/util-middleware': 3.0.0 + tslib: 2.6.2 + + '@smithy/credential-provider-imds@3.1.0': + dependencies: + '@smithy/node-config-provider': 3.1.0 + '@smithy/property-provider': 3.1.0 + '@smithy/types': 3.0.0 + '@smithy/url-parser': 3.0.0 + tslib: 2.6.2 + + '@smithy/fetch-http-handler@3.0.1': + dependencies: + '@smithy/protocol-http': 4.0.0 + '@smithy/querystring-builder': 3.0.0 + '@smithy/types': 3.0.0 + '@smithy/util-base64': 3.0.0 + tslib: 2.6.2 + + '@smithy/hash-node@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + '@smithy/util-buffer-from': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + + '@smithy/invalid-dependency@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/is-array-buffer@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/middleware-content-length@3.0.0': + dependencies: + '@smithy/protocol-http': 4.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/middleware-endpoint@3.0.1': + dependencies: + '@smithy/middleware-serde': 3.0.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + '@smithy/url-parser': 3.0.0 + '@smithy/util-middleware': 3.0.0 + tslib: 2.6.2 + + '@smithy/middleware-retry@3.0.3': + dependencies: + '@smithy/node-config-provider': 3.1.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/service-error-classification': 3.0.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + '@smithy/util-middleware': 3.0.0 + '@smithy/util-retry': 3.0.0 + tslib: 2.6.2 + uuid: 9.0.1 + + '@smithy/middleware-serde@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/middleware-stack@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/node-config-provider@3.1.0': + dependencies: + '@smithy/property-provider': 3.1.0 + '@smithy/shared-ini-file-loader': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/node-http-handler@3.0.0': + dependencies: + '@smithy/abort-controller': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/querystring-builder': 3.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/property-provider@3.1.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/protocol-http@4.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/querystring-builder@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + '@smithy/util-uri-escape': 3.0.0 + tslib: 2.6.2 + + '@smithy/querystring-parser@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/service-error-classification@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + '@smithy/shared-ini-file-loader@1.1.0': dependencies: '@smithy/types': 1.2.0 tslib: 2.6.2 + '@smithy/shared-ini-file-loader@3.1.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/signature-v4@3.0.0': + dependencies: + '@smithy/is-array-buffer': 3.0.0 + '@smithy/types': 3.0.0 + '@smithy/util-hex-encoding': 3.0.0 + '@smithy/util-middleware': 3.0.0 + '@smithy/util-uri-escape': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + + '@smithy/smithy-client@3.1.1': + dependencies: + '@smithy/middleware-endpoint': 3.0.1 + '@smithy/middleware-stack': 3.0.0 + '@smithy/protocol-http': 4.0.0 + '@smithy/types': 3.0.0 + '@smithy/util-stream': 3.0.1 + tslib: 2.6.2 + '@smithy/types@1.2.0': dependencies: tslib: 2.6.2 + '@smithy/types@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/url-parser@3.0.0': + dependencies: + '@smithy/querystring-parser': 3.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-base64@3.0.0': + dependencies: + '@smithy/util-buffer-from': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-body-length-browser@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/util-body-length-node@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/util-buffer-from@3.0.0': + dependencies: + '@smithy/is-array-buffer': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-config-provider@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/util-defaults-mode-browser@3.0.3': + dependencies: + '@smithy/property-provider': 3.1.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + bowser: 2.11.0 + tslib: 2.6.2 + + '@smithy/util-defaults-mode-node@3.0.3': + dependencies: + '@smithy/config-resolver': 3.0.1 + '@smithy/credential-provider-imds': 3.1.0 + '@smithy/node-config-provider': 3.1.0 + '@smithy/property-provider': 3.1.0 + '@smithy/smithy-client': 3.1.1 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-endpoints@2.0.1': + dependencies: + '@smithy/node-config-provider': 3.1.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-hex-encoding@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/util-middleware@3.0.0': + dependencies: + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-retry@3.0.0': + dependencies: + '@smithy/service-error-classification': 3.0.0 + '@smithy/types': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-stream@3.0.1': + dependencies: + '@smithy/fetch-http-handler': 3.0.1 + '@smithy/node-http-handler': 3.0.0 + '@smithy/types': 3.0.0 + '@smithy/util-base64': 3.0.0 + '@smithy/util-buffer-from': 3.0.0 + '@smithy/util-hex-encoding': 3.0.0 + '@smithy/util-utf8': 3.0.0 + tslib: 2.6.2 + + '@smithy/util-uri-escape@3.0.0': + dependencies: + tslib: 2.6.2 + + '@smithy/util-utf8@3.0.0': + dependencies: + '@smithy/util-buffer-from': 3.0.0 + tslib: 2.6.2 + '@tsconfig/node10@1.0.11': {} '@tsconfig/node12@1.0.11': {} @@ -4173,6 +5136,12 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/sinon@10.0.20': + dependencies: + '@types/sinonjs__fake-timers': 8.1.5 + + '@types/sinonjs__fake-timers@8.1.5': {} + '@types/stack-utils@2.0.3': {} '@types/yargs-parser@21.0.3': {} @@ -4334,7 +5303,19 @@ snapshots: dependencies: possible-typed-array-names: 1.0.0 - aws-sdk@2.1631.0: + aws-sdk-client-mock-jest@4.0.0(aws-sdk-client-mock@2.2.0): + dependencies: + aws-sdk-client-mock: 2.2.0 + expect: 29.7.0 + tslib: 2.6.2 + + aws-sdk-client-mock@2.2.0: + dependencies: + '@types/sinon': 10.0.20 + sinon: 14.0.2 + tslib: 2.6.2 + + aws-sdk@2.1632.0: dependencies: buffer: 4.9.2 events: 1.1.1 @@ -4435,6 +5416,8 @@ snapshots: inherits: 2.0.4 readable-stream: 3.6.2 + bowser@2.11.0: {} + brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -4468,7 +5451,7 @@ snapshots: buffer@4.9.2: dependencies: base64-js: 1.5.1 - ieee754: 1.1.13 + ieee754: 1.2.1 isarray: 1.0.0 buffer@6.0.3: @@ -4657,6 +5640,8 @@ snapshots: diff@4.0.2: {} + diff@5.2.0: {} + dir-glob@3.0.1: dependencies: path-type: 4.0.0 @@ -4887,6 +5872,10 @@ snapshots: fast-levenshtein@2.0.6: {} + fast-xml-parser@4.2.5: + dependencies: + strnum: 1.0.5 + fastq@1.17.1: dependencies: reusify: 1.0.4 @@ -5573,6 +6562,8 @@ snapshots: json5@2.2.3: {} + just-extend@6.2.0: {} + keyv@4.5.4: dependencies: json-buffer: 3.0.1 @@ -5609,6 +6600,8 @@ snapshots: lodash.debounce@4.0.8: {} + lodash.get@4.4.2: {} + lodash.memoize@4.1.2: {} lodash.merge@4.6.2: {} @@ -5671,6 +6664,14 @@ snapshots: nice-try@1.0.5: {} + nise@5.1.9: + dependencies: + '@sinonjs/commons': 3.0.1 + '@sinonjs/fake-timers': 11.2.2 + '@sinonjs/text-encoding': 0.7.2 + just-extend: 6.2.0 + path-to-regexp: 6.2.2 + node-domexception@1.0.0: {} node-fetch@3.3.2: @@ -5799,6 +6800,8 @@ snapshots: lru-cache: 10.2.2 minipass: 7.1.2 + path-to-regexp@6.2.2: {} + path-type@3.0.0: dependencies: pify: 3.0.0 @@ -6000,6 +7003,15 @@ snapshots: signal-exit@4.1.0: {} + sinon@14.0.2: + dependencies: + '@sinonjs/commons': 2.0.0 + '@sinonjs/fake-timers': 9.1.2 + '@sinonjs/samsam': 7.0.1 + diff: 5.2.0 + nise: 5.1.9 + supports-color: 7.2.0 + sisteransi@1.0.5: {} slash@3.0.0: {} @@ -6102,6 +7114,8 @@ snapshots: strip-json-comments@3.1.1: {} + strnum@1.0.5: {} + sucrase@3.35.0: dependencies: '@jridgewell/gen-mapping': 0.3.5 @@ -6199,6 +7213,8 @@ snapshots: v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + tslib@1.14.1: {} + tslib@2.6.2: {} tsup@6.7.0(ts-node@10.9.2(@types/node@18.19.33)(typescript@4.9.5))(typescript@4.9.5): @@ -6323,6 +7339,8 @@ snapshots: uuid@8.0.0: {} + uuid@9.0.1: {} + v8-compile-cache-lib@3.0.1: {} v8-to-istanbul@9.2.0: diff --git a/readme.md b/readme.md index fa8d601..afb03d3 100644 --- a/readme.md +++ b/readme.md @@ -35,6 +35,7 @@ $ aws-cost --help -k, --access-key [key] AWS access key -s, --secret-key [key] AWS secret key -r, --region [region] AWS region (default: us-east-1) + -a, --role-arn [arn] AWS role ARN to assume -p, --profile [profile] AWS profile to use (default: "default") @@ -63,6 +64,12 @@ aws-cost To configure the credentials using aws-cli, have a look at the [aws-cli docs](https://github.com/aws/aws-cli#configuration) for more information. +If you need to assume a role, you can pass the `role-arn` option: + +```bash +aws-cost -a arn:aws:iam::123456789012:role/your-role-arn +``` + ## Detailed Breakdown > The default usage is to get the cost breakdown by service @@ -197,7 +204,53 @@ Regarding the credentials, you need to have the following permissions in order t } ``` -Also, please note that this tool uses AWS Cost Explorer under the hood which [costs $0.01 per request](https://aws.amazon.com/aws-cost-management/aws-cost-explorer/pricing/). +If you need to use Role-Based Access Control (RBAC), you will need to configure two IAM roles: the provider role and the consumer role. + +1. **Provider Role** + + This role provides the necessary permissions for `aws-cost-cli`. It requires the above permissions policy and the following trust policy. + + **Trust Policy** + + Replace `arn:aws:iam::YOUR_ACCOUNT_ID:role/YourConsumerRole` with the ARN of the consumer role. + + ```json + { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "AWS": "arn:aws:iam::YOUR_ACCOUNT_ID:role/YourConsumerRole" + }, + "Action": "sts:AssumeRole" + } + ] + } + ``` + +2. **Consumer Role** + + This role is used by the user or service (such as GitHub Actions) that needs to assume the provider role to access cost information. It requires the following permissions policy. + + **Permissions Policy** + + Replace `arn:aws:iam::YOUR_ACCOUNT_ID:role/YourProviderRole` with the ARN of the provider role. + + ```json + { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": "sts:AssumeRole", + "Resource": "arn:aws:iam::YOUR_ACCOUNT_ID:role/YourProviderRole" + } + ] + } + ``` + +Please also note that this tool uses AWS Cost Explorer under the hood which [costs $0.01 per request](https://aws.amazon.com/aws-cost-management/aws-cost-explorer/pricing/). ## License diff --git a/src/config.test.ts b/src/config.test.ts new file mode 100644 index 0000000..953a213 --- /dev/null +++ b/src/config.test.ts @@ -0,0 +1,78 @@ +import { + STSClient, + AssumeRoleCommand, + AssumeRoleCommandOutput, + Credentials, +} from '@aws-sdk/client-sts'; +import 'aws-sdk-client-mock-jest'; +import { AwsClientStub, mockClient } from 'aws-sdk-client-mock'; +import { getAwsConfigFromOptionsOrFile } from './config'; + +let stsMock: AwsClientStub; + +beforeEach(() => { + stsMock = mockClient(STSClient) as AwsClientStub; +}); + +afterEach(() => { + stsMock.restore(); +}); + +describe('should assume role if roleArn is provided', (): void => { + const mockCredentials: Credentials = { + AccessKeyId: 'mockAccessKeyId', + SecretAccessKey: 'mockSecretAccessKey', + SessionToken: 'mockSessionToken', + Expiration: new Date(), + }; + + it('should assume role if `roleArn` is provided', async () => { + const roleArn = 'arn:aws:iam::123456789012:role/test-role'; + stsMock.on(AssumeRoleCommand).resolves({ + Credentials: mockCredentials, + $metadata: {}, + } as AssumeRoleCommandOutput); + + const awsConfig = await getAwsConfigFromOptionsOrFile({ + profile: 'default', + accessKey: '', + secretKey: '', + sessionToken: '', + region: 'us-east-1', + roleArn, + }); + + expect(stsMock).toHaveReceivedCommandWith(AssumeRoleCommand, { + RoleArn: roleArn, + }); + + expect(awsConfig.credentials).toEqual({ + accessKeyId: mockCredentials.AccessKeyId, + secretAccessKey: mockCredentials.SecretAccessKey, + sessionToken: mockCredentials.SessionToken, + }); + }); + + it('should allow ABAC if `{accessKey, secretKey, sessionToken}` provided', async () => { + const accessKey = 'testAccessKey'; + const secretKey = 'testSecretKey'; + const sessionToken = 'testSessionToken'; + + const awsConfig = await getAwsConfigFromOptionsOrFile({ + profile: 'default', + accessKey: accessKey, + secretKey: secretKey, + sessionToken: sessionToken, + region: 'us-east-1', + roleArn: '', + }); + + expect(stsMock).toHaveReceivedCommandTimes(AssumeRoleCommand, 0); + + expect(awsConfig.credentials).toEqual({ + accessKeyId: accessKey, + secretAccessKey: secretKey, + sessionToken: sessionToken, + }); + }); +}); diff --git a/src/config.ts b/src/config.ts index 0f040be..d1bd6fa 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,4 +1,5 @@ import { loadSharedConfigFiles } from '@aws-sdk/shared-ini-file-loader'; +import { STSClient, AssumeRoleCommand } from '@aws-sdk/client-sts'; import chalk from 'chalk'; import { printFatalError } from './logger'; @@ -23,8 +24,10 @@ export async function getAwsConfigFromOptionsOrFile(options: { secretKey; sessionToken; region: string; + roleArn?: string; }): Promise { - const { profile, accessKey, secretKey, sessionToken, region } = options; + const { profile, accessKey, secretKey, sessionToken, region, roleArn } = + options; if (accessKey || secretKey) { if (!accessKey || !secretKey) { @@ -46,7 +49,7 @@ export async function getAwsConfigFromOptionsOrFile(options: { } return { - credentials: await loadAwsCredentials(profile), + credentials: await loadAwsCredentials(profile, region, roleArn), region: region, }; } @@ -57,6 +60,8 @@ export async function getAwsConfigFromOptionsOrFile(options: { */ async function loadAwsCredentials( profile: string = 'default', + region: string, + roleArn = '', ): Promise { const configFiles = await loadSharedConfigFiles(); @@ -71,34 +76,54 @@ async function loadAwsCredentials( // https://github.com/kamranahmedse/aws-cost-cli/issues/1 // const configFile = configFiles.configFile; // const region: string = configFile?.[profile]?.region; + if (accessKey && secretKey) { + return { + accessKeyId: accessKey, + secretAccessKey: secretKey, + sessionToken: sessionToken, + }; + } else { + try { + const stsClient = new STSClient({ region: region }); + const assumeRoleCommand = new AssumeRoleCommand({ + RoleArn: roleArn, + RoleSessionName: 'aws-cost-cli', + }); + + const { Credentials } = await stsClient.send(assumeRoleCommand); + + if (Credentials) { + return { + accessKeyId: Credentials.AccessKeyId, + secretAccessKey: Credentials.SecretAccessKey, + sessionToken: Credentials.SessionToken, + }; + } + } catch (error) { + console.error('Error fetching temporary credentials:', error); + } - if (!accessKey || !secretKey) { const sharedCredentialsFile = process.env.AWS_SHARED_CREDENTIALS_FILE || '~/.aws/credentials'; const sharedConfigFile = process.env.AWS_CONFIG_FILE || '~/.aws/config'; printFatalError(` Could not find the AWS credentials in the following files for the profile "${profile}": - ${chalk.bold(sharedCredentialsFile)} - ${chalk.bold(sharedConfigFile)} + ${chalk.bold(sharedCredentialsFile)} + ${chalk.bold(sharedConfigFile)} If the config files exist at different locations, set the following environment variables: - ${chalk.bold(`AWS_SHARED_CREDENTIALS_FILE`)} - ${chalk.bold(`AWS_CONFIG_FILE`)} + ${chalk.bold(`AWS_SHARED_CREDENTIALS_FILE`)} + ${chalk.bold(`AWS_CONFIG_FILE`)} You can also configure the credentials via the following command: - ${chalk.bold(`aws configure --profile ${profile}`)} + ${chalk.bold(`aws configure --profile ${profile}`)} You can also provide the credentials via the following options: - ${chalk.bold(`--access-key`)} - ${chalk.bold(`--secret-key`)} - ${chalk.bold(`--region`)} + ${chalk.bold(`--access-key`)} + ${chalk.bold(`--secret-key`)} + ${chalk.bold(`--region`)} + ${chalk.bold(`--role-arn`)} `); } - - return { - accessKeyId: accessKey, - secretAccessKey: secretKey, - sessionToken: sessionToken, - }; } diff --git a/src/index.ts b/src/index.ts index 23ab101..79ecfc0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ program .option('-s, --secret-key [key]', 'AWS secret key') .option('-t, --session-Token [key]', 'AWS session Token') .option('-r, --region [region]', 'AWS region', 'us-east-1') + .option('--role-arn [arn]', 'ARN of IAM role') // Output variants .option('-j, --json', 'Get the output as JSON') .option('-u, --summary', 'Get only the summary without service breakdown') @@ -45,6 +46,7 @@ type OptionsType = { secretKey: string; sessionToken: string; region: string; + roleArn: string; // AWS profile to use profile: string; // Output variants @@ -71,6 +73,7 @@ const awsConfig = await getAwsConfigFromOptionsOrFile({ secretKey: options.secretKey, sessionToken: options.sessionToken, region: options.region, + roleArn: options.roleArn, }); const alias = await getAccountAlias(awsConfig);