Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions packages/deploymentUtils/src/specifications/deployApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export type ApiConfig = {
mtlsSecretName: string
clientCert: string
clientPrivateKey: string
proxygenPrivateKeyExportName: string
proxygenPrivateKeyExportName: string | undefined
proxygenKid: string
hiddenPaths: Array<string>
proxygenSecretBaseName: string | undefined
}

export async function deployApi(
Expand All @@ -32,9 +33,11 @@ export async function deployApi(
mtlsSecretName,
clientCert,
clientPrivateKey,
proxygenPrivateKeyExportName,
proxygenPrivateKeyExportName, // Use for prod proxygen, e.g ClinicalTrackerProxygenPrivateKey
proxygenKid,
hiddenPaths
hiddenPaths,
// eslint-disable-next-line max-len
proxygenSecretBaseName = undefined // Use for PTL proxygen, defaulted for backwards compatibility, e.g ClinicalTrackerProxygen
}: ApiConfig,
blueGreen: boolean,
dryRun: boolean
Expand All @@ -53,7 +56,11 @@ export async function deployApi(
})

const exports = await getCloudFormationExports()
const proxygenPrivateKeyArn = getCFConfigValue(exports, `secrets-cdk:Secrets:${proxygenPrivateKeyExportName}:Arn`)
/* Note: This secret name logic and the use of proxygenPrivateKeyExportName probably wants to eventually be phased out
for cleanliness/consistency in favour of using proxygenSecretBaseName for all and determining which proxygen to use
based on the provided apigeeEnvironment */
const proxygenSecretName = proxygenSecretBaseName || getCFConfigValue(
exports, `secrets-cdk:Secrets:${proxygenPrivateKeyExportName}:Arn`)

let put_secret_lambda = "lambda-resources-ProxygenPTLMTLSSecretPut"
let instance_put_lambda = "lambda-resources-ProxygenPTLInstancePut"
Expand All @@ -77,7 +84,7 @@ export async function deployApi(
secretKey: clientPrivateKey,
secretCert: clientCert,
kid: proxygenKid,
proxygenSecretName: proxygenPrivateKeyArn
proxygenSecretName
}
)
}
Expand All @@ -93,7 +100,7 @@ export async function deployApi(
specDefinition: spec,
instance,
kid: proxygenKid,
proxygenSecretName: proxygenPrivateKeyArn
proxygenSecretName
}
)

Expand Down Expand Up @@ -121,7 +128,7 @@ export async function deployApi(
specDefinition: spec,
instance,
kid: proxygenKid,
proxygenSecretName: proxygenPrivateKeyArn
proxygenSecretName
}
)
}
Expand Down
20 changes: 20 additions & 0 deletions packages/deploymentUtils/tests/specifications/deployApi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ function buildConfig(overrides: Partial<ApiConfig> = {}): ApiConfig {
proxygenPrivateKeyExportName: "proxygenKey",
proxygenKid: "kid-123",
hiddenPaths: [],
proxygenSecretBaseName: undefined,
...overrides
}
}
Expand Down Expand Up @@ -255,4 +256,23 @@ describe("deployApi", () => {
false
)).rejects.toThrow("Error calling lambda lambda-resources-ProxygenProdMTLSSecretPut: \"bad\"")
})

test("uses only the secret name when using ptl proxygen", async () => {
await deployApi(
buildConfig({
version: "2.0.0",
apigeeEnvironment: "internal-dev",
stackName: "eps-stack",
proxygenPrivateKeyExportName: "ptl-proxygen-private-key",
proxygenSecretBaseName: "ptl-proxygen"
}),
true,
false
)

const secretPayload = payloadFromCall(0)
expect(secretPayload).toMatchObject({
proxygenSecretName: "ptl-proxygen"
})
})
})