Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(dynamic-secrets): memory db

Daniela251777d9b7d
diff --git a/backend/package.json b/backend/package.json
index dbf1642520..5d8d1beb82 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -144,6 +144,7 @@
"@aws-sdk/client-elasticache": "^3.637.0",
"@aws-sdk/client-iam": "^3.525.0",
"@aws-sdk/client-kms": "^3.609.0",
+ "@aws-sdk/client-memorydb": "^3.637.0",
"@aws-sdk/client-route-53": "^3.810.0",
"@aws-sdk/client-s3": "^3.1020.0",
"@aws-sdk/client-secrets-manager": "^3.504.0",
diff --git a/backend/src/ee/services/dynamic-secret/providers/aws-memorydb.ts b/backend/src/ee/services/dynamic-secret/providers/aws-memorydb.ts
new file mode 100644
index 0000000000..2f46e60b04
--- /dev/null
+++ b/backend/src/ee/services/dynamic-secret/providers/aws-memorydb.ts
@@ -0,0 +1,265 @@
+import {
+ CreateUserCommand,
+ DeleteUserCommand,
+ DescribeClustersCommand,
+ MemoryDB,
+ UpdateACLCommand
+} from "@aws-sdk/client-memorydb";
+import handlebars from "handlebars";
+import { customAlphabet } from "nanoid";
+import { z } from "zod";
+
+import { TDynamicSecrets } from "@app/db/schemas";
+import { CustomAWSHasher } from "@app/lib/aws/hashing";
+import { crypto } from "@app/lib/crypto";
+import { BadRequestError } from "@app/lib/errors";
+import { sanitizeString } from "@app/lib/fn";
+import { validateHandlebarTemplate } from "@app/lib/template/validate-handlebars";
+
+import { ActorIdentityAttributes } from "../../dynamic-secret-lease/dynamic-secret-lease-types";
+import { AwsMemoryDbAuthType, DynamicSecretAwsMemoryDbSchema, TDynamicProviderFns } from "./models";
+import { generateUsername } from "./templateUtils";
+
+const CreateMemoryDbUserSchema = z.object({
+ UserName: z.string().trim().min(1),
+ AccessString: z.string().trim().min(1),
+ AuthenticationMode: z.object({
+ Type: z.literal("password"),
+ Passwords: z.array(z.string().trim().min(1)).min(1).max(1)
+ })
+});
+
+const DeleteMemoryDbUserSchema = z.object({
+ UserName: z.string().trim().min(1)
+});
+
+type TMemoryDbUser = { userName: string; password: string };
+type TBasicAWSCredentials = { accessKeyId: string; secretAccessKey: string };
+
+type TCreateMemoryDbUserInput = z.infer<typeof CreateMemoryDbUserSchema>;
+type TDeleteMemoryDbUserInput = z.infer<typeof DeleteMemoryDbUserSchema>;
+
+const MemoryDbUserManager = (credentials: TBasicAWSCredentials, region: string) => {
+ const memorydb = new MemoryDB({
+ region,
+ useFipsEndpoint: crypto.isFipsModeEnabled(),
+ sha256: CustomAWSHasher,
+ credentials
+ });
+
+ const getClusterAcl = async (clusterName: string): Promise<string> => {
+ const cluster = (
+ await memorydb.send(
+ new DescribeClustersCommand({
+ ClusterName: clusterName
+ })
+ )
+ ).Clusters?.[0];
+
+ if (!cluster) {
+ throw new BadRequestError({ message: `MemoryDB cluster ${clusterName} not found` });
+ }
+ if (!cluster.ACLName) {
+ throw new BadRequestError({
+ message: `MemoryDB cluster ${clusterName} has no ACL attached. Attach an ACL to the cluster before using it for dynamic secrets.`
+ });
+ }
+ return cluster.ACLName;
+ };
+
+ const $addUserToAcl = async (aclName: string, userName: string) => {
+ await memorydb.send(
+ new UpdateACLCommand({
+ ACLName: aclName,
+ UserNamesToAdd: [userName],
+ UserNamesToRemove: []
+ })
+ );
+ };
+
+ const createUser = async (creationInput: TCreateMemoryDbUserInput, clusterName: string) => {
+ const aclName = await getClusterAcl(clusterName);
+
+ await memorydb.send(new CreateUserCommand(creationInput));
+ await $addUserToAcl(aclName, creationInput.UserName);
+
+ return {
+ userName: creationInput.UserName,
+ password: creationInput.AuthenticationMode.Passwords[0]
+ };
+ };
+
+ const deleteUser = async (deletionInput: TDeleteMemoryDbUserInput): Promise<Pick<TMemoryDbUser, "userName">> => {
+ await memorydb.send(new DeleteUserCommand(deletionInput));
+ return { userName: deletionInput.UserName };
+ };
+
+ const verifyCredentials = async (clusterName: string) => {
+ await memorydb.send(
+ new DescribeClustersCommand({
+ ClusterName: clusterName
+ })
+ );
+ };
+
+ return {
+ createUser,
+ deleteUser,
+ verifyCredentials
+ };
+};
+
+const generatePassword = () => {
+ const charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~!*";
+ return customAlphabet(charset, 64)();
+};
+
+const $getAwsCredentials = (providerInputs: z.infer<typeof DynamicSecretAwsMemoryDbSchema>): TBasicAWSCredentials => {
+ if (providerInputs.auth.type === AwsMemoryDbAuthType.IAM) {
+ return {
+ accessKeyId: providerInputs.auth.accessKeyId,
+ secretAccessKey: providerInputs.auth.secretAccessKey
+ };
+ }
+ throw new BadRequestError({ message: "Unsupported MemoryDB auth type" });
+};
+
+export const AwsMemoryDbDatabaseProvider = (): TDynamicProviderFns => {
+ const validateProviderInputs = async (inputs: unknown) => {
+ const providerInputs = DynamicSecretAwsMemoryDbSchema.parse(inputs);
+
+ CreateMemoryDbUserSchema.parse(JSON.parse(providerInputs.creationStatement));
+ DeleteMemoryDbUserSchema.parse(JSON.parse(providerInputs.revocationStatement));
+ validateHandlebarTemplate("AWS MemoryDB creation", providerInputs.creationStatement, {
+ allowedExpressions: (val) => ["username", "password", "expiration"].includes(val)
+ });
+ if (providerInputs.revocationStatement) {
+ validateHandlebarTemplate("AWS MemoryDB revoke", providerInputs.revocationStatement, {
+ allowedExpressions: (val) => ["username"].includes(val)
+ });
+ }
+
+ return providerInputs;
+ };
+
+ const validateConnection = async (inputs: unknown) => {
+ const providerInputs = await validateProviderInputs(inputs);
+ const credentials = $getAwsCredentials(providerInputs);
+ try {
+ await MemoryDbUserManager(credentials, providerInputs.region).verifyCredentials(providerInputs.clusterName);
+ return true;
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [
+ credentials.accessKeyId,
+ credentials.secretAccessKey,
+ providerInputs.clusterName,
+ providerInputs.region
+ ]
+ });
+ throw new BadRequestError({
+ message: `Failed to connect with provider: ${sanitizedErrorMessage}`
+ });
+ }
+ };
+
+ const create = async (data: {
+ inputs: unknown;
+ expireAt: number;
+ usernameTemplate?: string | null;
+ identity: ActorIdentityAttributes;
+ dynamicSecret: TDynamicSecrets;
+ }) => {
+ const { inputs, expireAt, usernameTemplate, identity, dynamicSecret } = data;
+ const providerInputs = await validateProviderInputs(inputs);
+ if (!(await validateConnection(providerInputs))) {
+ throw new BadRequestError({ message: "Failed to establish connection" });
+ }
+
+ const credentials = $getAwsCredentials(providerInputs);
+
+ const leaseUsername = await generateUsername(usernameTemplate, {
+ decryptedDynamicSecretInputs: inputs,
+ dynamicSecret,
+ identity,
+ usernameCharset: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-",
+ usernamePrefix: "inf-"
+ });
+ const leasePassword = generatePassword();
+ const leaseExpiration = new Date(expireAt).toISOString();
+
+ const creationStatement = handlebars.compile(providerInputs.creationStatement, { noEscape: true })({
+ username: leaseUsername,
+ password: leasePassword,
+ expiration: leaseExpiration
+ });
+
+ const parsedStatement = CreateMemoryDbUserSchema.parse(JSON.parse(creationStatement));
+
+ try {
+ await MemoryDbUserManager(credentials, providerInputs.region).createUser(
+ parsedStatement,
+ providerInputs.clusterName
+ );
+
+ return {
+ entityId: leaseUsername,
+ data: {
+ DB_USERNAME: leaseUsername,
+ DB_PASSWORD: leasePassword
+ }
+ };
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [
+ leaseUsername,
+ leasePassword,
+ credentials.accessKeyId,
+ credentials.secretAccessKey,
+ providerInputs.clusterName
+ ]
+ });
+ throw new BadRequestError({
+ message: `Failed to create lease from provider: ${sanitizedErrorMessage}`
+ });
+ }
+ };
+
+ const revoke = async (inputs: unknown, entityId: string) => {
+ const providerInputs = await validateProviderInputs(inputs);
+ const credentials = $getAwsCredentials(providerInputs);
+
+ const revokeStatement = handlebars.compile(providerInputs.revocationStatement, { noEscape: true })({
+ username: entityId
+ });
+ const parsedStatement = DeleteMemoryDbUserSchema.parse(JSON.parse(revokeStatement));
+
+ try {
+ await MemoryDbUserManager(credentials, providerInputs.region).deleteUser(parsedStatement);
+
+ return { entityId };
+ } catch (err) {
+ const sanitizedErrorMessage = sanitizeString({
+ unsanitizedString: (err as Error)?.message,
+ tokens: [entityId, credentials.accessKeyId, credentials.secretAccessKey, providerInputs.clusterName]
+ });
+ throw new BadRequestError({
+ message: `Failed to revoke lease from provider: ${sanitizedErrorMessage}`
+ });
+ }
+ };
+
+ const renew = async (_inputs: unknown, entityId: string) => {
+ return { entityId };
+ };
+
+ return {
+ validateProviderInputs,
+ validateConnection,
+ create,
+ revoke,
+ renew
+ };
+};
diff --git a/backend/src/ee/services/dynamic-secret/providers/index.ts b/backend/src/ee/services/dynamic-secret/providers/index.ts
index 10573e1cad..aa0b77cf65 100644
--- a/backend/src/ee/services/dynamic-secret/providers/index.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/index.ts
@@ -4,6 +4,7 @@ import { TGatewayServiceFactory } from "../../gateway/gateway-service";
import { TGatewayV2ServiceFactory } from "../../gateway-v2/gateway-v2-service";
import { AwsElastiCacheDatabaseProvider } from "./aws-elasticache";
import { AwsIamProvider } from "./aws-iam";
+import { AwsMemoryDbDatabaseProvider } from "./aws-memorydb";
import { AzureEntraIDProvider } from "./azure-entra-id";
import { AzureSqlDatabaseProvider } from "./azure-sql-database";
import { CassandraProvider } from "./cassandra";
@@ -41,6 +42,7 @@ export const buildDynamicSecretProviders = ({
[DynamicSecretProviders.AwsIam]: AwsIamProvider(),
[DynamicSecretProviders.Redis]: RedisDatabaseProvider(),
[DynamicSecretProviders.AwsElastiCache]: AwsElastiCacheDatabaseProvider(),
+ [DynamicSecretProviders.AwsMemoryDb]: AwsMemoryDbDatabaseProvider(),
[DynamicSecretProviders.MongoAtlas]: MongoAtlasProvider(),
[DynamicSecretProviders.MongoDB]: MongoDBProvider(),
[DynamicSecretProviders.ElasticSearch]: ElasticSearchProvider(),
diff --git a/backend/src/ee/services/dynamic-secret/providers/models.ts b/backend/src/ee/services/dynamic-secret/providers/models.ts
index 6b04c0da20..2e0e3c5fd2 100644
--- a/backend/src/ee/services/dynamic-secret/providers/models.ts
+++ b/backend/src/ee/services/dynamic-secret/providers/models.ts
@@ -100,6 +100,24 @@ export const DynamicSecretAwsElastiCacheSchema = z.object({
revocationStatement: z.string().trim()
});
+export enum AwsMemoryDbAuthType {
+ IAM = "iam"
+}
+
+export const DynamicSecretAwsMemoryDbSchema = z.object({
+ clusterName: z.string().trim().min(1),
+ auth: z.discriminatedUnion("type", [
+ z.object({
+ type: z.literal(AwsMemoryDbAuthType.IAM),
+ accessKeyId: z.string().trim().min(1),
+ secretAccessKey: z.string().trim().min(1)
+ })
+ ]),
+ region: z.string().trim().min(1),
+ creationStatement: z.string().trim(),
+ revocationStatement: z.string().trim()
+});
+
export const DynamicSecretElasticSearchSchema = z.object({
host: z.string().trim().min(1),
port: z.number(),
@@ -695,6 +713,7 @@ export enum DynamicSecretProviders {
AwsIam = "aws-iam",
Redis = "redis",
AwsElastiCache = "aws-elasticache",
+ AwsMemoryDb = "aws-memorydb",
MongoAtlas = "mongo-db-atlas",
ElasticSearch = "elastic-search",
MongoDB = "mongo-db",
@@ -735,6 +754,7 @@ export const DynamicSecretProviderSchema = z.discriminatedUnion("type", [
z.object({ type: z.literal(DynamicSecretProviders.Redis), inputs: DynamicSecretRedisDBSchema }),
z.object({ type: z.literal(DynamicSecretProviders.SapHana), inputs: DynamicSecretSapHanaSchema }),
z.object({ type: z.literal(DynamicSecretProviders.AwsElastiCache), inputs: DynamicSecretAwsElastiCacheSchema }),
+ z.object({ type: z.literal(DynamicSecretProviders.AwsMemoryDb), inputs: DynamicSecretAwsMemoryDbSchema }),
z.object({ type: z.literal(DynamicSecretProviders.MongoAtlas), inputs: DynamicSecretMongoAtlasSchema }),
z.object({ type: z.literal(DynamicSecretProviders.ElasticSearch), inputs: DynamicSecretElasticSearchSchema }),
z.object({ type: z.literal(DynamicSecretProviders.MongoDB), inputs: DynamicSecretMongoDBSchema }),
diff --git a/frontend/src/hooks/api/dynamicSecret/types.ts b/frontend/src/hooks/api/dynamicSecret/types.ts
index 52c19f37fd..2df02f1d32 100644
--- a/frontend/src/hooks/api/dynamicSecret/types.ts
+++ b/frontend/src/hooks/api/dynamicSecret/types.ts
@@ -24,6 +24,7 @@ export enum DynamicSecretProviders {
AwsIam = "aws-iam",
Redis = "redis",
AwsElastiCache = "aws-elasticache",
+ AwsMemoryDb = "aws-memorydb",
MongoAtlas = "mongo-db-atlas",
ElasticSearch = "elastic-search",
MongoDB = "mongo-db",
@@ -62,6 +63,11 @@ export enum DynamicSecretAwsIamAuth {
IRSA = "irsa"
}
+// currently the only option, but we may want to extend this later to ACL-based auth
+export enum AwsMemoryDbAuthType {
+ IAM = "iam"
+}
+
export enum DynamicSecretAwsIamCredentialType {
IamUser = "iam-user",
TemporaryCredentials = "temporary-credentials"
@@ -159,6 +165,20 @@ export type TDynamicSecretProvider =
ca?: string | undefined;
};
}
+ | {
+ type: DynamicSecretProviders.AwsMemoryDb;
+ inputs: {
+ clusterName: string;
+ region: string;
+ auth: {
+ type: AwsMemoryDbAuthType.IAM;
+ accessKeyId: string;
+ secretAccessKey: string;
+ };
+ creationStatement: string;
+ revocationStatement: string;
+ };
+ }
| {
type: DynamicSecretProviders.MongoAtlas;
inputs: {
diff --git a/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx b/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
index 7fd3057474..5e8fc08863 100644
--- a/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
+++ b/frontend/src/pages/secret-manager/OverviewPage/components/DynamicSecretTableRow/DynamicSecretTableRow.tsx
@@ -41,6 +41,7 @@ const DYNAMIC_SECRET_PROVIDER_NAMES: Record<DynamicSecretProviders, string> = {
[DynamicSecretProviders.AwsIam]: "AWS IAM",
[DynamicSecretProviders.Redis]: "Redis",
[DynamicSecretProviders.AwsElastiCache]: "AWS ElastiCache",
+ [DynamicSecretProviders.AwsMemoryDb]: "AWS MemoryDB",
[DynamicSecretProviders.MongoAtlas]: "Mongo Atlas",
[DynamicSecretProviders.ElasticSearch]: "Elastic Search",
[DynamicSecretProviders.MongoDB]: "Mongo DB",
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsx
new file mode 100644
index 0000000000..cdcf6719cc
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/AwsMemoryDbInputForm.tsx
@@ -0,0 +1,350 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import ms from "ms";
+import { z } from "zod";
+
+import { TtlFormLabel } from "@app/components/features";
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+ Button,
+ FilterableSelect,
+ FormControl,
+ Input,
+ TextArea
+} from "@app/components/v2";
+import { useCreateDynamicSecret } from "@app/hooks/api";
+import { AwsMemoryDbAuthType, DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
+import { ProjectEnv } from "@app/hooks/api/types";
+
+const formSchema = z.object({
+ provider: z.object({
+ clusterName: z.string().trim().min(1),
+ region: z.string().trim().min(1),
+ auth: z.discriminatedUnion("type", [
+ z.object({
+ type: z.literal(AwsMemoryDbAuthType.IAM),
+ accessKeyId: z.string().trim().min(1),
+ secretAccessKey: z.string().trim().min(1)
+ })
+ ]),
+ creationStatement: z.string().trim(),
+ revocationStatement: z.string().trim()
+ }),
+ defaultTTL: z.string().superRefine((val, ctx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ name: z.string().refine((val) => val.toLowerCase() === val, "Must be lowercase"),
+ environment: z.object({ name: z.string(), slug: z.string() }),
+ usernameTemplate: z.string().nullable().optional()
+});
+type TForm = z.infer<typeof formSchema>;
+
+type Props = {
+ onCompleted: () => void;
+ onCancel: () => void;
+ secretPath: string;
+ projectSlug: string;
+ environments: ProjectEnv[];
+ isSingleEnvironmentMode?: boolean;
+};
+
+export const AwsMemoryDbInputForm = ({
+ onCompleted,
+ onCancel,
+ environments,
+ secretPath,
+ projectSlug,
+ isSingleEnvironmentMode
+}: Props) => {
+ const {
+ control,
+ formState: { isSubmitting },
+ handleSubmit
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ defaultValues: {
+ provider: {
+ auth: { type: AwsMemoryDbAuthType.IAM, accessKeyId: "", secretAccessKey: "" },
+ creationStatement: `{
+ "UserName": "{{username}}",
+ "AccessString": "on ~* +@all",
+ "AuthenticationMode": { "Type": "password", "Passwords": ["{{password}}"] }
+}`,
+ revocationStatement: `{
+ "UserName": "{{username}}"
+}`
+ },
+ environment: isSingleEnvironmentMode ? environments[0] : undefined,
+ usernameTemplate: "{{randomUsername}}"
+ }
+ });
+
+ const createDynamicSecret = useCreateDynamicSecret();
+
+ const handleCreateDynamicSecret = async ({
+ name,
+ maxTTL,
+ provider,
+ defaultTTL,
+ environment,
+ usernameTemplate
+ }: TForm) => {
+ if (createDynamicSecret.isPending) return;
+
+ const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
+ await createDynamicSecret.mutateAsync({
+ provider: { type: DynamicSecretProviders.AwsMemoryDb, inputs: provider },
+ maxTTL,
+ name,
+ path: secretPath,
+ defaultTTL,
+ projectSlug,
+ environmentSlug: environment.slug,
+ usernameTemplate:
+ !usernameTemplate || isDefaultUsernameTemplate ? undefined : usernameTemplate
+ });
+ onCompleted();
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit(handleCreateDynamicSecret)} autoComplete="off">
+ <div>
+ <div className="flex items-center space-x-2">
+ <div className="grow">
+ <Controller
+ control={control}
+ defaultValue=""
+ name="name"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="dynamic-secret" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="defaultTTL"
+ defaultValue="1h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Default TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="maxTTL"
+ defaultValue="24h"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Max TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ <div>
+ <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
+ Configuration
+ </div>
+ <div className="flex flex-col">
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="provider.clusterName"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Cluster name"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="my-memorydb-cluster" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="provider.region"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Region"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input placeholder="us-east-1" {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex w-full items-center space-x-2">
+ <Controller
+ control={control}
+ name="provider.auth.accessKeyId"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Key ID"
+ className="w-full"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} autoComplete="off" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.auth.secretAccessKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Access Key"
+ className="w-full"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} type="password" autoComplete="new-password" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div>
+ <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">
+ <AccordionItem value="advance-statements">
+ <AccordionTrigger>Modify MemoryDB Statements</AccordionTrigger>
+ <AccordionContent>
+ <Controller
+ control={control}
+ name="usernameTemplate"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Username Template"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ value={field.value || undefined}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ placeholder="{{randomUsername}}"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.creationStatement"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Creation Statement"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="username, password and expiration are dynamically provisioned"
+ >
+ <TextArea
+ {...field}
+ reSize="none"
+ rows={4}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="provider.revocationStatement"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Revocation Statement"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="username is dynamically provisioned"
+ >
+ <TextArea
+ {...field}
+ reSize="none"
+ rows={3}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ {!isSingleEnvironmentMode && (
+ <Controller
+ control={control}
+ name="environment"
+ render={({ field: { value, onChange }, fieldState: { error } }) => (
+ <FormControl
+ label="Environment"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <FilterableSelect
+ options={environments}
+ value={value}
+ onChange={onChange}
+ placeholder="Select the environment to create secret in..."
+ getOptionLabel={(option) => option.name}
+ getOptionValue={(option) => option.slug}
+ />
+ </FormControl>
+ )}
+ />
+ )}
+ </div>
+ </div>
+ </div>
+ </div>
+ <div className="mt-4 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Submit
+ </Button>
+ <Button variant="outline_bg" onClick={onCancel}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
index f610151aa3..56da897dfb 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/ActionBar/CreateDynamicSecretForm/CreateDynamicSecretForm.tsx
@@ -25,6 +25,7 @@ import { ProjectEnv } from "@app/hooks/api/types";
import { AwsElastiCacheInputForm } from "./AwsElastiCacheInputForm";
import { AwsIamInputForm } from "./AwsIamInputForm";
+import { AwsMemoryDbInputForm } from "./AwsMemoryDbInputForm";
import { AzureEntraIdInputForm } from "./AzureEntraIdInputForm";
import { AzureSqlDatabaseInputForm } from "./AzureSqlDatabaseInputForm";
import { CassandraInputForm } from "./CassandraInputForm";
@@ -82,6 +83,11 @@ const DYNAMIC_SECRET_LIST = [
provider: DynamicSecretProviders.AwsElastiCache,
title: "AWS ElastiCache"
},
+ {
+ icon: <FontAwesomeIcon icon={faAws} size="lg" />,
+ provider: DynamicSecretProviders.AwsMemoryDb,
+ title: "AWS MemoryDB"
+ },
{
icon: <FontAwesomeIcon icon={faAws} size="lg" />,
provider: DynamicSecretProviders.AwsIam,
@@ -313,6 +319,25 @@ export const CreateDynamicSecretForm = ({
/>
</motion.div>
)}
+ {wizardStep === WizardSteps.ProviderInputs &&
+ selectedProvider === DynamicSecretProviders.AwsMemoryDb && (
+ <motion.div
+ key="dynamic-aws-memorydb-step"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <AwsMemoryDbInputForm
+ onCompleted={handleFormReset}
+ onCancel={handleFormReset}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ environments={environments}
+ isSingleEnvironmentMode={isSingleEnvironmentMode}
+ />
+ </motion.div>
+ )}
{wizardStep === WizardSteps.ProviderInputs &&
selectedProvider === DynamicSecretProviders.Cassandra && (
<motion.div
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
index 830bec608a..4fa34e2373 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/CreateDynamicSecretLease.tsx
@@ -197,7 +197,10 @@ const renderOutputForm = (
);
}
- if (provider === DynamicSecretProviders.AwsElastiCache) {
+ if (
+ provider === DynamicSecretProviders.AwsElastiCache ||
+ provider === DynamicSecretProviders.AwsMemoryDb
+ ) {
const { DB_USERNAME, DB_PASSWORD } = data as {
DB_USERNAME: string;
DB_PASSWORD: string;
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsx
new file mode 100644
index 0000000000..39d2cc85fa
--- /dev/null
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretAwsMemoryDbProviderForm.tsx
@@ -0,0 +1,320 @@
+import { Controller, useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import ms from "ms";
+import { z } from "zod";
+
+import { TtlFormLabel } from "@app/components/features";
+import { createNotification } from "@app/components/notifications";
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+ Button,
+ FormControl,
+ Input,
+ TextArea
+} from "@app/components/v2";
+import { useUpdateDynamicSecret } from "@app/hooks/api";
+import { AwsMemoryDbAuthType, TDynamicSecret } from "@app/hooks/api/dynamicSecret/types";
+import { slugSchema } from "@app/lib/schemas";
+
+const formSchema = z.object({
+ inputs: z
+ .object({
+ clusterName: z.string().trim().min(1),
+ region: z.string().trim().min(1),
+ auth: z.discriminatedUnion("type", [
+ z.object({
+ type: z.literal(AwsMemoryDbAuthType.IAM),
+ accessKeyId: z.string().trim().min(1),
+ secretAccessKey: z.string().trim().min(1)
+ })
+ ]),
+ creationStatement: z.string().trim(),
+ revocationStatement: z.string().trim()
+ })
+ .partial(),
+ defaultTTL: z.string().superRefine((val, ctx) => {
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ }),
+ maxTTL: z
+ .string()
+ .optional()
+ .superRefine((val, ctx) => {
+ if (!val) return;
+ const valMs = ms(val);
+ if (valMs < 60 * 1000)
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be a greater than 1min" });
+ if (valMs > ms("10y"))
+ ctx.addIssue({ code: z.ZodIssueCode.custom, message: "TTL must be less than 10 years" });
+ })
+ .nullable(),
+ newName: slugSchema().optional(),
+ usernameTemplate: z.string().trim().nullable().optional()
+});
+type TForm = z.infer<typeof formSchema>;
+
+type Props = {
+ onClose: () => void;
+ dynamicSecret: TDynamicSecret & { inputs: unknown };
+ secretPath: string;
+ environment: string;
+ projectSlug: string;
+};
+
+export const EditDynamicSecretAwsMemoryDbProviderForm = ({
+ onClose,
+ dynamicSecret,
+ environment,
+ secretPath,
+ projectSlug
+}: Props) => {
+ const {
+ control,
+ formState: { isSubmitting },
+ handleSubmit
+ } = useForm<TForm>({
+ resolver: zodResolver(formSchema),
+ values: {
+ defaultTTL: dynamicSecret.defaultTTL,
+ maxTTL: dynamicSecret.maxTTL,
+ newName: dynamicSecret.name,
+ usernameTemplate: dynamicSecret?.usernameTemplate || "{{randomUsername}}",
+ inputs: {
+ ...(dynamicSecret.inputs as TForm["inputs"])
+ }
+ }
+ });
+
+ const updateDynamicSecret = useUpdateDynamicSecret();
+
+ const handleUpdateDynamicSecret = async ({
+ inputs,
+ maxTTL,
+ defaultTTL,
+ newName,
+ usernameTemplate
+ }: TForm) => {
+ if (updateDynamicSecret.isPending) return;
+ const isDefaultUsernameTemplate = usernameTemplate === "{{randomUsername}}";
+ await updateDynamicSecret.mutateAsync({
+ name: dynamicSecret.name,
+ path: secretPath,
+ projectSlug,
+ environmentSlug: environment,
+ data: {
+ maxTTL: maxTTL || undefined,
+ defaultTTL,
+ inputs,
+ newName: newName === dynamicSecret.name ? undefined : newName,
+ usernameTemplate: !usernameTemplate || isDefaultUsernameTemplate ? null : usernameTemplate
+ }
+ });
+ onClose();
+ createNotification({
+ type: "success",
+ text: "Successfully updated dynamic secret"
+ });
+ };
+
+ return (
+ <div>
+ <form onSubmit={handleSubmit(handleUpdateDynamicSecret)} autoComplete="off">
+ <div className="flex items-center space-x-2">
+ <div className="grow">
+ <Controller
+ control={control}
+ name="newName"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Name"
+ isError={Boolean(error)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="DYN-1" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="defaultTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Default TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="w-32">
+ <Controller
+ control={control}
+ name="maxTTL"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label={<TtlFormLabel label="Max TTL" />}
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} value={field.value || ""} />
+ </FormControl>
+ )}
+ />
+ </div>
+ </div>
+ <div>
+ <div className="mt-4 mb-4 border-b border-mineshaft-500 pb-2 pl-1 font-medium text-mineshaft-200">
+ Configuration
+ </div>
+ <div className="flex flex-col">
+ <div className="flex items-center space-x-2">
+ <Controller
+ control={control}
+ name="inputs.clusterName"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Cluster name"
+ className="grow"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} placeholder="my-memorydb-cluster" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ defaultValue=""
+ name="inputs.region"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Region"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input placeholder="us-east-1" {...field} type="text" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div className="flex w-full items-center space-x-2">
+ <Controller
+ control={control}
+ name="inputs.auth.accessKeyId"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Access Key ID"
+ className="w-full"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} autoComplete="off" />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.auth.secretAccessKey"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Secret Access Key"
+ className="w-full"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input {...field} type="password" autoComplete="new-password" />
+ </FormControl>
+ )}
+ />
+ </div>
+ <div>
+ <Accordion type="single" collapsible className="mb-2 w-full bg-mineshaft-700">
+ <AccordionItem value="advance-statements">
+ <AccordionTrigger>Modify MemoryDB Statements</AccordionTrigger>
+ <AccordionContent>
+ <Controller
+ control={control}
+ name="usernameTemplate"
+ defaultValue=""
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Username Template"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ >
+ <Input
+ {...field}
+ value={field.value || undefined}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.creationStatement"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Creation Statement"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="username, password and expiration are dynamically provisioned"
+ >
+ <TextArea
+ {...field}
+ reSize="none"
+ rows={4}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ <Controller
+ control={control}
+ name="inputs.revocationStatement"
+ render={({ field, fieldState: { error } }) => (
+ <FormControl
+ label="Revocation Statement"
+ isError={Boolean(error?.message)}
+ errorText={error?.message}
+ helperText="username is dynamically provisioned"
+ >
+ <TextArea
+ {...field}
+ reSize="none"
+ rows={3}
+ className="border-mineshaft-600 bg-mineshaft-900 text-sm"
+ />
+ </FormControl>
+ )}
+ />
+ </AccordionContent>
+ </AccordionItem>
+ </Accordion>
+ </div>
+ </div>
+ </div>
+ <div className="mt-4 flex items-center space-x-4">
+ <Button type="submit" isLoading={isSubmitting}>
+ Save
+ </Button>
+ <Button variant="outline_bg" onClick={onClose}>
+ Cancel
+ </Button>
+ </div>
+ </form>
+ </div>
+ );
+};
diff --git a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
index ee7d61f0be..7974af258c 100644
--- a/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
+++ b/frontend/src/pages/secret-manager/SecretDashboardPage/components/DynamicSecretListView/EditDynamicSecretForm/EditDynamicSecretForm.tsx
@@ -6,6 +6,7 @@ import { DynamicSecretProviders } from "@app/hooks/api/dynamicSecret/types";
import { EditDynamicSecretAwsElastiCacheProviderForm } from "./EditDynamicSecretAwsElastiCacheProviderForm";
import { EditDynamicSecretAwsIamForm } from "./EditDynamicSecretAwsIamForm";
+import { EditDynamicSecretAwsMemoryDbProviderForm } from "./EditDynamicSecretAwsMemoryDbProviderForm";
import { EditDynamicSecretAzureEntraIdForm } from "./EditDynamicSecretAzureEntraIdForm";
import { EditDynamicSecretAzureSqlDatabaseForm } from "./EditDynamicSecretAzureSqlDatabaseForm";
import { EditDynamicSecretCassandraForm } from "./EditDynamicSecretCassandraForm";
@@ -146,6 +147,23 @@ export const EditDynamicSecretForm = ({
/>
</motion.div>
)}
+ {dynamicSecretDetails?.type === DynamicSecretProviders.AwsMemoryDb && (
+ <motion.div
+ key="aws-memorydb-provider-edit"
+ transition={{ duration: 0.1 }}
+ initial={{ opacity: 0, translateX: 30 }}
+ animate={{ opacity: 1, translateX: 0 }}
+ exit={{ opacity: 0, translateX: -30 }}
+ >
+ <EditDynamicSecretAwsMemoryDbProviderForm
+ onClose={onClose}
+ projectSlug={projectSlug}
+ secretPath={secretPath}
+ dynamicSecret={dynamicSecretDetails}
+ environment={environment}
+ />
+ </motion.div>
+ )}
{dynamicSecretDetails?.type === DynamicSecretProviders.MongoAtlas && (
<motion.div
key="mongo-atlas-edit"