Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(docs): Final Docs Migration Cleanup #1431

Merged
merged 13 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions website/docs/cdktf/create-and-deploy/project-setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Terraform Cloud supports [connecting to VCS providers](/cloud-docs/vcs). To use
1. Commit the synthesized Terraform config (the `cdktf.out` directory) alongside your code, so that Terraform Cloud can use it to deploy your infrastructure.
1. On the **General Settings** page of your Terraform Cloud workspace, [set the Terraform working directory](/cloud-docs/workspaces/settings#terraform-working-directory) to the output directory of the stack you want to deploy. For example, use `cdktf.out/stacks/dev` if your stack is named `dev`.

Refer to the [Stacks page](/cdktf/concepts/stacks) for more information about using stacks to separate the state management for multiple environments in an application.
Refer to [Stacks](/cdktf/concepts/stacks) for more information about using stacks to separate the state management for multiple environments in an application.

~> **Important**: The synthesized Terraform config might contain credentials or other sensitive data that was provided as input for the `cdktf` application.

Expand Down Expand Up @@ -127,6 +127,10 @@ new MyStack(app, "hello-cdktf");
app.synth();
```

## Generate JSON Terraform Configuration

Run [`cdktf synth`](/cdktf/cli-reference/commands#synth) to synthesize your application into JSON configuration files that Terraform can use to manage infrastructure. You can then either use the JSON file with Terraform directly or provision your infrastructure using CDKTF CLI commands.

## Convert an HCL Project to a CDKTF TypeScript Project

You can initialize a new CDKTF TypeScript project from an existing project written in HashiCorp Configuration Language (HCL). This option is currently limited to the `typescript` template.
Expand Down Expand Up @@ -210,4 +214,4 @@ app.synth();

## Convert HCL Files to CDKTF Format

Use the `cdktf convert` command to convert individual HCL files to CDKTF-compatible files in your preferred programming language. Refer to the [`cdktf convert` command documentation](/cdktf/cli-reference/commands) for more information.
Use the `cdktf convert` command to convert individual HCL files to CDKTF-compatible files in your preferred programming language. Refer to the [`cdktf convert` command documentation](/cdktf/cli-reference/commands#convert) for more information.
18 changes: 0 additions & 18 deletions website/docs/cdktf/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,6 @@ Early adopters of CDK for Terraform should expect to encounter and work around b

These caveats apply to CDK for Terraform itself, which generates Terraform configurations. Generated Terraform configurations are applied using Terraform Core, a well established / mature tool to provision infrastructure.

## Feature Flags

CDK for Terraform uses feature flags to enable potentially breaking behaviors in a release. Flags are stored as Runtime context values in cdktf.json as shown here.

```json
{
"language": "typescript",
"app": "npm run --silent compile && node main.js",
"context": {
"excludeStackIdFromLogicalIds": "true"
}
}
```

Feature flags are disabled by default, so existing projects that do not specify the flag will continue to work as expected with later CDKTF releases. New projects created using `cdktf init` include flags enabling all features available in the release that created the project. Edit `cdktf.json` to disable any flags for which you prefer the old behavior, or to add flags to enable new behaviors after upgrading the CDK for Terraform.

See the CHANGELOG in a given release for a description of any new feature flags added in that release. The CDKTF source file [features.ts](https://github.com/hashicorp/terraform-cdk/blob/main/packages/cdktf/lib/features.ts) provides a complete list of all current feature flags.

## Get Started

- [Install CDKTF](https://learn.hashicorp.com/tutorials/terraform/cdktf-install?in=terraform/cdktf) and set up your first project on HashiCorp Learn.
Expand Down
36 changes: 36 additions & 0 deletions website/docs/cdktf/release/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
page_title: Releases
description: >-
We ship a CDK for Terraform release each month. Find a list of recent releases and a link to our changelog.
---

# Releases

-> **Note:** CDK for Terraform is currently in [beta](#project-maturity-and-production-readiness).

We ship a new Terraform Enterprise release each month. Recent releases are listed below. Our [CHANGELOG on github](https://github.com/hashicorp/terraform-cdk/blob/main/CHANGELOG.md) contains details about bug fixes, new features, and deprecations.
laurapacilio marked this conversation as resolved.
Show resolved Hide resolved

- [release name](link to changelog)

## Upgrade Guides

- [Upgrading to v0.7](/cdktf/release/upgrade-guide-v0-7)
laurapacilio marked this conversation as resolved.
Show resolved Hide resolved
- [Upgrading to v0.6](/cdktf/release/upgrade-guide-v0-6)

## Feature Flags

CDK for Terraform uses feature flags to enable potentially breaking behaviors in a release. Flags are stored as Runtime context values in cdktf.json as shown here.

```json
{
"language": "typescript",
"app": "npm run --silent compile && node main.js",
"context": {
"excludeStackIdFromLogicalIds": "true"
}
}
```

Feature flags are disabled by default, so existing projects that do not specify the flag will continue to work as expected with later CDKTF releases. New projects created using `cdktf init` include flags enabling all features available in the release that created the project. Edit `cdktf.json` to disable any flags for which you prefer the old behavior, or to add flags to enable new behaviors after upgrading the CDK for Terraform.

The CHANGELOG contains a description of any new feature flags added in each release. The CDKTF source file [features.ts](https://github.com/hashicorp/terraform-cdk/blob/main/packages/cdktf/lib/features.ts) provides a complete list of all current feature flags.
184 changes: 184 additions & 0 deletions website/docs/cdktf/release/upgrade-guide-v0-6.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
---
page_title: Upgrading to CDKTF Version 0.6
description: >-
Version 0.6 uses constructs version 10. Understand the API changes and learn how to migrate your projects.
---

# Upgrading to CDK for Terraform Version 0.6

CDK for Terraform version 0.6 uses [`constructs`](https://github.com/aws/constructs) version 10. For most users upgrading the versions should be seamless. If you are using more advanced APIs from the `constructs` library, refer to the [Constructs API Changes](#constructs-api-changes) section.

## Background

Since version 0.6 the `cdktf` package depends on `constructs` v10 (formerly was v3). While that jump might look big, v10 is actually going to be the next major version after v3. We made this change because the `constructs` lib v10 is supposed to stay around for a while and is supposed to offer a very stable API.

To achieve this stability in the core functionality a lot has been removed from v10. For further background information you can read into the [PR for v10](https://github.com/aws/constructs/pull/263) or the AWS CDK RFC [Removal of Construct Compatibility Layer](https://github.com/aws/aws-cdk-rfcs/blob/master/text/0192-remove-constructs-compat.md).

While using the v0.6 `cdktf-cli` to deploy stacks that are using an older version of `cdktf` and `constructs` should still work, we recommend upgrading the `cdktf` and `constructs` packages.

## Pre-built providers

All upcoming releases of the [pre-built providers](https://cdk.tf/prebuilt-providers) will depend on `constructs` v10. So we recommend to upgrade your project.
If you cannot upgrade the `cdktf` version, you can switch to [generating provider bindings](https://github.com/hashicorp/terraform-cdk/blob/main/docs/working-with-cdk-for-terraform/using-providers.md#importing-providers-and-modules) via `cdktf get`.

## Upgrading a TypeScript / JavaScript CDKTF project

To upgrade a TypeScript or JavaScript CDKTF project, adjust the versions in the `package.json` file of your project.

```jsonc
{
// ...
"dependencies": {
"cdktf": "^0.6.0",
"constructs": "^10.0.5"
}
}
```

Afterwards run `npm install` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

## Upgrading a Python CDKTF project

### `pipenv` (`python`-template)

To upgrade a Python CDKTF project using `pipenv`, adjust the versions in the `Pipfile` of your project.

```toml
[packages]
cdktf = "~=0.6.0"
```

Afterwards run `pipenv install` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

### Pip3 (`python-pip`-template)

To upgrade a Python CDKTF project using `pip3`, adjust the versions in the `requirements.txt` of your project.

```
cdktf~=0.6.0
```

Afterwards run `pip3 install -r requirements.txt` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

## Upgrading a Java CDKTF project

To upgrade a Java CDKTF project, adjust the versions in the `pom.xml` file of your project.

```xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<dependencies>
<dependency>
<groupId>com.hashicorp</groupId>
<artifactId>cdktf</artifactId>
<version>0.6.0</version>
</dependency>
<dependency>
<groupId>software.constructs</groupId>
<artifactId>constructs</artifactId>
<version>10.0.5</version>
</dependency>
</dependencies>
<!-- ... -->
</project>
```

Afterwards run `mvn install` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

## Upgrading a CSharp CDKTF project

To upgrade a C# CDKTF project, adjust the versions in the `*.csproj` file of your project.

```xml
<Project Sdk="Microsoft.NET.Sdk">
<!-- ... -->
<ItemGroup>
<PackageReference Include="HashiCorp.Cdktf" Version="0.6.0" />
</ItemGroup>
</Project>
```

Afterwards run `dotnet restore` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

## Upgrading a Golang CDKTF project

To upgrade a Golang CDKTF project, adjust the versions in the `go.mod` file of your project.

```
require github.com/aws/constructs-go/constructs/v10 v10.0.5
require github.com/hashicorp/terraform-cdk-go/cdktf v0.6.0
```

Afterwards run `go get` to update the depedencies and `cdktf get` to re-generate the provider bindings if you don't only use pre-built providers.

You also need to adjust all imports to refer to `constructs/v10` instead of `constructs/v3`.

```
import (
"github.com/aws/constructs-go/constructs/v10"
)
```

## Constructs API Changes

### `Aspects` moved to `cdktf`

`Aspects` are now part of `cdktf` as they've been removed from `constructs`. If you use them, you need to change your import statement to import them from the `cdktf` package. The API also has changed a bit:

```typescript
// to register Aspects, use
import { Aspects } from "cdktf"; // new
Aspects.of(construct).add(aspect);

// instead of
construct.node.applyAspect(aspect); // old
```

### `construct.node.addInfo()` / `addWarning()` / `addError()` moved to `Annotations`

The aforementioned methods are now available via the `Annotations` API:

```typescript
// use
import { Annotations } from "cdktf"; // new
Annotations.of(construct).addInfo("hello");

// instead of
construct.node.addInfo("hello"); // old
```

Annotations will also be printed by the `cdktf-cli` after your stack was synthesized. One ore more `error` annotations will make the `synth` fail.

### `onPrepare()` and `prepare()` have been removed

```typescript
// use
import { Aspects } from "cdktf";
class MyConstruct extends Construct {
constructor(scope: IConstruct, id: string) {
super(scope, id);

Aspects.of(this).add({
visit: (node: IConstruct) => {
// visit will also be called on any childs of this construct
if (node === this) console.log("some work");
},
});
}
}

// instead of
class MyConstruct extends Construct {
onPrepare() {
console.log("some work");
}
}
```

### `onSynthesize` has been removed

Should you need support for this, please file a [new issue](https://cdk.tf/feature) on this repo and describe your use-case.

## Further support

If you encounter anything that is missing from this guide or not working as expected, please don't hesitate to file a [bug](https://cdk.tf/bug) so we can improve this guide. You can also post your question to HashiCorp [Discuss](https://discuss.hashicorp.com/) using the [terraform-cdk](https://discuss.hashicorp.com/c/terraform-core/cdk-for-terraform/) category.
Loading