-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infrastructure): add deploy:dev task to infrastructure projects …
…for cdk hotswap deployment Adds a `deploy:dev` task to the infrastructure projects which perform a CDK hotswap deployment if possible in order to reduce dev cycle times. Given the dev cycle time reduction we consider this a better option than a local dev server, since local dev server requires managing credentials locally, as well as things like environment variables for pointing to other resources (eg ddb tables). Fixes #599
- Loading branch information
Showing
11 changed files
with
301 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/infrastructure/src/components/infrastructure-commands.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*! Copyright [Amazon.com](http://amazon.com/), Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 */ | ||
import { ProjectUtils } from "@aws/monorepo"; | ||
import { Component, Project } from "projen"; | ||
|
||
/** | ||
* Common commands for infrastructure projects | ||
*/ | ||
export class InfrastructureCommands extends Component { | ||
/** | ||
* Retrieves an instance of InfrastructureCommands if one is associated to the given project | ||
* @param project project instance | ||
*/ | ||
static of(project: Project): InfrastructureCommands | undefined { | ||
return project.components.find((c) => | ||
ProjectUtils.isNamedInstanceOf(c, InfrastructureCommands) | ||
) as InfrastructureCommands | undefined; | ||
} | ||
|
||
/** | ||
* Retrieves an instance of InfrastructureCommands if one is associated to the given project, | ||
* otherwise creates an InfrastructureCommands instance for the project. | ||
* @param project project instance | ||
*/ | ||
static ensure(project: Project): InfrastructureCommands { | ||
return ( | ||
InfrastructureCommands.of(project) || new InfrastructureCommands(project) | ||
); | ||
} | ||
|
||
constructor(project: Project) { | ||
super(project); | ||
|
||
// Add a development deployment task which uses hotswap for faster deployments | ||
// See: https://aws.amazon.com/blogs/developer/increasing-development-speed-with-cdk-watch/ | ||
const deployDevTask = project.addTask("deploy:dev", { | ||
receiveArgs: true, | ||
description: | ||
"Performs a hotswap CDK deployment, useful for faster development cycles", | ||
}); | ||
// --hotswap-fallback falls back to a regular deployment if there are resources which have | ||
// changed that cannot be hotswapped | ||
deployDevTask.exec( | ||
"cdk deploy --hotswap-fallback --require-approval never", | ||
{ | ||
receiveArgs: true, | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ import * as Mustache from "mustache"; | |
import { SampleFile } from "projen"; | ||
import { AwsCdkJavaApp } from "projen/lib/awscdk"; | ||
import { AwsCdkJavaAppOptions } from "./aws-cdk-java-app-options"; | ||
import { InfrastructureCommands } from "../../components/infrastructure-commands"; | ||
import { DEFAULT_STACK_NAME } from "../../consts"; | ||
|
||
/** | ||
|
@@ -65,6 +66,8 @@ export class InfrastructureJavaProject extends AwsCdkJavaApp { | |
}, | ||
}); | ||
|
||
InfrastructureCommands.ensure(this); | ||
|
||
this.pom.addPlugin("org.apache.maven.plugins/[email protected]"); | ||
this.pom.addPlugin("org.apache.maven.plugins/[email protected]", { | ||
configuration: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
.../infrastructure/test/projects/java/__snapshots__/infrastructure-java-project.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
.../infrastructure/test/projects/python/__snapshots__/infrastructure-py-project.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.