├── docs ├── .gitkeep └── go.md ├── .prettierrc.json ├── .prettierignore ├── API.md ├── .github ├── CODEOWNERS ├── dependabot.yml ├── workflows │ ├── pull-request-lint.yml │ ├── automerge.yml │ ├── auto-approve.yml │ ├── upgrade-main.yml │ ├── upgrade-cdktf.yml │ ├── upgrade-jsii-typescript.yml │ ├── build.yml │ └── release.yml └── MAINTENANCE.md ├── .copywrite.hcl ├── scripts ├── update-jsii-typescript.sh ├── update-cdktf.sh └── check-jsii-versions.js ├── .npmignore ├── projenrc ├── customized-license.ts ├── automerge.ts ├── auto-approve.ts ├── custom-docgen.ts ├── upgrade-cdktf.ts └── upgrade-jsii-typescript.ts ├── .projen ├── files.json ├── deps.json └── tasks.json ├── tsconfig.dev.json ├── .gitignore ├── .gitattributes ├── src └── index.ts ├── .eslintrc.json ├── test └── index.test.ts ├── package.json ├── .projenrc.ts ├── README.md └── LICENSE /docs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.prettierrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [] 3 | } 4 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | -------------------------------------------------------------------------------- /API.md: -------------------------------------------------------------------------------- 1 | # API Documentation 2 | 3 | You can find the documentation for the supported languages here: 4 | undefined 5 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in 2 | # the repo. Unless a later match takes precedence, 3 | # they will be requested for review when someone opens a 4 | # pull request. 5 | * @cdktf/tf-cdk-team 6 | -------------------------------------------------------------------------------- /.copywrite.hcl: -------------------------------------------------------------------------------- 1 | schema_version = 1 2 | 3 | project { 4 | license = "MPL-2.0" 5 | copyright_year = 2022 6 | 7 | # (OPTIONAL) A list of globs that should not have copyright/license headers. 8 | # Supports doublestar glob patterns for more flexibility in defining which 9 | # files or folders should be ignored 10 | header_ignore = [ 11 | # "vendors/**", 12 | # "**autogen**", 13 | "**/node_modules/**", 14 | ".mergify.yml", 15 | "coverage/**", 16 | "dist/**", 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /scripts/update-jsii-typescript.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) HashiCorp, Inc. 3 | # SPDX-License-Identifier: MPL-2.0 4 | 5 | set -ex 6 | 7 | PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd) 8 | NEW_VERSION=$1 9 | 10 | if [ -z "$NEW_VERSION" ]; then 11 | echo "Usage: $0 " 12 | exit 1 13 | fi 14 | 15 | echo "Updating JSII & TypeScript version to $NEW_VERSION" 16 | yarn 17 | sed -i "s/typescriptVersion = \".*\";/typescriptVersion = \"~$NEW_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts" 18 | CI=0 npx projen 19 | 20 | echo "Done" 21 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | /.projen/ 3 | /test-reports/ 4 | junit.xml 5 | /coverage/ 6 | permissions-backup.acl 7 | /dist/changelog.md 8 | /dist/version.txt 9 | /.prettierignore 10 | /.prettierrc.json 11 | /test/ 12 | /tsconfig.dev.json 13 | /src/ 14 | !/lib/ 15 | !/lib/**/*.js 16 | !/lib/**/*.d.ts 17 | dist 18 | /tsconfig.json 19 | /.github/ 20 | /.vscode/ 21 | /.idea/ 22 | /.projenrc.js 23 | tsconfig.tsbuildinfo 24 | /.eslintrc.json 25 | !.jsii 26 | scripts 27 | projenrc 28 | .copywrite.hcl 29 | /.gitattributes 30 | /.projenrc.ts 31 | /projenrc 32 | -------------------------------------------------------------------------------- /projenrc/customized-license.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { IResolver, License } from "projen"; 7 | import { TypeScriptProject } from "projen/lib/typescript"; 8 | 9 | const SPDX = "MPL-2.0"; 10 | 11 | export class CustomizedLicense extends License { 12 | constructor(project: TypeScriptProject) { 13 | super(project, { spdx: SPDX }); 14 | 15 | project.addFields({ license: SPDX }); 16 | } 17 | 18 | synthesizeContent(resolver: IResolver) { 19 | return ( 20 | "Copyright (c) 2022 HashiCorp, Inc.\n\n" + 21 | super.synthesizeContent(resolver) 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # NOTE: This file is not managed by Projen because if you enable Dependabot through Projen, 2 | # it will delete the upgrade-main job and expect you to only use Dependabot for updates. 3 | # That is not what we want either; we just want to use Dependabot for security updates. 4 | 5 | version: 2 6 | updates: 7 | - package-ecosystem: npm 8 | versioning-strategy: lockfile-only 9 | directory: / 10 | schedule: 11 | interval: daily 12 | ignore: 13 | - dependency-name: projen 14 | labels: 15 | - auto-approve 16 | - automerge 17 | - dependencies 18 | - security 19 | # Disable version updates for npm dependencies, only use Dependabot for security updates 20 | open-pull-requests-limit: 0 21 | -------------------------------------------------------------------------------- /.projen/files.json: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | ".eslintrc.json", 4 | ".gitattributes", 5 | ".github/workflows/auto-approve.yml", 6 | ".github/workflows/automerge.yml", 7 | ".github/workflows/build.yml", 8 | ".github/workflows/pull-request-lint.yml", 9 | ".github/workflows/release.yml", 10 | ".github/workflows/upgrade-cdktf.yml", 11 | ".github/workflows/upgrade-jsii-typescript.yml", 12 | ".github/workflows/upgrade-main.yml", 13 | ".gitignore", 14 | ".prettierignore", 15 | ".prettierrc.json", 16 | ".projen/deps.json", 17 | ".projen/files.json", 18 | ".projen/tasks.json", 19 | "API.md", 20 | "LICENSE", 21 | "tsconfig.dev.json" 22 | ], 23 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 24 | } 25 | -------------------------------------------------------------------------------- /.github/workflows/pull-request-lint.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: pull-request-lint 4 | on: 5 | pull_request_target: 6 | types: 7 | - labeled 8 | - opened 9 | - synchronize 10 | - reopened 11 | - ready_for_review 12 | - edited 13 | merge_group: {} 14 | jobs: 15 | validate: 16 | name: Validate PR title 17 | runs-on: ubuntu-latest 18 | permissions: 19 | pull-requests: write 20 | if: (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') 21 | steps: 22 | - uses: amannn/action-semantic-pull-request@0723387faaf9b38adef4775cd42cfd5155ed6017 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | with: 26 | types: |- 27 | feat 28 | fix 29 | chore 30 | requireScope: false 31 | -------------------------------------------------------------------------------- /tsconfig.dev.json: -------------------------------------------------------------------------------- 1 | // ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | { 3 | "compilerOptions": { 4 | "alwaysStrict": true, 5 | "declaration": true, 6 | "esModuleInterop": true, 7 | "experimentalDecorators": true, 8 | "inlineSourceMap": true, 9 | "inlineSources": true, 10 | "lib": [ 11 | "es2020" 12 | ], 13 | "module": "CommonJS", 14 | "noEmitOnError": false, 15 | "noFallthroughCasesInSwitch": true, 16 | "noImplicitAny": true, 17 | "noImplicitReturns": true, 18 | "noImplicitThis": true, 19 | "noUnusedLocals": true, 20 | "noUnusedParameters": true, 21 | "resolveJsonModule": true, 22 | "strict": true, 23 | "strictNullChecks": true, 24 | "strictPropertyInitialization": true, 25 | "stripInternal": true, 26 | "target": "ES2020" 27 | }, 28 | "include": [ 29 | "src/**/*.ts", 30 | "test/**/*.ts", 31 | ".projenrc.ts", 32 | "projenrc/**/*.ts" 33 | ], 34 | "exclude": [ 35 | "node_modules" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /scripts/update-cdktf.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) HashiCorp, Inc. 3 | # SPDX-License-Identifier: MPL-2.0 4 | 5 | set -ex 6 | 7 | PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE:-$0}")/.." && pwd) 8 | CDKTF_VERSION=$1 9 | CONSTRUCTS_VERSION=$2 10 | 11 | if [ -z "$CDKTF_VERSION" ]; then 12 | echo "Usage: $0 " 13 | exit 1 14 | fi 15 | if [ -z "$CONSTRUCTS_VERSION" ]; then 16 | echo "Usage: $0 " 17 | exit 1 18 | fi 19 | 20 | echo "Updating to cdktf version $CDKTF_VERSION and constructs version $CONSTRUCTS_VERSION" 21 | yarn 22 | sed -i "s/cdktfVersion: \".*\",/cdktfVersion: \"$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts" 23 | sed -i "s/\"cdktf@.*\",/\"cdktf@>=$CDKTF_VERSION\",/" "$PROJECT_ROOT/.projenrc.ts" 24 | sed -i "s/constructsVersion = \".*\";/constructsVersion = \"$CONSTRUCTS_VERSION\";/" "$PROJECT_ROOT/.projenrc.ts" 25 | CI=0 npx projen 26 | 27 | echo "Updating README" 28 | sed -i 's/`cdktf` >= .*/`cdktf` >= '"$CDKTF_VERSION"'/' "$PROJECT_ROOT/README.md" 29 | sed -i 's/`constructs` >= .*/`constructs` >= '"$CONSTRUCTS_VERSION"'/' "$PROJECT_ROOT/README.md" 30 | -------------------------------------------------------------------------------- /.github/workflows/automerge.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: automerge 4 | on: 5 | pull_request_target: 6 | types: 7 | - opened 8 | - labeled 9 | - ready_for_review 10 | - reopened 11 | - synchronize 12 | concurrency: 13 | group: ${{ github.workflow }}-${{ github.ref }} 14 | jobs: 15 | automerge: 16 | runs-on: ubuntu-latest 17 | permissions: 18 | contents: read 19 | if: contains(github.event.pull_request.labels.*.name, 'automerge') && github.event.pull_request.draft == false 20 | steps: 21 | - name: Checkout 22 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 23 | - name: Turn on automerge for this PR by a trusted user or bot 24 | if: github.event.pull_request.user.login == 'team-tf-cdk' || contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) || github.actor == 'dependabot[bot]' 25 | env: 26 | GH_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} 27 | run: gh pr merge --auto --squash ${{ github.event.pull_request.number }} 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | !/.gitattributes 3 | !/.projen/tasks.json 4 | !/.projen/deps.json 5 | !/.projen/files.json 6 | !/.github/workflows/pull-request-lint.yml 7 | !/package.json 8 | !/.npmignore 9 | logs 10 | *.log 11 | npm-debug.log* 12 | yarn-debug.log* 13 | yarn-error.log* 14 | lerna-debug.log* 15 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 16 | pids 17 | *.pid 18 | *.seed 19 | *.pid.lock 20 | lib-cov 21 | coverage 22 | *.lcov 23 | .nyc_output 24 | build/Release 25 | node_modules/ 26 | jspm_packages/ 27 | *.tsbuildinfo 28 | .eslintcache 29 | *.tgz 30 | .yarn-integrity 31 | .cache 32 | /test-reports/ 33 | junit.xml 34 | /coverage/ 35 | !/.github/workflows/build.yml 36 | /dist/changelog.md 37 | /dist/version.txt 38 | !/.github/workflows/release.yml 39 | !/.github/workflows/upgrade-main.yml 40 | !/.prettierignore 41 | !/.prettierrc.json 42 | !/test/ 43 | !/tsconfig.dev.json 44 | !/src/ 45 | /lib 46 | /dist/ 47 | !/.eslintrc.json 48 | .jsii 49 | tsconfig.json 50 | !/LICENSE 51 | !/.github/workflows/auto-approve.yml 52 | !/.github/workflows/automerge.yml 53 | !/.github/workflows/upgrade-cdktf.yml 54 | !/.github/workflows/upgrade-jsii-typescript.yml 55 | !docs/typescript.md 56 | !docs/python.md 57 | !docs/java.md 58 | !docs/csharp.md 59 | !/API.md 60 | !/.projenrc.ts 61 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | * text=auto eol=lf 4 | *.snap linguist-generated 5 | /.eslintrc.json linguist-generated 6 | /.gitattributes linguist-generated 7 | /.github/workflows/auto-approve.yml linguist-generated 8 | /.github/workflows/automerge.yml linguist-generated 9 | /.github/workflows/build.yml linguist-generated 10 | /.github/workflows/pull-request-lint.yml linguist-generated 11 | /.github/workflows/release.yml linguist-generated 12 | /.github/workflows/upgrade-cdktf.yml linguist-generated 13 | /.github/workflows/upgrade-jsii-typescript.yml linguist-generated 14 | /.github/workflows/upgrade-main.yml linguist-generated 15 | /.gitignore linguist-generated 16 | /.npmignore linguist-generated 17 | /.prettierignore linguist-generated 18 | /.prettierrc.json linguist-generated 19 | /.projen/** linguist-generated 20 | /.projen/deps.json linguist-generated 21 | /.projen/files.json linguist-generated 22 | /.projen/tasks.json linguist-generated 23 | /API.md linguist-generated 24 | /LICENSE linguist-generated 25 | /package.json linguist-generated 26 | /tsconfig.dev.json linguist-generated 27 | /yarn.lock linguist-generated 28 | docs/csharp.md linguist-generated 29 | docs/java.md linguist-generated 30 | docs/python.md linguist-generated 31 | docs/typescript.md linguist-generated -------------------------------------------------------------------------------- /.github/workflows/auto-approve.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: auto-approve 4 | on: 5 | pull_request_target: 6 | types: 7 | - opened 8 | - labeled 9 | - ready_for_review 10 | - reopened 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | jobs: 14 | approve: 15 | runs-on: ubuntu-latest 16 | permissions: 17 | contents: read 18 | pull-requests: write 19 | if: contains(github.event.pull_request.labels.*.name, 'auto-approve') && github.event.pull_request.draft == false 20 | steps: 21 | - name: Checkout PR 22 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 23 | with: 24 | ref: ${{ github.event.pull_request.head.ref }} 25 | repository: ${{ github.event.pull_request.head.repo.full_name }} 26 | - name: Auto-approve PRs by other users as team-tf-cdk 27 | if: github.event.pull_request.user.login != 'team-tf-cdk' && (contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association) || github.actor == 'dependabot[bot]') 28 | env: 29 | GH_TOKEN: ${{ secrets.PROJEN_GITHUB_TOKEN }} 30 | run: gh pr review ${{ github.event.pull_request.number }} --approve 31 | - name: Auto-approve PRs by team-tf-cdk as github-actions[bot] 32 | if: github.event.pull_request.user.login == 'team-tf-cdk' 33 | env: 34 | GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 35 | run: gh pr review ${{ github.event.pull_request.number }} --approve 36 | -------------------------------------------------------------------------------- /projenrc/automerge.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { javascript } from "projen"; 7 | import { JobPermission } from "projen/lib/github/workflows-model"; 8 | 9 | /** 10 | * Enables GitHub's built-in automerge for PRs with the "automerge" label 11 | */ 12 | export class Automerge { 13 | constructor(project: javascript.NodeProject) { 14 | const workflow = project.github?.addWorkflow("automerge"); 15 | 16 | if (!workflow) throw new Error("no workflow defined"); 17 | 18 | workflow.on({ 19 | pullRequestTarget: { 20 | types: [ 21 | "opened", 22 | "labeled", 23 | "ready_for_review", 24 | "reopened", 25 | "synchronize", 26 | ], 27 | }, 28 | }); 29 | 30 | (workflow.concurrency as any) = { 31 | group: "${{ github.workflow }}-${{ github.ref }}", 32 | }; 33 | 34 | const maintainerStatuses = `fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]')`; 35 | workflow.addJobs({ 36 | automerge: { 37 | runsOn: ["ubuntu-latest"], 38 | if: "contains(github.event.pull_request.labels.*.name, 'automerge') && github.event.pull_request.draft == false", 39 | steps: [ 40 | { 41 | name: "Checkout", 42 | uses: "actions/checkout@v3", 43 | }, 44 | { 45 | name: "Turn on automerge for this PR by a trusted user or bot", 46 | if: `github.event.pull_request.user.login == 'team-tf-cdk' || contains(${maintainerStatuses}, github.event.pull_request.author_association) || github.actor == 'dependabot[bot]'`, 47 | run: "gh pr merge --auto --squash ${{ github.event.pull_request.number }}", 48 | env: { 49 | GH_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}", 50 | }, 51 | }, 52 | ], 53 | permissions: { 54 | contents: JobPermission.READ, 55 | }, 56 | }, 57 | }); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /scripts/check-jsii-versions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | const today = new Date(); 6 | const oneMonthFromToday = new Date(); 7 | oneMonthFromToday.setDate(today.getDate() + 30); 8 | // console.debug("oneMonthFromToday", oneMonthFromToday.toDateString()); 9 | 10 | /** Return the earliest supported version whose EOS date is at least a month away */ 11 | async function getEarliestSupportedVersion() { 12 | // https://github.com/aws/jsii-compiler/blob/main/releases.json 13 | const response = await fetch("https://raw.githubusercontent.com/aws/jsii-compiler/main/releases.json"); 14 | const data = await response.json(); 15 | const activelySupportedVersions = Object.entries(data.maintenance).filter(([version, supportEndDate]) => { 16 | return new Date(supportEndDate) > oneMonthFromToday; 17 | }).sort((a, b) => { 18 | // Very naive sorting function: treat "5.4" like (int) 54, "5.5" like (int) 55, etc. and compare accordingly 19 | return parseInt(a[0].replace(".", ""), 10) > parseInt(b[0].replace(".", ""), 10); 20 | }); 21 | 22 | console.debug("Actively supported versions with an EOS date at least 1 month away") 23 | console.debug(Object.fromEntries(activelySupportedVersions)); 24 | 25 | return activelySupportedVersions[0][0]; 26 | } 27 | 28 | async function getDesiredVersion() { 29 | const earliestSupportedVersion = await getEarliestSupportedVersion(); 30 | console.debug("earliestSupportedVersion", earliestSupportedVersion); 31 | 32 | return earliestSupportedVersion; 33 | } 34 | 35 | module.exports = async ({github, context, core}) => { 36 | const version = await getDesiredVersion(); 37 | 38 | core.exportVariable('NEW_JSII_VERSION', version + ".0"); // e.g. "5.4.0" 39 | core.exportVariable('NEW_JSII_VERSION_SHORT', version); // e.g. "5.4" 40 | core.exportVariable('NEW_JSII_VERSION_MAJOR', version.split(".")[0]); // e.g. "5" 41 | core.exportVariable('NEW_JSII_VERSION_MINOR', version.split(".")[1]); // e.g. "4" 42 | } 43 | -------------------------------------------------------------------------------- /projenrc/auto-approve.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { javascript } from "projen"; 7 | import { JobPermission } from "projen/lib/github/workflows-model"; 8 | 9 | /** 10 | * Approves PRs with the "auto-approve" label 11 | */ 12 | export class AutoApprove { 13 | constructor(project: javascript.NodeProject) { 14 | const workflow = project.github?.addWorkflow("auto-approve"); 15 | 16 | if (!workflow) throw new Error("no workflow defined"); 17 | 18 | workflow.on({ 19 | pullRequestTarget: { 20 | types: ["opened", "labeled", "ready_for_review", "reopened"], 21 | }, 22 | }); 23 | 24 | (workflow.concurrency as any) = { 25 | group: "${{ github.workflow }}-${{ github.ref }}", 26 | }; 27 | 28 | const maintainerStatuses = `fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]')`; 29 | workflow.addJobs({ 30 | approve: { 31 | runsOn: ["ubuntu-latest"], 32 | if: "contains(github.event.pull_request.labels.*.name, 'auto-approve') && github.event.pull_request.draft == false", 33 | steps: [ 34 | { 35 | name: "Checkout PR", 36 | uses: "actions/checkout@v3", 37 | with: { 38 | ref: "${{ github.event.pull_request.head.ref }}", 39 | repository: 40 | "${{ github.event.pull_request.head.repo.full_name }}", 41 | }, 42 | }, 43 | { 44 | name: "Auto-approve PRs by other users as team-tf-cdk", 45 | if: `github.event.pull_request.user.login != 'team-tf-cdk' && (contains(${maintainerStatuses}, github.event.pull_request.author_association) || github.actor == 'dependabot[bot]')`, 46 | run: "gh pr review ${{ github.event.pull_request.number }} --approve", 47 | env: { 48 | GH_TOKEN: "${{ secrets.PROJEN_GITHUB_TOKEN }}", 49 | }, 50 | }, 51 | { 52 | name: "Auto-approve PRs by team-tf-cdk as github-actions[bot]", 53 | if: "github.event.pull_request.user.login == 'team-tf-cdk'", 54 | run: "gh pr review ${{ github.event.pull_request.number }} --approve", 55 | env: { 56 | GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}", 57 | }, 58 | }, 59 | ], 60 | permissions: { 61 | contents: JobPermission.READ, 62 | pullRequests: JobPermission.WRITE, 63 | }, 64 | }, 65 | }); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { 7 | App, 8 | AppConfig, 9 | TerraformProvider, 10 | TerraformStack, 11 | TerraformVariable, 12 | TerraformVariableConfig, 13 | TerraformOutput, 14 | TerraformOutputConfig, 15 | } from "cdktf"; 16 | import { Construct } from "constructs"; 17 | 18 | export class TFModuleApp extends App { 19 | constructor(options?: AppConfig) { 20 | // We don't want the provider validation to kick in 21 | super({ ...(options || {}), skipValidation: true }); 22 | } 23 | } 24 | 25 | export class ProviderRequirement extends TerraformProvider { 26 | constructor( 27 | scope: Construct, 28 | providerName: string, 29 | providerVersionConstraint?: string, 30 | terraformProviderSource?: string 31 | ) { 32 | super(scope, providerName, { 33 | terraformResourceType: providerName, 34 | terraformGeneratorMetadata: { 35 | providerName, 36 | providerVersionConstraint, 37 | }, 38 | terraformProviderSource, 39 | }); 40 | } 41 | } 42 | 43 | export class TFModuleStack extends TerraformStack { 44 | public toTerraform(): any { 45 | const tf = super.toTerraform(); 46 | delete tf.provider; 47 | delete tf.terraform.backend; 48 | return tf; 49 | } 50 | } 51 | 52 | export type TFModuleVariableConfig = TerraformVariableConfig; 53 | export class TFModuleVariable extends TerraformVariable { 54 | constructor(scope: Construct, name: string, config: TFModuleVariableConfig) { 55 | super(scope, name, config); 56 | this.overrideLogicalId(name); 57 | } 58 | 59 | public toTerraform(): any { 60 | const toTerraform = super.toTerraform(); 61 | const value = toTerraform.variable[this.friendlyUniqueId]; 62 | return { 63 | variable: { 64 | // We need to put this into an extra array so that cdktf get works with the output properly 65 | [this.friendlyUniqueId]: [value], 66 | }, 67 | }; 68 | } 69 | } 70 | 71 | export type TFModuleOutputConfig = TerraformOutputConfig; 72 | export class TFModuleOutput extends TerraformOutput { 73 | constructor(scope: Construct, name: string, config: TFModuleOutputConfig) { 74 | super(scope, name, config); 75 | this.overrideLogicalId(name); 76 | } 77 | 78 | public toTerraform(): any { 79 | const toTerraform = super.toTerraform(); 80 | const value = toTerraform.output[this.friendlyUniqueId]; 81 | return { 82 | output: { 83 | // We need to put this into an extra array so that cdktf get works with the output properly 84 | [this.friendlyUniqueId]: [value], 85 | }, 86 | }; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /projenrc/custom-docgen.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { FileBase } from "projen"; 7 | import { JsiiProject } from "projen/lib/cdk"; 8 | 9 | interface JsiiDocgenOptions { 10 | /** 11 | * File path for generated docs. 12 | * @default "API.md" 13 | */ 14 | readonly filePath?: string; 15 | 16 | readonly languages: ("typescript" | "python" | "java" | "csharp" | "go")[]; 17 | readonly documentationDirectory?: string; 18 | } 19 | 20 | class DocumentationEntryPoint extends FileBase { 21 | constructor(node: JsiiProject, private readonly options: JsiiDocgenOptions) { 22 | super(node, options.filePath ?? "API.md"); 23 | } 24 | protected synthesizeContent(): string | undefined { 25 | const documentationDir = this.options.documentationDirectory ?? "docs"; 26 | return `# API Documentation 27 | 28 | You can find the documentation for the supported languages here: 29 | ${this.options.languages.forEach( 30 | (language) => `- [${language}](${documentationDir}/${language}` 31 | )} 32 | `; 33 | } 34 | } 35 | 36 | export class JsiiDocgen { 37 | constructor( 38 | node: JsiiProject, 39 | options: JsiiDocgenOptions = { 40 | languages: ["typescript"], 41 | } 42 | ) { 43 | node.addDevDeps("jsii-docgen"); 44 | 45 | const filePath = options.filePath ?? "API.md"; 46 | 47 | if (options.languages.length === 0) { 48 | throw new Error("No languages specified"); 49 | } else if (options.languages.length === 1) { 50 | const docgen = node.addTask("docgen", { 51 | description: "Generate API.md from .jsii manifest", 52 | exec: `jsii-docgen -r0 -o ${filePath} -l ${options.languages[0]}`, 53 | }); 54 | 55 | // spawn docgen after compilation (requires the .jsii manifest). 56 | node.postCompileTask.spawn(docgen); 57 | node.gitignore.include(`/${filePath}`); 58 | node.annotateGenerated(`/${filePath}`); 59 | } else { 60 | const documentationDir = options.documentationDirectory ?? "docs"; 61 | options.languages.forEach((language) => { 62 | const languageDocsPath = `${documentationDir}/${language}.md`; 63 | const docgen = node.addTask(`docgen-${language}`, { 64 | description: `Generate API.md from .jsii manifest for ${language}`, 65 | exec: `jsii-docgen -r0 -o ${languageDocsPath} -l ${language}`, 66 | }); 67 | 68 | // spawn docgen after compilation (requires the .jsii manifest). 69 | node.postCompileTask.spawn(docgen); 70 | node.gitignore.include(languageDocsPath); 71 | node.annotateGenerated(languageDocsPath); 72 | }); 73 | 74 | new DocumentationEntryPoint(node, options); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /.projen/deps.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": [ 3 | { 4 | "name": "@cdktf/provider-null", 5 | "version": ">=11.0.0", 6 | "type": "build" 7 | }, 8 | { 9 | "name": "@cdktf/provider-random", 10 | "version": ">=12.0.0", 11 | "type": "build" 12 | }, 13 | { 14 | "name": "@types/jest", 15 | "type": "build" 16 | }, 17 | { 18 | "name": "@types/node", 19 | "version": "ts5.8", 20 | "type": "build" 21 | }, 22 | { 23 | "name": "@typescript-eslint/eslint-plugin", 24 | "version": "^8", 25 | "type": "build" 26 | }, 27 | { 28 | "name": "@typescript-eslint/parser", 29 | "version": "^8", 30 | "type": "build" 31 | }, 32 | { 33 | "name": "commit-and-tag-version", 34 | "version": "^12", 35 | "type": "build" 36 | }, 37 | { 38 | "name": "constructs", 39 | "version": "^10.0.0", 40 | "type": "build" 41 | }, 42 | { 43 | "name": "eslint-config-prettier", 44 | "type": "build" 45 | }, 46 | { 47 | "name": "eslint-import-resolver-typescript", 48 | "type": "build" 49 | }, 50 | { 51 | "name": "eslint-plugin-import", 52 | "type": "build" 53 | }, 54 | { 55 | "name": "eslint-plugin-prettier", 56 | "type": "build" 57 | }, 58 | { 59 | "name": "eslint", 60 | "version": "^9", 61 | "type": "build" 62 | }, 63 | { 64 | "name": "jest", 65 | "type": "build" 66 | }, 67 | { 68 | "name": "jest-junit", 69 | "version": "^16", 70 | "type": "build" 71 | }, 72 | { 73 | "name": "jsii-diff", 74 | "type": "build" 75 | }, 76 | { 77 | "name": "jsii-docgen", 78 | "type": "build" 79 | }, 80 | { 81 | "name": "jsii-pacmak", 82 | "type": "build" 83 | }, 84 | { 85 | "name": "jsii-rosetta", 86 | "version": "~5.8.0", 87 | "type": "build" 88 | }, 89 | { 90 | "name": "jsii", 91 | "version": "~5.8.0", 92 | "type": "build" 93 | }, 94 | { 95 | "name": "prettier", 96 | "type": "build" 97 | }, 98 | { 99 | "name": "projen", 100 | "type": "build" 101 | }, 102 | { 103 | "name": "ts-jest", 104 | "type": "build" 105 | }, 106 | { 107 | "name": "ts-node", 108 | "type": "build" 109 | }, 110 | { 111 | "name": "typescript", 112 | "version": "~5.8.0", 113 | "type": "build" 114 | }, 115 | { 116 | "name": "cdktf", 117 | "version": ">=0.21.0", 118 | "type": "peer" 119 | }, 120 | { 121 | "name": "constructs", 122 | "version": "^10.4.2", 123 | "type": "peer" 124 | } 125 | ], 126 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 127 | } 128 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | // ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | { 3 | "env": { 4 | "jest": true, 5 | "node": true 6 | }, 7 | "root": true, 8 | "plugins": [ 9 | "@typescript-eslint", 10 | "import" 11 | ], 12 | "parser": "@typescript-eslint/parser", 13 | "parserOptions": { 14 | "ecmaVersion": 2018, 15 | "sourceType": "module", 16 | "project": "./tsconfig.dev.json" 17 | }, 18 | "extends": [ 19 | "plugin:import/typescript", 20 | "plugin:prettier/recommended" 21 | ], 22 | "settings": { 23 | "import/parsers": { 24 | "@typescript-eslint/parser": [ 25 | ".ts", 26 | ".tsx" 27 | ] 28 | }, 29 | "import/resolver": { 30 | "node": {}, 31 | "typescript": { 32 | "project": "./tsconfig.dev.json", 33 | "alwaysTryTypes": true 34 | } 35 | } 36 | }, 37 | "ignorePatterns": [ 38 | "*.js", 39 | "*.d.ts", 40 | "node_modules/", 41 | "*.generated.ts", 42 | "coverage", 43 | "!.projenrc.ts", 44 | "!projenrc/**/*.ts" 45 | ], 46 | "rules": { 47 | "curly": [ 48 | "error", 49 | "multi-line", 50 | "consistent" 51 | ], 52 | "@typescript-eslint/no-require-imports": "error", 53 | "import/no-extraneous-dependencies": [ 54 | "error", 55 | { 56 | "devDependencies": [ 57 | "**/test/**", 58 | "**/build-tools/**", 59 | ".projenrc.ts", 60 | "projenrc/**/*.ts" 61 | ], 62 | "optionalDependencies": false, 63 | "peerDependencies": true 64 | } 65 | ], 66 | "import/no-unresolved": [ 67 | "error" 68 | ], 69 | "import/order": [ 70 | "warn", 71 | { 72 | "groups": [ 73 | "builtin", 74 | "external" 75 | ], 76 | "alphabetize": { 77 | "order": "asc", 78 | "caseInsensitive": true 79 | } 80 | } 81 | ], 82 | "import/no-duplicates": [ 83 | "error" 84 | ], 85 | "no-shadow": [ 86 | "off" 87 | ], 88 | "@typescript-eslint/no-shadow": "error", 89 | "@typescript-eslint/no-floating-promises": "error", 90 | "no-return-await": [ 91 | "off" 92 | ], 93 | "@typescript-eslint/return-await": "error", 94 | "dot-notation": [ 95 | "error" 96 | ], 97 | "no-bitwise": [ 98 | "error" 99 | ], 100 | "@typescript-eslint/member-ordering": [ 101 | "error", 102 | { 103 | "default": [ 104 | "public-static-field", 105 | "public-static-method", 106 | "protected-static-field", 107 | "protected-static-method", 108 | "private-static-field", 109 | "private-static-method", 110 | "field", 111 | "constructor", 112 | "method" 113 | ] 114 | } 115 | ] 116 | }, 117 | "overrides": [ 118 | { 119 | "files": [ 120 | ".projenrc.ts" 121 | ], 122 | "rules": { 123 | "@typescript-eslint/no-require-imports": "off", 124 | "import/no-extraneous-dependencies": "off" 125 | } 126 | } 127 | ] 128 | } 129 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-main.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-main 4 | on: 5 | workflow_dispatch: {} 6 | schedule: 7 | - cron: 0 0 * * 1 8 | jobs: 9 | upgrade: 10 | name: Upgrade 11 | runs-on: ubuntu-latest 12 | permissions: 13 | contents: read 14 | outputs: 15 | patch_created: ${{ steps.create_patch.outputs.patch_created }} 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 19 | with: 20 | ref: main 21 | - name: Install dependencies 22 | run: yarn install --check-files --frozen-lockfile 23 | - name: Upgrade dependencies 24 | run: npx projen upgrade 25 | - name: Find mutations 26 | id: create_patch 27 | run: |- 28 | git add . 29 | git diff --staged --patch --exit-code > repo.patch || echo "patch_created=true" >> $GITHUB_OUTPUT 30 | shell: bash 31 | working-directory: ./ 32 | - name: Upload patch 33 | if: steps.create_patch.outputs.patch_created 34 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 35 | with: 36 | name: repo.patch 37 | path: repo.patch 38 | overwrite: true 39 | pr: 40 | name: Create Pull Request 41 | needs: upgrade 42 | runs-on: ubuntu-latest 43 | permissions: 44 | contents: read 45 | if: ${{ needs.upgrade.outputs.patch_created }} 46 | steps: 47 | - name: Checkout 48 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 49 | with: 50 | ref: main 51 | - name: Download patch 52 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 53 | with: 54 | name: repo.patch 55 | path: ${{ runner.temp }} 56 | - name: Apply patch 57 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 58 | - name: Set git identity 59 | run: |- 60 | git config user.name "team-tf-cdk" 61 | git config user.email "github-team-tf-cdk@hashicorp.com" 62 | - name: Create Pull Request 63 | id: create-pr 64 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e 65 | with: 66 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 67 | commit-message: |- 68 | chore(deps): upgrade dependencies 69 | 70 | Upgrades project dependencies. See details in [workflow run]. 71 | 72 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 73 | 74 | ------ 75 | 76 | *Automatically created by projen via the "upgrade-main" workflow* 77 | branch: github-actions/upgrade-main 78 | title: "chore(deps): upgrade dependencies" 79 | labels: auto-approve,automerge,dependencies 80 | body: |- 81 | Upgrades project dependencies. See details in [workflow run]. 82 | 83 | [Workflow Run]: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} 84 | 85 | ------ 86 | 87 | *Automatically created by projen via the "upgrade-main" workflow* 88 | author: team-tf-cdk 89 | committer: team-tf-cdk 90 | signoff: true 91 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-cdktf.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-cdktf 4 | on: 5 | schedule: 6 | - cron: 35 */6 * * * 7 | workflow_dispatch: {} 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | jobs: 11 | upgrade: 12 | name: Upgrade CDKTF 13 | runs-on: ubuntu-latest 14 | permissions: 15 | contents: read 16 | env: 17 | CI: "true" 18 | CHECKPOINT_DISABLE: "1" 19 | steps: 20 | - name: Checkout 21 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 22 | - name: Setup Node.js 23 | uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 24 | with: {} 25 | - name: Install 26 | run: yarn install 27 | - name: Get current CDKTF version 28 | id: current_version 29 | run: |- 30 | OLD_VERSION=$(npm list cdktf --depth=0 --json | jq -r '.dependencies.cdktf.version') 31 | OLD_VERSION_SHORT=$(cut -d "." -f 2 <<< "$OLD_VERSION") 32 | echo "value=$OLD_VERSION" >> $GITHUB_OUTPUT 33 | echo "short=$OLD_VERSION_SHORT" >> $GITHUB_OUTPUT 34 | - name: Get latest CDKTF version 35 | id: latest_version 36 | run: |- 37 | CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version') 38 | CDKTF_VERSION_SHORT=$(cut -d "." -f 2 <<< "$CDKTF_VERSION") 39 | CONSTRUCTS_VERSION=$(yarn info cdktf --json | jq -r '.data.peerDependencies.constructs') 40 | CONSTRUCTS_VERSION_EXACT=$(cut -d "^" -f 2 <<< "$CONSTRUCTS_VERSION") 41 | echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT 42 | echo "short=$CDKTF_VERSION_SHORT" >> $GITHUB_OUTPUT 43 | echo "constructs=$CONSTRUCTS_VERSION_EXACT" >> $GITHUB_OUTPUT 44 | - name: Run upgrade script 45 | if: steps.current_version.outputs.short != steps.latest_version.outputs.short 46 | run: scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} ${{ steps.latest_version.outputs.constructs }} 47 | - name: Create draft pull request 48 | if: steps.current_version.outputs.short != steps.latest_version.outputs.short 49 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e 50 | with: 51 | commit-message: "chore!: upgrade to cdktf ${{ steps.latest_version.outputs.value }}" 52 | branch: auto/upgrade-cdktf-${{ steps.latest_version.outputs.short }} 53 | base: main 54 | title: "chore!: upgrade to cdktf ${{ steps.latest_version.outputs.value }}" 55 | body: |- 56 | This PR initiates the upgrade of CDKTF from version `${{ steps.current_version.outputs.value }}` to version `${{ steps.latest_version.outputs.value }}`. 57 | Unfortunately, not everything can be automated, and the following steps need to be completed manually: 58 | 59 | - [ ] Update `@cdktf/provider-null` to a version compatible with `cdktf@${{ steps.latest_version.outputs.value }}` [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/106036d2d6b65652b68dabb2648b1f7980c6421d/.projenrc.ts#L78). Look up the version [here](https://github.com/cdktf/cdktf-provider-null/releases/). 60 | - [ ] Update `@cdktf/provider-random` to a version compatible with `cdktf@${{ steps.latest_version.outputs.value }}` [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/106036d2d6b65652b68dabb2648b1f7980c6421d/.projenrc.ts#L79). Look up the version [here](https://github.com/cdktf/cdktf-provider-random/releases/). 61 | - [ ] Run `npx projen` 62 | 63 | Please checkout this PR, complete the above steps, push the changes to this branch, and then mark this PR as ready for review to complete the upgrade. Thanks! 64 | labels: automerge,auto-approve,dependencies 65 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 66 | author: team-tf-cdk 67 | committer: team-tf-cdk 68 | signoff: true 69 | delete-branch: true 70 | draft: true 71 | -------------------------------------------------------------------------------- /test/index.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { NullProvider } from "@cdktf/provider-null/lib/provider"; 7 | import { Resource } from "@cdktf/provider-null/lib/resource"; 8 | import { RemoteBackend, Testing } from "cdktf"; 9 | import { Construct } from "constructs"; 10 | import { 11 | TFModuleStack, 12 | TFModuleVariable, 13 | ProviderRequirement, 14 | TFModuleOutput, 15 | } from "../src"; 16 | 17 | test("synthesizes a specific provider", () => { 18 | const app = Testing.app(); 19 | class MyStack extends TFModuleStack { 20 | constructor(scope: Construct, id: string) { 21 | super(scope, id); 22 | 23 | new NullProvider(this, "null"); 24 | new Resource(this, "resource"); 25 | } 26 | } 27 | const stack = new MyStack(app, "MyStack"); 28 | expect(Testing.synth(stack)).toMatchInlineSnapshot(` 29 | "{ 30 | "resource": { 31 | "null_resource": { 32 | "resource": { 33 | } 34 | } 35 | }, 36 | "terraform": { 37 | "required_providers": { 38 | "null": { 39 | "source": "null", 40 | "version": "3.2.4" 41 | } 42 | } 43 | } 44 | }" 45 | `); 46 | }); 47 | 48 | test("synthesizes an abstract provider", () => { 49 | const app = Testing.app(); 50 | class MyStack extends TFModuleStack { 51 | constructor(scope: Construct, id: string) { 52 | super(scope, id); 53 | 54 | new ProviderRequirement(this, "null", ">= 2.0.0"); 55 | new Resource(this, "resource"); 56 | } 57 | } 58 | const stack = new MyStack(app, "MyStack"); 59 | expect(Testing.synth(stack)).toMatchInlineSnapshot(` 60 | "{ 61 | "resource": { 62 | "null_resource": { 63 | "resource": { 64 | } 65 | } 66 | }, 67 | "terraform": { 68 | "required_providers": { 69 | "null": { 70 | "version": ">= 2.0.0" 71 | } 72 | } 73 | } 74 | }" 75 | `); 76 | }); 77 | 78 | test("synthesizes a provider with a specific source", () => { 79 | const app = Testing.app(); 80 | class MyStack extends TFModuleStack { 81 | constructor(scope: Construct, id: string) { 82 | super(scope, id); 83 | 84 | new ProviderRequirement(this, "null", ">= 2.0.0", "hashicorp/null"); 85 | new Resource(this, "resource"); 86 | } 87 | } 88 | const stack = new MyStack(app, "MyStack"); 89 | expect(Testing.synth(stack)).toMatchInlineSnapshot(` 90 | "{ 91 | "resource": { 92 | "null_resource": { 93 | "resource": { 94 | } 95 | } 96 | }, 97 | "terraform": { 98 | "required_providers": { 99 | "null": { 100 | "source": "hashicorp/null", 101 | "version": ">= 2.0.0" 102 | } 103 | } 104 | } 105 | }" 106 | `); 107 | }); 108 | 109 | test("synthesizes no backend", () => { 110 | const app = Testing.app(); 111 | class MyStack extends TFModuleStack { 112 | constructor(scope: Construct, id: string) { 113 | super(scope, id); 114 | 115 | new RemoteBackend(this, { 116 | organization: "test", 117 | workspaces: [{ name: "test" }], 118 | }); 119 | new NullProvider(this, "null"); 120 | new Resource(this, "resource"); 121 | } 122 | } 123 | const stack = new MyStack(app, "MyStack"); 124 | expect(Testing.synth(stack)).toMatchInlineSnapshot(` 125 | "{ 126 | "resource": { 127 | "null_resource": { 128 | "resource": { 129 | } 130 | } 131 | }, 132 | "terraform": { 133 | "required_providers": { 134 | "null": { 135 | "source": "null", 136 | "version": "3.2.4" 137 | } 138 | } 139 | } 140 | }" 141 | `); 142 | }); 143 | 144 | test("synthesizes variables and outputs", () => { 145 | const app = Testing.app(); 146 | class MyStack extends TFModuleStack { 147 | constructor(scope: Construct, id: string) { 148 | super(scope, id); 149 | 150 | new TFModuleVariable(this, "my_variable", { 151 | type: "string", 152 | }); 153 | new NullProvider(this, "null"); 154 | const res = new Resource(this, "resource"); 155 | 156 | new TFModuleOutput(this, "my_output", { 157 | value: res.id, 158 | }); 159 | } 160 | } 161 | const stack = new MyStack(app, "MyStack"); 162 | expect(Testing.synth(stack)).toMatchInlineSnapshot(` 163 | "{ 164 | "output": { 165 | "my_output": [ 166 | { 167 | "value": "\${null_resource.resource.id}" 168 | } 169 | ] 170 | }, 171 | "resource": { 172 | "null_resource": { 173 | "resource": { 174 | } 175 | } 176 | }, 177 | "terraform": { 178 | "required_providers": { 179 | "null": { 180 | "source": "null", 181 | "version": "3.2.4" 182 | } 183 | } 184 | }, 185 | "variable": { 186 | "my_variable": [ 187 | { 188 | "type": "string" 189 | } 190 | ] 191 | } 192 | }" 193 | `); 194 | }); 195 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@cdktf/tf-module-stack", 3 | "description": "A drop-in replacement for cdktf.TerraformStack that lets you define Terraform modules as constructs", 4 | "repository": { 5 | "type": "git", 6 | "url": "https://github.com/cdktf/cdktf-tf-module-stack.git" 7 | }, 8 | "scripts": { 9 | "build": "npx projen build", 10 | "bump": "npx projen bump", 11 | "clobber": "npx projen clobber", 12 | "compat": "npx projen compat", 13 | "compile": "npx projen compile", 14 | "default": "npx projen default", 15 | "docgen-csharp": "npx projen docgen-csharp", 16 | "docgen-java": "npx projen docgen-java", 17 | "docgen-python": "npx projen docgen-python", 18 | "docgen-typescript": "npx projen docgen-typescript", 19 | "eject": "npx projen eject", 20 | "eslint": "npx projen eslint", 21 | "package": "npx projen package", 22 | "package-all": "npx projen package-all", 23 | "package:dotnet": "npx projen package:dotnet", 24 | "package:go": "npx projen package:go", 25 | "package:java": "npx projen package:java", 26 | "package:js": "npx projen package:js", 27 | "package:python": "npx projen package:python", 28 | "post-compile": "npx projen post-compile", 29 | "post-upgrade": "npx projen post-upgrade", 30 | "pre-compile": "npx projen pre-compile", 31 | "release": "npx projen release", 32 | "test": "npx projen test", 33 | "test:watch": "npx projen test:watch", 34 | "unbump": "npx projen unbump", 35 | "upgrade": "npx projen upgrade", 36 | "watch": "npx projen watch", 37 | "projen": "npx projen" 38 | }, 39 | "author": { 40 | "name": "HashiCorp", 41 | "url": "https://hashicorp.com", 42 | "organization": true 43 | }, 44 | "devDependencies": { 45 | "@cdktf/provider-null": ">=11.0.0", 46 | "@cdktf/provider-random": ">=12.0.0", 47 | "@types/jest": "^29", 48 | "@types/node": "ts5.8", 49 | "@typescript-eslint/eslint-plugin": "^8", 50 | "@typescript-eslint/parser": "^8", 51 | "cdktf": "0.21.0", 52 | "commit-and-tag-version": "^12", 53 | "constructs": "10.4.2", 54 | "eslint": "^9", 55 | "eslint-config-prettier": "^8.10.2", 56 | "eslint-import-resolver-typescript": "^2.7.1", 57 | "eslint-plugin-import": "^2.32.0", 58 | "eslint-plugin-prettier": "^4.2.5", 59 | "jest": "^29", 60 | "jest-junit": "^16", 61 | "jsii": "~5.8.0", 62 | "jsii-diff": "^1.119.0", 63 | "jsii-docgen": "^10.11.3", 64 | "jsii-pacmak": "^1.119.0", 65 | "jsii-rosetta": "~5.8.0", 66 | "prettier": "^2.8.8", 67 | "projen": "^0.98.11", 68 | "ts-jest": "^29.4.5", 69 | "ts-node": "10.9.2", 70 | "typescript": "~5.8.0" 71 | }, 72 | "peerDependencies": { 73 | "cdktf": ">=0.21.0", 74 | "constructs": "^10.4.2" 75 | }, 76 | "keywords": [ 77 | "cdk", 78 | "cdktf", 79 | "terraform" 80 | ], 81 | "main": "lib/index.js", 82 | "license": "MPL-2.0", 83 | "publishConfig": { 84 | "access": "public" 85 | }, 86 | "version": "0.0.0", 87 | "jest": { 88 | "coverageProvider": "v8", 89 | "testMatch": [ 90 | "/@(src|test)/**/*(*.)@(spec|test).ts?(x)", 91 | "/@(src|test)/**/__tests__/**/*.ts?(x)", 92 | "/@(projenrc)/**/*(*.)@(spec|test).ts?(x)", 93 | "/@(projenrc)/**/__tests__/**/*.ts?(x)" 94 | ], 95 | "clearMocks": true, 96 | "collectCoverage": true, 97 | "coverageReporters": [ 98 | "json", 99 | "lcov", 100 | "clover", 101 | "cobertura", 102 | "text" 103 | ], 104 | "coverageDirectory": "coverage", 105 | "coveragePathIgnorePatterns": [ 106 | "/node_modules/", 107 | "dist" 108 | ], 109 | "testPathIgnorePatterns": [ 110 | "/node_modules/", 111 | "dist" 112 | ], 113 | "watchPathIgnorePatterns": [ 114 | "/node_modules/" 115 | ], 116 | "reporters": [ 117 | "default", 118 | [ 119 | "jest-junit", 120 | { 121 | "outputDirectory": "test-reports" 122 | } 123 | ] 124 | ], 125 | "transform": { 126 | "^.+\\.[t]sx?$": [ 127 | "ts-jest", 128 | { 129 | "tsconfig": "tsconfig.dev.json" 130 | } 131 | ] 132 | } 133 | }, 134 | "types": "lib/index.d.ts", 135 | "stability": "stable", 136 | "jsii": { 137 | "outdir": "dist", 138 | "targets": { 139 | "java": { 140 | "package": "com.hashicorp.cdktf.tf_module_stack", 141 | "maven": { 142 | "groupId": "com.hashicorp", 143 | "artifactId": "cdktf-tf-module-stack" 144 | } 145 | }, 146 | "python": { 147 | "distName": "cdktf-tf-module-stack", 148 | "module": "cdktf_tf_module_stack" 149 | }, 150 | "dotnet": { 151 | "namespace": "HashiCorp.Cdktf.TfModuleStack", 152 | "packageId": "HashiCorp.Cdktf.TfModuleStack" 153 | }, 154 | "go": { 155 | "moduleName": "github.com/cdktf/cdktf-tf-module-stack-go", 156 | "packageName": "tfmodulestack" 157 | } 158 | }, 159 | "tsc": { 160 | "outDir": "lib", 161 | "rootDir": "src" 162 | } 163 | }, 164 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 165 | } 166 | -------------------------------------------------------------------------------- /.github/workflows/upgrade-jsii-typescript.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: upgrade-jsii-typescript 4 | on: 5 | schedule: 6 | - cron: 36 15 * * * 7 | workflow_dispatch: 8 | inputs: 9 | version: 10 | description: New JSII/TypeScript version (e.g. "5.8.0"), without carets or tildes 11 | required: false 12 | type: string 13 | concurrency: 14 | group: ${{ github.workflow }}-${{ github.ref }} 15 | jobs: 16 | version: 17 | name: Determine version to upgrade to 18 | runs-on: ubuntu-latest 19 | permissions: 20 | contents: read 21 | outputs: 22 | current: ${{ steps.current_version.outputs.value }} 23 | latest: ${{ steps.latest_version.outputs.value }} 24 | short: ${{ steps.latest_version.outputs.short }} 25 | should_upgrade: ${{ steps.latest_version.outputs.is_newer }} 26 | steps: 27 | - name: Checkout 28 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 29 | - name: Setup Node.js 30 | uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 31 | with: {} 32 | - name: Install 33 | run: yarn install 34 | - name: Get current JSII version 35 | id: current_version 36 | run: |- 37 | CURRENT_VERSION=$(npm list jsii --depth=0 --json | jq -r '.dependencies.jsii.version') 38 | CURRENT_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$CURRENT_VERSION") 39 | CURRENT_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION") 40 | CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION") 41 | echo "CURRENT_JSII_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV 42 | echo "CURRENT_JSII_VERSION_SHORT=$CURRENT_VERSION_SHORT" >> $GITHUB_ENV 43 | echo "CURRENT_JSII_VERSION_MAJOR=$CURRENT_VERSION_MAJOR" >> $GITHUB_ENV 44 | echo "CURRENT_JSII_VERSION_MINOR=$CURRENT_VERSION_MINOR" >> $GITHUB_ENV 45 | echo "value=$CURRENT_VERSION" >> $GITHUB_OUTPUT 46 | - name: Get the earliest supported JSII version whose EOS date is at least a month away 47 | if: ${{ ! inputs.version }} 48 | uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea 49 | with: 50 | script: |- 51 | const script = require('./scripts/check-jsii-versions.js') 52 | await script({github, context, core}) 53 | - name: Save the manually-input version to environment variables for comparison 54 | if: ${{ inputs.version }} 55 | env: 56 | NEW_VERSION: ${{ inputs.version }} 57 | run: |- 58 | NEW_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$NEW_VERSION") 59 | NEW_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$NEW_VERSION") 60 | NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION") 61 | echo "NEW_JSII_VERSION=$NEW_VERSION" >> $GITHUB_ENV 62 | echo "NEW_JSII_VERSION_SHORT=$NEW_VERSION_SHORT" >> $GITHUB_ENV 63 | echo "NEW_JSII_VERSION_MAJOR=$NEW_VERSION_MAJOR" >> $GITHUB_ENV 64 | echo "NEW_JSII_VERSION_MINOR=$NEW_VERSION_MINOR" >> $GITHUB_ENV 65 | - name: Output env variables for use in the next job 66 | id: latest_version 67 | run: |- 68 | echo "value=$NEW_JSII_VERSION" >> $GITHUB_OUTPUT 69 | echo "short=$NEW_JSII_VERSION_SHORT" >> $GITHUB_OUTPUT 70 | [[ "$NEW_JSII_VERSION_MAJOR" > "$CURRENT_JSII_VERSION_MAJOR" || ("$NEW_JSII_VERSION_MAJOR" == "$CURRENT_JSII_VERSION_MAJOR" && "$NEW_JSII_VERSION_MINOR" > "$CURRENT_JSII_VERSION_MINOR") ]] && IS_NEWER=true 71 | echo "is_newer=$IS_NEWER" >> $GITHUB_OUTPUT 72 | upgrade: 73 | name: Upgrade JSII & TypeScript 74 | needs: version 75 | runs-on: ubuntu-latest 76 | permissions: 77 | contents: read 78 | env: 79 | CI: "true" 80 | CHECKPOINT_DISABLE: "1" 81 | if: always() && needs.version.outputs.should_upgrade 82 | steps: 83 | - name: Checkout 84 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 85 | - name: Setup Node.js 86 | uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 87 | with: {} 88 | - name: Install 89 | run: yarn install 90 | - name: Run upgrade script 91 | run: scripts/update-jsii-typescript.sh ${{ needs.version.outputs.latest }} 92 | - name: Create Pull Request 93 | uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e 94 | with: 95 | base: main 96 | branch: auto/upgrade-jsii-ts-${{ needs.version.outputs.short }} 97 | commit-message: "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}" 98 | title: "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}" 99 | body: "This PR increases the version of JSII and TypeScript to `~${{ needs.version.outputs.latest }}` because the previous version is close to EOL or no longer supported. Support timeline: https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support" 100 | labels: auto-approve,automerge,automated 101 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 102 | author: team-tf-cdk 103 | committer: team-tf-cdk 104 | signoff: true 105 | delete-branch: true 106 | -------------------------------------------------------------------------------- /.projenrc.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { ConstructLibraryCdktf } from "projen/lib/cdktf"; 7 | import { NpmAccess, UpgradeDependenciesSchedule } from "projen/lib/javascript"; 8 | import { AutoApprove } from "./projenrc/auto-approve"; 9 | import { Automerge } from "./projenrc/automerge"; 10 | import { JsiiDocgen } from "./projenrc/custom-docgen"; 11 | import { CustomizedLicense } from "./projenrc/customized-license"; 12 | import { UpgradeCDKTF } from "./projenrc/upgrade-cdktf"; 13 | import { UpgradeJSIIAndTypeScript } from "./projenrc/upgrade-jsii-typescript"; 14 | 15 | const githubActionPinnedVersions = { 16 | "actions/checkout": "11bd71901bbe5b1630ceea73d27597364c9af683", // v4.2.2 17 | "actions/download-artifact": "95815c38cf2ff2164869cbab79da8d1f422bc89e", // v4.2.1 18 | "actions/github-script": "60a0d83039c74a4aee543508d2ffcb1c3799cdea", // v7.0.1 19 | "actions/setup-dotnet": "67a3573c9a986a3f9c594539f4ab511d57bb3ce9", // v4.3.1 20 | "actions/setup-go": "0aaccfd150d50ccaeb58ebd88d36e91967a5f35b", // v5.4.0 21 | "actions/setup-java": "3a4f6e1af504cf6a31855fa899c6aa5355ba6c12", // v4.7.0 22 | "actions/setup-node": "cdca7365b2dadb8aad0a33bc7601856ffabcc48e", // v4.3.0 23 | "actions/setup-python": "42375524e23c412d93fb67b49958b491fce71c38", // v5.4.0 24 | "actions/upload-artifact": "ea165f8d65b6e75b540449e92b4886f43607fa02", // v4.6.2 25 | "amannn/action-semantic-pull-request": 26 | "0723387faaf9b38adef4775cd42cfd5155ed6017", // v5.5.3 27 | "hashicorp/setup-copywrite": "32638da2d4e81d56a0764aa1547882fc4d209636", // v1.1.3 28 | "peter-evans/create-pull-request": "271a8d0340265f705b14b6d32b9829c1cb33d45e", // v7.0.8 29 | }; 30 | 31 | const constructsVersion = "10.4.2"; 32 | /** JSII and TS should always use the same major/minor version range */ 33 | const typescriptVersion = "~5.8.0"; 34 | const project = new ConstructLibraryCdktf({ 35 | author: "HashiCorp", 36 | authorAddress: "https://hashicorp.com", 37 | authorOrganization: true, 38 | defaultReleaseBranch: "main", 39 | name: "@cdktf/tf-module-stack", 40 | repositoryUrl: "https://github.com/cdktf/cdktf-tf-module-stack.git", 41 | prettier: true, 42 | projenrcTs: true, 43 | licensed: false, 44 | pullRequestTemplate: false, 45 | npmAccess: NpmAccess.PUBLIC, 46 | mergify: false, 47 | depsUpgradeOptions: { 48 | workflowOptions: { 49 | labels: ["auto-approve", "automerge", "dependencies"], 50 | schedule: UpgradeDependenciesSchedule.WEEKLY, 51 | }, 52 | }, 53 | minMajorVersion: 1, 54 | cdktfVersion: "0.21.0", 55 | description: 56 | "A drop-in replacement for cdktf.TerraformStack that lets you define Terraform modules as constructs" /* The description is just a string that helps people understand the purpose of the package. */, 57 | workflowGitIdentity: { 58 | name: "team-tf-cdk", 59 | email: "github-team-tf-cdk@hashicorp.com", 60 | }, 61 | publishToPypi: { 62 | distName: "cdktf-tf-module-stack", 63 | module: "cdktf_tf_module_stack", 64 | }, 65 | publishToNuget: { 66 | dotNetNamespace: "HashiCorp.Cdktf.TfModuleStack", 67 | packageId: "HashiCorp.Cdktf.TfModuleStack", 68 | }, 69 | publishToMaven: { 70 | javaPackage: "com.hashicorp.cdktf.tf_module_stack", 71 | mavenGroupId: "com.hashicorp", 72 | mavenArtifactId: "cdktf-tf-module-stack", 73 | mavenEndpoint: "https://hashicorp.oss.sonatype.org", 74 | }, 75 | publishToGo: { 76 | gitUserEmail: "github-team-tf-cdk@hashicorp.com", 77 | gitUserName: "CDK for Terraform Team", 78 | moduleName: `github.com/cdktf/cdktf-tf-module-stack-go`, 79 | packageName: "tfmodulestack", 80 | }, 81 | docgen: false, 82 | typescriptVersion, 83 | jsiiVersion: typescriptVersion, 84 | }); 85 | 86 | new CustomizedLicense(project); 87 | new AutoApprove(project); 88 | new Automerge(project); 89 | new UpgradeCDKTF(project); 90 | new UpgradeJSIIAndTypeScript(project, typescriptVersion); 91 | 92 | project.addPeerDeps("cdktf@>=0.21.0", `constructs@^${constructsVersion}`); 93 | project.addDevDeps( 94 | "@cdktf/provider-null@>=11.0.0", 95 | "@cdktf/provider-random@>=12.0.0" 96 | ); 97 | 98 | new JsiiDocgen(project, { 99 | // We don't have docs for go because major changes lead to documentation changes 100 | // This blocks the release process 101 | languages: ["typescript", "python", "java", "csharp"], 102 | }); 103 | 104 | project.jest?.addIgnorePattern("dist"); 105 | project.addKeywords("cdktf", "terraform"); 106 | 107 | project.addPackageIgnore("scripts"); 108 | project.addPackageIgnore("projenrc"); 109 | project.addPackageIgnore("/.projenrc.ts"); 110 | 111 | project.addPackageIgnore(".copywrite.hcl"); 112 | // Run copywrite tool to add copyright headers to all files 113 | project.buildWorkflow?.addPostBuildSteps( 114 | { 115 | name: "Setup Copywrite tool", 116 | uses: "hashicorp/setup-copywrite", 117 | }, 118 | { name: "Add headers using Copywrite tool", run: "copywrite headers" } 119 | ); 120 | 121 | // Use pinned versions of github actions 122 | Object.entries(githubActionPinnedVersions).forEach(([action, sha]) => { 123 | project.github?.actions.set(action, `${action}@${sha}`); 124 | }); 125 | 126 | const releaseWorkflow = project.tryFindObjectFile( 127 | ".github/workflows/release.yml" 128 | ); 129 | releaseWorkflow?.addOverride("on.push", { 130 | branches: ["main"], 131 | "paths-ignore": [ 132 | // don't do a release if the change was only to these files/directories 133 | "examples/**", 134 | ".github/ISSUE_TEMPLATE/**", 135 | ".github/CODEOWNERS", 136 | ".github/dependabot.yml", 137 | ".github/**/*.md", 138 | ], 139 | }); 140 | // always publish a new GitHub release, even when publishing to a particular package manager fails 141 | releaseWorkflow?.addOverride("jobs.release_github.needs", "release"); 142 | 143 | project.synth(); 144 | -------------------------------------------------------------------------------- /projenrc/upgrade-cdktf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { javascript } from "projen"; 7 | import { JobPermission } from "projen/lib/github/workflows-model"; 8 | 9 | /** 10 | * Checks for new versions of CDKTF and creates a PR with an upgrade change if there are changes. 11 | */ 12 | export class UpgradeCDKTF { 13 | constructor(project: javascript.NodeProject) { 14 | const workflow = project.github?.addWorkflow("upgrade-cdktf"); 15 | 16 | if (!workflow) throw new Error("no workflow defined"); 17 | 18 | workflow.on({ 19 | schedule: [{ cron: "35 */6 * * *" }], // Runs four times a day 20 | workflowDispatch: {}, // allow manual triggering 21 | }); 22 | 23 | (workflow.concurrency as any) = { 24 | group: "${{ github.workflow }}-${{ github.ref }}", 25 | }; 26 | 27 | workflow.addJobs({ 28 | upgrade: { 29 | name: "Upgrade CDKTF", 30 | runsOn: ["ubuntu-latest"], 31 | steps: [ 32 | { 33 | name: "Checkout", 34 | uses: "actions/checkout", 35 | }, 36 | { 37 | name: "Setup Node.js", 38 | uses: "actions/setup-node", 39 | with: { 40 | "node-version": project.minNodeVersion, 41 | }, 42 | }, 43 | { 44 | name: "Install", 45 | run: "yarn install", 46 | }, 47 | { 48 | name: "Get current CDKTF version", 49 | id: "current_version", 50 | run: [ 51 | `OLD_VERSION=$(npm list cdktf --depth=0 --json | jq -r '.dependencies.cdktf.version')`, 52 | `OLD_VERSION_SHORT=$(cut -d "." -f 2 <<< "$OLD_VERSION")`, 53 | `echo "value=$OLD_VERSION" >> $GITHUB_OUTPUT`, 54 | `echo "short=$OLD_VERSION_SHORT" >> $GITHUB_OUTPUT`, 55 | ].join("\n"), 56 | // NOTE: No, there is no good way to do this in Yarn, until (if) we upgrade to Yarn 2+ (see below) 57 | }, 58 | { 59 | name: "Get latest CDKTF version", 60 | id: "latest_version", 61 | run: [ 62 | `CDKTF_VERSION=$(yarn info cdktf --json | jq -r '.data.version')`, 63 | `CDKTF_VERSION_SHORT=$(cut -d "." -f 2 <<< "$CDKTF_VERSION")`, 64 | `CONSTRUCTS_VERSION=$(yarn info cdktf --json | jq -r '.data.peerDependencies.constructs')`, 65 | `CONSTRUCTS_VERSION_EXACT=$(cut -d "^" -f 2 <<< "$CONSTRUCTS_VERSION")`, // strip the caret off the beginning 66 | `echo "value=$CDKTF_VERSION" >> $GITHUB_OUTPUT`, 67 | `echo "short=$CDKTF_VERSION_SHORT" >> $GITHUB_OUTPUT`, 68 | `echo "constructs=$CONSTRUCTS_VERSION_EXACT" >> $GITHUB_OUTPUT`, 69 | ].join("\n"), 70 | // IMPORTANT: the above behavior changed in Yarn 2+; `yarn info` instead gives the version of the installed package 71 | // If/when we upgrade we'll likely want to switch to `yarn npm info`: https://yarnpkg.com/cli/npm/info 72 | }, 73 | { 74 | name: "Run upgrade script", 75 | if: "steps.current_version.outputs.short != steps.latest_version.outputs.short", 76 | run: "scripts/update-cdktf.sh ${{ steps.latest_version.outputs.value }} ${{ steps.latest_version.outputs.constructs }}", 77 | }, 78 | { 79 | name: "Create draft pull request", 80 | if: "steps.current_version.outputs.short != steps.latest_version.outputs.short", 81 | uses: "peter-evans/create-pull-request", 82 | with: { 83 | "commit-message": 84 | "chore!: upgrade to cdktf ${{ steps.latest_version.outputs.value }}", 85 | branch: 86 | "auto/upgrade-cdktf-${{ steps.latest_version.outputs.short }}", 87 | base: "main", 88 | title: 89 | "chore!: upgrade to cdktf ${{ steps.latest_version.outputs.value }}", 90 | body: [ 91 | "This PR initiates the upgrade of CDKTF from version `${{ steps.current_version.outputs.value }}` to version `${{ steps.latest_version.outputs.value }}`.", 92 | "Unfortunately, not everything can be automated, and the following steps need to be completed manually:", 93 | " ", 94 | "- [ ] Update `@cdktf/provider-null` to a version compatible with `cdktf@${{ steps.latest_version.outputs.value }}` [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/106036d2d6b65652b68dabb2648b1f7980c6421d/.projenrc.ts#L78). Look up the version [here](https://github.com/cdktf/cdktf-provider-null/releases/).", 95 | "- [ ] Update `@cdktf/provider-random` to a version compatible with `cdktf@${{ steps.latest_version.outputs.value }}` [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/106036d2d6b65652b68dabb2648b1f7980c6421d/.projenrc.ts#L79). Look up the version [here](https://github.com/cdktf/cdktf-provider-random/releases/).", 96 | "- [ ] Run `npx projen`", 97 | " ", 98 | "Please checkout this PR, complete the above steps, push the changes to this branch, and then mark this PR as ready for review to complete the upgrade. Thanks!", 99 | ].join("\n"), 100 | labels: "automerge,auto-approve,dependencies", 101 | token: "${{ secrets.PROJEN_GITHUB_TOKEN }}", 102 | author: "team-tf-cdk ", 103 | committer: "team-tf-cdk ", 104 | signoff: true, 105 | "delete-branch": true, 106 | draft: true, 107 | }, 108 | }, 109 | ], 110 | env: { 111 | CI: "true", 112 | CHECKPOINT_DISABLE: "1", 113 | }, 114 | permissions: { 115 | contents: JobPermission.READ, 116 | }, 117 | }, 118 | }); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /projenrc/upgrade-jsii-typescript.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) HashiCorp, Inc. 3 | * SPDX-License-Identifier: MPL-2.0 4 | */ 5 | 6 | import { javascript } from "projen"; 7 | import { JobPermission } from "projen/lib/github/workflows-model"; 8 | 9 | /** 10 | * Helper script for upgrading JSII and TypeScript in the right way. 11 | * Auto-updates to the next version a month before the previous JSII version goes EOS 12 | * Can also be triggered manually with a hard-coded version of JSII/TypeScript as input 13 | * https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support 14 | */ 15 | export class UpgradeJSIIAndTypeScript { 16 | constructor(project: javascript.NodeProject, typescriptVersion: string) { 17 | const workflow = project.github?.addWorkflow("upgrade-jsii-typescript"); 18 | if (!workflow) throw new Error("no workflow defined"); 19 | 20 | const plainVersion = typescriptVersion.replace("~", ""); 21 | workflow.on({ 22 | schedule: [{ cron: "36 15 * * *" }], // Runs once a day 23 | workflowDispatch: { 24 | inputs: { 25 | version: { 26 | description: `New JSII/TypeScript version (e.g. "${plainVersion}"), without carets or tildes`, 27 | required: false, 28 | type: "string", 29 | }, 30 | }, 31 | }, 32 | }); 33 | 34 | (workflow.concurrency as any) = { 35 | group: "${{ github.workflow }}-${{ github.ref }}", 36 | }; 37 | 38 | workflow.addJobs({ 39 | version: { 40 | name: "Determine version to upgrade to", 41 | runsOn: ["ubuntu-latest"], 42 | steps: [ 43 | { 44 | name: "Checkout", 45 | uses: "actions/checkout", 46 | }, 47 | { 48 | name: "Setup Node.js", 49 | uses: "actions/setup-node", 50 | with: { 51 | "node-version": project.minNodeVersion, 52 | }, 53 | }, 54 | { 55 | name: "Install", 56 | run: "yarn install", 57 | }, 58 | { 59 | name: "Get current JSII version", 60 | id: "current_version", 61 | run: [ 62 | `CURRENT_VERSION=$(npm list jsii --depth=0 --json | jq -r '.dependencies.jsii.version')`, 63 | `CURRENT_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$CURRENT_VERSION")`, 64 | `CURRENT_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$CURRENT_VERSION")`, 65 | `CURRENT_VERSION_MINOR=$(cut -d "." -f 2 <<< "$CURRENT_VERSION")`, 66 | `echo "CURRENT_JSII_VERSION=$CURRENT_VERSION" >> $GITHUB_ENV`, 67 | `echo "CURRENT_JSII_VERSION_SHORT=$CURRENT_VERSION_SHORT" >> $GITHUB_ENV`, 68 | `echo "CURRENT_JSII_VERSION_MAJOR=$CURRENT_VERSION_MAJOR" >> $GITHUB_ENV`, 69 | `echo "CURRENT_JSII_VERSION_MINOR=$CURRENT_VERSION_MINOR" >> $GITHUB_ENV`, 70 | `echo "value=$CURRENT_VERSION" >> $GITHUB_OUTPUT`, 71 | ].join("\n"), 72 | }, 73 | { 74 | name: "Get the earliest supported JSII version whose EOS date is at least a month away", 75 | if: "${{ ! inputs.version }}", 76 | uses: "actions/github-script", 77 | with: { 78 | script: [ 79 | `const script = require('./scripts/check-jsii-versions.js')`, 80 | `await script({github, context, core})`, 81 | ].join("\n"), 82 | }, 83 | }, 84 | { 85 | // In an ideal world this is where we'd validate that the manually-input version actually exists 86 | // In practice, I couldn't figure out how to do this properly and it wasn't worth the effort 87 | // name: "Check if the manually-input version actually exists (has been published to NPM)", 88 | name: "Save the manually-input version to environment variables for comparison", 89 | if: "${{ inputs.version }}", 90 | env: { 91 | NEW_VERSION: "${{ inputs.version }}", 92 | }, 93 | run: [ 94 | // My command line skillz aren't good enough to figure out how to make the below work (error if the version doesn't exist) 95 | // `yarn info jsii versions --json | jq -e 'select(.data | index("$NEW_VERSION"))`, 96 | `NEW_VERSION_SHORT=$(cut -d "." -f 1,2 <<< "$NEW_VERSION")`, 97 | `NEW_VERSION_MAJOR=$(cut -d "." -f 1 <<< "$NEW_VERSION")`, 98 | `NEW_VERSION_MINOR=$(cut -d "." -f 2 <<< "$NEW_VERSION")`, 99 | `echo "NEW_JSII_VERSION=$NEW_VERSION" >> $GITHUB_ENV`, 100 | `echo "NEW_JSII_VERSION_SHORT=$NEW_VERSION_SHORT" >> $GITHUB_ENV`, 101 | `echo "NEW_JSII_VERSION_MAJOR=$NEW_VERSION_MAJOR" >> $GITHUB_ENV`, 102 | `echo "NEW_JSII_VERSION_MINOR=$NEW_VERSION_MINOR" >> $GITHUB_ENV`, 103 | ].join("\n"), 104 | }, 105 | { 106 | name: "Output env variables for use in the next job", 107 | id: "latest_version", 108 | run: [ 109 | `echo "value=$NEW_JSII_VERSION" >> $GITHUB_OUTPUT`, 110 | `echo "short=$NEW_JSII_VERSION_SHORT" >> $GITHUB_OUTPUT`, 111 | `[[ "$NEW_JSII_VERSION_MAJOR" > "$CURRENT_JSII_VERSION_MAJOR" || ("$NEW_JSII_VERSION_MAJOR" == "$CURRENT_JSII_VERSION_MAJOR" && "$NEW_JSII_VERSION_MINOR" > "$CURRENT_JSII_VERSION_MINOR") ]] && IS_NEWER=true`, 112 | `echo "is_newer=$IS_NEWER" >> $GITHUB_OUTPUT`, 113 | ].join("\n"), 114 | }, 115 | ], 116 | outputs: { 117 | current: { 118 | stepId: "current_version", 119 | outputName: "value", 120 | }, 121 | latest: { 122 | stepId: "latest_version", 123 | outputName: "value", 124 | }, 125 | short: { 126 | stepId: "latest_version", 127 | outputName: "short", 128 | }, 129 | should_upgrade: { 130 | stepId: "latest_version", 131 | outputName: "is_newer", 132 | }, 133 | }, 134 | permissions: { 135 | contents: JobPermission.READ, 136 | }, 137 | }, 138 | upgrade: { 139 | name: "Upgrade JSII & TypeScript", 140 | runsOn: ["ubuntu-latest"], 141 | needs: ["version"], 142 | if: "always() && needs.version.outputs.should_upgrade", 143 | steps: [ 144 | { 145 | name: "Checkout", 146 | uses: "actions/checkout", 147 | }, 148 | { 149 | name: "Setup Node.js", 150 | uses: "actions/setup-node", 151 | with: { 152 | "node-version": project.minNodeVersion, 153 | }, 154 | }, 155 | { 156 | name: "Install", 157 | run: "yarn install", 158 | }, 159 | { 160 | name: "Run upgrade script", 161 | run: "scripts/update-jsii-typescript.sh ${{ needs.version.outputs.latest }}", 162 | }, 163 | { 164 | name: "Create Pull Request", 165 | uses: "peter-evans/create-pull-request", 166 | with: { 167 | base: "main", 168 | branch: "auto/upgrade-jsii-ts-${{ needs.version.outputs.short }}", 169 | "commit-message": 170 | "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}", 171 | title: 172 | "chore(deps): upgrade jsii & typescript to v${{ needs.version.outputs.short }}", 173 | body: [ 174 | "This PR increases the version of JSII and TypeScript to `~${{ needs.version.outputs.latest }}` ", 175 | "because the previous version is close to EOL or no longer supported. Support timeline: ", 176 | "https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support", 177 | ].join(" "), 178 | labels: "auto-approve,automerge,automated", 179 | token: "${{ secrets.PROJEN_GITHUB_TOKEN }}", 180 | author: "team-tf-cdk ", 181 | committer: "team-tf-cdk ", 182 | signoff: true, 183 | "delete-branch": true, 184 | }, 185 | }, 186 | ], 187 | env: { 188 | CI: "true", 189 | CHECKPOINT_DISABLE: "1", 190 | }, 191 | permissions: { 192 | contents: JobPermission.READ, 193 | }, 194 | }, 195 | }); 196 | } 197 | } 198 | -------------------------------------------------------------------------------- /.github/MAINTENANCE.md: -------------------------------------------------------------------------------- 1 | # Maintenance Guide 2 | 3 | This document is intended for maintainers of this repository and outlines how to perform various maintenance-related activities, including descriptions of what processes are currently automated and which are not (yet). 4 | 5 | This repository contains extensive GitHub Actions [workflows](https://github.com/cdktf/cdktf-tf-module-stack/tree/main/.github/workflows) that automate as much of the project's lifecycle as possible. The project is built using [Projen](https://projen.io/) and as such **these workflows should not be edited directly**. Their sources can be found in the [`.projenrc/`](https://github.com/cdktf/cdktf-tf-module-stack/tree/main/projenrc) directory, and new workflows are added to the project in [`.projenrc.ts`](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/.projenrc.ts). 6 | 7 | This project is considered experimental, and does not offer any support or maintenance guarantees. 8 | 9 | 10 | ## Security & Dependency Management 11 | 12 | Dependency upgrades (for security purposes as well as a best practice) can be divided into three categories: fully-automated, semi-automated, and not automated. 13 | 14 | ### Fully Automated 15 | 16 | The following Actions exist to automate various dependency upgrades: 17 | 18 | - [upgrade-jsii-typescript](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-jsii-typescript.yml): This is a custom workflow (source [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/projenrc/upgrade-jsii-typescript.ts)) that checks the [JSII support timeline](https://github.com/aws/jsii-compiler/blob/main/README.md#gear-maintenance--support) daily via [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/check-jsii-versions.js) script to see if the current version is less than 30 days away from EOS, and if so, creates a PR upgrading to the next supported version. The code for the upgrade itself lives in [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/update-jsii-typescript.sh) script. This process is 100% automated; as long as the build succeeds and any tests pass, the PR will be automatically merged without any human intervention. 19 | - This workflow can also be manually triggered, optionally taking a hard-coded JSII/TypeScript version as input in case we ever want to upgrade to a newer version without waiting until the old one is less than 30 days away from EOS. 20 | - [upgrade-main](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-main.yml): This is a Projen built-in/default workflow that handles automated dependency updates. It currently runs on a weekly basis, which can be configured [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L49). Projen will upgrade itself as part of this process. This process is 100% automated; as long as the build succeeds and any tests pass, the PR that is generated will be automatically merged without any human intervention. 21 | 22 | Dependabot is also [configured](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/.github/dependabot.yml) to check for new security updates daily and, if found, make changes to the lockfile only. This is because Dependabot can sometimes address security issues in dependencies more quickly than Projen due to its atomic nature. While you could tweak the Dependabot settings, note that Projen and Dependabot do not generally play nicely together; in particular, Dependabot cannot make changes to `package.json` because Projen would just override these changes (hence the reason why Dependabot is currently limited to lockfile-only). If you wanted to fully automate dependency management using Dependabot, you would want to disable Projen's [automatic updates](https://projen.io/docs/api/typescript#projen.typescript.TypeScriptProjectOptions.property.depsUpgrade). 23 | 24 | ### Semi-Automated 25 | 26 | The following Actions either need to be manually triggered or require significant manual effort as part of the upgrade process: 27 | 28 | - [upgrade-cdktf](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/upgrade-cdktf.yml): This is a custom workflow (source [here](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/projenrc/upgrade-cdktf.ts)) that runs four times a day and checks whether there is a new minor version of CDKTF itself (e.g. `0.19`, `0.20`, `0.21`, etc.), using the latest version published to npm as the source of truth. If a new version is found, it runs [this](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/scripts/update-cdktf.sh) script to update the CDKTF version in all the right places, and then it creates a draft PR. The reason for the draft status is because a few steps related to the upgrade cannot be automated and must be done manually by an engineer; these are outlined step-by-step in the PR body. Once the steps are completed, the PR can be marked as ready for review & approved in order to complete the upgrade. 29 | 30 | ### Not Automated 31 | 32 | - **GitHub Actions version pinning**: Because this project leverages Projen, HashiCorp Security's [tsccr-helper](https://github.com/hashicorp/security-tsccr?tab=readme-ov-file#tsccr-helper-cli) CLI and other tooling cannot be used to manage/upgrade GitHub Actions versions. Instead, we have consolidated all of the versions into a single [object](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L15-L29) in code that must be manually updated. Historically, one of the maintainers has followed these manual steps on a roughly monthly basis: 33 | 1. Look up the latest supported versions [here](https://github.com/hashicorp/security-tsccr/tree/main/components/github_actions) 34 | 2. Update the [object](https://github.com/cdktf/cdktf-tf-module-stack/blob/b9939ad9f3bc6bc5bd7a4f348c953d776778506d/.projenrc.ts#L15-L29) 35 | 3. Run `npx projen` 36 | 4. Create a new PR with the title `chore(deps): update pinned versions of GitHub Actions` 37 | 38 | Also worth noting: Unlike many of our other Projen-based projects, this one does not have a script that automatically upgrades Node.js because this library does not enforce a `minNodeVersion`. If we did at some point want to start enforcing a `minNodeVersion`, we should copy over the `upgrade-node` script that our other Projen projects use. 39 | 40 | 41 | ## Releasing 42 | 43 | Releases are fully automated by Projen and require no manual intervention whatsoever. In general, this repository is configured to publish a new release for each pull request that gets merged. The only way to force it to create one release that combines multiple merged PRs is to ensure that all of these PRs get merged into `main` at exactly the same time. The new version number is automatically calculated by Projen using [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) and [Semantic Versioning](https://semver.org/). 44 | 45 | If you wanted to change the logic that governs when releases are triggered (such as running them on a schedule, or only for certain types of commits), see Projen's [documentation](https://projen.io/docs/publishing/releases-and-versioning) on this subject. 46 | 47 | ### Package Managers 48 | 49 | This library is currently published to these package managers: 50 | 51 | - **npm**: The package is called [@cdktf/tf-module-stack](https://www.npmjs.com/package/@cdktf/tf-module-stack), and publishing is done using an access token associated with the shared [cdktf-team](https://www.npmjs.com/~cdktf-team) account. Credentials to access this account can be found in the CDK for Terraform Team 1Password Vault. 52 | - **PyPi**: The package is called [cdktf-tf-module-stack](https://pypi.org/project/cdktf-tf-module-stack), and publishing is done using an access token associated with the shared [cdktf-team](https://pypi.org/user/cdktf-team/) account. Credentials to access this account can be found in the CDK for Terraform Team 1Password Vault. 53 | - **NuGet**: The package is called [HashiCorp.Cdktf.TfModuleStack](https://www.nuget.org/packages/HashiCorp.Cdktf.TfModuleStack), and publishing is done using an access token associated with the [HashiCorp](https://www.nuget.org/profiles/hashicorp) organization in NuGet. You need an individual account in order to access NuGet, and an existing member can add you to the HashiCorp org. The access token expires once a year and needs to be manually rotated, so if publishing to NuGet is broken, this is a likely culprit. 54 | - **Maven**: The package is called [cdktf-tf-module-stack](https://mvnrepository.com/artifact/com.hashicorp/cdktf-tf-module-stack), and publishing is done using a username, password, and GPG key associated with the `terraform-cdk-packages` account. Credentials to access this account can be found in the CDK for Terraform Team 1Password Vault. 55 | 56 | While it is not a package manager per se, a Go package is published to GitHub at [`github.com/cdktf/cdktf-tf-module-stack-go`](https://github.com/cdktf/cdktf-tf-module-stack-go). Publishing to that is done using an access token associated with the [team-tf-cdk](https://github.com/team-tf-cdk) bot account. 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Future of Terraform CDK 2 | 3 | ## Sunset Notice 4 | 5 | Terraform CDK (CDKTF) will sunset and be archived on December 10, 2025. HashiCorp, an IBM Company, will no longer maintain or develop the project after that date. Unfortunately, Terraform CDK did not find product-market fit at scale. HashiCorp, an IBM Company, has chosen to focus its investments on Terraform core and its broader ecosystem. 6 | 7 | As of December 10, 2025, Terraform CDK will be archived on GitHub, and the documentation will reflect its deprecated status. The archived code will remain available on GitHub, but it will be read-only. No further updates, fixes, or improvements (including compatibility updates) will be made. 8 | 9 | You will be able to continue to use Terraform CDK at your own risk. Terraform CDK is licensed under the Mozilla Public License (MPL). HashiCorp, an IBM Company, does not apply any additional restrictions. We encourage community forks if there’s interest in continuing development independently. 10 | 11 | ## Migration to HCL 12 | 13 | You can use the following command to generate Terraform-compatible .tf files directly from your Terraform CDK project: 14 | 15 | `cdktf synth --hcl` 16 | 17 | This will produce readable HCL configuration files, making it easier to migrate away from Terraform CDK. After running the command, you can use standard Terraform CLI commands (`terraform init`, `terraform plan`, `terraform apply`) to continue managing your infrastructure. Please note that while this helps bootstrap your configuration, you may still need to review and adjust the generated files for clarity, organization, or best practices. 18 | 19 | ### Note on AWS CDK 20 | 21 | If your infrastructure is defined in Terraform CDK but also tightly integrated with AWS CDK, you may find it more consistent to migrate directly to the AWS CDK ecosystem. If you are not using AWS CDK, we highly recommend migrating to standard Terraform and HCL for long-term support and ecosystem alignment. 22 | 23 | ## FAQ 24 | 25 | Q: Is CDKTF still being developed? 26 | 27 | A: No. CDKTF will sunset and be archived on December 10, 2025. HashiCorp, an IBM Company, will no longer maintain or develop the project after that date. 28 | 29 | Q: Why is CDKTF being sunset? 30 | 31 | A: CDKTF did not find product-market fit at scale. We’ve chosen to focus our investments on Terraform core and its broader ecosystem. 32 | 33 | Q: Will CDKTF be removed from GitHub? 34 | 35 | A: CDKTF will be archived on GitHub, and documentation will reflect its deprecated status. 36 | 37 | Q: Can I still use CDKTF after it's sunset? 38 | 39 | A: Yes, the archived code will remain available on GitHub, but it will be read-only. No further updates, fixes, or improvements will be made. 40 | 41 | Q: Will CDKTF continue to support new versions of Terraform or providers? 42 | 43 | A: No. Compatibility updates will not be made after the EOL date. 44 | 45 | Q: Can I fork CDKTF and maintain it myself? 46 | 47 | A: Yes. CDKTF is open source, and we encourage community forks if there’s interest in continuing development independently. 48 | 49 | Q: Can I keep using CDKTF? 50 | 51 | A: You may continue to use it at your own risk. HashiCorp, an IBM Company, will no longer be maintaining it. 52 | 53 | Q: Is there a migration tool? 54 | 55 | A: You can use the following command to generate Terraform-compatible .tf files directly from your CDKTF project: 56 | 57 | `cdktf synth --hcl` 58 | 59 | This will produce readable HCL configuration files, making it easier to migrate away from CDKTF. After running the command, you can use standard Terraform CLI commands (terraform init, terraform plan, terraform apply) to continue managing your infrastructure. Please note that while this helps bootstrap your configuration, you may still need to review and adjust the generated files for clarity, organization, or best practices. 60 | 61 | Q: What migration guidance can we provide to customers? 62 | 63 | A: For users looking to migrate away from CDKTF: 64 | 65 | If your infrastructure is defined in CDKTF but also tightly integrated with AWS CDK, you may find it more consistent to migrate directly to the AWS CDK ecosystem. 66 | 67 | If you are not using AWS CDK, we highly recommend migrating to standard Terraform and HCL for long-term support and ecosystem alignment. 68 | 69 | --- 70 | 71 | # cdktf-tf-module-stack 72 | 73 | ![Status: Tech Preview](https://img.shields.io/badge/status-experimental-EAAA32) [![Releases](https://img.shields.io/github/release/cdktf/cdktf-tf-module-stack.svg)](https://github.com/cdktf/cdktf-tf-module-stack/releases) 74 | [![LICENSE](https://img.shields.io/github/license/cdktf/cdktf-tf-module-stack.svg)](https://github.com/cdktf/cdktf-tf-module-stack/blob/main/LICENSE) 75 | [![build](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/build.yml/badge.svg)](https://github.com/cdktf/cdktf-tf-module-stack/actions/workflows/build.yml) 76 | 77 | A drop-in replacement for cdktf.TerraformStack that lets you define Terraform modules as constructs. 78 | 79 | _cdktf-tf-module-stack_ is in technical preview, which means it's a community supported project. It still requires extensive testing and polishing to mature into a HashiCorp officially supported project. Please [file issues](https://github.com/cdktf/cdktf-tf-module-stack/issues/new/choose) generously and detail your experience while using the library. We welcome your feedback. 80 | 81 | By using the software in this repository, you acknowledge that: 82 | 83 | * _cdktf-tf-module-stack_ is still in development, may change, and has not been released as a commercial product by HashiCorp and is not currently supported in any way by HashiCorp. 84 | * _cdktf-tf-module-stack_ is provided on an "as-is" basis, and may include bugs, errors, or other issues. 85 | * _cdktf-tf-module-stack_ is NOT INTENDED FOR PRODUCTION USE, use of the Software may result in unexpected results, loss of data, or other unexpected results, and HashiCorp disclaims any and all liability resulting from use of _cdktf-tf-module-stack_. 86 | * HashiCorp reserves all rights to make all decisions about the features, functionality and commercial release (or non-release) of _cdktf-tf-module-stack_, at any time and without any obligation or liability whatsoever. 87 | 88 | ## Compatibility 89 | 90 | * `cdktf` >= 0.21.0 91 | * `constructs` >= 10.4.2 92 | 93 | ## Available Packages 94 | 95 | ### NPM 96 | 97 | The npm package is available at [https://www.npmjs.com/package/@cdktf/tf-module-stack](https://www.npmjs.com/package/@cdktf/tf-module-stack). 98 | 99 | `npm install @cdktf/tf-module-stack` 100 | 101 | NOTE: Originally, this package was named `cdktf-tf-module-stack`, and the legacy versions (<= 0.2.0) can be found on npm [here](https://www.npmjs.com/package/cdktf-tf-module-stack). 102 | 103 | ### PyPI 104 | 105 | The PyPI package is available at [https://pypi.org/project/cdktf-tf-module-stack](https://pypi.org/project/cdktf-tf-module-stack). 106 | 107 | `pipenv install cdktf-tf-module-stack` 108 | 109 | ### Nuget 110 | 111 | The Nuget package is available at [https://www.nuget.org/packages/HashiCorp.Cdktf.TfModuleStack](https://www.nuget.org/packages/HashiCorp.Cdktf.TfModuleStack). 112 | 113 | `dotnet add package HashiCorp.Cdktf.TfModuleStack` 114 | 115 | ### Maven 116 | 117 | The Maven package is available at [https://mvnrepository.com/artifact/com.hashicorp/cdktf-tf-module-stack](https://mvnrepository.com/artifact/com.hashicorp/cdktf-tf-module-stack). 118 | 119 | ``` 120 | 121 | com.hashicorp 122 | cdktf-tf-module-stack 123 | [REPLACE WITH DESIRED VERSION] 124 | 125 | ``` 126 | 127 | ### Go 128 | 129 | The go package is generated into the [`github.com/cdktf/cdktf-tf-module-stack-go`](https://github.com/cdktf/cdktf-tf-module-stack-go) package. 130 | 131 | `go get github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack` 132 | 133 | ## Usage 134 | 135 | ### Typescript 136 | 137 | ```ts 138 | import { App } from "cdktf"; 139 | import { 140 | TFModuleStack, 141 | TFModuleVariable, 142 | TFModuleOutput, 143 | ProviderRequirement, 144 | } from "@cdktf/tf-module-stack"; 145 | import { Resource } from '@cdktf/provider-null/lib/resource'; 146 | 147 | class MyAwesomeModule extends TFModuleStack { 148 | constructor(scope: Construct, id: string) { 149 | super(scope, id); 150 | 151 | new ProviderRequirement(this, "null", "~> 2.0"); 152 | const resource = new Resource(this, "resource"); 153 | 154 | new TFModuleVariable(this, "my_var", { 155 | type: "string", 156 | description: "A variable", 157 | default: "default", 158 | }); 159 | 160 | new TFModuleOutput(this, "my_output", { 161 | value: resource.id, 162 | }); 163 | } 164 | } 165 | 166 | const app = new App(); 167 | new MyAwesomeModule(app, "my-awesome-module"); 168 | app.synth(); 169 | ``` 170 | 171 | ### Python 172 | 173 | ```python 174 | from constructs import Construct 175 | from cdktf import App, TerraformStack 176 | from imports.null.resource import Resource 177 | from cdktf_tf_module_stack import TFModuleStack, TFModuleVariable, TFModuleOutput, ProviderRequirement 178 | 179 | 180 | class MyAwesomeModule(TFModuleStack): 181 | def __init__(self, scope: Construct, ns: str): 182 | super().__init__(scope, ns) 183 | 184 | ProviderRequirement(self, "null", provider_version_constraint="~> 2.0") 185 | 186 | TFModuleVariable(self, "my_var", type="string", description="A variable", default="default") 187 | 188 | resource = Resource(self, "resource") 189 | 190 | TFModuleOutput(self, "my_output", value=resource.id) 191 | 192 | 193 | app = App() 194 | MyAwesomeModule(app, "my-awesome-module") 195 | app.synth() 196 | ``` 197 | 198 | This will synthesize a Terraform JSON file that looks like this: 199 | 200 | ```json 201 | { 202 | "output": { 203 | "my_output": [ 204 | { 205 | "value": "${null_resource.resource.id}" 206 | } 207 | ] 208 | }, 209 | "resource": { 210 | "null_resource": { 211 | "resource": {} 212 | } 213 | }, 214 | "terraform": { 215 | "required_providers": { 216 | "null": { 217 | "source": "null", 218 | "version": "~> 2.0" 219 | } 220 | }, 221 | "variable": { 222 | "my_var": { 223 | "default": "default", 224 | "description": "A variable", 225 | "type": "string" 226 | } 227 | } 228 | } 229 | } 230 | ``` 231 | 232 | Please note that the provider section is missing, so that the Terraform Workspace using the generated module can be used with any provider matching the version. 233 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: build 4 | on: 5 | pull_request: {} 6 | workflow_dispatch: {} 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | permissions: 11 | contents: write 12 | outputs: 13 | self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }} 14 | env: 15 | CI: "true" 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 19 | with: 20 | ref: ${{ github.event.pull_request.head.ref }} 21 | repository: ${{ github.event.pull_request.head.repo.full_name }} 22 | - name: Install dependencies 23 | run: yarn install --check-files 24 | - name: build 25 | run: npx projen build 26 | - name: Setup Copywrite tool 27 | uses: hashicorp/setup-copywrite@32638da2d4e81d56a0764aa1547882fc4d209636 28 | - name: Add headers using Copywrite tool 29 | run: copywrite headers 30 | - name: Find mutations 31 | id: self_mutation 32 | run: |- 33 | git add . 34 | git diff --staged --patch --exit-code > repo.patch || echo "self_mutation_happened=true" >> $GITHUB_OUTPUT 35 | shell: bash 36 | working-directory: ./ 37 | - name: Upload patch 38 | if: steps.self_mutation.outputs.self_mutation_happened 39 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 40 | with: 41 | name: repo.patch 42 | path: repo.patch 43 | overwrite: true 44 | - name: Fail build on mutation 45 | if: steps.self_mutation.outputs.self_mutation_happened 46 | run: |- 47 | echo "::error::Files were changed during build (see build log). If this was triggered from a fork, you will need to update your branch." 48 | cat repo.patch 49 | exit 1 50 | - name: Backup artifact permissions 51 | run: cd dist && getfacl -R . > permissions-backup.acl 52 | continue-on-error: true 53 | - name: Upload artifact 54 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 55 | with: 56 | name: build-artifact 57 | path: dist 58 | overwrite: true 59 | self-mutation: 60 | needs: build 61 | runs-on: ubuntu-latest 62 | permissions: 63 | contents: write 64 | if: always() && needs.build.outputs.self_mutation_happened && !(github.event.pull_request.head.repo.full_name != github.repository) 65 | steps: 66 | - name: Checkout 67 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 68 | with: 69 | token: ${{ secrets.PROJEN_GITHUB_TOKEN }} 70 | ref: ${{ github.event.pull_request.head.ref }} 71 | repository: ${{ github.event.pull_request.head.repo.full_name }} 72 | - name: Download patch 73 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 74 | with: 75 | name: repo.patch 76 | path: ${{ runner.temp }} 77 | - name: Apply patch 78 | run: '[ -s ${{ runner.temp }}/repo.patch ] && git apply ${{ runner.temp }}/repo.patch || echo "Empty patch. Skipping."' 79 | - name: Set git identity 80 | run: |- 81 | git config user.name "team-tf-cdk" 82 | git config user.email "github-team-tf-cdk@hashicorp.com" 83 | - name: Push changes 84 | env: 85 | PULL_REQUEST_REF: ${{ github.event.pull_request.head.ref }} 86 | run: |- 87 | git add . 88 | git commit -s -m "chore: self mutation" 89 | git push origin "HEAD:$PULL_REQUEST_REF" 90 | package-js: 91 | needs: build 92 | runs-on: ubuntu-latest 93 | permissions: 94 | contents: read 95 | if: ${{ !needs.build.outputs.self_mutation_happened }} 96 | steps: 97 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 98 | with: 99 | node-version: lts/* 100 | - name: Download build artifacts 101 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 102 | with: 103 | name: build-artifact 104 | path: dist 105 | - name: Restore build artifact permissions 106 | run: cd dist && setfacl --restore=permissions-backup.acl 107 | continue-on-error: true 108 | - name: Checkout 109 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 110 | with: 111 | ref: ${{ github.event.pull_request.head.ref }} 112 | repository: ${{ github.event.pull_request.head.repo.full_name }} 113 | path: .repo 114 | - name: Install Dependencies 115 | run: cd .repo && yarn install --check-files --frozen-lockfile 116 | - name: Extract build artifact 117 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 118 | - name: Move build artifact out of the way 119 | run: mv dist dist.old 120 | - name: Create js artifact 121 | run: cd .repo && npx projen package:js 122 | - name: Collect js artifact 123 | run: mv .repo/dist dist 124 | package-java: 125 | needs: build 126 | runs-on: ubuntu-latest 127 | permissions: 128 | contents: read 129 | if: ${{ !needs.build.outputs.self_mutation_happened }} 130 | steps: 131 | - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 132 | with: 133 | distribution: corretto 134 | java-version: "11" 135 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 136 | with: 137 | node-version: lts/* 138 | - name: Download build artifacts 139 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 140 | with: 141 | name: build-artifact 142 | path: dist 143 | - name: Restore build artifact permissions 144 | run: cd dist && setfacl --restore=permissions-backup.acl 145 | continue-on-error: true 146 | - name: Checkout 147 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 148 | with: 149 | ref: ${{ github.event.pull_request.head.ref }} 150 | repository: ${{ github.event.pull_request.head.repo.full_name }} 151 | path: .repo 152 | - name: Install Dependencies 153 | run: cd .repo && yarn install --check-files --frozen-lockfile 154 | - name: Extract build artifact 155 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 156 | - name: Move build artifact out of the way 157 | run: mv dist dist.old 158 | - name: Create java artifact 159 | run: cd .repo && npx projen package:java 160 | - name: Collect java artifact 161 | run: mv .repo/dist dist 162 | package-python: 163 | needs: build 164 | runs-on: ubuntu-latest 165 | permissions: 166 | contents: read 167 | if: ${{ !needs.build.outputs.self_mutation_happened }} 168 | steps: 169 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 170 | with: 171 | node-version: lts/* 172 | - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 173 | with: 174 | python-version: 3.x 175 | - name: Download build artifacts 176 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 177 | with: 178 | name: build-artifact 179 | path: dist 180 | - name: Restore build artifact permissions 181 | run: cd dist && setfacl --restore=permissions-backup.acl 182 | continue-on-error: true 183 | - name: Checkout 184 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 185 | with: 186 | ref: ${{ github.event.pull_request.head.ref }} 187 | repository: ${{ github.event.pull_request.head.repo.full_name }} 188 | path: .repo 189 | - name: Install Dependencies 190 | run: cd .repo && yarn install --check-files --frozen-lockfile 191 | - name: Extract build artifact 192 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 193 | - name: Move build artifact out of the way 194 | run: mv dist dist.old 195 | - name: Create python artifact 196 | run: cd .repo && npx projen package:python 197 | - name: Collect python artifact 198 | run: mv .repo/dist dist 199 | package-dotnet: 200 | needs: build 201 | runs-on: ubuntu-latest 202 | permissions: 203 | contents: read 204 | if: ${{ !needs.build.outputs.self_mutation_happened }} 205 | steps: 206 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 207 | with: 208 | node-version: lts/* 209 | - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 210 | with: 211 | dotnet-version: 6.x 212 | - name: Download build artifacts 213 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 214 | with: 215 | name: build-artifact 216 | path: dist 217 | - name: Restore build artifact permissions 218 | run: cd dist && setfacl --restore=permissions-backup.acl 219 | continue-on-error: true 220 | - name: Checkout 221 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 222 | with: 223 | ref: ${{ github.event.pull_request.head.ref }} 224 | repository: ${{ github.event.pull_request.head.repo.full_name }} 225 | path: .repo 226 | - name: Install Dependencies 227 | run: cd .repo && yarn install --check-files --frozen-lockfile 228 | - name: Extract build artifact 229 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 230 | - name: Move build artifact out of the way 231 | run: mv dist dist.old 232 | - name: Create dotnet artifact 233 | run: cd .repo && npx projen package:dotnet 234 | - name: Collect dotnet artifact 235 | run: mv .repo/dist dist 236 | package-go: 237 | needs: build 238 | runs-on: ubuntu-latest 239 | permissions: 240 | contents: read 241 | if: ${{ !needs.build.outputs.self_mutation_happened }} 242 | steps: 243 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 244 | with: 245 | node-version: lts/* 246 | - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b 247 | with: 248 | go-version: ^1.18.0 249 | - name: Download build artifacts 250 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 251 | with: 252 | name: build-artifact 253 | path: dist 254 | - name: Restore build artifact permissions 255 | run: cd dist && setfacl --restore=permissions-backup.acl 256 | continue-on-error: true 257 | - name: Checkout 258 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 259 | with: 260 | ref: ${{ github.event.pull_request.head.ref }} 261 | repository: ${{ github.event.pull_request.head.repo.full_name }} 262 | path: .repo 263 | - name: Install Dependencies 264 | run: cd .repo && yarn install --check-files --frozen-lockfile 265 | - name: Extract build artifact 266 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 267 | - name: Move build artifact out of the way 268 | run: mv dist dist.old 269 | - name: Create go artifact 270 | run: cd .repo && npx projen package:go 271 | - name: Collect go artifact 272 | run: mv .repo/dist dist 273 | -------------------------------------------------------------------------------- /.projen/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "tasks": { 3 | "build": { 4 | "name": "build", 5 | "description": "Full release build", 6 | "steps": [ 7 | { 8 | "spawn": "default" 9 | }, 10 | { 11 | "spawn": "pre-compile" 12 | }, 13 | { 14 | "spawn": "compile" 15 | }, 16 | { 17 | "spawn": "post-compile" 18 | }, 19 | { 20 | "spawn": "test" 21 | }, 22 | { 23 | "spawn": "package" 24 | } 25 | ] 26 | }, 27 | "bump": { 28 | "name": "bump", 29 | "description": "Bumps version based on latest git tag and generates a changelog entry", 30 | "env": { 31 | "OUTFILE": "package.json", 32 | "CHANGELOG": "dist/changelog.md", 33 | "BUMPFILE": "dist/version.txt", 34 | "RELEASETAG": "dist/releasetag.txt", 35 | "RELEASE_TAG_PREFIX": "", 36 | "BUMP_PACKAGE": "commit-and-tag-version@^12" 37 | }, 38 | "steps": [ 39 | { 40 | "builtin": "release/bump-version" 41 | } 42 | ], 43 | "condition": "git log --oneline -1 | grep -qv \"chore(release):\"" 44 | }, 45 | "clobber": { 46 | "name": "clobber", 47 | "description": "hard resets to HEAD of origin and cleans the local repo", 48 | "env": { 49 | "BRANCH": "$(git branch --show-current)" 50 | }, 51 | "steps": [ 52 | { 53 | "exec": "git checkout -b scratch", 54 | "name": "save current HEAD in \"scratch\" branch" 55 | }, 56 | { 57 | "exec": "git checkout $BRANCH" 58 | }, 59 | { 60 | "exec": "git fetch origin", 61 | "name": "fetch latest changes from origin" 62 | }, 63 | { 64 | "exec": "git reset --hard origin/$BRANCH", 65 | "name": "hard reset to origin commit" 66 | }, 67 | { 68 | "exec": "git clean -fdx", 69 | "name": "clean all untracked files" 70 | }, 71 | { 72 | "say": "ready to rock! (unpushed commits are under the \"scratch\" branch)" 73 | } 74 | ], 75 | "condition": "git diff --exit-code > /dev/null" 76 | }, 77 | "compat": { 78 | "name": "compat", 79 | "description": "Perform API compatibility check against latest version", 80 | "steps": [ 81 | { 82 | "exec": "jsii-diff npm:$(node -p \"require('./package.json').name\") -k --ignore-file .compatignore || (echo \"\nUNEXPECTED BREAKING CHANGES: add keys such as 'removed:constructs.Node.of' to .compatignore to skip.\n\" && exit 1)" 83 | } 84 | ] 85 | }, 86 | "compile": { 87 | "name": "compile", 88 | "description": "Only compile", 89 | "steps": [ 90 | { 91 | "exec": "jsii --silence-warnings=reserved-word" 92 | } 93 | ] 94 | }, 95 | "default": { 96 | "name": "default", 97 | "description": "Synthesize project files", 98 | "steps": [ 99 | { 100 | "exec": "ts-node --project tsconfig.dev.json .projenrc.ts" 101 | } 102 | ] 103 | }, 104 | "docgen-csharp": { 105 | "name": "docgen-csharp", 106 | "description": "Generate API.md from .jsii manifest for csharp", 107 | "steps": [ 108 | { 109 | "exec": "jsii-docgen -r0 -o docs/csharp.md -l csharp" 110 | } 111 | ] 112 | }, 113 | "docgen-java": { 114 | "name": "docgen-java", 115 | "description": "Generate API.md from .jsii manifest for java", 116 | "steps": [ 117 | { 118 | "exec": "jsii-docgen -r0 -o docs/java.md -l java" 119 | } 120 | ] 121 | }, 122 | "docgen-python": { 123 | "name": "docgen-python", 124 | "description": "Generate API.md from .jsii manifest for python", 125 | "steps": [ 126 | { 127 | "exec": "jsii-docgen -r0 -o docs/python.md -l python" 128 | } 129 | ] 130 | }, 131 | "docgen-typescript": { 132 | "name": "docgen-typescript", 133 | "description": "Generate API.md from .jsii manifest for typescript", 134 | "steps": [ 135 | { 136 | "exec": "jsii-docgen -r0 -o docs/typescript.md -l typescript" 137 | } 138 | ] 139 | }, 140 | "eject": { 141 | "name": "eject", 142 | "description": "Remove projen from the project", 143 | "env": { 144 | "PROJEN_EJECTING": "true" 145 | }, 146 | "steps": [ 147 | { 148 | "spawn": "default" 149 | } 150 | ] 151 | }, 152 | "eslint": { 153 | "name": "eslint", 154 | "description": "Runs eslint against the codebase", 155 | "env": { 156 | "ESLINT_USE_FLAT_CONFIG": "false", 157 | "NODE_NO_WARNINGS": "1" 158 | }, 159 | "steps": [ 160 | { 161 | "exec": "eslint --ext .ts,.tsx --fix --no-error-on-unmatched-pattern $@ src test build-tools projenrc .projenrc.ts", 162 | "receiveArgs": true 163 | } 164 | ] 165 | }, 166 | "install": { 167 | "name": "install", 168 | "description": "Install project dependencies and update lockfile (non-frozen)", 169 | "steps": [ 170 | { 171 | "exec": "yarn install --check-files" 172 | } 173 | ] 174 | }, 175 | "install:ci": { 176 | "name": "install:ci", 177 | "description": "Install project dependencies using frozen lockfile", 178 | "steps": [ 179 | { 180 | "exec": "yarn install --check-files --frozen-lockfile" 181 | } 182 | ] 183 | }, 184 | "package": { 185 | "name": "package", 186 | "description": "Creates the distribution package", 187 | "steps": [ 188 | { 189 | "spawn": "package:js", 190 | "condition": "node -e \"if (!process.env.CI) process.exit(1)\"" 191 | }, 192 | { 193 | "spawn": "package-all", 194 | "condition": "node -e \"if (process.env.CI) process.exit(1)\"" 195 | } 196 | ] 197 | }, 198 | "package-all": { 199 | "name": "package-all", 200 | "description": "Packages artifacts for all target languages", 201 | "steps": [ 202 | { 203 | "spawn": "package:js" 204 | }, 205 | { 206 | "spawn": "package:java" 207 | }, 208 | { 209 | "spawn": "package:python" 210 | }, 211 | { 212 | "spawn": "package:dotnet" 213 | }, 214 | { 215 | "spawn": "package:go" 216 | } 217 | ] 218 | }, 219 | "package:dotnet": { 220 | "name": "package:dotnet", 221 | "description": "Create dotnet language bindings", 222 | "steps": [ 223 | { 224 | "exec": "jsii-pacmak -v --target dotnet" 225 | } 226 | ] 227 | }, 228 | "package:go": { 229 | "name": "package:go", 230 | "description": "Create go language bindings", 231 | "steps": [ 232 | { 233 | "exec": "jsii-pacmak -v --target go" 234 | } 235 | ] 236 | }, 237 | "package:java": { 238 | "name": "package:java", 239 | "description": "Create java language bindings", 240 | "steps": [ 241 | { 242 | "exec": "jsii-pacmak -v --target java" 243 | } 244 | ] 245 | }, 246 | "package:js": { 247 | "name": "package:js", 248 | "description": "Create js language bindings", 249 | "steps": [ 250 | { 251 | "exec": "jsii-pacmak -v --target js" 252 | } 253 | ] 254 | }, 255 | "package:python": { 256 | "name": "package:python", 257 | "description": "Create python language bindings", 258 | "steps": [ 259 | { 260 | "exec": "jsii-pacmak -v --target python" 261 | } 262 | ] 263 | }, 264 | "post-compile": { 265 | "name": "post-compile", 266 | "description": "Runs after successful compilation", 267 | "steps": [ 268 | { 269 | "spawn": "docgen-typescript" 270 | }, 271 | { 272 | "spawn": "docgen-python" 273 | }, 274 | { 275 | "spawn": "docgen-java" 276 | }, 277 | { 278 | "spawn": "docgen-csharp" 279 | } 280 | ] 281 | }, 282 | "post-upgrade": { 283 | "name": "post-upgrade", 284 | "description": "Runs after upgrading dependencies" 285 | }, 286 | "pre-compile": { 287 | "name": "pre-compile", 288 | "description": "Prepare the project for compilation" 289 | }, 290 | "release": { 291 | "name": "release", 292 | "description": "Prepare a release from \"main\" branch", 293 | "env": { 294 | "RELEASE": "true", 295 | "MIN_MAJOR": "1" 296 | }, 297 | "steps": [ 298 | { 299 | "exec": "rm -fr dist" 300 | }, 301 | { 302 | "spawn": "bump" 303 | }, 304 | { 305 | "spawn": "build" 306 | }, 307 | { 308 | "spawn": "unbump" 309 | }, 310 | { 311 | "exec": "git diff --ignore-space-at-eol --exit-code" 312 | } 313 | ] 314 | }, 315 | "test": { 316 | "name": "test", 317 | "description": "Run tests", 318 | "steps": [ 319 | { 320 | "exec": "jest --passWithNoTests --updateSnapshot", 321 | "receiveArgs": true 322 | }, 323 | { 324 | "spawn": "eslint" 325 | } 326 | ] 327 | }, 328 | "test:watch": { 329 | "name": "test:watch", 330 | "description": "Run jest in watch mode", 331 | "steps": [ 332 | { 333 | "exec": "jest --watch" 334 | } 335 | ] 336 | }, 337 | "unbump": { 338 | "name": "unbump", 339 | "description": "Restores version to 0.0.0", 340 | "env": { 341 | "OUTFILE": "package.json", 342 | "CHANGELOG": "dist/changelog.md", 343 | "BUMPFILE": "dist/version.txt", 344 | "RELEASETAG": "dist/releasetag.txt", 345 | "RELEASE_TAG_PREFIX": "", 346 | "BUMP_PACKAGE": "commit-and-tag-version@^12" 347 | }, 348 | "steps": [ 349 | { 350 | "builtin": "release/reset-version" 351 | } 352 | ] 353 | }, 354 | "upgrade": { 355 | "name": "upgrade", 356 | "description": "upgrade dependencies", 357 | "env": { 358 | "CI": "0" 359 | }, 360 | "steps": [ 361 | { 362 | "exec": "npx npm-check-updates@18 --upgrade --target=minor --peer --no-deprecated --dep=dev,peer,prod,optional --filter=@types/jest,eslint-config-prettier,eslint-import-resolver-typescript,eslint-plugin-import,eslint-plugin-prettier,jest,jsii-diff,jsii-docgen,jsii-pacmak,prettier,projen,ts-jest,ts-node" 363 | }, 364 | { 365 | "exec": "yarn install --check-files" 366 | }, 367 | { 368 | "exec": "yarn upgrade @cdktf/provider-null @cdktf/provider-random @types/jest @types/node @typescript-eslint/eslint-plugin @typescript-eslint/parser commit-and-tag-version constructs eslint-config-prettier eslint-import-resolver-typescript eslint-plugin-import eslint-plugin-prettier eslint jest jest-junit jsii-diff jsii-docgen jsii-pacmak jsii-rosetta jsii prettier projen ts-jest ts-node typescript cdktf" 369 | }, 370 | { 371 | "exec": "npx projen" 372 | }, 373 | { 374 | "spawn": "post-upgrade" 375 | } 376 | ] 377 | }, 378 | "watch": { 379 | "name": "watch", 380 | "description": "Watch & compile in the background", 381 | "steps": [ 382 | { 383 | "exec": "jsii -w --silence-warnings=reserved-word" 384 | } 385 | ] 386 | } 387 | }, 388 | "env": { 389 | "PATH": "$(npx -c \"node --print process.env.PATH\")" 390 | }, 391 | "//": "~~ Generated by projen. To modify, edit .projenrc.ts and run \"npx projen\"." 392 | } 393 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen". 2 | 3 | name: release 4 | on: 5 | push: 6 | branches: 7 | - main 8 | paths-ignore: 9 | - examples/** 10 | - .github/ISSUE_TEMPLATE/** 11 | - .github/CODEOWNERS 12 | - .github/dependabot.yml 13 | - .github/**/*.md 14 | workflow_dispatch: {} 15 | concurrency: 16 | group: ${{ github.workflow }} 17 | cancel-in-progress: false 18 | jobs: 19 | release: 20 | runs-on: ubuntu-latest 21 | permissions: 22 | contents: write 23 | outputs: 24 | latest_commit: ${{ steps.git_remote.outputs.latest_commit }} 25 | tag_exists: ${{ steps.check_tag_exists.outputs.exists }} 26 | env: 27 | CI: "true" 28 | steps: 29 | - name: Checkout 30 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 31 | with: 32 | fetch-depth: 0 33 | - name: Set git identity 34 | run: |- 35 | git config user.name "github-actions[bot]" 36 | git config user.email "41898282+github-actions[bot]@users.noreply.github.com" 37 | - name: Install dependencies 38 | run: yarn install --check-files --frozen-lockfile 39 | - name: release 40 | run: npx projen release 41 | - name: Check if version has already been tagged 42 | id: check_tag_exists 43 | run: |- 44 | TAG=$(cat dist/releasetag.txt) 45 | ([ ! -z "$TAG" ] && git ls-remote -q --exit-code --tags origin $TAG && (echo "exists=true" >> $GITHUB_OUTPUT)) || (echo "exists=false" >> $GITHUB_OUTPUT) 46 | cat $GITHUB_OUTPUT 47 | - name: Check for new commits 48 | id: git_remote 49 | run: |- 50 | echo "latest_commit=$(git ls-remote origin -h ${{ github.ref }} | cut -f1)" >> $GITHUB_OUTPUT 51 | cat $GITHUB_OUTPUT 52 | shell: bash 53 | - name: Backup artifact permissions 54 | if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} 55 | run: cd dist && getfacl -R . > permissions-backup.acl 56 | continue-on-error: true 57 | - name: Upload artifact 58 | if: ${{ steps.git_remote.outputs.latest_commit == github.sha }} 59 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 60 | with: 61 | name: build-artifact 62 | path: dist 63 | overwrite: true 64 | release_github: 65 | name: Publish to GitHub Releases 66 | needs: release 67 | runs-on: ubuntu-latest 68 | permissions: 69 | contents: write 70 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 71 | steps: 72 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 73 | with: 74 | node-version: lts/* 75 | - name: Download build artifacts 76 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 77 | with: 78 | name: build-artifact 79 | path: dist 80 | - name: Restore build artifact permissions 81 | run: cd dist && setfacl --restore=permissions-backup.acl 82 | continue-on-error: true 83 | - name: Release 84 | env: 85 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 86 | run: errout=$(mktemp); gh release create $(cat dist/releasetag.txt) -R $GITHUB_REPOSITORY -F dist/changelog.md -t $(cat dist/releasetag.txt) --target $GITHUB_SHA 2> $errout && true; exitcode=$?; if [ $exitcode -ne 0 ] && ! grep -q "Release.tag_name already exists" $errout; then cat $errout; exit $exitcode; fi 87 | release_npm: 88 | name: Publish to npm 89 | needs: release 90 | runs-on: ubuntu-latest 91 | permissions: 92 | id-token: write 93 | contents: read 94 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 95 | steps: 96 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 97 | with: 98 | node-version: lts/* 99 | - name: Download build artifacts 100 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 101 | with: 102 | name: build-artifact 103 | path: dist 104 | - name: Restore build artifact permissions 105 | run: cd dist && setfacl --restore=permissions-backup.acl 106 | continue-on-error: true 107 | - name: Checkout 108 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 109 | with: 110 | path: .repo 111 | - name: Install Dependencies 112 | run: cd .repo && yarn install --check-files --frozen-lockfile 113 | - name: Extract build artifact 114 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 115 | - name: Move build artifact out of the way 116 | run: mv dist dist.old 117 | - name: Create js artifact 118 | run: cd .repo && npx projen package:js 119 | - name: Collect js artifact 120 | run: mv .repo/dist dist 121 | - name: Release 122 | env: 123 | NPM_DIST_TAG: latest 124 | NPM_REGISTRY: registry.npmjs.org 125 | NPM_CONFIG_PROVENANCE: "true" 126 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 127 | run: npx -p publib@latest publib-npm 128 | release_maven: 129 | name: Publish to Maven Central 130 | needs: release 131 | runs-on: ubuntu-latest 132 | permissions: 133 | contents: read 134 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 135 | steps: 136 | - uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 137 | with: 138 | distribution: corretto 139 | java-version: "11" 140 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 141 | with: 142 | node-version: lts/* 143 | - name: Download build artifacts 144 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 145 | with: 146 | name: build-artifact 147 | path: dist 148 | - name: Restore build artifact permissions 149 | run: cd dist && setfacl --restore=permissions-backup.acl 150 | continue-on-error: true 151 | - name: Checkout 152 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 153 | with: 154 | path: .repo 155 | - name: Install Dependencies 156 | run: cd .repo && yarn install --check-files --frozen-lockfile 157 | - name: Extract build artifact 158 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 159 | - name: Move build artifact out of the way 160 | run: mv dist dist.old 161 | - name: Create java artifact 162 | run: cd .repo && npx projen package:java 163 | - name: Collect java artifact 164 | run: mv .repo/dist dist 165 | - name: Release 166 | env: 167 | MAVEN_ENDPOINT: https://hashicorp.oss.sonatype.org 168 | MAVEN_GPG_PRIVATE_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} 169 | MAVEN_GPG_PRIVATE_KEY_PASSPHRASE: ${{ secrets.MAVEN_GPG_PRIVATE_KEY_PASSPHRASE }} 170 | MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} 171 | MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} 172 | MAVEN_STAGING_PROFILE_ID: ${{ secrets.MAVEN_STAGING_PROFILE_ID }} 173 | run: npx -p publib@latest publib-maven 174 | release_pypi: 175 | name: Publish to PyPI 176 | needs: release 177 | runs-on: ubuntu-latest 178 | permissions: 179 | contents: read 180 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 181 | steps: 182 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 183 | with: 184 | node-version: lts/* 185 | - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 186 | with: 187 | python-version: 3.x 188 | - name: Download build artifacts 189 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 190 | with: 191 | name: build-artifact 192 | path: dist 193 | - name: Restore build artifact permissions 194 | run: cd dist && setfacl --restore=permissions-backup.acl 195 | continue-on-error: true 196 | - name: Checkout 197 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 198 | with: 199 | path: .repo 200 | - name: Install Dependencies 201 | run: cd .repo && yarn install --check-files --frozen-lockfile 202 | - name: Extract build artifact 203 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 204 | - name: Move build artifact out of the way 205 | run: mv dist dist.old 206 | - name: Create python artifact 207 | run: cd .repo && npx projen package:python 208 | - name: Collect python artifact 209 | run: mv .repo/dist dist 210 | - name: Release 211 | env: 212 | TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }} 213 | TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} 214 | run: npx -p publib@latest publib-pypi 215 | release_nuget: 216 | name: Publish to NuGet Gallery 217 | needs: release 218 | runs-on: ubuntu-latest 219 | permissions: 220 | contents: read 221 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 222 | steps: 223 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 224 | with: 225 | node-version: lts/* 226 | - uses: actions/setup-dotnet@67a3573c9a986a3f9c594539f4ab511d57bb3ce9 227 | with: 228 | dotnet-version: 6.x 229 | - name: Download build artifacts 230 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 231 | with: 232 | name: build-artifact 233 | path: dist 234 | - name: Restore build artifact permissions 235 | run: cd dist && setfacl --restore=permissions-backup.acl 236 | continue-on-error: true 237 | - name: Checkout 238 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 239 | with: 240 | path: .repo 241 | - name: Install Dependencies 242 | run: cd .repo && yarn install --check-files --frozen-lockfile 243 | - name: Extract build artifact 244 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 245 | - name: Move build artifact out of the way 246 | run: mv dist dist.old 247 | - name: Create dotnet artifact 248 | run: cd .repo && npx projen package:dotnet 249 | - name: Collect dotnet artifact 250 | run: mv .repo/dist dist 251 | - name: Release 252 | env: 253 | NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }} 254 | run: npx -p publib@latest publib-nuget 255 | release_golang: 256 | name: Publish to GitHub Go Module Repository 257 | needs: release 258 | runs-on: ubuntu-latest 259 | permissions: 260 | contents: read 261 | if: needs.release.outputs.tag_exists != 'true' && needs.release.outputs.latest_commit == github.sha 262 | steps: 263 | - uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e 264 | with: 265 | node-version: lts/* 266 | - uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b 267 | with: 268 | go-version: ^1.18.0 269 | - name: Download build artifacts 270 | uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e 271 | with: 272 | name: build-artifact 273 | path: dist 274 | - name: Restore build artifact permissions 275 | run: cd dist && setfacl --restore=permissions-backup.acl 276 | continue-on-error: true 277 | - name: Checkout 278 | uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 279 | with: 280 | path: .repo 281 | - name: Install Dependencies 282 | run: cd .repo && yarn install --check-files --frozen-lockfile 283 | - name: Extract build artifact 284 | run: tar --strip-components=1 -xzvf dist/js/*.tgz -C .repo 285 | - name: Move build artifact out of the way 286 | run: mv dist dist.old 287 | - name: Create go artifact 288 | run: cd .repo && npx projen package:go 289 | - name: Collect go artifact 290 | run: mv .repo/dist dist 291 | - name: Release 292 | env: 293 | GIT_USER_NAME: CDK for Terraform Team 294 | GIT_USER_EMAIL: github-team-tf-cdk@hashicorp.com 295 | GITHUB_TOKEN: ${{ secrets.GO_GITHUB_TOKEN }} 296 | run: npx -p publib@latest publib-golang 297 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2022 HashiCorp, Inc. 2 | 3 | Mozilla Public License, version 2.0 4 | 5 | 1. Definitions 6 | 7 | 1.1. “Contributor” 8 | 9 | means each individual or legal entity that creates, contributes to the 10 | creation of, or owns Covered Software. 11 | 12 | 1.2. “Contributor Version” 13 | 14 | means the combination of the Contributions of others (if any) used by a 15 | Contributor and that particular Contributor’s Contribution. 16 | 17 | 1.3. “Contribution” 18 | 19 | means Covered Software of a particular Contributor. 20 | 21 | 1.4. “Covered Software” 22 | 23 | means Source Code Form to which the initial Contributor has attached the 24 | notice in Exhibit A, the Executable Form of such Source Code Form, and 25 | Modifications of such Source Code Form, in each case including portions 26 | thereof. 27 | 28 | 1.5. “Incompatible With Secondary Licenses” 29 | means 30 | 31 | a. that the initial Contributor has attached the notice described in 32 | Exhibit B to the Covered Software; or 33 | 34 | b. that the Covered Software was made available under the terms of version 35 | 1.1 or earlier of the License, but not also under the terms of a 36 | Secondary License. 37 | 38 | 1.6. “Executable Form” 39 | 40 | means any form of the work other than Source Code Form. 41 | 42 | 1.7. “Larger Work” 43 | 44 | means a work that combines Covered Software with other material, in a separate 45 | file or files, that is not Covered Software. 46 | 47 | 1.8. “License” 48 | 49 | means this document. 50 | 51 | 1.9. “Licensable” 52 | 53 | means having the right to grant, to the maximum extent possible, whether at the 54 | time of the initial grant or subsequently, any and all of the rights conveyed by 55 | this License. 56 | 57 | 1.10. “Modifications” 58 | 59 | means any of the following: 60 | 61 | a. any file in Source Code Form that results from an addition to, deletion 62 | from, or modification of the contents of Covered Software; or 63 | 64 | b. any new file in Source Code Form that contains any Covered Software. 65 | 66 | 1.11. “Patent Claims” of a Contributor 67 | 68 | means any patent claim(s), including without limitation, method, process, 69 | and apparatus claims, in any patent Licensable by such Contributor that 70 | would be infringed, but for the grant of the License, by the making, 71 | using, selling, offering for sale, having made, import, or transfer of 72 | either its Contributions or its Contributor Version. 73 | 74 | 1.12. “Secondary License” 75 | 76 | means either the GNU General Public License, Version 2.0, the GNU Lesser 77 | General Public License, Version 2.1, the GNU Affero General Public 78 | License, Version 3.0, or any later versions of those licenses. 79 | 80 | 1.13. “Source Code Form” 81 | 82 | means the form of the work preferred for making modifications. 83 | 84 | 1.14. “You” (or “Your”) 85 | 86 | means an individual or a legal entity exercising rights under this 87 | License. For legal entities, “You” includes any entity that controls, is 88 | controlled by, or is under common control with You. For purposes of this 89 | definition, “control” means (a) the power, direct or indirect, to cause 90 | the direction or management of such entity, whether by contract or 91 | otherwise, or (b) ownership of more than fifty percent (50%) of the 92 | outstanding shares or beneficial ownership of such entity. 93 | 94 | 95 | 2. License Grants and Conditions 96 | 97 | 2.1. Grants 98 | 99 | Each Contributor hereby grants You a world-wide, royalty-free, 100 | non-exclusive license: 101 | 102 | a. under intellectual property rights (other than patent or trademark) 103 | Licensable by such Contributor to use, reproduce, make available, 104 | modify, display, perform, distribute, and otherwise exploit its 105 | Contributions, either on an unmodified basis, with Modifications, or as 106 | part of a Larger Work; and 107 | 108 | b. under Patent Claims of such Contributor to make, use, sell, offer for 109 | sale, have made, import, and otherwise transfer either its Contributions 110 | or its Contributor Version. 111 | 112 | 2.2. Effective Date 113 | 114 | The licenses granted in Section 2.1 with respect to any Contribution become 115 | effective for each Contribution on the date the Contributor first distributes 116 | such Contribution. 117 | 118 | 2.3. Limitations on Grant Scope 119 | 120 | The licenses granted in this Section 2 are the only rights granted under this 121 | License. No additional rights or licenses will be implied from the distribution 122 | or licensing of Covered Software under this License. Notwithstanding Section 123 | 2.1(b) above, no patent license is granted by a Contributor: 124 | 125 | a. for any code that a Contributor has removed from Covered Software; or 126 | 127 | b. for infringements caused by: (i) Your and any other third party’s 128 | modifications of Covered Software, or (ii) the combination of its 129 | Contributions with other software (except as part of its Contributor 130 | Version); or 131 | 132 | c. under Patent Claims infringed by Covered Software in the absence of its 133 | Contributions. 134 | 135 | This License does not grant any rights in the trademarks, service marks, or 136 | logos of any Contributor (except as may be necessary to comply with the 137 | notice requirements in Section 3.4). 138 | 139 | 2.4. Subsequent Licenses 140 | 141 | No Contributor makes additional grants as a result of Your choice to 142 | distribute the Covered Software under a subsequent version of this License 143 | (see Section 10.2) or under the terms of a Secondary License (if permitted 144 | under the terms of Section 3.3). 145 | 146 | 2.5. Representation 147 | 148 | Each Contributor represents that the Contributor believes its Contributions 149 | are its original creation(s) or it has sufficient rights to grant the 150 | rights to its Contributions conveyed by this License. 151 | 152 | 2.6. Fair Use 153 | 154 | This License is not intended to limit any rights You have under applicable 155 | copyright doctrines of fair use, fair dealing, or other equivalents. 156 | 157 | 2.7. Conditions 158 | 159 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in 160 | Section 2.1. 161 | 162 | 163 | 3. Responsibilities 164 | 165 | 3.1. Distribution of Source Form 166 | 167 | All distribution of Covered Software in Source Code Form, including any 168 | Modifications that You create or to which You contribute, must be under the 169 | terms of this License. You must inform recipients that the Source Code Form 170 | of the Covered Software is governed by the terms of this License, and how 171 | they can obtain a copy of this License. You may not attempt to alter or 172 | restrict the recipients’ rights in the Source Code Form. 173 | 174 | 3.2. Distribution of Executable Form 175 | 176 | If You distribute Covered Software in Executable Form then: 177 | 178 | a. such Covered Software must also be made available in Source Code Form, 179 | as described in Section 3.1, and You must inform recipients of the 180 | Executable Form how they can obtain a copy of such Source Code Form by 181 | reasonable means in a timely manner, at a charge no more than the cost 182 | of distribution to the recipient; and 183 | 184 | b. You may distribute such Executable Form under the terms of this License, 185 | or sublicense it under different terms, provided that the license for 186 | the Executable Form does not attempt to limit or alter the recipients’ 187 | rights in the Source Code Form under this License. 188 | 189 | 3.3. Distribution of a Larger Work 190 | 191 | You may create and distribute a Larger Work under terms of Your choice, 192 | provided that You also comply with the requirements of this License for the 193 | Covered Software. If the Larger Work is a combination of Covered Software 194 | with a work governed by one or more Secondary Licenses, and the Covered 195 | Software is not Incompatible With Secondary Licenses, this License permits 196 | You to additionally distribute such Covered Software under the terms of 197 | such Secondary License(s), so that the recipient of the Larger Work may, at 198 | their option, further distribute the Covered Software under the terms of 199 | either this License or such Secondary License(s). 200 | 201 | 3.4. Notices 202 | 203 | You may not remove or alter the substance of any license notices (including 204 | copyright notices, patent notices, disclaimers of warranty, or limitations 205 | of liability) contained within the Source Code Form of the Covered 206 | Software, except that You may alter any license notices to the extent 207 | required to remedy known factual inaccuracies. 208 | 209 | 3.5. Application of Additional Terms 210 | 211 | You may choose to offer, and to charge a fee for, warranty, support, 212 | indemnity or liability obligations to one or more recipients of Covered 213 | Software. However, You may do so only on Your own behalf, and not on behalf 214 | of any Contributor. You must make it absolutely clear that any such 215 | warranty, support, indemnity, or liability obligation is offered by You 216 | alone, and You hereby agree to indemnify every Contributor for any 217 | liability incurred by such Contributor as a result of warranty, support, 218 | indemnity or liability terms You offer. You may include additional 219 | disclaimers of warranty and limitations of liability specific to any 220 | jurisdiction. 221 | 222 | 4. Inability to Comply Due to Statute or Regulation 223 | 224 | If it is impossible for You to comply with any of the terms of this License 225 | with respect to some or all of the Covered Software due to statute, judicial 226 | order, or regulation then You must: (a) comply with the terms of this License 227 | to the maximum extent possible; and (b) describe the limitations and the code 228 | they affect. Such description must be placed in a text file included with all 229 | distributions of the Covered Software under this License. Except to the 230 | extent prohibited by statute or regulation, such description must be 231 | sufficiently detailed for a recipient of ordinary skill to be able to 232 | understand it. 233 | 234 | 5. Termination 235 | 236 | 5.1. The rights granted under this License will terminate automatically if You 237 | fail to comply with any of its terms. However, if You become compliant, 238 | then the rights granted under this License from a particular Contributor 239 | are reinstated (a) provisionally, unless and until such Contributor 240 | explicitly and finally terminates Your grants, and (b) on an ongoing basis, 241 | if such Contributor fails to notify You of the non-compliance by some 242 | reasonable means prior to 60 days after You have come back into compliance. 243 | Moreover, Your grants from a particular Contributor are reinstated on an 244 | ongoing basis if such Contributor notifies You of the non-compliance by 245 | some reasonable means, this is the first time You have received notice of 246 | non-compliance with this License from such Contributor, and You become 247 | compliant prior to 30 days after Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, counter-claims, 251 | and cross-claims) alleging that a Contributor Version directly or 252 | indirectly infringes any patent, then the rights granted to You by any and 253 | all Contributors for the Covered Software under Section 2.1 of this License 254 | shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user 257 | license agreements (excluding distributors and resellers) which have been 258 | validly granted by You or Your distributors under this License prior to 259 | termination shall survive termination. 260 | 261 | 6. Disclaimer of Warranty 262 | 263 | Covered Software is provided under this License on an “as is” basis, without 264 | warranty of any kind, either expressed, implied, or statutory, including, 265 | without limitation, warranties that the Covered Software is free of defects, 266 | merchantable, fit for a particular purpose or non-infringing. The entire 267 | risk as to the quality and performance of the Covered Software is with You. 268 | Should any Covered Software prove defective in any respect, You (not any 269 | Contributor) assume the cost of any necessary servicing, repair, or 270 | correction. This disclaimer of warranty constitutes an essential part of this 271 | License. No use of any Covered Software is authorized under this License 272 | except under this disclaimer. 273 | 274 | 7. Limitation of Liability 275 | 276 | Under no circumstances and under no legal theory, whether tort (including 277 | negligence), contract, or otherwise, shall any Contributor, or anyone who 278 | distributes Covered Software as permitted above, be liable to You for any 279 | direct, indirect, special, incidental, or consequential damages of any 280 | character including, without limitation, damages for lost profits, loss of 281 | goodwill, work stoppage, computer failure or malfunction, or any and all 282 | other commercial damages or losses, even if such party shall have been 283 | informed of the possibility of such damages. This limitation of liability 284 | shall not apply to liability for death or personal injury resulting from such 285 | party’s negligence to the extent applicable law prohibits such limitation. 286 | Some jurisdictions do not allow the exclusion or limitation of incidental or 287 | consequential damages, so this exclusion and limitation may not apply to You. 288 | 289 | 8. Litigation 290 | 291 | Any litigation relating to this License may be brought only in the courts of 292 | a jurisdiction where the defendant maintains its principal place of business 293 | and such litigation shall be governed by laws of that jurisdiction, without 294 | reference to its conflict-of-law provisions. Nothing in this Section shall 295 | prevent a party’s ability to bring cross-claims or counter-claims. 296 | 297 | 9. Miscellaneous 298 | 299 | This License represents the complete agreement concerning the subject matter 300 | hereof. If any provision of this License is held to be unenforceable, such 301 | provision shall be reformed only to the extent necessary to make it 302 | enforceable. Any law or regulation which provides that the language of a 303 | contract shall be construed against the drafter shall not be used to construe 304 | this License against a Contributor. 305 | 306 | 307 | 10. Versions of the License 308 | 309 | 10.1. New Versions 310 | 311 | Mozilla Foundation is the license steward. Except as provided in Section 312 | 10.3, no one other than the license steward has the right to modify or 313 | publish new versions of this License. Each version will be given a 314 | distinguishing version number. 315 | 316 | 10.2. Effect of New Versions 317 | 318 | You may distribute the Covered Software under the terms of the version of 319 | the License under which You originally received the Covered Software, or 320 | under the terms of any subsequent version published by the license 321 | steward. 322 | 323 | 10.3. Modified Versions 324 | 325 | If you create software not governed by this License, and you want to 326 | create a new license for such software, you may create and use a modified 327 | version of this License if you rename the license and remove any 328 | references to the name of the license steward (except to note that such 329 | modified license differs from this License). 330 | 331 | 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses 332 | If You choose to distribute Source Code Form that is Incompatible With 333 | Secondary Licenses under the terms of this version of the License, the 334 | notice described in Exhibit B of this License must be attached. 335 | 336 | Exhibit A - Source Code Form License Notice 337 | 338 | This Source Code Form is subject to the 339 | terms of the Mozilla Public License, v. 340 | 2.0. If a copy of the MPL was not 341 | distributed with this file, You can 342 | obtain one at 343 | http://mozilla.org/MPL/2.0/. 344 | 345 | If it is not possible or desirable to put the notice in a particular file, then 346 | You may include the notice in a location (such as a LICENSE file in a relevant 347 | directory) where a recipient would be likely to look for such a notice. 348 | 349 | You may add additional accurate notices of copyright ownership. 350 | 351 | Exhibit B - “Incompatible With Secondary Licenses” Notice 352 | 353 | This Source Code Form is “Incompatible 354 | With Secondary Licenses”, as defined by 355 | the Mozilla Public License, v. 2.0. 356 | -------------------------------------------------------------------------------- /docs/go.md: -------------------------------------------------------------------------------- 1 | # API Reference 2 | 3 | ## Constructs 4 | 5 | ### ProviderRequirement 6 | 7 | #### Initializers 8 | 9 | ```go 10 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 11 | 12 | tfmodulestack.NewProviderRequirement(scope Construct, providerName *string, providerVersionConstraint *string, terraformProviderSource *string) ProviderRequirement 13 | ``` 14 | 15 | | **Name** | **Type** | **Description** | 16 | | --- | --- | --- | 17 | | scope | github.com/aws/constructs-go/constructs/v10.Construct | *No description.* | 18 | | providerName | *string | *No description.* | 19 | | providerVersionConstraint | *string | *No description.* | 20 | | terraformProviderSource | *string | *No description.* | 21 | 22 | --- 23 | 24 | ##### `scope`Required 25 | 26 | - *Type:* github.com/aws/constructs-go/constructs/v10.Construct 27 | 28 | --- 29 | 30 | ##### `providerName`Required 31 | 32 | - *Type:* *string 33 | 34 | --- 35 | 36 | ##### `providerVersionConstraint`Optional 37 | 38 | - *Type:* *string 39 | 40 | --- 41 | 42 | ##### `terraformProviderSource`Optional 43 | 44 | - *Type:* *string 45 | 46 | --- 47 | 48 | #### Methods 49 | 50 | | **Name** | **Description** | 51 | | --- | --- | 52 | | ToString | Returns a string representation of this construct. | 53 | | AddOverride | *No description.* | 54 | | OverrideLogicalId | Overrides the auto-generated logical ID with a specific ID. | 55 | | ResetOverrideLogicalId | Resets a previously passed logical Id to use the auto-generated logical id again. | 56 | | ToMetadata | *No description.* | 57 | | ToTerraform | Adds this resource to the terraform JSON output. | 58 | 59 | --- 60 | 61 | ##### `ToString` 62 | 63 | ```go 64 | func ToString() *string 65 | ``` 66 | 67 | Returns a string representation of this construct. 68 | 69 | ##### `AddOverride` 70 | 71 | ```go 72 | func AddOverride(path *string, value interface{}) 73 | ``` 74 | 75 | ###### `path`Required 76 | 77 | - *Type:* *string 78 | 79 | --- 80 | 81 | ###### `value`Required 82 | 83 | - *Type:* interface{} 84 | 85 | --- 86 | 87 | ##### `OverrideLogicalId` 88 | 89 | ```go 90 | func OverrideLogicalId(newLogicalId *string) 91 | ``` 92 | 93 | Overrides the auto-generated logical ID with a specific ID. 94 | 95 | ###### `newLogicalId`Required 96 | 97 | - *Type:* *string 98 | 99 | The new logical ID to use for this stack element. 100 | 101 | --- 102 | 103 | ##### `ResetOverrideLogicalId` 104 | 105 | ```go 106 | func ResetOverrideLogicalId() 107 | ``` 108 | 109 | Resets a previously passed logical Id to use the auto-generated logical id again. 110 | 111 | ##### `ToMetadata` 112 | 113 | ```go 114 | func ToMetadata() interface{} 115 | ``` 116 | 117 | ##### `ToTerraform` 118 | 119 | ```go 120 | func ToTerraform() interface{} 121 | ``` 122 | 123 | Adds this resource to the terraform JSON output. 124 | 125 | #### Static Functions 126 | 127 | | **Name** | **Description** | 128 | | --- | --- | 129 | | IsConstruct | Checks if `x` is a construct. | 130 | | IsTerraformElement | *No description.* | 131 | | IsTerraformProvider | *No description.* | 132 | 133 | --- 134 | 135 | ##### ~~`IsConstruct`~~ 136 | 137 | ```go 138 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 139 | 140 | tfmodulestack.ProviderRequirement_IsConstruct(x interface{}) *bool 141 | ``` 142 | 143 | Checks if `x` is a construct. 144 | 145 | ###### `x`Required 146 | 147 | - *Type:* interface{} 148 | 149 | Any object. 150 | 151 | --- 152 | 153 | ##### `IsTerraformElement` 154 | 155 | ```go 156 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 157 | 158 | tfmodulestack.ProviderRequirement_IsTerraformElement(x interface{}) *bool 159 | ``` 160 | 161 | ###### `x`Required 162 | 163 | - *Type:* interface{} 164 | 165 | --- 166 | 167 | ##### `IsTerraformProvider` 168 | 169 | ```go 170 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 171 | 172 | tfmodulestack.ProviderRequirement_IsTerraformProvider(x interface{}) *bool 173 | ``` 174 | 175 | ###### `x`Required 176 | 177 | - *Type:* interface{} 178 | 179 | --- 180 | 181 | #### Properties 182 | 183 | | **Name** | **Type** | **Description** | 184 | | --- | --- | --- | 185 | | Node | github.com/aws/constructs-go/constructs/v10.Node | The tree node. | 186 | | CdktfStack | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack | *No description.* | 187 | | Fqn | *string | *No description.* | 188 | | FriendlyUniqueId | *string | *No description.* | 189 | | MetaAttributes | *map[string]interface{} | *No description.* | 190 | | TerraformResourceType | *string | *No description.* | 191 | | TerraformGeneratorMetadata | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformProviderGeneratorMetadata | *No description.* | 192 | | TerraformProviderSource | *string | *No description.* | 193 | | Alias | *string | *No description.* | 194 | 195 | --- 196 | 197 | ##### `Node`Required 198 | 199 | ```go 200 | func Node() Node 201 | ``` 202 | 203 | - *Type:* github.com/aws/constructs-go/constructs/v10.Node 204 | 205 | The tree node. 206 | 207 | --- 208 | 209 | ##### `CdktfStack`Required 210 | 211 | ```go 212 | func CdktfStack() TerraformStack 213 | ``` 214 | 215 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 216 | 217 | --- 218 | 219 | ##### `Fqn`Required 220 | 221 | ```go 222 | func Fqn() *string 223 | ``` 224 | 225 | - *Type:* *string 226 | 227 | --- 228 | 229 | ##### `FriendlyUniqueId`Required 230 | 231 | ```go 232 | func FriendlyUniqueId() *string 233 | ``` 234 | 235 | - *Type:* *string 236 | 237 | --- 238 | 239 | ##### `MetaAttributes`Required 240 | 241 | ```go 242 | func MetaAttributes() *map[string]interface{} 243 | ``` 244 | 245 | - *Type:* *map[string]interface{} 246 | 247 | --- 248 | 249 | ##### `TerraformResourceType`Required 250 | 251 | ```go 252 | func TerraformResourceType() *string 253 | ``` 254 | 255 | - *Type:* *string 256 | 257 | --- 258 | 259 | ##### `TerraformGeneratorMetadata`Optional 260 | 261 | ```go 262 | func TerraformGeneratorMetadata() TerraformProviderGeneratorMetadata 263 | ``` 264 | 265 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformProviderGeneratorMetadata 266 | 267 | --- 268 | 269 | ##### `TerraformProviderSource`Optional 270 | 271 | ```go 272 | func TerraformProviderSource() *string 273 | ``` 274 | 275 | - *Type:* *string 276 | 277 | --- 278 | 279 | ##### `Alias`Optional 280 | 281 | ```go 282 | func Alias() *string 283 | ``` 284 | 285 | - *Type:* *string 286 | 287 | --- 288 | 289 | 290 | ### TFModuleApp 291 | 292 | #### Initializers 293 | 294 | ```go 295 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 296 | 297 | tfmodulestack.NewTFModuleApp(options AppConfig) TFModuleApp 298 | ``` 299 | 300 | | **Name** | **Type** | **Description** | 301 | | --- | --- | --- | 302 | | options | github.com/hashicorp/terraform-cdk-go/cdktf.AppConfig | *No description.* | 303 | 304 | --- 305 | 306 | ##### `options`Optional 307 | 308 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.AppConfig 309 | 310 | --- 311 | 312 | #### Methods 313 | 314 | | **Name** | **Description** | 315 | | --- | --- | 316 | | ToString | Returns a string representation of this construct. | 317 | | CrossStackReference | Creates a reference from one stack to another, invoked on prepareStack since it creates extra resources. | 318 | | Synth | Synthesizes all resources to the output directory. | 319 | 320 | --- 321 | 322 | ##### `ToString` 323 | 324 | ```go 325 | func ToString() *string 326 | ``` 327 | 328 | Returns a string representation of this construct. 329 | 330 | ##### `CrossStackReference` 331 | 332 | ```go 333 | func CrossStackReference(fromStack TerraformStack, toStack TerraformStack, identifier *string) *string 334 | ``` 335 | 336 | Creates a reference from one stack to another, invoked on prepareStack since it creates extra resources. 337 | 338 | ###### `fromStack`Required 339 | 340 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 341 | 342 | --- 343 | 344 | ###### `toStack`Required 345 | 346 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 347 | 348 | --- 349 | 350 | ###### `identifier`Required 351 | 352 | - *Type:* *string 353 | 354 | --- 355 | 356 | ##### `Synth` 357 | 358 | ```go 359 | func Synth() 360 | ``` 361 | 362 | Synthesizes all resources to the output directory. 363 | 364 | #### Static Functions 365 | 366 | | **Name** | **Description** | 367 | | --- | --- | 368 | | IsConstruct | Checks if `x` is a construct. | 369 | | IsApp | *No description.* | 370 | | Of | *No description.* | 371 | 372 | --- 373 | 374 | ##### ~~`IsConstruct`~~ 375 | 376 | ```go 377 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 378 | 379 | tfmodulestack.TFModuleApp_IsConstruct(x interface{}) *bool 380 | ``` 381 | 382 | Checks if `x` is a construct. 383 | 384 | ###### `x`Required 385 | 386 | - *Type:* interface{} 387 | 388 | Any object. 389 | 390 | --- 391 | 392 | ##### `IsApp` 393 | 394 | ```go 395 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 396 | 397 | tfmodulestack.TFModuleApp_IsApp(x interface{}) *bool 398 | ``` 399 | 400 | ###### `x`Required 401 | 402 | - *Type:* interface{} 403 | 404 | --- 405 | 406 | ##### `Of` 407 | 408 | ```go 409 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 410 | 411 | tfmodulestack.TFModuleApp_Of(construct IConstruct) App 412 | ``` 413 | 414 | ###### `construct`Required 415 | 416 | - *Type:* github.com/aws/constructs-go/constructs/v10.IConstruct 417 | 418 | --- 419 | 420 | #### Properties 421 | 422 | | **Name** | **Type** | **Description** | 423 | | --- | --- | --- | 424 | | Node | github.com/aws/constructs-go/constructs/v10.Node | The tree node. | 425 | | Manifest | github.com/hashicorp/terraform-cdk-go/cdktf.Manifest | *No description.* | 426 | | Outdir | *string | The output directory into which resources will be synthesized. | 427 | | SkipValidation | *bool | Whether to skip the validation during synthesis of the app. | 428 | | TargetStackId | *string | The stack which will be synthesized. | 429 | 430 | --- 431 | 432 | ##### `Node`Required 433 | 434 | ```go 435 | func Node() Node 436 | ``` 437 | 438 | - *Type:* github.com/aws/constructs-go/constructs/v10.Node 439 | 440 | The tree node. 441 | 442 | --- 443 | 444 | ##### `Manifest`Required 445 | 446 | ```go 447 | func Manifest() Manifest 448 | ``` 449 | 450 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.Manifest 451 | 452 | --- 453 | 454 | ##### `Outdir`Required 455 | 456 | ```go 457 | func Outdir() *string 458 | ``` 459 | 460 | - *Type:* *string 461 | 462 | The output directory into which resources will be synthesized. 463 | 464 | --- 465 | 466 | ##### `SkipValidation`Optional 467 | 468 | ```go 469 | func SkipValidation() *bool 470 | ``` 471 | 472 | - *Type:* *bool 473 | 474 | Whether to skip the validation during synthesis of the app. 475 | 476 | --- 477 | 478 | ##### `TargetStackId`Optional 479 | 480 | ```go 481 | func TargetStackId() *string 482 | ``` 483 | 484 | - *Type:* *string 485 | 486 | The stack which will be synthesized. 487 | 488 | If not set, all stacks will be synthesized. 489 | 490 | --- 491 | 492 | 493 | ### TFModuleOutput 494 | 495 | #### Initializers 496 | 497 | ```go 498 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 499 | 500 | tfmodulestack.NewTFModuleOutput(scope Construct, name *string, config TerraformOutputConfig) TFModuleOutput 501 | ``` 502 | 503 | | **Name** | **Type** | **Description** | 504 | | --- | --- | --- | 505 | | scope | github.com/aws/constructs-go/constructs/v10.Construct | *No description.* | 506 | | name | *string | *No description.* | 507 | | config | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformOutputConfig | *No description.* | 508 | 509 | --- 510 | 511 | ##### `scope`Required 512 | 513 | - *Type:* github.com/aws/constructs-go/constructs/v10.Construct 514 | 515 | --- 516 | 517 | ##### `name`Required 518 | 519 | - *Type:* *string 520 | 521 | --- 522 | 523 | ##### `config`Required 524 | 525 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformOutputConfig 526 | 527 | --- 528 | 529 | #### Methods 530 | 531 | | **Name** | **Description** | 532 | | --- | --- | 533 | | ToString | Returns a string representation of this construct. | 534 | | AddOverride | *No description.* | 535 | | OverrideLogicalId | Overrides the auto-generated logical ID with a specific ID. | 536 | | ResetOverrideLogicalId | Resets a previously passed logical Id to use the auto-generated logical id again. | 537 | | ToMetadata | *No description.* | 538 | | ToTerraform | *No description.* | 539 | 540 | --- 541 | 542 | ##### `ToString` 543 | 544 | ```go 545 | func ToString() *string 546 | ``` 547 | 548 | Returns a string representation of this construct. 549 | 550 | ##### `AddOverride` 551 | 552 | ```go 553 | func AddOverride(path *string, value interface{}) 554 | ``` 555 | 556 | ###### `path`Required 557 | 558 | - *Type:* *string 559 | 560 | --- 561 | 562 | ###### `value`Required 563 | 564 | - *Type:* interface{} 565 | 566 | --- 567 | 568 | ##### `OverrideLogicalId` 569 | 570 | ```go 571 | func OverrideLogicalId(newLogicalId *string) 572 | ``` 573 | 574 | Overrides the auto-generated logical ID with a specific ID. 575 | 576 | ###### `newLogicalId`Required 577 | 578 | - *Type:* *string 579 | 580 | The new logical ID to use for this stack element. 581 | 582 | --- 583 | 584 | ##### `ResetOverrideLogicalId` 585 | 586 | ```go 587 | func ResetOverrideLogicalId() 588 | ``` 589 | 590 | Resets a previously passed logical Id to use the auto-generated logical id again. 591 | 592 | ##### `ToMetadata` 593 | 594 | ```go 595 | func ToMetadata() interface{} 596 | ``` 597 | 598 | ##### `ToTerraform` 599 | 600 | ```go 601 | func ToTerraform() interface{} 602 | ``` 603 | 604 | #### Static Functions 605 | 606 | | **Name** | **Description** | 607 | | --- | --- | 608 | | IsConstruct | Checks if `x` is a construct. | 609 | | IsTerraformElement | *No description.* | 610 | | IsTerraformOutput | *No description.* | 611 | 612 | --- 613 | 614 | ##### ~~`IsConstruct`~~ 615 | 616 | ```go 617 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 618 | 619 | tfmodulestack.TFModuleOutput_IsConstruct(x interface{}) *bool 620 | ``` 621 | 622 | Checks if `x` is a construct. 623 | 624 | ###### `x`Required 625 | 626 | - *Type:* interface{} 627 | 628 | Any object. 629 | 630 | --- 631 | 632 | ##### `IsTerraformElement` 633 | 634 | ```go 635 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 636 | 637 | tfmodulestack.TFModuleOutput_IsTerraformElement(x interface{}) *bool 638 | ``` 639 | 640 | ###### `x`Required 641 | 642 | - *Type:* interface{} 643 | 644 | --- 645 | 646 | ##### `IsTerraformOutput` 647 | 648 | ```go 649 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 650 | 651 | tfmodulestack.TFModuleOutput_IsTerraformOutput(x interface{}) *bool 652 | ``` 653 | 654 | ###### `x`Required 655 | 656 | - *Type:* interface{} 657 | 658 | --- 659 | 660 | #### Properties 661 | 662 | | **Name** | **Type** | **Description** | 663 | | --- | --- | --- | 664 | | Node | github.com/aws/constructs-go/constructs/v10.Node | The tree node. | 665 | | CdktfStack | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack | *No description.* | 666 | | Fqn | *string | *No description.* | 667 | | FriendlyUniqueId | *string | *No description.* | 668 | | StaticId | *bool | *No description.* | 669 | | Value | interface{} | *No description.* | 670 | | DependsOn | *[]github.com/hashicorp/terraform-cdk-go/cdktf.ITerraformDependable | *No description.* | 671 | | Description | *string | *No description.* | 672 | | Sensitive | *bool | *No description.* | 673 | 674 | --- 675 | 676 | ##### `Node`Required 677 | 678 | ```go 679 | func Node() Node 680 | ``` 681 | 682 | - *Type:* github.com/aws/constructs-go/constructs/v10.Node 683 | 684 | The tree node. 685 | 686 | --- 687 | 688 | ##### `CdktfStack`Required 689 | 690 | ```go 691 | func CdktfStack() TerraformStack 692 | ``` 693 | 694 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 695 | 696 | --- 697 | 698 | ##### `Fqn`Required 699 | 700 | ```go 701 | func Fqn() *string 702 | ``` 703 | 704 | - *Type:* *string 705 | 706 | --- 707 | 708 | ##### `FriendlyUniqueId`Required 709 | 710 | ```go 711 | func FriendlyUniqueId() *string 712 | ``` 713 | 714 | - *Type:* *string 715 | 716 | --- 717 | 718 | ##### `StaticId`Required 719 | 720 | ```go 721 | func StaticId() *bool 722 | ``` 723 | 724 | - *Type:* *bool 725 | 726 | --- 727 | 728 | ##### `Value`Required 729 | 730 | ```go 731 | func Value() interface{} 732 | ``` 733 | 734 | - *Type:* interface{} 735 | 736 | --- 737 | 738 | ##### `DependsOn`Optional 739 | 740 | ```go 741 | func DependsOn() *[]ITerraformDependable 742 | ``` 743 | 744 | - *Type:* *[]github.com/hashicorp/terraform-cdk-go/cdktf.ITerraformDependable 745 | 746 | --- 747 | 748 | ##### `Description`Optional 749 | 750 | ```go 751 | func Description() *string 752 | ``` 753 | 754 | - *Type:* *string 755 | 756 | --- 757 | 758 | ##### `Sensitive`Optional 759 | 760 | ```go 761 | func Sensitive() *bool 762 | ``` 763 | 764 | - *Type:* *bool 765 | 766 | --- 767 | 768 | 769 | ### TFModuleStack 770 | 771 | #### Initializers 772 | 773 | ```go 774 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 775 | 776 | tfmodulestack.NewTFModuleStack(scope Construct, id *string) TFModuleStack 777 | ``` 778 | 779 | | **Name** | **Type** | **Description** | 780 | | --- | --- | --- | 781 | | scope | github.com/aws/constructs-go/constructs/v10.Construct | *No description.* | 782 | | id | *string | *No description.* | 783 | 784 | --- 785 | 786 | ##### `scope`Required 787 | 788 | - *Type:* github.com/aws/constructs-go/constructs/v10.Construct 789 | 790 | --- 791 | 792 | ##### `id`Required 793 | 794 | - *Type:* *string 795 | 796 | --- 797 | 798 | #### Methods 799 | 800 | | **Name** | **Description** | 801 | | --- | --- | 802 | | ToString | Returns a string representation of this construct. | 803 | | AddDependency | *No description.* | 804 | | AddOverride | *No description.* | 805 | | AllProviders | *No description.* | 806 | | DependsOn | *No description.* | 807 | | EnsureBackendExists | *No description.* | 808 | | GetLogicalId | *No description.* | 809 | | PrepareStack | *No description.* | 810 | | RegisterIncomingCrossStackReference | *No description.* | 811 | | RegisterOutgoingCrossStackReference | *No description.* | 812 | | RunAllValidations | Run all validations on the stack. | 813 | | ToTerraform | *No description.* | 814 | 815 | --- 816 | 817 | ##### `ToString` 818 | 819 | ```go 820 | func ToString() *string 821 | ``` 822 | 823 | Returns a string representation of this construct. 824 | 825 | ##### `AddDependency` 826 | 827 | ```go 828 | func AddDependency(dependency TerraformStack) 829 | ``` 830 | 831 | ###### `dependency`Required 832 | 833 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 834 | 835 | --- 836 | 837 | ##### `AddOverride` 838 | 839 | ```go 840 | func AddOverride(path *string, value interface{}) 841 | ``` 842 | 843 | ###### `path`Required 844 | 845 | - *Type:* *string 846 | 847 | --- 848 | 849 | ###### `value`Required 850 | 851 | - *Type:* interface{} 852 | 853 | --- 854 | 855 | ##### `AllProviders` 856 | 857 | ```go 858 | func AllProviders() *[]TerraformProvider 859 | ``` 860 | 861 | ##### `DependsOn` 862 | 863 | ```go 864 | func DependsOn(stack TerraformStack) *bool 865 | ``` 866 | 867 | ###### `stack`Required 868 | 869 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 870 | 871 | --- 872 | 873 | ##### `EnsureBackendExists` 874 | 875 | ```go 876 | func EnsureBackendExists() TerraformBackend 877 | ``` 878 | 879 | ##### `GetLogicalId` 880 | 881 | ```go 882 | func GetLogicalId(tfElement interface{}) *string 883 | ``` 884 | 885 | ###### `tfElement`Required 886 | 887 | - *Type:* interface{} 888 | 889 | --- 890 | 891 | ##### `PrepareStack` 892 | 893 | ```go 894 | func PrepareStack() 895 | ``` 896 | 897 | ##### `RegisterIncomingCrossStackReference` 898 | 899 | ```go 900 | func RegisterIncomingCrossStackReference(fromStack TerraformStack) TerraformRemoteState 901 | ``` 902 | 903 | ###### `fromStack`Required 904 | 905 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 906 | 907 | --- 908 | 909 | ##### `RegisterOutgoingCrossStackReference` 910 | 911 | ```go 912 | func RegisterOutgoingCrossStackReference(identifier *string) TerraformOutput 913 | ``` 914 | 915 | ###### `identifier`Required 916 | 917 | - *Type:* *string 918 | 919 | --- 920 | 921 | ##### `RunAllValidations` 922 | 923 | ```go 924 | func RunAllValidations() 925 | ``` 926 | 927 | Run all validations on the stack. 928 | 929 | ##### `ToTerraform` 930 | 931 | ```go 932 | func ToTerraform() interface{} 933 | ``` 934 | 935 | #### Static Functions 936 | 937 | | **Name** | **Description** | 938 | | --- | --- | 939 | | IsConstruct | Checks if `x` is a construct. | 940 | | IsStack | *No description.* | 941 | | Of | *No description.* | 942 | 943 | --- 944 | 945 | ##### ~~`IsConstruct`~~ 946 | 947 | ```go 948 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 949 | 950 | tfmodulestack.TFModuleStack_IsConstruct(x interface{}) *bool 951 | ``` 952 | 953 | Checks if `x` is a construct. 954 | 955 | ###### `x`Required 956 | 957 | - *Type:* interface{} 958 | 959 | Any object. 960 | 961 | --- 962 | 963 | ##### `IsStack` 964 | 965 | ```go 966 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 967 | 968 | tfmodulestack.TFModuleStack_IsStack(x interface{}) *bool 969 | ``` 970 | 971 | ###### `x`Required 972 | 973 | - *Type:* interface{} 974 | 975 | --- 976 | 977 | ##### `Of` 978 | 979 | ```go 980 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 981 | 982 | tfmodulestack.TFModuleStack_Of(construct IConstruct) TerraformStack 983 | ``` 984 | 985 | ###### `construct`Required 986 | 987 | - *Type:* github.com/aws/constructs-go/constructs/v10.IConstruct 988 | 989 | --- 990 | 991 | #### Properties 992 | 993 | | **Name** | **Type** | **Description** | 994 | | --- | --- | --- | 995 | | Node | github.com/aws/constructs-go/constructs/v10.Node | The tree node. | 996 | | Dependencies | *[]github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack | *No description.* | 997 | | Synthesizer | github.com/hashicorp/terraform-cdk-go/cdktf.IStackSynthesizer | *No description.* | 998 | 999 | --- 1000 | 1001 | ##### `Node`Required 1002 | 1003 | ```go 1004 | func Node() Node 1005 | ``` 1006 | 1007 | - *Type:* github.com/aws/constructs-go/constructs/v10.Node 1008 | 1009 | The tree node. 1010 | 1011 | --- 1012 | 1013 | ##### `Dependencies`Required 1014 | 1015 | ```go 1016 | func Dependencies() *[]TerraformStack 1017 | ``` 1018 | 1019 | - *Type:* *[]github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 1020 | 1021 | --- 1022 | 1023 | ##### `Synthesizer`Required 1024 | 1025 | ```go 1026 | func Synthesizer() IStackSynthesizer 1027 | ``` 1028 | 1029 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.IStackSynthesizer 1030 | 1031 | --- 1032 | 1033 | 1034 | ### TFModuleVariable 1035 | 1036 | #### Initializers 1037 | 1038 | ```go 1039 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 1040 | 1041 | tfmodulestack.NewTFModuleVariable(scope Construct, name *string, config TerraformVariableConfig) TFModuleVariable 1042 | ``` 1043 | 1044 | | **Name** | **Type** | **Description** | 1045 | | --- | --- | --- | 1046 | | scope | github.com/aws/constructs-go/constructs/v10.Construct | *No description.* | 1047 | | name | *string | *No description.* | 1048 | | config | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformVariableConfig | *No description.* | 1049 | 1050 | --- 1051 | 1052 | ##### `scope`Required 1053 | 1054 | - *Type:* github.com/aws/constructs-go/constructs/v10.Construct 1055 | 1056 | --- 1057 | 1058 | ##### `name`Required 1059 | 1060 | - *Type:* *string 1061 | 1062 | --- 1063 | 1064 | ##### `config`Required 1065 | 1066 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformVariableConfig 1067 | 1068 | --- 1069 | 1070 | #### Methods 1071 | 1072 | | **Name** | **Description** | 1073 | | --- | --- | 1074 | | ToString | Returns a string representation of this construct. | 1075 | | AddOverride | *No description.* | 1076 | | OverrideLogicalId | Overrides the auto-generated logical ID with a specific ID. | 1077 | | ResetOverrideLogicalId | Resets a previously passed logical Id to use the auto-generated logical id again. | 1078 | | ToMetadata | *No description.* | 1079 | | ToTerraform | *No description.* | 1080 | | AddValidation | *No description.* | 1081 | | SynthesizeAttributes | *No description.* | 1082 | 1083 | --- 1084 | 1085 | ##### `ToString` 1086 | 1087 | ```go 1088 | func ToString() *string 1089 | ``` 1090 | 1091 | Returns a string representation of this construct. 1092 | 1093 | ##### `AddOverride` 1094 | 1095 | ```go 1096 | func AddOverride(path *string, value interface{}) 1097 | ``` 1098 | 1099 | ###### `path`Required 1100 | 1101 | - *Type:* *string 1102 | 1103 | --- 1104 | 1105 | ###### `value`Required 1106 | 1107 | - *Type:* interface{} 1108 | 1109 | --- 1110 | 1111 | ##### `OverrideLogicalId` 1112 | 1113 | ```go 1114 | func OverrideLogicalId(newLogicalId *string) 1115 | ``` 1116 | 1117 | Overrides the auto-generated logical ID with a specific ID. 1118 | 1119 | ###### `newLogicalId`Required 1120 | 1121 | - *Type:* *string 1122 | 1123 | The new logical ID to use for this stack element. 1124 | 1125 | --- 1126 | 1127 | ##### `ResetOverrideLogicalId` 1128 | 1129 | ```go 1130 | func ResetOverrideLogicalId() 1131 | ``` 1132 | 1133 | Resets a previously passed logical Id to use the auto-generated logical id again. 1134 | 1135 | ##### `ToMetadata` 1136 | 1137 | ```go 1138 | func ToMetadata() interface{} 1139 | ``` 1140 | 1141 | ##### `ToTerraform` 1142 | 1143 | ```go 1144 | func ToTerraform() interface{} 1145 | ``` 1146 | 1147 | ##### `AddValidation` 1148 | 1149 | ```go 1150 | func AddValidation(validation TerraformVariableValidationConfig) 1151 | ``` 1152 | 1153 | ###### `validation`Required 1154 | 1155 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformVariableValidationConfig 1156 | 1157 | --- 1158 | 1159 | ##### `SynthesizeAttributes` 1160 | 1161 | ```go 1162 | func SynthesizeAttributes() *map[string]interface{} 1163 | ``` 1164 | 1165 | #### Static Functions 1166 | 1167 | | **Name** | **Description** | 1168 | | --- | --- | 1169 | | IsConstruct | Checks if `x` is a construct. | 1170 | | IsTerraformElement | *No description.* | 1171 | 1172 | --- 1173 | 1174 | ##### ~~`IsConstruct`~~ 1175 | 1176 | ```go 1177 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 1178 | 1179 | tfmodulestack.TFModuleVariable_IsConstruct(x interface{}) *bool 1180 | ``` 1181 | 1182 | Checks if `x` is a construct. 1183 | 1184 | ###### `x`Required 1185 | 1186 | - *Type:* interface{} 1187 | 1188 | Any object. 1189 | 1190 | --- 1191 | 1192 | ##### `IsTerraformElement` 1193 | 1194 | ```go 1195 | import "github.com/cdktf/cdktf-tf-module-stack-go/tfmodulestack" 1196 | 1197 | tfmodulestack.TFModuleVariable_IsTerraformElement(x interface{}) *bool 1198 | ``` 1199 | 1200 | ###### `x`Required 1201 | 1202 | - *Type:* interface{} 1203 | 1204 | --- 1205 | 1206 | #### Properties 1207 | 1208 | | **Name** | **Type** | **Description** | 1209 | | --- | --- | --- | 1210 | | Node | github.com/aws/constructs-go/constructs/v10.Node | The tree node. | 1211 | | CdktfStack | github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack | *No description.* | 1212 | | Fqn | *string | *No description.* | 1213 | | FriendlyUniqueId | *string | *No description.* | 1214 | | BooleanValue | github.com/hashicorp/terraform-cdk-go/cdktf.IResolvable | *No description.* | 1215 | | ListValue | *[]*string | *No description.* | 1216 | | NumberValue | *f64 | *No description.* | 1217 | | StringValue | *string | *No description.* | 1218 | | Value | interface{} | *No description.* | 1219 | | Default | interface{} | *No description.* | 1220 | | Description | *string | *No description.* | 1221 | | Nullable | *bool | *No description.* | 1222 | | Sensitive | *bool | *No description.* | 1223 | | Type | *string | *No description.* | 1224 | | Validation | *[]github.com/hashicorp/terraform-cdk-go/cdktf.TerraformVariableValidationConfig | *No description.* | 1225 | 1226 | --- 1227 | 1228 | ##### `Node`Required 1229 | 1230 | ```go 1231 | func Node() Node 1232 | ``` 1233 | 1234 | - *Type:* github.com/aws/constructs-go/constructs/v10.Node 1235 | 1236 | The tree node. 1237 | 1238 | --- 1239 | 1240 | ##### `CdktfStack`Required 1241 | 1242 | ```go 1243 | func CdktfStack() TerraformStack 1244 | ``` 1245 | 1246 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.TerraformStack 1247 | 1248 | --- 1249 | 1250 | ##### `Fqn`Required 1251 | 1252 | ```go 1253 | func Fqn() *string 1254 | ``` 1255 | 1256 | - *Type:* *string 1257 | 1258 | --- 1259 | 1260 | ##### `FriendlyUniqueId`Required 1261 | 1262 | ```go 1263 | func FriendlyUniqueId() *string 1264 | ``` 1265 | 1266 | - *Type:* *string 1267 | 1268 | --- 1269 | 1270 | ##### `BooleanValue`Required 1271 | 1272 | ```go 1273 | func BooleanValue() IResolvable 1274 | ``` 1275 | 1276 | - *Type:* github.com/hashicorp/terraform-cdk-go/cdktf.IResolvable 1277 | 1278 | --- 1279 | 1280 | ##### `ListValue`Required 1281 | 1282 | ```go 1283 | func ListValue() *[]*string 1284 | ``` 1285 | 1286 | - *Type:* *[]*string 1287 | 1288 | --- 1289 | 1290 | ##### `NumberValue`Required 1291 | 1292 | ```go 1293 | func NumberValue() *f64 1294 | ``` 1295 | 1296 | - *Type:* *f64 1297 | 1298 | --- 1299 | 1300 | ##### `StringValue`Required 1301 | 1302 | ```go 1303 | func StringValue() *string 1304 | ``` 1305 | 1306 | - *Type:* *string 1307 | 1308 | --- 1309 | 1310 | ##### `Value`Required 1311 | 1312 | ```go 1313 | func Value() interface{} 1314 | ``` 1315 | 1316 | - *Type:* interface{} 1317 | 1318 | --- 1319 | 1320 | ##### `Default`Optional 1321 | 1322 | ```go 1323 | func Default() interface{} 1324 | ``` 1325 | 1326 | - *Type:* interface{} 1327 | 1328 | --- 1329 | 1330 | ##### `Description`Optional 1331 | 1332 | ```go 1333 | func Description() *string 1334 | ``` 1335 | 1336 | - *Type:* *string 1337 | 1338 | --- 1339 | 1340 | ##### `Nullable`Optional 1341 | 1342 | ```go 1343 | func Nullable() *bool 1344 | ``` 1345 | 1346 | - *Type:* *bool 1347 | 1348 | --- 1349 | 1350 | ##### `Sensitive`Optional 1351 | 1352 | ```go 1353 | func Sensitive() *bool 1354 | ``` 1355 | 1356 | - *Type:* *bool 1357 | 1358 | --- 1359 | 1360 | ##### `Type`Optional 1361 | 1362 | ```go 1363 | func Type() *string 1364 | ``` 1365 | 1366 | - *Type:* *string 1367 | 1368 | --- 1369 | 1370 | ##### `Validation`Optional 1371 | 1372 | ```go 1373 | func Validation() *[]TerraformVariableValidationConfig 1374 | ``` 1375 | 1376 | - *Type:* *[]github.com/hashicorp/terraform-cdk-go/cdktf.TerraformVariableValidationConfig 1377 | 1378 | --- 1379 | 1380 | 1381 | 1382 | 1383 | 1384 | --------------------------------------------------------------------------------