Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
PR fix suggestions for aws secret rotations
carlosmonastyrski5819b8c57699
diff --git a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-constants.ts b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-constants.tsindex b4e0928fc3..1b36b5f308 100644--- a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-constants.ts+++ b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-constants.ts@@ -8,7 +8,7 @@ export const AWS_IAM_USER_SECRET_ROTATION_LIST_OPTION: TSecretRotationV2ListItemconnection: AppConnection.AWS,template: {secretsMapping: {- accessKeyId: "AWS_ACCESS_KEY",+ accessKeyId: "AWS_ACCESS_KEY_ID",secretAccessKey: "AWS_SECRET_ACCESS_KEY"}}diff --git a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.tsindex 1c6e5d3bbd..fe9cd42000 100644--- a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts+++ b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-fns.ts@@ -18,7 +18,7 @@ export const awsIamUserSecretRotationFactory: TRotationFactory<TAwsIamUserSecretRotationGeneratedCredentials> = (secretRotation) => {const {- parameters: { region, clientName },+ parameters: { region, userName },connection,secretsMapping} = secretRotation;@@ -27,26 +27,29 @@ export const awsIamUserSecretRotationFactory: TRotationFactory<const { credentials } = await getAwsConnectionConfig(connection, region);const iam = new AWS.IAM({ credentials });- const { AccessKeyMetadata } = await iam.listAccessKeys({ UserName: clientName }).promise();+ const { AccessKeyMetadata } = await iam.listAccessKeys({ UserName: userName }).promise();if (AccessKeyMetadata && AccessKeyMetadata.length > 0) {- for (const key of AccessKeyMetadata) {- if (key.Status === "Inactive" && key.AccessKeyId) {- // eslint-disable-next-line no-await-in-loop- await iam- .deleteAccessKey({- UserName: clientName,- AccessKeyId: key.AccessKeyId- })- .promise();- }- }+ // Delete inactive keys+ await Promise.all(+ AccessKeyMetadata.map((key) => {+ if (key.Status === "Inactive" && key.AccessKeyId) {+ return iam+ .deleteAccessKey({+ UserName: userName,+ AccessKeyId: key.AccessKeyId+ })+ .promise();+ }+ return Promise.resolve();+ })+ );const activeKey = AccessKeyMetadata.find((k) => k.Status === "Active");if (activeKey && activeKey.AccessKeyId) {await iam.updateAccessKey({- UserName: clientName,+ UserName: userName,AccessKeyId: activeKey.AccessKeyId,Status: "Inactive"})@@ -54,7 +57,7 @@ export const awsIamUserSecretRotationFactory: TRotationFactory<}}- const { AccessKey } = await iam.createAccessKey({ UserName: clientName }).promise();+ const { AccessKey } = await iam.createAccessKey({ UserName: userName }).promise();return {accessKeyId: AccessKey.AccessKeyId,@@ -77,15 +80,16 @@ export const awsIamUserSecretRotationFactory: TRotationFactory<const { credentials } = await getAwsConnectionConfig(connection, region);const iam = new AWS.IAM({ credentials });- for (const generatedCredential of generatedCredentials) {- // eslint-disable-next-line no-await-in-loop- await iam- .deleteAccessKey({- UserName: clientName,- AccessKeyId: generatedCredential.accessKeyId- })- .promise();- }+ await Promise.all(+ generatedCredentials.map((generatedCredential) =>+ iam+ .deleteAccessKey({+ UserName: userName,+ AccessKeyId: generatedCredential.accessKeyId+ })+ .promise()+ )+ );return callback();};diff --git a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-schemas.ts b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-schemas.tsindex 70104d93a5..007a2534ed 100644--- a/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-schemas.ts+++ b/backend/src/ee/services/secret-rotation-v2/aws-iam-user-secret/aws-iam-user-secret-rotation-schemas.ts@@ -20,11 +20,11 @@ export const AwsIamUserSecretRotationGeneratedCredentialsSchema = z.max(2);const AwsIamUserSecretRotationParametersSchema = z.object({- clientName: z+ userName: z.string().trim().min(1, "Client Name Required")- .describe(SecretRotations.PARAMETERS.AWS_IAM_USER_SECRET.clientName),+ .describe(SecretRotations.PARAMETERS.AWS_IAM_USER_SECRET.userName),region: z.nativeEnum(AWSRegion).describe(SecretRotations.PARAMETERS.AWS_IAM_USER_SECRET.region)});diff --git a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.tsindex 74aba0017e..9af78e19a6 100644--- a/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts+++ b/backend/src/ee/services/secret-rotation-v2/secret-rotation-v2-maps.ts@@ -3,7 +3,7 @@ import { AppConnection } from "@app/services/app-connection/app-connection-enumsexport const SECRET_ROTATION_NAME_MAP: Record<SecretRotation, string> = {[SecretRotation.PostgresCredentials]: "PostgreSQL Credentials",- [SecretRotation.MsSqlCredentials]: "Microsoft SQL Sever Credentials",+ [SecretRotation.MsSqlCredentials]: "Microsoft SQL Server Credentials",[SecretRotation.Auth0ClientSecret]: "Auth0 Client Secret",[SecretRotation.AwsIamUserSecret]: "AWS IAM User Secret"};diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.tsindex 70c4b743e1..c128a99a33 100644--- a/backend/src/lib/api-docs/constants.ts+++ b/backend/src/lib/api-docs/constants.ts@@ -2017,7 +2017,7 @@ export const SecretRotations = {clientId: "The client ID of the Auth0 Application to rotate the client secret for."},AWS_IAM_USER_SECRET: {- clientName: "The name of the client to rotate credentials for.",+ userName: "The name of the client to rotate credentials for.",region: "The AWS region to rotate credentials for."}},diff --git a/backend/src/server/routes/v1/app-connection-routers/aws-connection-router.ts b/backend/src/server/routes/v1/app-connection-routers/aws-connection-router.tsindex ff4ef96f93..3226a6aa8f 100644--- a/backend/src/server/routes/v1/app-connection-routers/aws-connection-router.ts+++ b/backend/src/server/routes/v1/app-connection-routers/aws-connection-router.ts@@ -69,7 +69,17 @@ export const registerAwsConnectionRouter = async (server: FastifyZodProvider) =>schema: {params: z.object({connectionId: z.string().uuid()- })+ }),+ response: {+ 200: z.object({+ iamUsers: z+ .object({+ UserName: z.string(),+ Arn: z.string()+ })+ .array()+ })+ }},onRequest: verifyAuth([AuthMode.JWT]),handler: async (req) => {diff --git a/backend/src/services/app-connection/aws/aws-connection-service.ts b/backend/src/services/app-connection/aws/aws-connection-service.tsindex 891d12997d..369116a9cf 100644--- a/backend/src/services/app-connection/aws/aws-connection-service.ts+++ b/backend/src/services/app-connection/aws/aws-connection-service.ts@@ -78,9 +78,16 @@ const listAwsIamUsers = async (appConnection: TAwsConnection) => {const iam = new AWS.IAM({ credentials });- const users = await iam.listUsers().promise();+ const userEntries: AWS.IAM.User[] = [];+ let userMarker: string | undefined;+ do {+ // eslint-disable-next-line no-await-in-loop+ const response = await iam.listUsers({ MaxItems: 100, Marker: userMarker }).promise();+ userEntries.push(...(response.Users || []));+ userMarker = response.Marker;+ } while (userMarker);- return users.Users;+ return userEntries;};export const awsConnectionService = (getAppConnection: TGetAppConnectionFunc) => {diff --git a/docs/documentation/platform/secret-rotation/aws-iam.mdx b/docs/documentation/platform/secret-rotation/aws-iam.mdxindex 01ae7e3f78..ee491eb6ab 100644--- a/docs/documentation/platform/secret-rotation/aws-iam.mdx+++ b/docs/documentation/platform/secret-rotation/aws-iam.mdx@@ -114,7 +114,7 @@ In the following steps, we explore the end-to-end workflow for setting up this s"minutes": 29.5},"parameters": {- "clientName": "<string>",+ "userName": "<string>","region": "us-east-1"},"secretsMapping": {@@ -171,7 +171,7 @@ In the following steps, we explore the end-to-end workflow for setting up this s"lastRotationMessage": "<string>","type": "aws-iam-user-secret","parameters": {- "clientName": "<string>",+ "userName": "<string>","region": "us-east-1"}}diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/AwsIamUserSecretRotationParametersFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/AwsIamUserSecretRotationParametersFields.tsxindex d1429dd552..bc3ce86e8b 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/AwsIamUserSecretRotationParametersFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ParametersFields/AwsIamUserSecretRotationParametersFields.tsx@@ -25,7 +25,7 @@ export const AwsIamUserSecretRotationParametersFields = () => {return (<><Controller- name="parameters.clientName"+ name="parameters.userName"control={control}render={({ field: { value, onChange }, fieldState: { error } }) => (<FormControl@@ -70,13 +70,13 @@ export const AwsIamUserSecretRotationParametersFields = () => {)}/><Controller+ control={control}+ name="parameters.region"render={({ field: { value, onChange }, fieldState: { error } }) => (<FormControl isError={Boolean(error)} errorText={error?.message} label="Region"><AwsRegionSelect value={value} onChange={onChange} /></FormControl>)}- control={control}- name="parameters.region"/></>);diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/AwsIamUserSecretRotationReviewFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/AwsIamUserSecretRotationReviewFields.tsxindex c685691dcd..d84c0753fd 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/AwsIamUserSecretRotationReviewFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2ReviewFields/AwsIamUserSecretRotationReviewFields.tsx@@ -19,11 +19,11 @@ export const AwsIamUserSecretRotationReviewFields = () => {<><SecretRotationReviewSection label="Parameters"><GenericFieldLabel label="Region">{parameters.region}</GenericFieldLabel>- <GenericFieldLabel label="User Name">{parameters.clientName}</GenericFieldLabel>+ <GenericFieldLabel label="User Name">{parameters.userName}</GenericFieldLabel></SecretRotationReviewSection><SecretRotationReviewSection label="Secrets Mapping">- <GenericFieldLabel label="Access Key ID">{accessKeyId}</GenericFieldLabel>- <GenericFieldLabel label="Access Key Secret">{secretAccessKey}</GenericFieldLabel>+ <GenericFieldLabel label="Secret Access Key ID">{accessKeyId}</GenericFieldLabel>+ <GenericFieldLabel label="Secret Access Key">{secretAccessKey}</GenericFieldLabel></SecretRotationReviewSection></>);diff --git a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/AwsIamUserSecretRotationSecretsMappingFields.tsx b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/AwsIamUserSecretRotationSecretsMappingFields.tsxindex f7b32494de..2c64321224 100644--- a/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/AwsIamUserSecretRotationSecretsMappingFields.tsx+++ b/frontend/src/components/secret-rotations-v2/forms/SecretRotationV2SecretsMappingFields/AwsIamUserSecretRotationSecretsMappingFields.tsx@@ -35,7 +35,7 @@ export const AwsIamUserSecretRotationSecretsMappingFields = () => {)},{- name: "Client Secret",+ name: "Secret Access Key",input: (<Controllerrender={({ field: { value, onChange }, fieldState: { error } }) => (diff --git a/frontend/src/components/secret-rotations-v2/forms/schemas/aws-iam-user-secret-rotation-schema.ts b/frontend/src/components/secret-rotations-v2/forms/schemas/aws-iam-user-secret-rotation-schema.tsindex 799ec22a5b..9481d400cc 100644--- a/frontend/src/components/secret-rotations-v2/forms/schemas/aws-iam-user-secret-rotation-schema.ts+++ b/frontend/src/components/secret-rotations-v2/forms/schemas/aws-iam-user-secret-rotation-schema.ts@@ -7,7 +7,7 @@ export const AwsIamUserSecretRotationSchema = z.object({type: z.literal(SecretRotation.AwsIamUserSecret),parameters: z.object({- clientName: z.string().trim().min(1, "Client Name required"),+ userName: z.string().trim().min(1, "User Name required"),region: z.string().trim().min(1, "Region required")}),secretsMapping: z.object({diff --git a/frontend/src/hooks/api/appConnections/aws/types.ts b/frontend/src/hooks/api/appConnections/aws/types.tsindex 8509344eaf..d2c7c39cb9 100644--- a/frontend/src/hooks/api/appConnections/aws/types.ts+++ b/frontend/src/hooks/api/appConnections/aws/types.ts@@ -28,7 +28,4 @@ export type TAwsConnectionListIamUsersResponse = {iamUsers: TAwsConnectionIamUser[];};-export type TAwsIamUserSecret = {- arn: string;- UserName: string;-};+export type TAwsIamUserSecret = TAwsConnectionIamUser;diff --git a/frontend/src/hooks/api/secretRotationsV2/types/aws-iam-access-key-rotation.ts b/frontend/src/hooks/api/secretRotationsV2/types/aws-iam-user-secret-rotation.tssimilarity index 97%rename from frontend/src/hooks/api/secretRotationsV2/types/aws-iam-access-key-rotation.tsrename to frontend/src/hooks/api/secretRotationsV2/types/aws-iam-user-secret-rotation.tsindex 70d6a74e0c..20f1c874ce 100644--- a/frontend/src/hooks/api/secretRotationsV2/types/aws-iam-access-key-rotation.ts+++ b/frontend/src/hooks/api/secretRotationsV2/types/aws-iam-user-secret-rotation.ts@@ -9,7 +9,7 @@ export type TAwsIamUserSecretRotation = TSecretRotationV2Base & {type: SecretRotation.AwsIamUserSecret;parameters: {region: string;- clientName: string;+ userName: string;};secretsMapping: {accessKeyId: string;diff --git a/frontend/src/hooks/api/secretRotationsV2/types/index.ts b/frontend/src/hooks/api/secretRotationsV2/types/index.tsindex af860e40e8..212175ae09 100644--- a/frontend/src/hooks/api/secretRotationsV2/types/index.ts+++ b/frontend/src/hooks/api/secretRotationsV2/types/index.ts@@ -8,7 +8,7 @@ import {TAwsIamUserSecretRotation,TAwsIamUserSecretRotationGeneratedCredentialsResponse,TAwsIamUserSecretRotationOption-} from "@app/hooks/api/secretRotationsV2/types/aws-iam-access-key-rotation";+} from "@app/hooks/api/secretRotationsV2/types/aws-iam-user-secret-rotation";import {TMsSqlCredentialsRotation,TMsSqlCredentialsRotationGeneratedCredentialsResponse