Skip to content

Commit

Permalink
fix(cli): fix init templates for sample-app & lib
Browse files Browse the repository at this point in the history
  • Loading branch information
netroy committed Jan 14, 2020
1 parent f320c62 commit 5848126
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 16 deletions.
@@ -1,4 +1,4 @@
namespace HelloCdk
namespace %name.PascalCased%

open Amazon.CDK
open Amazon.CDK.AWS.SNS
Expand Down
@@ -1,9 +1,11 @@
open Amazon.CDK
open %name.PascalCased%Stack
open %name.PascalCased%

[<EntryPoint>]
let main _ =
let app = App(null)
%name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps) |> ignore

%name.PascalCased%Stack(app, "%name.PascalCased%Stack", StackProps()) |> ignore

app.Synth() |> ignore
0
Expand Up @@ -19,6 +19,6 @@ public void testStack() throws IOException {
%name.PascalCased%Stack stack = new %name.PascalCased%Stack(app, "test");

JsonNode actual = JSON.valueToTree(app.synth().getStackArtifact(stack.getArtifactId()).getTemplate());
assertThat(actual.asText(), CoreMatchers.both(CoreMatchers.containsString("AWS::SQS::Queue")).and(CoreMatchers.containsString("AWS::SNS::Topic")));
assertThat(actual.toString(), CoreMatchers.both(CoreMatchers.containsString("AWS::SQS::Queue")).and(CoreMatchers.containsString("AWS::SNS::Topic")));
}
}
@@ -1,13 +1,13 @@

# Welcome to your CDK Python project!

You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`%name.PascalCased%Stack`)
You should explore the contents of this project. It demonstrates a CDK app with an instance of a stack (`%name.PythonModule%_stack`)
which contains an Amazon SQS queue that is subscribed to an Amazon SNS topic.

The `cdk.json` file tells the CDK Toolkit how to execute your app.

This project is set up like a standard Python project. The initialization process also creates
a virtualenv within this project, stored under the .env directory. To create the virtualenv
a virtualenv within this project, stored under the .env directory. To create the virtualenv
it assumes that there is a `python3` executable in your path with access to the `venv` package.
If for any reason the automatic creation of the virtualenv fails, you can create the virtualenv
manually once the init process completes.
Expand Down
Expand Up @@ -2,10 +2,10 @@

from aws_cdk import core

from %name%.%name%_stack import %name.PascalCased%Stack
from %name.PythonModule%.%name.PythonModule%_stack import %name.PascalCased%Stack


app = core.App()
%name.PascalCased%Stack(app, "%name%", env={'region': 'us-west-2'})
%name.PascalCased%Stack(app, "%name.StackName%", env={'region': 'us-west-2'})

app.synth()
Expand Up @@ -6,7 +6,7 @@


setuptools.setup(
name="%name%",
name="%name.PythonModule%",
version="0.0.1",

description="A sample CDK Python app",
Expand All @@ -15,8 +15,8 @@

author="author",

package_dir={"": "%name%"},
packages=setuptools.find_packages(where="%name%"),
package_dir={"": "%name.PythonModule%"},
packages=setuptools.find_packages(where="%name.PythonModule%"),

install_requires=[
"aws-cdk.core",
Expand Down
Expand Up @@ -2,13 +2,13 @@
import pytest

from aws_cdk import core
from %name%.%name%_stack import %name.PascalCased%Stack
from %name%.%name.PythonModule%_stack import %name.PascalCased%Stack


def get_template():
app = core.App()
%name.PascalCased%Stack(app, "%name%")
return json.dumps(app.synth().get_stack("%name%").template)
%name.PascalCased%Stack(app, "%name.StackName%")
return json.dumps(app.synth().get_stack("%name.StackName%").template)


def test_sqs_queue_created():
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/test/integ/init/common.bash
@@ -1,5 +1,5 @@
set -eu
init_test_dir=/tmp/cdk-init-test
init_test_dir="${init_test_dir:=/tmp/cdk-init-test}"

function setup() {
rm -rf $init_test_dir
Expand Down
7 changes: 7 additions & 0 deletions packages/aws-cdk/test/integ/init/test-python-stackname.sh
@@ -0,0 +1,7 @@
#!/bin/bash
# Naming shim for backwards compatibility with legacy
# tests and canaries.
set -eu
scriptdir=$(cd $(dirname $0) && pwd)
init_test_dir=/tmp/cdkInitTest
source $scriptdir/test-python.sh
6 changes: 5 additions & 1 deletion packages/aws-cdk/test/integ/init/test-typescript.sh
Expand Up @@ -25,5 +25,9 @@ for template in $templates; do
npm ls # this will fail if we have unmet peer dependencies
npm run build
npm run test
cdk synth

# Can't run `cdk synth` on libraries
if [[ $template != "lib" ]]; then
cdk synth
fi
done

0 comments on commit 5848126

Please sign in to comment.