Skip to content

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

add region

Matheus Nogueira8935076413fa
diff --git a/backend/src/ee/routes/v1/honey-token-router.ts b/backend/src/ee/routes/v1/honey-token-router.ts
index c0d0bfdb9e..57e803cb12 100644
--- a/backend/src/ee/routes/v1/honey-token-router.ts
+++ b/backend/src/ee/routes/v1/honey-token-router.ts
@@ -425,7 +425,9 @@ export const registerHoneyTokenRouter = async (server: FastifyZodProvider) => {
connectionId: z.string().nullable(),
createdAt: z.date().nullable(),
updatedAt: z.date().nullable(),
- decryptedConfig: z.object({ webhookSigningKey: z.string(), stackName: z.string() }).nullable()
+ decryptedConfig: z
+ .object({ webhookSigningKey: z.string(), stackName: z.string(), awsRegion: z.string() })
+ .nullable()
})
})
}
diff --git a/backend/src/ee/services/honey-token/honey-token-config-service.ts b/backend/src/ee/services/honey-token/honey-token-config-service.ts
index c28d397db1..8afec5a46b 100644
--- a/backend/src/ee/services/honey-token/honey-token-config-service.ts
+++ b/backend/src/ee/services/honey-token/honey-token-config-service.ts
@@ -68,10 +68,12 @@ export const honeyTokenConfigServiceFactory = ({
}: THoneyTokenConfigServiceFactoryDep) => {
const verifyStackDeployment = async ({
connectionId: connId,
- stackName
+ stackName,
+ awsRegion
}: {
connectionId: string;
stackName: string;
+ awsRegion: string;
}): Promise<{ deployed: boolean; status: string | null }> => {
try {
const appConnection = await appConnectionDAL.findById(connId);
@@ -83,7 +85,7 @@ export const honeyTokenConfigServiceFactory = ({
const awsConfig = decryptedConnection as unknown as TAwsConnectionConfig;
const { credentials: awsCredentials } = await getAwsConnectionConfig(awsConfig);
- const cfn = new CloudFormationClient({ credentials: awsCredentials, region: "us-east-1" });
+ const cfn = new CloudFormationClient({ credentials: awsCredentials, region: awsRegion });
const res = await cfn.send(new DescribeStacksCommand({ StackName: stackName }));
const stack = res.Stacks?.[0];
@@ -111,8 +113,8 @@ export const honeyTokenConfigServiceFactory = ({
}
logger.warn(
- { err, connectionId: connId, stackName },
- `Failed to verify CloudFormation stack [stackName=${stackName}]`
+ { err, connectionId: connId, stackName, awsRegion },
+ `Failed to verify CloudFormation stack [stackName=${stackName}] [awsRegion=${awsRegion}]`
);
return { deployed: false, status: null };
}
@@ -127,7 +129,7 @@ export const honeyTokenConfigServiceFactory = ({
orgPermission: OrgServiceActor;
type: HoneyTokenType;
connectionId: string;
- config: { webhookSigningKey: string; stackName?: string };
+ config: { webhookSigningKey: string; stackName?: string; awsRegion?: string };
}) => {
const { permission } = await permissionService.getOrgPermission({
scope: OrganizationActionScope.Any,
@@ -211,7 +213,8 @@ export const honeyTokenConfigServiceFactory = ({
const stackDeployment = await verifyStackDeployment({
connectionId: config.connectionId,
- stackName: storedConfig.stackName
+ stackName: storedConfig.stackName,
+ awsRegion: storedConfig.awsRegion
});
return {
@@ -247,7 +250,11 @@ export const honeyTokenConfigServiceFactory = ({
connectionId: null,
createdAt: null,
updatedAt: null,
- decryptedConfig: { webhookSigningKey: generatedKey, stackName: "infisical-honey-tokens" }
+ decryptedConfig: {
+ webhookSigningKey: generatedKey,
+ stackName: "infisical-honey-tokens",
+ awsRegion: "us-east-1"
+ }
};
}
@@ -256,7 +263,7 @@ export const honeyTokenConfigServiceFactory = ({
orgId: orgPermission.orgId
});
- let decryptedConfig: { webhookSigningKey: string; stackName: string } | null = null;
+ let decryptedConfig: { webhookSigningKey: string; stackName: string; awsRegion: string } | null = null;
if (config.encryptedConfig) {
const decrypted = decryptor({
cipherTextBlob: config.encryptedConfig
diff --git a/backend/src/ee/services/honey-token/honey-token-types.ts b/backend/src/ee/services/honey-token/honey-token-types.ts
index 7e2905bbeb..62ec7f2d6b 100644
--- a/backend/src/ee/services/honey-token/honey-token-types.ts
+++ b/backend/src/ee/services/honey-token/honey-token-types.ts
@@ -33,7 +33,8 @@ export type THoneyTokenEventMetadata = z.infer<typeof HoneyTokenEventMetadataSch
export const AwsHoneyTokenConfigSchema = z.object({
webhookSigningKey: z.string().min(1),
- stackName: z.string().min(1).max(128).default("infisical-honey-tokens")
+ stackName: z.string().min(1).max(128).default("infisical-honey-tokens"),
+ awsRegion: z.string().min(1).default("us-east-1")
});
export type TAwsHoneyTokenConfig = z.infer<typeof AwsHoneyTokenConfigSchema>;
diff --git a/frontend/src/hooks/api/honeyToken/types.ts b/frontend/src/hooks/api/honeyToken/types.ts
index bfa3c26468..a1a9d47ee7 100644
--- a/frontend/src/hooks/api/honeyToken/types.ts
+++ b/frontend/src/hooks/api/honeyToken/types.ts
@@ -12,6 +12,7 @@ export type THoneyTokenConfig = {
decryptedConfig: {
webhookSigningKey: string;
stackName: string;
+ awsRegion: string;
} | null;
};
@@ -21,5 +22,6 @@ export type TUpsertHoneyTokenConfigDTO = {
config: {
webhookSigningKey: string;
stackName?: string;
+ awsRegion?: string;
};
};
diff --git a/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/HoneyTokenModal.tsx b/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/HoneyTokenModal.tsx
index b500d28903..56def8d114 100644
--- a/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/HoneyTokenModal.tsx
+++ b/frontend/src/pages/organization/SettingsPage/components/OrgProductSettingsTab/HoneyTokenModal.tsx
@@ -37,11 +37,13 @@ const CF_TEMPLATE_URL =
"https://infisical-static-assets.s3.us-east-1.amazonaws.com/honey-tokens/honey-tokens-v1.yaml";
const DEFAULT_STACK_NAME = "infisical-honey-tokens";
+const DEFAULT_AWS_REGION = "us-east-1";
const schema = z.object({
connectionId: z.string().min(1, "AWS Connection is required"),
webhookSigningKey: z.string().min(1, "Webhook Signing Key is required"),
- stackName: z.string().trim().min(1, "Stack name is required").max(128)
+ stackName: z.string().trim().min(1, "Stack name is required").max(128),
+ awsRegion: z.string().trim().min(1, "AWS region is required")
});
type FormData = z.infer<typeof schema>;
@@ -80,7 +82,8 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
defaultValues: {
connectionId: "",
webhookSigningKey: "",
- stackName: DEFAULT_STACK_NAME
+ stackName: DEFAULT_STACK_NAME,
+ awsRegion: DEFAULT_AWS_REGION
}
});
@@ -90,7 +93,8 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
reset({
connectionId: existingConfig.connectionId ?? "",
webhookSigningKey: existingConfig.decryptedConfig.webhookSigningKey,
- stackName: existingConfig.decryptedConfig.stackName ?? DEFAULT_STACK_NAME
+ stackName: existingConfig.decryptedConfig.stackName ?? DEFAULT_STACK_NAME,
+ awsRegion: existingConfig.decryptedConfig.awsRegion ?? DEFAULT_AWS_REGION
});
}, [existingConfig, reset]);
@@ -101,25 +105,28 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
reset({
connectionId: existingConfig.connectionId ?? "",
webhookSigningKey: existingConfig.decryptedConfig.webhookSigningKey,
- stackName: existingConfig.decryptedConfig.stackName ?? DEFAULT_STACK_NAME
+ stackName: existingConfig.decryptedConfig.stackName ?? DEFAULT_STACK_NAME,
+ awsRegion: existingConfig.decryptedConfig.awsRegion ?? DEFAULT_AWS_REGION
});
} else {
reset({
connectionId: "",
webhookSigningKey: "",
- stackName: DEFAULT_STACK_NAME
+ stackName: DEFAULT_STACK_NAME,
+ awsRegion: DEFAULT_AWS_REGION
});
}
}, [isOpen]); // eslint-disable-line react-hooks/exhaustive-deps
const webhookSigningKey = watch("webhookSigningKey");
const stackName = watch("stackName");
+ const awsRegion = watch("awsRegion");
const cfCommand = useMemo(
() =>
[
"aws cloudformation create-stack \\",
- " --region us-east-1 \\",
+ ` --region ${awsRegion || DEFAULT_AWS_REGION} \\`,
` --stack-name ${stackName || DEFAULT_STACK_NAME} \\`,
` --template-url ${CF_TEMPLATE_URL} \\`,
" --capabilities CAPABILITY_NAMED_IAM \\",
@@ -127,7 +134,7 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
` ParameterKey=WebhookUrl,ParameterValue=${webhookUrl} \\`,
` ParameterKey=WebhookSigningKey,ParameterValue=${webhookSigningKey}`
].join("\n"),
- [stackName, webhookSigningKey, webhookUrl]
+ [awsRegion, stackName, webhookSigningKey, webhookUrl]
);
const onSubmit = async (data: FormData) => {
@@ -137,7 +144,8 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
connectionId: data.connectionId,
config: {
webhookSigningKey: data.webhookSigningKey,
- stackName: data.stackName
+ stackName: data.stackName,
+ awsRegion: data.awsRegion
}
});
createNotification({
@@ -260,6 +268,19 @@ export const HoneyTokenModal = ({ isOpen, onOpenChange }: Props) => {
</Field>
)}
/>
+ <Controller
+ control={control}
+ name="awsRegion"
+ render={({ field, fieldState: { error } }) => (
+ <Field>
+ <FieldLabel>AWS Region</FieldLabel>
+ <FieldContent>
+ <Input {...field} placeholder={DEFAULT_AWS_REGION} isError={Boolean(error)} />
+ <FieldError errors={[error]} />
+ </FieldContent>
+ </Field>
+ )}
+ />
</AccordionContent>
</AccordionItem>
</Accordion>