< Summary - Envilder IaC (CDK)

Information
Class: src/iac/lib/stacks/customStack.ts
Assembly: Default
File(s): src/iac/lib/stacks/customStack.ts
Tag: 151_24479375065
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 56
Line coverage: 88.8%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

src/iac/lib/stacks/customStack.ts

#LineLine coverage
 1import { Stack, type StackProps, Tags } from "aws-cdk-lib";
 2import type { Construct } from "constructs";
 3import type { AppEnvironment } from "../core/types";
 4import { formatRepoNameForCloudFormation } from "./utils";
 5
 6export interface DomainConfig {
 7  subdomain?: string;
 8  domainName: string;
 9  hostedZoneId: string;
 10  certificateId: string;
 11}
 12
 13export interface CustomStackProps extends StackProps {
 14  githubRepo: string;
 15  envName: AppEnvironment;
 16  name: string;
 17  stackName: string;
 18}
 19
 20export class CustomStack extends Stack {
 21  props: CustomStackProps;
 22
 23  constructor(scope: Construct, props: CustomStackProps) {
 124    super(scope, getStackName(props), props);
 25
 126    this.props = props;
 27
 128    this.addProjectTags();
 29  }
 30
 31  getStackId(): string {
 032    return getStackName(this.props);
 33  }
 34
 35  private addProjectTags(): void {
 136    Tags.of(this).add("StackId", getStackName(this.props), {
 37      priority: 300,
 38    });
 39
 140    Tags.of(this).add("Environment", this.props.envName.valueOf(), {
 41      priority: 300,
 42    });
 43
 144    Tags.of(this).add("Project", this.props.githubRepo, {
 45      priority: 300,
 46    });
 47  }
 48
 49  public getCloudFormationRepoName(): string {
 250    return formatRepoNameForCloudFormation(this.props.githubRepo);
 51  }
 52}
 53
 54function getStackName(props: CustomStackProps): string {
 255  return `macalbert-${formatRepoNameForCloudFormation(props.githubRepo)}-${props.name}-${props.envName}-stack`.toLowerCa
 56}