Skip to content

Commit

Permalink
chore(cli): change Java init templates to be less repetitive (aws#13995)
Browse files Browse the repository at this point in the history
The Java init templates were recently fixed to use `new` instead
of the builder, because the builder would instantiate the wrong class
(`Stack` instead of `MyStack`) (aws#13988).

However, the structure was changed to have 3 different `new` calls
in 3 different comment blocks.

Change it back to the old structure: there is one instantiation, and
uncommenting just passes or doesn't pass the `env` property. Except
this time we use `new` instead of the builder.


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
rix0rrr authored and hollanddd committed Aug 26, 2021
1 parent c236862 commit 239b3e5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,31 @@ public class %name.PascalCased%App {
public static void main(final String[] args) {
App app = new App();

// If you don't specify 'env', this stack will be environment-agnostic.
// Account/Region-dependent features and context lookups will not work,
// but a single synthesized template can be deployed anywhere.
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack");

// Replace the above stack intialization with the following to specialize
// this stack for the AWS Account and Region that are implied by the current
// CLI configuration.
/*
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps.builder()
// If you don't specify 'env', this stack will be environment-agnostic.
// Account/Region-dependent features and context lookups will not work,
// but a single synthesized template can be deployed anywhere.

// Uncomment the next block to specialize this stack for the AWS Account
// and Region that are implied by the current CLI configuration.
/*
.env(Environment.builder()
.account(System.getenv("CDK_DEFAULT_ACCOUNT"))
.region(System.getenv("CDK_DEFAULT_REGION"))
.build())
.build());
*/
*/

// Replace the above stack initialization with the following if you know exactly
// what Account and Region you want to deploy the stack to.
/*
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps.builder()
// Uncomment the next block if you know exactly what Account and Region you
// want to deploy the stack to.
/*
.env(Environment.builder()
.account("123456789012")
.region("us-east-1")
.build())
*/

// For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
.build());
*/

// For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html

app.synth();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,41 @@

import software.amazon.awscdk.lib.App;
import software.amazon.awscdk.lib.Environment;
import software.amazon.awscdk.lib.StackProps;

import java.util.Arrays;

public class %name.PascalCased%App {
public static void main(final String[] args) {
App app = new App();

// If you don't specify 'env', this stack will be environment-agnostic.
// Account/Region-dependent features and context lookups will not work,
// but a single synthesized template can be deployed anywhere.
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack");

// Replace the above stack intialization with the following to specialize
// this stack for the AWS Account and Region that are implied by the current
// CLI configuration.
/*
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps.builder()
// If you don't specify 'env', this stack will be environment-agnostic.
// Account/Region-dependent features and context lookups will not work,
// but a single synthesized template can be deployed anywhere.

// Uncomment the next block to specialize this stack for the AWS Account
// and Region that are implied by the current CLI configuration.
/*
.env(Environment.builder()
.account(System.getenv("CDK_DEFAULT_ACCOUNT"))
.region(System.getenv("CDK_DEFAULT_REGION"))
.build())
.build());
*/
*/

// Replace the above stack initialization with the following if you know exactly
// what Account and Region you want to deploy the stack to.
/*
new %name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps.builder()
// Uncomment the next block if you know exactly what Account and Region you
// want to deploy the stack to.
/*
.env(Environment.builder()
.account("123456789012")
.region("us-east-1")
.build())
*/

// For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html
.build());
*/

// For more information, see https://docs.aws.amazon.com/cdk/latest/guide/environments.html

app.synth();
}
}

0 comments on commit 239b3e5

Please sign in to comment.