Skip to content

Commit

Permalink
feat(infrastructure): allow stackName to be configurable (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
agdimech authored Oct 29, 2023
1 parent 4057d69 commit e1a6e49
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Main {
.nagPacks(Arrays.asList(new AwsPrototypingChecks()))
.build());
new ApplicationStack(app, "infra-dev", StackProps.builder()
new ApplicationStack(app, "{{{stackName}}}", StackProps.builder()
.env(Environment.builder()
.account(System.getenv("CDK_DEFAULT_ACCOUNT"))
.region(System.getenv("CDK_DEFAULT_REGION"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dev_env = Environment(
)

app = PDKNag.app(nag_packs=[AwsPrototypingChecks()])
ApplicationStack(app, "infra-dev", env=dev_env)
ApplicationStack(app, "{{{stackName}}}", env=dev_env)

graph = CdkGraph(app, plugins=[CdkGraphDiagramPlugin(
defaults=IDiagramConfigBase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const devEnv = {
nagPacks: [new AwsPrototypingChecks()],
});

new ApplicationStack(app, "infra-dev", { env: devEnv });
new ApplicationStack(app, "{{{stackName}}}", { env: devEnv });

const graph = new CdkGraph(app, {
plugins: [
Expand Down
3 changes: 3 additions & 0 deletions packages/infrastructure/src/consts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0 */
export const DEFAULT_STACK_NAME = "infra-dev";
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import * as Mustache from "mustache";
import { SampleFile } from "projen";
import { AwsCdkJavaApp } from "projen/lib/awscdk";
import { AwsCdkJavaAppOptions } from "./aws-cdk-java-app-options";
import { DEFAULT_STACK_NAME } from "../../consts";

/**
* Configuration options for the InfrastructureJavaProject.
*/
export interface InfrastructureJavaProjectOptions extends AwsCdkJavaAppOptions {
/**
* Stack name.
*
* @default infra-dev
*/
readonly stackName?: string;

/**
* TypeSafeApi instance to use when setting up the initial project sample code.
*/
Expand Down Expand Up @@ -110,6 +118,7 @@ export class InfrastructureJavaProject extends AwsCdkJavaApp {
const mustacheConfig = {
hasApi,
hasWebsite,
stackName: options.stackName || DEFAULT_STACK_NAME,
infraPackage: `${options.typeSafeApi?.infrastructure.java?.pom.groupId}.${options.typeSafeApi?.infrastructure.java?.pom.name}.infra`,
groupId,
websiteDistRelativePath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ import * as Mustache from "mustache";
import { SampleFile } from "projen";
import { AwsCdkPythonApp } from "projen/lib/awscdk";
import { AwsCdkPythonAppOptions } from "./aws-cdk-py-app-options";
import { DEFAULT_STACK_NAME } from "../../consts";

/**
* Configuration options for the InfrastructurePyProject.
*/
export interface InfrastructurePyProjectOptions extends AwsCdkPythonAppOptions {
/**
* Stack name.
*
* @default infra-dev
*/
readonly stackName?: string;

/**
* TypeSafeApi instance to use when setting up the initial project sample code.
*/
Expand Down Expand Up @@ -96,6 +104,7 @@ export class InfrastructurePyProject extends AwsCdkPythonApp {
const mustacheConfig = {
hasApi,
hasWebsite,
stackName: options.stackName || DEFAULT_STACK_NAME,
infraPackage: options.typeSafeApi?.infrastructure.python?.moduleName,
moduleName,
websiteDistRelativePath:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,20 @@ import { SampleFile } from "projen";
import { AwsCdkTypeScriptApp } from "projen/lib/awscdk";
import { NodeProject } from "projen/lib/javascript";
import { AwsCdkTypeScriptAppOptions } from "./aws-cdk-ts-app-options";
import { DEFAULT_STACK_NAME } from "../../consts";

/**
* Configuration options for the InfrastructureTsProject.
*/
export interface InfrastructureTsProjectOptions
extends AwsCdkTypeScriptAppOptions {
/**
* Stack name.
*
* @default infra-dev
*/
readonly stackName?: string;

/**
* TypeSafeApi instance to use when setting up the initial project sample code.
*/
Expand Down Expand Up @@ -91,6 +99,7 @@ export class InfrastructureTsProject extends AwsCdkTypeScriptApp {
const mustacheConfig = {
hasApi,
hasWebsite,
stackName: options.stackName || DEFAULT_STACK_NAME,
infraPackage:
options.typeSafeApi?.infrastructure.typescript?.package.packageName,
websiteDistRelativePath:
Expand Down

0 comments on commit e1a6e49

Please sign in to comment.