From 9941ea10ae189a975380f53cbb9123d66b9aafb6 Mon Sep 17 00:00:00 2001 From: Anubhav Mishra Date: Sat, 9 May 2020 22:55:26 -0700 Subject: [PATCH] minor output changes and updated README.md --- CHANGELOG.md | 4 +++ README.md | 36 +++++++++++--------- package.json | 4 +-- packages/cdktf-cli/bin/cmds/synth.ts | 2 +- packages/cdktf-cli/templates/typescript/help | 5 +-- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 173764c8ab..9755ee77e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.0.2-alpha.2 + +Minor output changes and updated README.md example. + ## 0.0.2-alpha.1 Alpha release for Github and NPM diff --git a/README.md b/README.md index 3265b1bdfe..3f8bceb418 100644 --- a/README.md +++ b/README.md @@ -73,34 +73,36 @@ If you want to use already built examples. Please go to the [examples/](./exampl Let's take a simple Typescript application that uses the CDK for Terraform package. ```typescript -import { Construct, Token } from 'constructs'; +import { Construct } from 'constructs'; import { App, TerraformStack } from 'cdktf'; -import { DynamodbTable } from './.gen/providers/aws/dynamodb-table'; -import { SnsTopic } from './.gen/providers/aws/sns-topic'; +import { Instance } from './.gen/providers/aws/instance'; export class HelloTerra extends TerraformStack { constructor(scope: Construct, id: string) { super(scope, id); - const table = new DynamodbTable(this, 'Hello', { - name: 'my-first-table', - hashKey: 'temp', - attribute: [ - { name: 'id', type: 'S' } - ] - }); - - new SnsTopic(this, 'Topic', { - displayName: 'my-first-sns-topic' - }); + new Instance(this, 'Hello', { + ami: "ami-2757f631", + instanceType: "t2.micro" + }) } } -const app = new App({ outdir: 'cdk.out' }); +const app = new App(); new HelloTerra(app, 'hello-terra'); app.synth(); ``` +**Compile Application** + +You can now compile the application by running `npm run compile` or `yarn compile`. + +```bash +yarn compile +``` + +This will compile Typescript to Javascript. + **Synthesize Application** When you are ready you can run the `synthesize` command to generate Terraform JSON configuration for the application. @@ -109,11 +111,11 @@ When you are ready you can run the `synthesize` command to generate Terraform JS cdktf synth ``` -This command will generate a directory called `cdk.out`. This directory contains the Terraform JSON configuration for +This command will generate a directory called `dist`. This directory contains the Terraform JSON configuration for your application. ```bash -cd cdk.out +cd dist ``` **Apply Configuration** diff --git a/package.json b/package.json index dcd3233462..40d59df62c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "root", - "version": "0.0.2-alpha.1", + "version": "0.0.2-alpha.2", "private": true, "scripts": { "build": "lerna run build", @@ -23,4 +23,4 @@ "changelog-parser": "^2.8.0", "lerna": "^3.20.2" } -} \ No newline at end of file +} diff --git a/packages/cdktf-cli/bin/cmds/synth.ts b/packages/cdktf-cli/bin/cmds/synth.ts index 43560b8335..0a3feb63a4 100644 --- a/packages/cdktf-cli/bin/cmds/synth.ts +++ b/packages/cdktf-cli/bin/cmds/synth.ts @@ -26,7 +26,7 @@ class Command implements yargs.CommandModule { } }); - console.log(`Generating Terraform code in the output directory: "${outdir}"`) + console.log(`Generating Terraform code in the output directory: "${outdir}/"`) if (!await fs.pathExists(outdir)) { console.error(`ERROR: synthesis failed, app expected to create "${outdir}"`); diff --git a/packages/cdktf-cli/templates/typescript/help b/packages/cdktf-cli/templates/typescript/help index cb77a9df2a..f5819fcdaf 100644 --- a/packages/cdktf-cli/templates/typescript/help +++ b/packages/cdktf-cli/templates/typescript/help @@ -7,12 +7,13 @@ Compile: npm run compile Compile typescript code to javascript (or "yarn watch") npm run watch Watch for changes and compile typescript in the background - npm run build Get + compile + npm run build cdktf get and compile typescript Synthesize: - npm run synth Synthesize Terraform resources from stacks to dist/ (ready for 'terraform apply') + cdktf synth Synthesize Terraform resources from stacks to dist/ (ready for 'terraform apply') Deploy: + terraform init ./dist terraform apply ./dist Upgrades: