Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(infrastructure): allow stackName to be configurable #617

Merged
merged 1 commit into from
Oct 29, 2023
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
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
Loading