@@ -5,40 +5,62 @@ import {
55 StackProps
66} from "aws-cdk-lib"
77import { AwsSolutionsChecks } from "cdk-nag"
8- import { getConfigFromEnvVar , getBooleanConfigFromEnvVar , calculateVersionedStackName } from "../config"
8+ import { getConfigFromEnvVar , getBooleanConfigFromEnvVar } from "../config"
99
1010export interface StandardStackProps extends StackProps {
11- readonly stackName : string
11+ /** Semantic version of the deployment (from `versionNumber`). */
1212 readonly version : string
13+ /** Git commit identifier baked into the stack. */
1314 readonly commitId : string
15+ /** Whether the stack originates from a pull-request environment. */
1416 readonly isPullRequest : boolean
17+ /** Logical environment identifier (for example `dev`, `prod`). */
1518 readonly environment : string
19+ /** CDK environment configuration used when synthesizing the stack. */
20+ readonly env : {
21+ /** AWS region targeted by the stack. */
22+ readonly region : string
23+ }
1624}
1725
1826export interface CreateAppParams {
1927 readonly productName : string
2028 readonly appName : string
2129 readonly repoName : string
2230 readonly driftDetectionGroup : string
23- readonly isStateless ?: boolean
2431 readonly region ?: string
2532 readonly projectType ?: string
2633 readonly publicFacing ?: string
2734 readonly serviceCategory ?: string
2835}
2936
37+ /**
38+ * Initialize a CDK `App` pre-loaded with NHS EPS tags and mandatory configuration.
39+ *
40+ * Reads stack metadata from environment variables, and returns
41+ * both the created `App` instance and the resolved stack props (including version info).
42+ *
43+ * @param params - High-level app metadata and optional deployment modifiers.
44+ * @param params.productName - Product tag value for the stack.
45+ * @param params.appName - Identifier used for `cdkApp` tagging.
46+ * @param params.repoName - Repository name stored on the stack tags.
47+ * @param params.driftDetectionGroup - Baseline drift detection tag (suffixes `-pull-request` when `isPullRequest`).
48+ * @param params.region - AWS region assigned to the stack environment (default `eu-west-2`).
49+ * @param params.projectType - Tag describing the project classification (default `Production`).
50+ * @param params.publicFacing - Public-facing classification tag (default `Y`).
51+ * @param params.serviceCategory - Service category tag (default `Platinum`).
52+ * @returns The constructed CDK `App` and the resolved stack props for downstream stacks.
53+ */
3054export function createApp ( {
3155 productName,
3256 appName,
3357 repoName,
3458 driftDetectionGroup,
35- isStateless = true ,
3659 region = "eu-west-2" ,
3760 projectType = "Production" ,
3861 publicFacing = "Y" ,
3962 serviceCategory = "Platinum"
4063} : CreateAppParams ) : { app : App , props : StandardStackProps } {
41- let stackName = getConfigFromEnvVar ( "stackName" )
4264 const versionNumber = getConfigFromEnvVar ( "versionNumber" )
4365 const commitId = getConfigFromEnvVar ( "commitId" )
4466 const isPullRequest = getBooleanConfigFromEnvVar ( "isPullRequest" )
@@ -68,22 +90,16 @@ export function createApp({
6890 Tags . of ( app ) . add ( "DeploymentTool" , "CDK" )
6991 Tags . of ( app ) . add ( "version" , versionNumber )
7092 Tags . of ( app ) . add ( "commit" , commitId )
71- Tags . of ( app ) . add ( "stackName" , stackName )
7293 Tags . of ( app ) . add ( "cdkApp" , appName )
7394 Tags . of ( app ) . add ( "repo" , repoName )
7495 Tags . of ( app ) . add ( "cfnDriftDetectionGroup" , cfnDriftDetectionGroup )
7596
76- if ( isStateless && ! isPullRequest ) {
77- stackName = calculateVersionedStackName ( stackName , versionNumber )
78- }
79-
8097 return {
8198 app,
8299 props : {
83100 env : {
84101 region
85102 } ,
86- stackName,
87103 version : versionNumber ,
88104 commitId,
89105 isPullRequest,
0 commit comments