Skip to content

Commit

Permalink
minor output changes and updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhavmishra committed May 10, 2020
1 parent 11498f4 commit 9941ea1
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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**
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -23,4 +23,4 @@
"changelog-parser": "^2.8.0",
"lerna": "^3.20.2"
}
}
}
2 changes: 1 addition & 1 deletion packages/cdktf-cli/bin/cmds/synth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}"`);
Expand Down
5 changes: 3 additions & 2 deletions packages/cdktf-cli/templates/typescript/help
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 9941ea1

Please sign in to comment.