diff --git a/.github/workflows/diff-fdr-dev.yml b/.github/workflows/diff-fdr-dev.yml index c94a01e57d..b8b942c369 100644 --- a/.github/workflows/diff-fdr-dev.yml +++ b/.github/workflows/diff-fdr-dev.yml @@ -1,6 +1,13 @@ name: Diff FDR Dev on: + pull_request: + branches: + - "*" + paths: + - "servers/fdr-deploy/scripts/**" + - ".github/workflows/diff-fdr-dev.yml" + - "pnpm-lock.yaml" push: branches: - "*" diff --git a/servers/fdr-deploy/scripts/elasticache-stack.ts b/servers/fdr-deploy/scripts/elasticache-stack.ts index a4fdd082f6..706039eeac 100644 --- a/servers/fdr-deploy/scripts/elasticache-stack.ts +++ b/servers/fdr-deploy/scripts/elasticache-stack.ts @@ -1,5 +1,5 @@ import { EnvironmentType } from "@fern-fern/fern-cloud-sdk/api"; -import { Environment, Stack, StackProps, Token } from "aws-cdk-lib"; +import { CfnOutput, Environment, Stack, StackProps, Token } from "aws-cdk-lib"; import { IVpc, Peer, Port, SecurityGroup } from "aws-cdk-lib/aws-ec2"; import { CfnReplicationGroup, CfnSubnetGroup } from "aws-cdk-lib/aws-elasticache"; import { Construct } from "constructs"; @@ -72,5 +72,8 @@ export class ElastiCacheStack extends Stack { Port.tcp(Token.asNumber(this.redisEndpointPort)), "Redis Port Ingress rule", ); + + new CfnOutput(this, `${props.cacheName}Host`, { value: this.redisEndpointAddress }); + new CfnOutput(this, `${props.cacheName}Port`, { value: this.redisEndpointPort }); } } diff --git a/servers/fdr-deploy/scripts/fdr-deploy-stack.ts b/servers/fdr-deploy/scripts/fdr-deploy-stack.ts index 29683c6843..2c81228f90 100644 --- a/servers/fdr-deploy/scripts/fdr-deploy-stack.ts +++ b/servers/fdr-deploy/scripts/fdr-deploy-stack.ts @@ -1,5 +1,5 @@ import { EnvironmentInfo, EnvironmentType } from "@fern-fern/fern-cloud-sdk/api"; -import { CfnOutput, Duration, RemovalPolicy, Stack, StackProps } from "aws-cdk-lib"; +import { Duration, RemovalPolicy, Stack, StackProps } from "aws-cdk-lib"; import { Certificate } from "aws-cdk-lib/aws-certificatemanager"; import { Alarm } from "aws-cdk-lib/aws-cloudwatch"; import * as actions from "aws-cdk-lib/aws-cloudwatch-actions"; @@ -21,8 +21,6 @@ const CONTAINER_NAME = "fern-definition-registry"; const SERVICE_NAME = "fdr"; export class FdrDeployStack extends Stack { - private readonly fernDocsCacheEndpoint: string; - constructor( scope: Construct, id: string, @@ -79,6 +77,18 @@ export class FdrDeployStack extends Stack { versioned: true, }); + const fernDocsCache = new ElastiCacheStack(this, "FernDocsCache", { + cacheName: "FernDocsCache", + IVpc: vpc, + numCacheShards: 1, + numCacheReplicasPerShard: environmentType === EnvironmentType.Prod ? 2 : undefined, + clusterMode: "enabled", + cacheNodeType: "cache.r7g.large", + envType: environmentType, + env: props?.env, + ingressSecurityGroup: fdrSg, + }); + const cloudmapNamespaceName = environmentInfo.cloudMapNamespaceInfo.namespaceName; const cloudMapNamespace = PrivateDnsNamespace.fromPrivateDnsNamespaceAttributes(this, "private-cloudmap", { namespaceArn: environmentInfo.cloudMapNamespaceInfo.namespaceArn, @@ -111,6 +121,7 @@ export class FdrDeployStack extends Stack { ALGOLIA_SEARCH_API_KEY: getEnvironmentVariableOrThrow("ALGOLIA_SEARCH_API_KEY"), SLACK_TOKEN: getEnvironmentVariableOrThrow("FERNIE_SLACK_APP_TOKEN"), LOG_LEVEL: getLogLevel(environmentType), + DOCS_CACHE_ENDPOINT: `${fernDocsCache.redisEndpointAddress}:${fernDocsCache.redisEndpointPort}`, ENABLE_CUSTOMER_NOTIFICATIONS: (environmentType === "PROD").toString(), }, containerName: CONTAINER_NAME, @@ -197,20 +208,6 @@ export class FdrDeployStack extends Stack { evaluationPeriods: 5, }); lb500CountAlarm.addAlarmAction(new actions.SnsAction(snsTopic)); - - const fernDocsCache = new ElastiCacheStack(this, "FernDocsElastiCache", { - cacheName: "FernDocsElastiCache", - IVpc: vpc, - numCacheShards: 1, - numCacheReplicasPerShard: environmentType === EnvironmentType.Prod ? 2 : undefined, - clusterMode: "enabled", - cacheNodeType: "cache.r7g.large", - envType: environmentType, - env: props?.env, - }); - - this.fernDocsCacheEndpoint = `${fernDocsCache.redisEndpointAddress}:${fernDocsCache.redisEndpointPort}`; - new CfnOutput(this, "FernDocsCacheEndpoint", { value: this.fernDocsCacheEndpoint }); } }