Skip to content

Commit cff8f68

Browse files
committed
Adjust rest api gateway to work around mTLS naming issues where required
1 parent 615765c commit cff8f68

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

packages/cdkConstructs/src/constructs/RestApiGateway.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import {addSuppressions} from "../utils/helpers"
4040
export interface RestApiGatewayProps {
4141
/** Stack name, used as prefix for resource naming and DNS records. */
4242
readonly stackName: string
43+
/** Stack UUID, used as a unique identifier for the stack. Optional */
44+
readonly stackUUID?: string
4345
/** Shared retention period for API and deployment-related log groups. */
4446
readonly logRetentionInDays: number
4547
/** Truststore object key to enable mTLS; leave undefined to disable mTLS or when enableServiceDomain is false. */
@@ -56,6 +58,14 @@ export interface RestApiGatewayProps {
5658
readonly enableServiceDomain?: boolean
5759
}
5860

61+
const function getTrustStoreKeyPrefix(stackName: string, stackUUID?: string) {
62+
if (stackUUID) {
63+
return `cpt-api/${stackName}-${stackUUID}-truststore`
64+
} else {
65+
return `cpt-api/${props.stackName}-truststore`
66+
}
67+
}
68+
5969
/** Creates a regional REST API with standard logging, DNS, and optional mTLS/CSOC integration. */
6070
export class RestApiGateway extends Construct {
6171
/** Created API Gateway instance. */
@@ -158,7 +168,7 @@ export class RestApiGateway extends Construct {
158168
let mtlsConfig: MTLSConfig | undefined
159169

160170
if (enableServiceDomain && props.mutualTlsTrustStoreKey) {
161-
const trustStoreKeyPrefix = `cpt-api/${props.stackName}-truststore`
171+
const trustStoreKeyPrefix = getTrustStoreKeyPrefix(props.stackName, props.stackUUID)
162172
const logGroup = new LogGroup(this, "LambdaLogGroup", {
163173
encryptionKey: cloudWatchLogsKmsKey,
164174
logGroupName: `/aws/lambda/${props.stackName}-truststore-deployment`,

0 commit comments

Comments
 (0)