From 31ed90950b53176ed951ccab539824a2d3613ecc Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 15:49:29 +0200 Subject: [PATCH 01/11] Add docs for cdktf.json --- .../cdktf-json.md | 88 +++++++++++++++++++ .../importing-providers-and-modules.md | 2 +- 2 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 docs/working-with-cdk-for-terraform/cdktf-json.md diff --git a/docs/working-with-cdk-for-terraform/cdktf-json.md b/docs/working-with-cdk-for-terraform/cdktf-json.md new file mode 100644 index 0000000000..fb39140edb --- /dev/null +++ b/docs/working-with-cdk-for-terraform/cdktf-json.md @@ -0,0 +1,88 @@ +# cdktf.json Configuration File + +With the `cdktf.json` in your project root directory you can configure the behaviour of the Terraform CDK CLI: + +## Specification + +```ts +export enum Language { + TYPESCRIPT = 'typescript', + PYTHON = 'python', + DOTNET = 'dotnet', // not yet supported + JAVA = 'java', // not yet supported +} + +export interface Config { + readonly app?: string; // The command to run in order to synthesize the code to Terraform compatible JSON + readonly language?: Language; // Target language for building provider or module bindings. Currently supported: `typescript` or `python` + readonly output: string; // Default: 'cdktf.out'. Where the synthesized JSON should go. Also will be the working directory for Terraform operations + readonly codeMakerOutput: string; // Default: '.gen'. Path where generated provider bindings will be rendered to. + readonly terraformProviders?: string[]; // Terraform Providers to build + readonly terraformModules?: string[]; // Terraform Modules to build +} +``` + +### Terraform Providers + +With Terraform 0.13 the following specifications are possible: + +#### For HashiCorp maintained providers + +Official HashiCorp [maintained providers](https://registry.terraform.io/browse/providers?tier=official) (e.g. `aws`, `google` or `azurerm`) can be specified in a short version like this: `"aws@~> 2.0"` + +#### 3rd Party Providers + +Community providers have to provide a fully qualified name, e.g. to define the Docker provider: `terraform-providers/docker@~> 2.0` + +## Examples + +### Minimal Configuration + +A minimal configuration would define `app` only. This is useful, when planning to use [prebuilt providers]() and therefore no provider or modules bindings should be generated. + +```json +{ + "app": "npm run --silent compile && node main.js" +} +``` + +### Changing Code Output Directories + +This will synthesize JSON into `my-workdir` and all Terraform operations - such as `deploy` or `destroy` - will be performed in this directory. + +```json +{ + "app": "npm run --silent compile && node main.js", + "output": "my-workdir", +} +``` + +### Building Providers + +This will synthesize JSON into `my-workdir` and all Terraform operations - such as `deploy` or `destroy` - will be performed in this directory. See more details about this [here](./importing-providers-and-modules.md) + +```json +{ + "language": "typescript", + "app": "npm run --silent compile && node main.js", + "terraformProviders": [ + "aws@~> 2.0" + ] +} +``` + +### Building Providers in Custom Directory + +This will generate the `aws` provider bindings in the folder `./imports`. + +```json +{ + "language": "typescript", + "app": "npm run --silent compile && node main.js", + "terraformProviders": [ + "aws@~> 2.0" + ], + "codeMakerOutput": "imports" +} +``` + diff --git a/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md b/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md index 16f45d6b87..24fe10932a 100644 --- a/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md +++ b/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md @@ -31,7 +31,7 @@ new MyStack(app, 'hello-terraform'); app.synth(); ``` -The project also has the `cdktf.json` file that defines what providers and modules are being used by the project. +The project also has the [cdktf.json](./cdktf-json.md) file that defines what providers and modules are being used by the project. ```bash vim cdktf.json From 4192f448b28b6829dbcbc739e74834cbdbdab192 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 15:55:54 +0200 Subject: [PATCH 02/11] Ignore missing codeMakerOutput when no provider / module was specified --- packages/cdktf-cli/bin/cmds/synth.ts | 2 +- packages/cdktf-cli/lib/config.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cdktf-cli/bin/cmds/synth.ts b/packages/cdktf-cli/bin/cmds/synth.ts index e909c17645..b652463ab0 100644 --- a/packages/cdktf-cli/bin/cmds/synth.ts +++ b/packages/cdktf-cli/bin/cmds/synth.ts @@ -25,7 +25,7 @@ class Command implements yargs.CommandModule { const outdir = argv.output; const jsonOutput = argv.json; - if (!await fs.pathExists(config.codeMakerOutput)) { + if (config.checkCodeMakerOutput && !await fs.pathExists(config.codeMakerOutput)) { console.error(`ERROR: synthesis failed, run "cdktf get" to generate providers in ${config.codeMakerOutput}`); process.exit(1); } diff --git a/packages/cdktf-cli/lib/config.ts b/packages/cdktf-cli/lib/config.ts index 2d456125ff..cb28f5710a 100644 --- a/packages/cdktf-cli/lib/config.ts +++ b/packages/cdktf-cli/lib/config.ts @@ -16,6 +16,7 @@ export interface Config { readonly codeMakerOutput: string; readonly terraformProviders?: string[]; readonly terraformModules?: string[]; + checkCodeMakerOutput?: boolean; } export function readConfigSync(): Config { @@ -28,5 +29,7 @@ export function readConfigSync(): Config { }; } + config.checkCodeMakerOutput = Array.isArray(config.terraformModules) || Array.isArray(config.terraformProviders) + return config; } \ No newline at end of file From 89c428f783b44be13d96c1306aeb6d21862d3029 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 15:56:47 +0200 Subject: [PATCH 03/11] Add minimal template - fixes #308 --- packages/cdktf-cli/templates/python/help | 17 ++++++- .../typescript-minimal/.hooks.sscaff.js | 48 +++++++++++++++++++ .../templates/typescript-minimal/.npmrc | 1 + .../templates/typescript-minimal/cdktf.json | 3 ++ .../templates/typescript-minimal/help | 42 ++++++++++++++++ .../templates/typescript-minimal/main.ts | 15 ++++++ .../templates/typescript-minimal/package.json | 20 ++++++++ .../typescript-minimal/tsconfig.json | 33 +++++++++++++ .../typescript-minimal/{{}}.gitignore | 7 +++ packages/cdktf-cli/templates/typescript/help | 15 +++++- 10 files changed, 199 insertions(+), 2 deletions(-) create mode 100644 packages/cdktf-cli/templates/typescript-minimal/.hooks.sscaff.js create mode 100644 packages/cdktf-cli/templates/typescript-minimal/.npmrc create mode 100644 packages/cdktf-cli/templates/typescript-minimal/cdktf.json create mode 100644 packages/cdktf-cli/templates/typescript-minimal/help create mode 100644 packages/cdktf-cli/templates/typescript-minimal/main.ts create mode 100644 packages/cdktf-cli/templates/typescript-minimal/package.json create mode 100644 packages/cdktf-cli/templates/typescript-minimal/tsconfig.json create mode 100644 packages/cdktf-cli/templates/typescript-minimal/{{}}.gitignore diff --git a/packages/cdktf-cli/templates/python/help b/packages/cdktf-cli/templates/python/help index 99c5dfb822..52e3b42c8d 100644 --- a/packages/cdktf-cli/templates/python/help +++ b/packages/cdktf-cli/templates/python/help @@ -9,7 +9,7 @@ Synthesize: cdktf synth Synthesize Terraform resources to cdktf.out/ - + Diff: cdktf diff Perform a diff (terraform plan) for the given stack @@ -19,4 +19,19 @@ Destroy: cdktf destroy Destroy the given stack + Use Prebuilt Providers: + + You can add one or multiple of the prebuilt providers listed below: + + npm install -a @cdktf/provider-aws + npm install -a @cdktf/provider-google + npm install -a @cdktf/provider-azurerm + npm install -a @cdktf/provider-docker + npm install -a @cdktf/provider-github + npm install -a @cdktf/provider-null + + Check for an up to date list here https://cdk.tf/provider + + Alternatively, you can also build the provider bindings yourself: + ======================================================================================================== \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript-minimal/.hooks.sscaff.js b/packages/cdktf-cli/templates/typescript-minimal/.hooks.sscaff.js new file mode 100644 index 0000000000..f4901be597 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/.hooks.sscaff.js @@ -0,0 +1,48 @@ +const { execSync } = require('child_process'); +const { readFileSync, writeFileSync } = require('fs'); + +const constructs_version = require('../../package.json').dependencies.constructs; + +exports.post = ctx => { + // Terraform Cloud configuration settings if the organization name and workspace is set. + if (ctx.OrganizationName != '') { + console.log(`\nGenerating Terraform Cloud configuration for '${ctx.OrganizationName}' organization and '${ctx.WorkspaceName}' workspace.....`) + terraformCloudConfig(ctx.$base, ctx.OrganizationName, ctx.WorkspaceName); + } + + const npm_cdktf = ctx.npm_cdktf; + const npm_cdktf_cli = ctx.npm_cdktf_cli; + + if (!npm_cdktf) { throw new Error(`missing context "npm_cdktf"`); } + if (!npm_cdktf_cli) { throw new Error(`missing context "npm_cdktf_cli"`); } + + installDeps([npm_cdktf, `constructs@${constructs_version}`]); + installDeps([npm_cdktf_cli, '@types/node', 'typescript'], true); + + console.log(readFileSync('./help', 'utf-8')); +}; + +function installDeps(deps, isDev) { + const devDep = isDev ? '-D' : ''; + // make sure we're installing dev dependencies as well + const env = Object.assign({}, process.env) + env['NODE_ENV'] = 'development' + + execSync(`npm install ${devDep} ${deps.join(' ')}`, { stdio: 'inherit', env }); +} + +function terraformCloudConfig(baseName, organizationName, workspaceName) { + template = readFileSync('./main.ts', 'utf-8'); + + result = template.replace(`import { App, TerraformStack } from 'cdktf';`, `import { App, TerraformStack, RemoteBackend } from 'cdktf';`); + result = result.replace(`new MyStack(app, '${baseName}');`, `const stack = new MyStack(app, '${baseName}'); +new RemoteBackend(stack, { + hostname: 'app.terraform.io', + organization: '${organizationName}', + workspaces: { + name: '${workspaceName}' + } +});`); + + writeFileSync('./main.ts', result, 'utf-8'); +} diff --git a/packages/cdktf-cli/templates/typescript-minimal/.npmrc b/packages/cdktf-cli/templates/typescript-minimal/.npmrc new file mode 100644 index 0000000000..4fd021952d --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/.npmrc @@ -0,0 +1 @@ +engine-strict=true \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript-minimal/cdktf.json b/packages/cdktf-cli/templates/typescript-minimal/cdktf.json new file mode 100644 index 0000000000..b5a6e8bd14 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/cdktf.json @@ -0,0 +1,3 @@ +{ + "app": "npm run --silent compile && node main.js" +} \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript-minimal/help b/packages/cdktf-cli/templates/typescript-minimal/help new file mode 100644 index 0000000000..97aaaa6178 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/help @@ -0,0 +1,42 @@ +======================================================================================================== + + Your cdktf typescript project is ready! + + cat help Print this message + + 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 Compile typescript + + Synthesize: + cdktf synth Synthesize Terraform resources from stacks to cdktf.out/ (ready for 'terraform apply') + + Diff: + cdktf diff Perform a diff (terraform plan) for the given stack + + Deploy: + cdktf deploy Deploy the given stack + + Destroy: + cdktf destroy Destroy the stack + + + Upgrades: + npm run upgrade Upgrade cdktf modules to latest version + npm run upgrade:next Upgrade cdktf modules to latest "@next" version (last commit) + + Use Prebuilt Providers: + + You can add one or multiple of the prebuilt providers listed below: + + npm install -a @cdktf/provider-aws + npm install -a @cdktf/provider-google + npm install -a @cdktf/provider-azurerm + npm install -a @cdktf/provider-docker + npm install -a @cdktf/provider-github + npm install -a @cdktf/provider-null + + Check for an up to date list here https://cdk.tf/provider + +======================================================================================================== diff --git a/packages/cdktf-cli/templates/typescript-minimal/main.ts b/packages/cdktf-cli/templates/typescript-minimal/main.ts new file mode 100644 index 0000000000..ff1c8e9041 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/main.ts @@ -0,0 +1,15 @@ +import { Construct } from 'constructs'; +import { App, TerraformStack } from 'cdktf'; + +class MyStack extends TerraformStack { + constructor(scope: Construct, name: string) { + super(scope, name); + + // define resources here + + } +} + +const app = new App(); +new MyStack(app, '{{ $base }}'); +app.synth(); diff --git a/packages/cdktf-cli/templates/typescript-minimal/package.json b/packages/cdktf-cli/templates/typescript-minimal/package.json new file mode 100644 index 0000000000..00f9070735 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/package.json @@ -0,0 +1,20 @@ +{ + "name": "{{ $base }}", + "version": "1.0.0", + "main": "main.js", + "types": "main.ts", + "license": "MPL-2.0", + "private": true, + "scripts": { + "build": "tsc", + "synth": "cdktf synth", + "compile": "tsc --pretty", + "watch": "tsc -w", + "test": "echo ok", + "upgrade": "npm i cdktf@latest cdktf-cli@latest", + "upgrade:next": "npm i cdktf@next cdktf-cli@next" + }, + "engines": { + "node": ">=10.12" + } +} \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript-minimal/tsconfig.json b/packages/cdktf-cli/templates/typescript-minimal/tsconfig.json new file mode 100644 index 0000000000..c2650dbf07 --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "alwaysStrict": true, + "charset": "utf8", + "declaration": true, + "experimentalDecorators": true, + "inlineSourceMap": true, + "inlineSources": true, + "lib": [ + "es2018" + ], + "module": "CommonJS", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "strict": true, + "strictNullChecks": true, + "strictPropertyInitialization": true, + "stripInternal": true, + "target": "ES2018" + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript-minimal/{{}}.gitignore b/packages/cdktf-cli/templates/typescript-minimal/{{}}.gitignore new file mode 100644 index 0000000000..1b238805be --- /dev/null +++ b/packages/cdktf-cli/templates/typescript-minimal/{{}}.gitignore @@ -0,0 +1,7 @@ +*.d.ts +*.js +node_modules +cdktf.out +terraform.tfstate* +.gen +.terraform \ No newline at end of file diff --git a/packages/cdktf-cli/templates/typescript/help b/packages/cdktf-cli/templates/typescript/help index 9662c25dc4..81e4aba48f 100644 --- a/packages/cdktf-cli/templates/typescript/help +++ b/packages/cdktf-cli/templates/typescript/help @@ -20,11 +20,24 @@ Destroy: cdktf destroy Destroy the stack - + Upgrades: npm run get Import/update Terraform providers and modules (you should check-in this directory) npm run upgrade Upgrade cdktf modules to latest version npm run upgrade:next Upgrade cdktf modules to latest "@next" version (last commit) + Use Prebuilt Providers: + + You can add one or multiple of the prebuilt providers listed below: + + npm install -a @cdktf/provider-aws + npm install -a @cdktf/provider-google + npm install -a @cdktf/provider-azurerm + npm install -a @cdktf/provider-docker + npm install -a @cdktf/provider-github + npm install -a @cdktf/provider-null + + Check for an up to date list here https://cdk.tf/provider + ======================================================================================================== From b2d2f2af4f576f94dff02efbaef6c0106e7cf11f Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 16:05:38 +0200 Subject: [PATCH 04/11] Use new typescript-minimal template where it makes sense --- test/test-providers/test.sh | 2 +- test/test-terraform-cloud/test.sh | 4 ++-- test/test-typescript-deploy/test.sh | 2 +- test/test-typescript-destroy/test.sh | 2 +- test/test-typescript-diff/test.sh | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/test-providers/test.sh b/test/test-providers/test.sh index 396a286765..8d733b98c6 100755 --- a/test/test-providers/test.sh +++ b/test/test-providers/test.sh @@ -10,7 +10,7 @@ cd $(mktemp -d) mkdir test && cd test # initialize an empty project -cdktf init --template typescript --project-name="typescript-test" --project-description="typescript test app" --local +cdktf init --template typescript-minimal --project-name="typescript-test" --project-description="typescript test app" --local # put some code in it cp ${scriptdir}/main.ts . diff --git a/test/test-terraform-cloud/test.sh b/test/test-terraform-cloud/test.sh index 73b3ad45ad..80dd0fab79 100755 --- a/test/test-terraform-cloud/test.sh +++ b/test/test-terraform-cloud/test.sh @@ -22,7 +22,7 @@ mkdir test && cd test # to define remote state backend and test # the deploy which should call into Terraform # Cloud for the remote state. -cdktf init --template typescript --project-name="typescript-test" --project-description="typescript test app" --local +cdktf init --template typescript-minimal --project-name="typescript-test" --project-description="typescript test app" --local # put some code in it cp ${scriptdir}/main.ts . @@ -36,6 +36,6 @@ cdktf destroy --auto-approve # diff cdktf deploy --auto-approve > output -diff output ${scriptdir}/expected/output +diff output ${scriptdir}/expected/output echo "PASS" \ No newline at end of file diff --git a/test/test-typescript-deploy/test.sh b/test/test-typescript-deploy/test.sh index 962b4c24c5..c5940f9fde 100755 --- a/test/test-typescript-deploy/test.sh +++ b/test/test-typescript-deploy/test.sh @@ -10,7 +10,7 @@ cd $(mktemp -d) mkdir test && cd test # initialize an empty project -cdktf init --template typescript --project-name="typescript-test" --project-description="typescript test app" --local +cdktf init --template typescript-minimal --project-name="typescript-test" --project-description="typescript test app" --local # put some code in it cp ${scriptdir}/main.ts . diff --git a/test/test-typescript-destroy/test.sh b/test/test-typescript-destroy/test.sh index bc7bc5624a..5edbb0029b 100755 --- a/test/test-typescript-destroy/test.sh +++ b/test/test-typescript-destroy/test.sh @@ -10,7 +10,7 @@ cd $(mktemp -d) mkdir test && cd test # initialize an empty project -cdktf init --template typescript --project-name="typescript-test" --project-description="typescript test app" --local +cdktf init --template typescript-minimal --project-name="typescript-test" --project-description="typescript test app" --local # put some code in it cp ${scriptdir}/main.ts . diff --git a/test/test-typescript-diff/test.sh b/test/test-typescript-diff/test.sh index 36b47b3b5b..4a905278de 100755 --- a/test/test-typescript-diff/test.sh +++ b/test/test-typescript-diff/test.sh @@ -10,7 +10,7 @@ cd $(mktemp -d) mkdir test && cd test # initialize an empty project -cdktf init --template typescript --project-name="typescript-test" --project-description="typescript test app" --local +cdktf init --template typescript-minimal --project-name="typescript-test" --project-description="typescript test app" --local # put some code in it cp ${scriptdir}/main.ts . From 4bf71399e6b72528036d7c2470108db81dd0d8e7 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 16:17:17 +0200 Subject: [PATCH 05/11] Update docs --- docs/working-with-cdk-for-terraform/cdktf-json.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/docs/working-with-cdk-for-terraform/cdktf-json.md b/docs/working-with-cdk-for-terraform/cdktf-json.md index fb39140edb..f9552ff455 100644 --- a/docs/working-with-cdk-for-terraform/cdktf-json.md +++ b/docs/working-with-cdk-for-terraform/cdktf-json.md @@ -22,9 +22,11 @@ export interface Config { } ``` -### Terraform Providers +### Terraform Providers and Modules -With Terraform 0.13 the following specifications are possible: +The [following specifications](https://www.terraform.io/docs/configuration/provider-requirements.html#requiring-providers) schema should be followed for providers and modules + +[source](https://www.terraform.io/docs/configuration/provider-requirements.html#source-addresses)@[version](https://www.terraform.io/docs/configuration/provider-requirements.html#version-constraints) #### For HashiCorp maintained providers @@ -34,6 +36,10 @@ Official HashiCorp [maintained providers](https://registry.terraform.io/browse/p Community providers have to provide a fully qualified name, e.g. to define the Docker provider: `terraform-providers/docker@~> 2.0` +#### Modules + +Similar to 3rd Party providers, the full registry namespace should be provided. Please note that only modules from the registry are supported at this point. + ## Examples ### Minimal Configuration @@ -59,7 +65,7 @@ This will synthesize JSON into `my-workdir` and all Terraform operations - such ### Building Providers -This will synthesize JSON into `my-workdir` and all Terraform operations - such as `deploy` or `destroy` - will be performed in this directory. See more details about this [here](./importing-providers-and-modules.md) +This will synthesize JSON into `my-workdir` and all Terraform operations - such as `deploy` or `destroy` - will be performed in this directory. See more details about this [here](./using-providers-and-modules.md) ```json { From 423d11f556e7878cc2207b34b99770b89dc437dd Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 16:24:15 +0200 Subject: [PATCH 06/11] Add section about prebuilt providers --- README.md | 2 +- ...ules.md => using-providers-and-modules.md} | 24 ++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) rename docs/working-with-cdk-for-terraform/{importing-providers-and-modules.md => using-providers-and-modules.md} (80%) diff --git a/README.md b/README.md index 181542f2e3..51a9935427 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Choose a language: ## Documentation * Install and run a quick start tutorial at [HashiCorp Learn](https://learn.hashicorp.com/terraform/cdktf/cdktf-install) -* Using CDK for Terraform CLI for importing Terraform [modules and providers](./docs/working-with-cdk-for-terraform/importing-providers-and-modules.md). +* Using CDK for Terraform CLI for importing Terraform [modules and providers](./docs/working-with-cdk-for-terraform/using-providers-and-modules.md). * Explore the CDK for Terraform [CLI](./docs/cli-commands.md). * Defining Terraform [outputs](./docs/working-with-cdk-for-terraform/terraform-outputs.md). * Using Terraform [remote backend](./docs/working-with-cdk-for-terraform/remote-backend.md). diff --git a/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md similarity index 80% rename from docs/working-with-cdk-for-terraform/importing-providers-and-modules.md rename to docs/working-with-cdk-for-terraform/using-providers-and-modules.md index 24fe10932a..c3300211b6 100644 --- a/docs/working-with-cdk-for-terraform/importing-providers-and-modules.md +++ b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md @@ -1,4 +1,26 @@ -# Importing Providers and Modules +# Using Providers and Modules + +## Prebuilt Providers + +To improve the general user experience around provider imports and to allow building further abstractions on top of the Terraform provider bindings, a few popular providers are offered as prebuilt packages. At the moment the following providers are built and published to NPM / PyPi on a regular basis automatically. + +- [AWS Provider](https://cdk.tf/provider/aws) +- [Google Provider](https://cdk.tf/provider/google) +- [Azure Provider](https://cdk.tf/provider/azurerm) +- [Kubernetes Provider](https://cdk.tf/provider/kubernetes) +- [Docker Provider](https://cdk.tf/provider/docker) +- [Github Provider](https://cdk.tf/provider/github) +- [Null Provider](https://cdk.tf/provider/null) + +Please check the [Terraform CDK Proivders](https://cdk.tf/provider) organisation as well for an up to date list. As these are are normal npm / pypi packages, they can be used as any other dependency. + +e.g. in Typescript / Node: + +``` +npm install -a @cdktf/provider-aws +``` + +## Build Providers and Modules CDK for Terraform allows you to import Terraform [providers](https://www.terraform.io/docs/providers/index.html) and [modules](https://www.terraform.io/docs/modules/index.html) to your project using this workflow. From cccba84d704fc3575be0c55714649c3ad248530d Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Thu, 20 Aug 2020 16:37:24 +0200 Subject: [PATCH 07/11] Add prebuilt provider example --- examples/typescript/aws-prebuilt/.gitignore | 4 ++ examples/typescript/aws-prebuilt/README.md | 15 ++++++ examples/typescript/aws-prebuilt/cdktf.json | 3 ++ examples/typescript/aws-prebuilt/main.ts | 49 +++++++++++++++++++ examples/typescript/aws-prebuilt/package.json | 21 ++++++++ .../typescript/aws-prebuilt/tsconfig.json | 33 +++++++++++++ examples/typescript/aws-prebuilt/yarn.lock | 18 +++++++ yarn.lock | 35 +++++++++---- 8 files changed, 169 insertions(+), 9 deletions(-) create mode 100644 examples/typescript/aws-prebuilt/.gitignore create mode 100644 examples/typescript/aws-prebuilt/README.md create mode 100644 examples/typescript/aws-prebuilt/cdktf.json create mode 100644 examples/typescript/aws-prebuilt/main.ts create mode 100644 examples/typescript/aws-prebuilt/package.json create mode 100644 examples/typescript/aws-prebuilt/tsconfig.json create mode 100644 examples/typescript/aws-prebuilt/yarn.lock diff --git a/examples/typescript/aws-prebuilt/.gitignore b/examples/typescript/aws-prebuilt/.gitignore new file mode 100644 index 0000000000..0c26ec69e2 --- /dev/null +++ b/examples/typescript/aws-prebuilt/.gitignore @@ -0,0 +1,4 @@ +.gen +cdktf.out +terraform.tfstate* +!tsconfig.json \ No newline at end of file diff --git a/examples/typescript/aws-prebuilt/README.md b/examples/typescript/aws-prebuilt/README.md new file mode 100644 index 0000000000..6fbdaf30fa --- /dev/null +++ b/examples/typescript/aws-prebuilt/README.md @@ -0,0 +1,15 @@ +# Typescript AWS with Prebuilt Provider + +A CDK for Terraform application in TypeScript using the prebuilt [AWS provider](https://cdk.tf/provider/aws). + +## Usage + +Install project dependencies: + +```shell +yarn install +``` + +You can now edit the [main.ts](./main.ts) file if you want to modify any code. + +Perform a `cdktf diff` to get a plan of what would be deployed. \ No newline at end of file diff --git a/examples/typescript/aws-prebuilt/cdktf.json b/examples/typescript/aws-prebuilt/cdktf.json new file mode 100644 index 0000000000..b5a6e8bd14 --- /dev/null +++ b/examples/typescript/aws-prebuilt/cdktf.json @@ -0,0 +1,3 @@ +{ + "app": "npm run --silent compile && node main.js" +} \ No newline at end of file diff --git a/examples/typescript/aws-prebuilt/main.ts b/examples/typescript/aws-prebuilt/main.ts new file mode 100644 index 0000000000..08050dc1be --- /dev/null +++ b/examples/typescript/aws-prebuilt/main.ts @@ -0,0 +1,49 @@ +import { Construct } from 'constructs'; +import { App, TerraformStack, TerraformOutput } from 'cdktf'; +import { DataAwsRegion, AwsProvider, DynamodbTable, SnsTopic } from '@cdktf/provider-aws' + +export class HelloTerra extends TerraformStack { + constructor(scope: Construct, id: string) { + super(scope, id); + + new AwsProvider(this, 'aws', { + region: 'eu-central-1' + }) + + const region = new DataAwsRegion(this, 'region') + + const table = new DynamodbTable(this, 'Hello', { + name: `my-first-table-${region.name}`, + hashKey: 'temp', + attribute: [ + { name: 'id', type: 'S' }, + ], + billingMode: "PAY_PER_REQUEST" + }); + + table.addOverride('hash_key', 'id') + // table.addOverride('hash_key', 'foo') + table.addOverride('lifecycle', { create_before_destroy: true }) + + const topicCount = 1 + const topics = [...Array(topicCount).keys()].map((i) => { + return new SnsTopic(this, `Topic${i}`, { + displayName: `my-first-sns-topic${i}` + }); + }) + + new TerraformOutput(this, 'table_name', { + value: table.name + }) + + topics.forEach((topic, i) => { + new TerraformOutput(this, `sns_topic${i}`, { + value: topic.name + }) + }) + } +} + +const app = new App(); +new HelloTerra(app, 'hello-terra'); +app.synth(); \ No newline at end of file diff --git a/examples/typescript/aws-prebuilt/package.json b/examples/typescript/aws-prebuilt/package.json new file mode 100644 index 0000000000..44cb92015d --- /dev/null +++ b/examples/typescript/aws-prebuilt/package.json @@ -0,0 +1,21 @@ +{ + "name": "@examples/typescript-aws-prebuilt", + "version": "0.0.0", + "main": "index.js", + "license": "MPL-2.0", + "scripts": { + "build": "tsc", + "compile": "tsc --pretty", + "synth": "cdktf synth" + }, + "devDependencies": { + "@types/node": "^14.0.26", + "cdktf-cli": "0.0.0", + "typescript": "^3.9.7" + }, + "dependencies": { + "@cdktf/provider-aws": "^0.0.19", + "cdktf": "0.0.0", + "constructs": "^3.0.0" + } +} diff --git a/examples/typescript/aws-prebuilt/tsconfig.json b/examples/typescript/aws-prebuilt/tsconfig.json new file mode 100644 index 0000000000..936e05cef5 --- /dev/null +++ b/examples/typescript/aws-prebuilt/tsconfig.json @@ -0,0 +1,33 @@ +{ + "compilerOptions": { + "alwaysStrict": true, + "charset": "utf8", + "declaration": true, + "experimentalDecorators": true, + "inlineSourceMap": true, + "inlineSources": true, + "lib": [ + "es2018" + ], + "module": "CommonJS", + "noEmitOnError": true, + "noFallthroughCasesInSwitch": true, + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "resolveJsonModule": true, + "strict": true, + "strictNullChecks": true, + "strictPropertyInitialization": true, + "stripInternal": true, + "target": "ES2018" + }, + "include": [ + "**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/examples/typescript/aws-prebuilt/yarn.lock b/examples/typescript/aws-prebuilt/yarn.lock new file mode 100644 index 0000000000..4165686e5b --- /dev/null +++ b/examples/typescript/aws-prebuilt/yarn.lock @@ -0,0 +1,18 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@types/node@^13.1.1": + version "13.1.4" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.4.tgz#4cfd90175a200ee9b02bd6b1cd19bc349741607e" + integrity sha512-Lue/mlp2egZJoHXZr4LndxDAd7i/7SQYhV0EjWfb/a4/OZ6tuVwMCVPiwkU5nsEipxEf7hmkSU7Em5VQ8P5NGA== + +constructs@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/constructs/-/constructs-2.0.1.tgz#274d6b8ce6a698813495c444466b0c745349ddb5" + integrity sha512-edR85YFGI9TBT9byAo5vAfI0PRi+jFGzinwN3RAJwKfv6Yc9x9kALYfoEmgotp95qT7/k/iUQWHrH9BMJeqpdg== + +typescript@^3.7.4: + version "3.7.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.4.tgz#1743a5ec5fef6a1fa9f3e4708e33c81c73876c19" + integrity sha512-A25xv5XCtarLwXpcDNZzCGvW2D1S3/bACratYBx2sax8PefsFhlYmkQicKHvpYflFS8if4zne5zT5kpJ7pzuvw== diff --git a/yarn.lock b/yarn.lock index d10dbd1dc8..fa259330e8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -272,6 +272,11 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== +"@cdktf/provider-aws@^0.0.19": + version "0.0.19" + resolved "https://registry.yarnpkg.com/@cdktf/provider-aws/-/provider-aws-0.0.19.tgz#e6965a0465e7f04de338b1f4fc53cd7edfe1b1d1" + integrity sha512-ZKxKZhV2A46xScSvaqmb2+pdS2J+ndadmOtClOQo4QQldswYmvvvG5sRm2RKtvKcHHmZNpcsANLrFtXKI97gFA== + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" @@ -1519,6 +1524,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.0.26.tgz#22a3b8a46510da8944b67bfc27df02c34a35331c" integrity sha512-W+fpe5s91FBGE0pEa0lnqGLL4USgpLgs4nokw16SrBBco/gQxuua7KnArSEOd5iaMqbbSHV10vUDkJYJJqpXKA== +"@types/node@^14.0.27": + version "14.6.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-14.6.0.tgz#7d4411bf5157339337d7cff864d9ff45f177b499" + integrity sha512-mikldZQitV94akrc4sCcSjtJfsTKt4p+e/s0AGscVA6XArQ9kFclP+ZiYUMnq987rc6QlYxXv/EivqlfSLxpKA== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -2970,12 +2980,19 @@ domexception@^1.0.1: dependencies: webidl-conversions "^4.0.2" -dot-prop@^5.1.1: - version "5.2.0" - resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-5.2.0.tgz#c34ecc29556dc45f1f4c22697b6f4904e0cc4fcb" - integrity sha512-uEUyaDKoSQ1M4Oq8l45hSE26SnTxL6snNnqvK/VWx5wJhmff5z0FUVJDKDanor/6w3kzE3i7XZOk+7wC0EXr1A== +dot-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-3.0.0.tgz#1b708af094a49c9a0e7dbcad790aba539dac1177" + integrity sha1-G3CK8JSknJoOfbyteQq6U52sEXc= dependencies: - is-obj "^2.0.0" + is-obj "^1.0.0" + +dot-prop@^4.2.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/dot-prop/-/dot-prop-4.2.1.tgz#45884194a71fc2cda71cbb4bceb3a4dd2f433ba4" + integrity sha512-l0p4+mIuJIua0mhxGoh4a+iNL9bmeK5DvnSVQa6T0OhrVmaEa1XScX5Etc673FePCJOArq/4Pa2cLGODUWTPOQ== + dependencies: + is-obj "^1.0.0" duplexer@^0.1.1: version "0.1.1" @@ -4413,10 +4430,10 @@ is-number@^7.0.0: resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== -is-obj@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-2.0.0.tgz#473fb05d973705e3fd9620545018ca8e22ef4982" - integrity sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w== +is-obj@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-obj/-/is-obj-1.0.1.tgz#3e4729ac1f5fde025cd7d83a896dab9f4f67db0f" + integrity sha1-PkcprB9f3gJc19g6iW2rn09n2w8= is-plain-obj@^1.0.0, is-plain-obj@^1.1.0: version "1.1.0" From c76fb8c368ff9671cfd5a922f83b44574fe13940 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Fri, 21 Aug 2020 20:29:59 +0200 Subject: [PATCH 08/11] Apply feedback --- .../cdktf-json.md | 63 +++++++++++++++++-- .../using-providers-and-modules.md | 18 +++--- examples/typescript/aws-prebuilt/README.md | 2 +- packages/cdktf-cli/templates/python/help | 2 +- .../templates/typescript-minimal/help | 2 +- packages/cdktf-cli/templates/typescript/help | 2 +- 6 files changed, 70 insertions(+), 19 deletions(-) diff --git a/docs/working-with-cdk-for-terraform/cdktf-json.md b/docs/working-with-cdk-for-terraform/cdktf-json.md index f9552ff455..810afe523e 100644 --- a/docs/working-with-cdk-for-terraform/cdktf-json.md +++ b/docs/working-with-cdk-for-terraform/cdktf-json.md @@ -44,7 +44,7 @@ Similar to 3rd Party providers, the full registry namespace should be provided. ### Minimal Configuration -A minimal configuration would define `app` only. This is useful, when planning to use [prebuilt providers]() and therefore no provider or modules bindings should be generated. +A minimal configuration would define `app` only. This is useful, when planning to use [prebuilt providers](https://github.com/terraform-cdk-providers) and therefore no provider or modules bindings should be generated. ```json { @@ -65,7 +65,7 @@ This will synthesize JSON into `my-workdir` and all Terraform operations - such ### Building Providers -This will synthesize JSON into `my-workdir` and all Terraform operations - such as `deploy` or `destroy` - will be performed in this directory. See more details about this [here](./using-providers-and-modules.md) +With this `terraformProviders` configuration, a `cdktf get` will build the latest AWS provider within the 2.X version range. The generated code will be saved into `.gen` by default. This can be adjusted with `codeMakerOutput`, see other examples below. ```json { @@ -77,18 +77,69 @@ This will synthesize JSON into `my-workdir` and all Terraform operations - such } ``` -### Building Providers in Custom Directory +### Building Modules + +With this `terraformModules` configuration, a `cdktf get` will build the latest `terraform-aws-modules/vpc/aws` module from the Terraform Registry. The generated code will be saved into `.gen` by default. This can be adjusted with `codeMakerOutput` - see other examples below. + +```json +{ + "language": "typescript", + "app": "npm run --silent compile && node main.js", + "terraformModules": [ + "terraform-aws-modules/vpc/aws" + ] +} +``` + +### Building Providers & Modules -This will generate the `aws` provider bindings in the folder `./imports`. +This combines examples above, a `cdktf get` will build both the AWS provider and the latest `terraform-aws-modules/vpc/aws` module from the Terraform Registry. ```json { "language": "typescript", "app": "npm run --silent compile && node main.js", + "terraformModules": [ + "terraform-aws-modules/vpc/aws" + ], "terraformProviders": [ "aws@~> 2.0" - ], - "codeMakerOutput": "imports" + ] +} +``` + +### Building Multiple Providers + +It's possible to build multiple providers or modules as well. + +```json +{ + "language": "typescript", + "app": "npm run --silent compile && node main.js", + "terraformProviders": [ + "null", + "aws", + "google", + "azurerm", + "kubernetes", + "consul", + "vault", + "nomad", + ] } ``` +### Building Providers in Custom Directory + +This will generate the `aws` provider bindings in the folder `./imports`. This is used in the Python template, to make it easier to reference the generated classes. + +```json +{ + "language": "python", + "app": "pipenv run ./main.py", + "terraformProviders": [ + "aws@~> 2.0" + ], + "codeMakerOutput": "imports" +} +``` \ No newline at end of file diff --git a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md index c3300211b6..98231e7171 100644 --- a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md +++ b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md @@ -4,15 +4,15 @@ To improve the general user experience around provider imports and to allow building further abstractions on top of the Terraform provider bindings, a few popular providers are offered as prebuilt packages. At the moment the following providers are built and published to NPM / PyPi on a regular basis automatically. -- [AWS Provider](https://cdk.tf/provider/aws) -- [Google Provider](https://cdk.tf/provider/google) -- [Azure Provider](https://cdk.tf/provider/azurerm) -- [Kubernetes Provider](https://cdk.tf/provider/kubernetes) -- [Docker Provider](https://cdk.tf/provider/docker) -- [Github Provider](https://cdk.tf/provider/github) -- [Null Provider](https://cdk.tf/provider/null) - -Please check the [Terraform CDK Proivders](https://cdk.tf/provider) organisation as well for an up to date list. As these are are normal npm / pypi packages, they can be used as any other dependency. +- [AWS Provider](https://github.com/terraform-cdk-providers/cdktf-provider-aws) +- [Google Provider](https://github.com/terraform-cdk-providers/cdktf-provider-google) +- [Azure Provider](https://github.com/terraform-cdk-providers/cdktf-provider-azurerm) +- [Kubernetes Provider](https://github.com/terraform-cdk-providers/cdktf-provider-kubernetes) +- [Docker Provider](https://github.com/terraform-cdk-providers/cdktf-provider-docker) +- [Github Provider](https://github.com/terraform-cdk-providers/cdktf-provider-github) +- [Null Provider](https://github.com/terraform-cdk-providers/cdktf-provider-null) + +Please check the [Terraform CDK Proivders](https://github.com/terraform-cdk-providers) organisation as well for an up to date list. As these are are normal npm / pypi packages, they can be used as any other dependency. e.g. in Typescript / Node: diff --git a/examples/typescript/aws-prebuilt/README.md b/examples/typescript/aws-prebuilt/README.md index 6fbdaf30fa..956302ddb7 100644 --- a/examples/typescript/aws-prebuilt/README.md +++ b/examples/typescript/aws-prebuilt/README.md @@ -1,6 +1,6 @@ # Typescript AWS with Prebuilt Provider -A CDK for Terraform application in TypeScript using the prebuilt [AWS provider](https://cdk.tf/provider/aws). +A CDK for Terraform application in TypeScript using the prebuilt [AWS provider](https://github.com/terraform-cdk-providers/cdktf-provider-aws). ## Usage diff --git a/packages/cdktf-cli/templates/python/help b/packages/cdktf-cli/templates/python/help index 52e3b42c8d..08b57bb198 100644 --- a/packages/cdktf-cli/templates/python/help +++ b/packages/cdktf-cli/templates/python/help @@ -30,7 +30,7 @@ npm install -a @cdktf/provider-github npm install -a @cdktf/provider-null - Check for an up to date list here https://cdk.tf/provider + Check for an up to date list here https://github.com/terraform-cdk-providers Alternatively, you can also build the provider bindings yourself: diff --git a/packages/cdktf-cli/templates/typescript-minimal/help b/packages/cdktf-cli/templates/typescript-minimal/help index 97aaaa6178..8605fd4a9e 100644 --- a/packages/cdktf-cli/templates/typescript-minimal/help +++ b/packages/cdktf-cli/templates/typescript-minimal/help @@ -37,6 +37,6 @@ npm install -a @cdktf/provider-github npm install -a @cdktf/provider-null - Check for an up to date list here https://cdk.tf/provider + Check for an up to date list here https://github.com/terraform-cdk-providers ======================================================================================================== diff --git a/packages/cdktf-cli/templates/typescript/help b/packages/cdktf-cli/templates/typescript/help index 81e4aba48f..e5956adf67 100644 --- a/packages/cdktf-cli/templates/typescript/help +++ b/packages/cdktf-cli/templates/typescript/help @@ -38,6 +38,6 @@ npm install -a @cdktf/provider-github npm install -a @cdktf/provider-null - Check for an up to date list here https://cdk.tf/provider + Check for an up to date list here https://github.com/terraform-cdk-providers ======================================================================================================== From dfa0f6ac79ec35ab62b4a86a2241810f2481f4b5 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Fri, 21 Aug 2020 20:52:48 +0200 Subject: [PATCH 09/11] Check for actual presence of the given array --- packages/cdktf-cli/lib/config.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/cdktf-cli/lib/config.ts b/packages/cdktf-cli/lib/config.ts index cb28f5710a..0c0bb583ea 100644 --- a/packages/cdktf-cli/lib/config.ts +++ b/packages/cdktf-cli/lib/config.ts @@ -8,6 +8,9 @@ const DEFAULTS = { codeMakerOutput: '.gen' } +function isPresent(input: string[] | undefined): boolean { + return Array.isArray(input) && input.length > 0 +} export interface Config { readonly app?: string; @@ -29,7 +32,7 @@ export function readConfigSync(): Config { }; } - config.checkCodeMakerOutput = Array.isArray(config.terraformModules) || Array.isArray(config.terraformProviders) + config.checkCodeMakerOutput = isPresent(config.terraformModules) || isPresent(config.terraformProviders) return config; } \ No newline at end of file From a620a2d37e706404d38893273445df71ba97bd87 Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Fri, 21 Aug 2020 22:47:37 +0200 Subject: [PATCH 10/11] Update docs/working-with-cdk-for-terraform/using-providers-and-modules.md Co-authored-by: Anubhav Mishra --- .../using-providers-and-modules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md index 98231e7171..1977e4615b 100644 --- a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md +++ b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md @@ -20,7 +20,7 @@ e.g. in Typescript / Node: npm install -a @cdktf/provider-aws ``` -## Build Providers and Modules +## Importing Providers and Modules CDK for Terraform allows you to import Terraform [providers](https://www.terraform.io/docs/providers/index.html) and [modules](https://www.terraform.io/docs/modules/index.html) to your project using this workflow. @@ -205,4 +205,4 @@ cdktf synth --json } } -``` \ No newline at end of file +``` From 52cf934416f084b269567160b1dd63cef686628b Mon Sep 17 00:00:00 2001 From: Sebastian Korfmann Date: Fri, 21 Aug 2020 22:47:45 +0200 Subject: [PATCH 11/11] Update docs/working-with-cdk-for-terraform/using-providers-and-modules.md Co-authored-by: Anubhav Mishra --- .../using-providers-and-modules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md index 1977e4615b..dbf242766b 100644 --- a/docs/working-with-cdk-for-terraform/using-providers-and-modules.md +++ b/docs/working-with-cdk-for-terraform/using-providers-and-modules.md @@ -12,7 +12,7 @@ To improve the general user experience around provider imports and to allow buil - [Github Provider](https://github.com/terraform-cdk-providers/cdktf-provider-github) - [Null Provider](https://github.com/terraform-cdk-providers/cdktf-provider-null) -Please check the [Terraform CDK Proivders](https://github.com/terraform-cdk-providers) organisation as well for an up to date list. As these are are normal npm / pypi packages, they can be used as any other dependency. +Please check the [Terraform CDK Providers](https://github.com/terraform-cdk-providers) organization as well for an up to date list. As these are normal NPM / PyPI packages, they can be used as any other dependency. e.g. in Typescript / Node: