@cdk8s/cdktf-resolver 0.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.gitattributes ADDED
@@ -0,0 +1,39 @@
1
+ # ~~ Generated by projen. To modify, edit .projenrc.ts and run "npx projen".
2
+
3
+ *.snap linguist-generated
4
+ /.eslintrc.json linguist-generated
5
+ /.gitattributes linguist-generated
6
+ /.github/ISSUE_TEMPLATE/bug.md linguist-generated
7
+ /.github/ISSUE_TEMPLATE/config.yml linguist-generated
8
+ /.github/ISSUE_TEMPLATE/feature-request.md linguist-generated
9
+ /.github/pull_request_template.md linguist-generated
10
+ /.github/workflows/auto-approve.yml linguist-generated
11
+ /.github/workflows/build.yml linguist-generated
12
+ /.github/workflows/pull-request-lint.yml linguist-generated
13
+ /.github/workflows/release.yml linguist-generated
14
+ /.github/workflows/security.yml linguist-generated
15
+ /.github/workflows/stale.yml linguist-generated
16
+ /.github/workflows/triage.yml linguist-generated
17
+ /.github/workflows/upgrade-compiler-dependencies-main.yml linguist-generated
18
+ /.github/workflows/upgrade-configuration-main.yml linguist-generated
19
+ /.github/workflows/upgrade-dev-dependencies-main.yml linguist-generated
20
+ /.github/workflows/upgrade-runtime-dependencies-main.yml linguist-generated
21
+ /.gitignore linguist-generated
22
+ /.mergify.yml linguist-generated
23
+ /.npmignore linguist-generated
24
+ /.npmrc linguist-generated
25
+ /.projen/** linguist-generated
26
+ /.projen/deps.json linguist-generated
27
+ /.projen/files.json linguist-generated
28
+ /.projen/tasks.json linguist-generated
29
+ /API.md linguist-generated
30
+ /CODE_OF_CONDUCT.md linguist-generated
31
+ /DCO linguist-generated
32
+ /git-hooks/prepare-commit-msg linguist-generated
33
+ /git-hooks/README.md linguist-generated
34
+ /git-hooks/setup.sh linguist-generated
35
+ /LICENSE linguist-generated
36
+ /package.json linguist-generated
37
+ /SECURITY.md linguist-generated
38
+ /tsconfig.dev.json linguist-generated
39
+ /yarn.lock linguist-generated
package/.jsii ADDED
@@ -0,0 +1,236 @@
1
+ {
2
+ "author": {
3
+ "name": "Amazon Web Services",
4
+ "roles": [
5
+ "author"
6
+ ],
7
+ "url": "https://aws.amazon.com"
8
+ },
9
+ "dependencies": {
10
+ "cdk8s": "^2.66.2",
11
+ "cdktf": "^0.18.0",
12
+ "constructs": "^10.2.70"
13
+ },
14
+ "dependencyClosure": {
15
+ "cdk8s": {
16
+ "targets": {
17
+ "dotnet": {
18
+ "namespace": "Org.Cdk8s",
19
+ "packageId": "Org.Cdk8s"
20
+ },
21
+ "go": {
22
+ "moduleName": "github.com/cdk8s-team/cdk8s-core-go"
23
+ },
24
+ "java": {
25
+ "maven": {
26
+ "artifactId": "cdk8s",
27
+ "groupId": "org.cdk8s"
28
+ },
29
+ "package": "org.cdk8s"
30
+ },
31
+ "js": {
32
+ "npm": "cdk8s"
33
+ },
34
+ "python": {
35
+ "distName": "cdk8s",
36
+ "module": "cdk8s"
37
+ }
38
+ }
39
+ },
40
+ "cdktf": {
41
+ "submodules": {
42
+ "cdktf.testingMatchers": {}
43
+ },
44
+ "targets": {
45
+ "dotnet": {
46
+ "namespace": "HashiCorp.Cdktf",
47
+ "packageId": "HashiCorp.Cdktf"
48
+ },
49
+ "go": {
50
+ "moduleName": "github.com/hashicorp/terraform-cdk-go",
51
+ "packageName": "cdktf"
52
+ },
53
+ "java": {
54
+ "maven": {
55
+ "artifactId": "cdktf",
56
+ "groupId": "com.hashicorp"
57
+ },
58
+ "package": "com.hashicorp.cdktf"
59
+ },
60
+ "js": {
61
+ "npm": "cdktf"
62
+ },
63
+ "python": {
64
+ "distName": "cdktf",
65
+ "module": "cdktf"
66
+ }
67
+ }
68
+ },
69
+ "constructs": {
70
+ "targets": {
71
+ "dotnet": {
72
+ "namespace": "Constructs",
73
+ "packageId": "Constructs"
74
+ },
75
+ "go": {
76
+ "moduleName": "github.com/aws/constructs-go"
77
+ },
78
+ "java": {
79
+ "maven": {
80
+ "artifactId": "constructs",
81
+ "groupId": "software.constructs"
82
+ },
83
+ "package": "software.constructs"
84
+ },
85
+ "js": {
86
+ "npm": "constructs"
87
+ },
88
+ "python": {
89
+ "distName": "constructs",
90
+ "module": "constructs"
91
+ }
92
+ }
93
+ }
94
+ },
95
+ "description": "@cdk8s/cdktf-resolver",
96
+ "docs": {
97
+ "stability": "stable"
98
+ },
99
+ "homepage": "https://github.com/cdk8s-team/cdk8s-cdktf-resolver.git",
100
+ "jsiiVersion": "5.2.11 (build f6c85b3)",
101
+ "license": "Apache-2.0",
102
+ "metadata": {
103
+ "jsii": {
104
+ "pacmak": {
105
+ "hasDefaultInterfaces": true
106
+ }
107
+ },
108
+ "tscRootDir": "src"
109
+ },
110
+ "name": "@cdk8s/cdktf-resolver",
111
+ "readme": {
112
+ "markdown": "# CDK For Terraform Resolver\n\nThe `CdkTfResolver` is able to resolve any [`TerraformOutput`](https://developer.hashicorp.com/terraform/cdktf/concepts/variables-and-outputs#output-values)\ndefined by your CDKTF application. In this example, we create an S3 `Bucket` with the CDKTF, and pass its (deploy time generated)\nname as an environment variable to a Kubernetes `CronJob` resource.\n\n```ts\nimport * as tf from \"cdktf\";\nimport * as aws from \"@cdktf/provider-aws\";\nimport * as k8s from 'cdk8s';\nimport * as kplus from 'cdk8s-plus-26';\n\nimport { CdkTfResolver } from '@cdk8s/cdktf-resolver';\n\nconst awsApp = new tf.App();\nconst stack = new tf.TerraformStack(awsApp, 'aws');\n\nconst k8sApp = new k8s.App({ resolvers: [new CdkTfResolver()] });\nconst manifest = new k8s.Chart(k8sApp, 'Manifest', { resolver });\n\nconst bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');\nconst bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {\n value: bucket.bucket,\n});\n\nnew kplus.CronJob(manifest, 'CronJob', {\n schedule: k8s.Cron.daily(),\n containers: [{\n image: 'job',\n envVariables: {\n // directly passing the value of the `TerraformOutput` containing\n // the deploy time bucket name\n BUCKET_NAME: kplus.EnvValue.fromValue(bucketName.value),\n }\n }]\n});\n\nawsApp.synth();\nk8sApp.synth();\n```\n\nDuring cdk8s synthesis, the custom resolver will detect that `bucketName.value` is not a concrete value,\nbut rather a value of a `TerraformOutput`. It will then perform `cdktf` CLI commands in order to fetch the\nactual value from the deployed infrastructure in your account. This means that in order\nfor `cdk8s synth` to succeed, it must be executed *after* the CDKTF resources\nhave been deployed. So your deployment workflow should (conceptually) be:\n\n1. `cdktf deploy`\n2. `cdk8s synth`\n\n> Note that the `CdkTfResolver` is **only** able to fetch tokens that have a `TerraformOutput` defined for them.\n\n##### Permissions\n\nSince running `cdk8s synth` will now require reading terraform outputs, it must have permissions to do so.\nIn case a remote state file is used, this means providing a set of credentials for the account that have access\nto where the state is stored. This will vary depending on your cloud provider, but in most cases will involve giving\nread permissions on a blob storage device (e.g S3 bucket).\n\nNote that the permissions cdk8s require are far more scoped down than those normally required for the\ndeployment of CDKTF applications. It is therefore recommended to not reuse the same set of credentials,\nand instead create a scoped down `ReadOnly` role dedicated for cdk8s resolvers.\n\nFollowing are the set of commands the resolver will execute:\n\n- [`cdktf output`](https://developer.hashicorp.com/terraform/cdktf/cli-reference/commands#output)\n\n## Cross Repository Workflow\n\nAs we've seen, your `cdk8s` application needs access to the objects defined in your cloud application. If both applications\nare defined within the same file, this is trivial to achieve. If they are in different files, a simple `import` statement will suffice.\nHowever, what if the applications are managed in two separate repositories? This makes it a little trickier, but still possible.\n\nIn this scenario, `cdktf.ts` in the CDKTF application, stored in a dedicated repository.\n\n```ts\nimport * as tf from \"cdktf\";\nimport * as aws from \"@cdktf/provider-aws\";\n\nimport { CdkTfResolver } from '@cdk8s/cdktf-resolver';\n\nconst awsApp = new tf.App();\nconst stack = new tf.TerraformStack(awsApp, 'aws');\n\nconst bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');\nconst bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {\n value: bucket.bucket,\n});\n\nawsApp.synth();\n```\n\nIn order for the `cdk8s` application to have cross repository access, the CDKTF object instances\nthat we want to expose need to be available via a package repository. To do this, break up the\nCDKTF application into the following files:\n\n`app.ts`\n\n```ts\nimport * as tf from \"cdktf\";\nimport * as aws from \"@cdktf/provider-aws\";\n\nimport { CdkTfResolver } from '@cdk8s/cdktf-resolver';\n\nconst awsApp = new tf.App();\nconst stack = new tf.TerraformStack(awsApp, 'aws');\n\nconst bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');\n// export the thing we want to have available for cdk8s applications\nexport const bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {\n value: bucket.bucket,\n});\n\n// note that we don't call awsApp.synth here\n```\n\n`main.ts`\n\n```ts\nimport { awsApp } from './app.ts'\n\nawsApp.synth();\n```\n\nNow, publish the `app.ts` file to a package manager, so that your `cdk8s` application can install and import it.\nThis approach might be somewhat counter intuitive, because normally we only publish classes to the package manager,\nnot instances. Indeed, these types of applications introduce a new use-case that requires the sharing of instances.\nConceptually, this is no different than writing state<sup>*</sup> to an SSM parameter or an S3 bucket, and it allows us to remain\nin the boundaries of our programming language, and the typing guarantees it provides.\n\n> <sup>*</sup> Actually, we are only publishing instructions for fetching state, not the state itself.\n\nAssuming `app.ts` was published as the `my-cdktf-app` package, our `cdk8s` application will now look like so:\n\n```ts\nimport * as k8s from 'cdk8s';\nimport * as kplus from 'cdk8s-plus-27';\n\n// import the desired instance from the CDKTF app.\nimport { bucketName } from 'my-cdktf-app';\n\nimport { CdkTfResolver } from '@cdk8s/cdktf-resolver';\n\nconst k8sApp = new k8s.App({ resolvers: [new CdkTfResolver()] });\nconst manifest = new k8s.Chart(k8sApp, 'Manifest');\n\nnew kplus.CronJob(manifest, 'CronJob', {\n schedule: k8s.Cron.daily(),\n containers: [{\n image: 'job',\n envVariables: {\n // directly passing the value of the `TerraformOutput` containing\n // the deploy time bucket name\n BUCKET_NAME: kplus.EnvValue.fromValue(bucketName.value),\n }\n }]\n});\n\nk8sApp.synth();\n```"
113
+ },
114
+ "repository": {
115
+ "type": "git",
116
+ "url": "https://github.com/cdk8s-team/cdk8s-cdktf-resolver.git"
117
+ },
118
+ "schema": "jsii/0.10.0",
119
+ "targets": {
120
+ "dotnet": {
121
+ "namespace": "Org.Cdk8s.CdktfResolver",
122
+ "packageId": "Org.Cdk8s.CdktfResolver"
123
+ },
124
+ "go": {
125
+ "moduleName": "github.com/cdk8s-team/cdk8s-cdktf-resolver-go"
126
+ },
127
+ "java": {
128
+ "maven": {
129
+ "artifactId": "cdk8s-cdktf-resolver",
130
+ "groupId": "org.cdk8s"
131
+ },
132
+ "package": "org.cdk8s.cdktfresolver"
133
+ },
134
+ "js": {
135
+ "npm": "@cdk8s/cdktf-resolver"
136
+ },
137
+ "python": {
138
+ "distName": "cdk8s-cdktf-resolver",
139
+ "module": "cdk8s_cdktf_resolver"
140
+ }
141
+ },
142
+ "types": {
143
+ "@cdk8s/cdktf-resolver.CdktfResolver": {
144
+ "assembly": "@cdk8s/cdktf-resolver",
145
+ "docs": {
146
+ "stability": "stable"
147
+ },
148
+ "fqn": "@cdk8s/cdktf-resolver.CdktfResolver",
149
+ "initializer": {
150
+ "docs": {
151
+ "stability": "stable"
152
+ },
153
+ "locationInModule": {
154
+ "filename": "src/resolve.ts",
155
+ "line": 22
156
+ },
157
+ "parameters": [
158
+ {
159
+ "name": "props",
160
+ "type": {
161
+ "fqn": "@cdk8s/cdktf-resolver.CdktfResolverProps"
162
+ }
163
+ }
164
+ ]
165
+ },
166
+ "interfaces": [
167
+ "cdk8s.IResolver"
168
+ ],
169
+ "kind": "class",
170
+ "locationInModule": {
171
+ "filename": "src/resolve.ts",
172
+ "line": 16
173
+ },
174
+ "methods": [
175
+ {
176
+ "docs": {
177
+ "remarks": "To replace a value, implementations must invoke `context.replaceValue`.",
178
+ "stability": "stable",
179
+ "summary": "This function is invoked on every property during cdk8s synthesis."
180
+ },
181
+ "locationInModule": {
182
+ "filename": "src/resolve.ts",
183
+ "line": 26
184
+ },
185
+ "name": "resolve",
186
+ "overrides": "cdk8s.IResolver",
187
+ "parameters": [
188
+ {
189
+ "name": "context",
190
+ "type": {
191
+ "fqn": "cdk8s.ResolutionContext"
192
+ }
193
+ }
194
+ ]
195
+ }
196
+ ],
197
+ "name": "CdktfResolver",
198
+ "symbolId": "src/resolve:CdktfResolver"
199
+ },
200
+ "@cdk8s/cdktf-resolver.CdktfResolverProps": {
201
+ "assembly": "@cdk8s/cdktf-resolver",
202
+ "datatype": true,
203
+ "docs": {
204
+ "stability": "stable"
205
+ },
206
+ "fqn": "@cdk8s/cdktf-resolver.CdktfResolverProps",
207
+ "kind": "interface",
208
+ "locationInModule": {
209
+ "filename": "src/resolve.ts",
210
+ "line": 8
211
+ },
212
+ "name": "CdktfResolverProps",
213
+ "properties": [
214
+ {
215
+ "abstract": true,
216
+ "docs": {
217
+ "stability": "stable",
218
+ "summary": "The CDKTF App instance in which the outputs are deinfed in."
219
+ },
220
+ "immutable": true,
221
+ "locationInModule": {
222
+ "filename": "src/resolve.ts",
223
+ "line": 13
224
+ },
225
+ "name": "app",
226
+ "type": {
227
+ "fqn": "cdktf.App"
228
+ }
229
+ }
230
+ ],
231
+ "symbolId": "src/resolve:CdktfResolverProps"
232
+ }
233
+ },
234
+ "version": "0.0.0",
235
+ "fingerprint": "FqZZC54xY//nsfG/k9EjjuRj+gHkWDBkzDoTrH7BJnU="
236
+ }
package/.projenrc.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { Cdk8sTeamJsiiProject } from '@cdk8s/projen-common';
2
+ import { NpmAccess } from 'projen/lib/javascript';
3
+ const project = new Cdk8sTeamJsiiProject({
4
+ defaultReleaseBranch: 'main',
5
+ name: '@cdk8s/cdktf-resolver',
6
+ projenrcTs: true,
7
+ release: true,
8
+ devDeps: ['@cdk8s/projen-common', 'cdktf-cli', 'cdk8s-cli', '@cdktf/provider-aws', 'fs-extra', '@types/fs-extra'],
9
+ peerDeps: ['cdktf', 'cdk8s', 'constructs'],
10
+ jsiiVersion: '^5',
11
+ releaseWorkflowSetupSteps: [
12
+ {
13
+ uses: 'aws-actions/configure-aws-credentials@v3',
14
+ with: {
15
+ 'aws-region': 'us-east-1',
16
+ 'role-to-assume': '${{ secrets.AWS_ROLE_TO_ASSUME }}',
17
+ 'role-session-name': 'cdk8s-awscdk-resolver-release',
18
+ },
19
+ },
20
+ {
21
+ name: 'Install terraform | GPG',
22
+ run: 'wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg',
23
+ },
24
+ {
25
+ name: 'Install terraform | Sources',
26
+ run: 'echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list',
27
+ },
28
+ {
29
+ name: 'Install terraform | Binary',
30
+ run: 'sudo apt update && sudo apt install terraform',
31
+ },
32
+ ],
33
+ npmAccess: NpmAccess.PUBLIC,
34
+ });
35
+
36
+ // ignore integ tests because we will add a dedicated task
37
+ // for them that only runs on release
38
+ project.jest?.addIgnorePattern('/test/integ/');
39
+
40
+ const integTask = project.addTask('integ');
41
+ integTask.exec(jest('integ/integ.test.ts'));
42
+
43
+ // run integ on release.
44
+ // we don't run it on each PR because it brings security and operational
45
+ // issues which are not worth the effort at this moment.
46
+ const releaseTask = project.tasks.tryFind('release')!;
47
+ releaseTask.exec(`npx projen ${integTask.name}`);
48
+
49
+ // required for OIDC authentication
50
+ const releaseWorkflow = project.tryFindObjectFile('.github/workflows/release.yml');
51
+ releaseWorkflow!.addOverride('jobs.release.permissions.id-token', 'write');
52
+
53
+ project.synth();
54
+
55
+ function jest(args: string) {
56
+ // we override 'testPathIgnorePatterns' and 'testMatch' so that it matches only integration tests
57
+ // see https://github.com/jestjs/jest/issues/7914
58
+ return `jest --verbose --testMatch "<rootDir>/test/integ/**/*.test.ts" --testPathIgnorePatterns "/node_modules/" --passWithNoTests --all --updateSnapshot --coverageProvider=v8 ${args}`;
59
+ };
package/API.md ADDED
@@ -0,0 +1,249 @@
1
+ # CDK For Terraform Resolver
2
+
3
+ The `CdkTfResolver` is able to resolve any [`TerraformOutput`](https://developer.hashicorp.com/terraform/cdktf/concepts/variables-and-outputs#output-values)
4
+ defined by your CDKTF application. In this example, we create an S3 `Bucket` with the CDKTF, and pass its (deploy time generated)
5
+ name as an environment variable to a Kubernetes `CronJob` resource.
6
+
7
+ ```ts
8
+ import * as tf from "cdktf";
9
+ import * as aws from "@cdktf/provider-aws";
10
+ import * as k8s from 'cdk8s';
11
+ import * as kplus from 'cdk8s-plus-26';
12
+
13
+ import { CdkTfResolver } from '@cdk8s/cdktf-resolver';
14
+
15
+ const awsApp = new tf.App();
16
+ const stack = new tf.TerraformStack(awsApp, 'aws');
17
+
18
+ const k8sApp = new k8s.App({ resolvers: [new CdkTfResolver()] });
19
+ const manifest = new k8s.Chart(k8sApp, 'Manifest', { resolver });
20
+
21
+ const bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');
22
+ const bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {
23
+ value: bucket.bucket,
24
+ });
25
+
26
+ new kplus.CronJob(manifest, 'CronJob', {
27
+ schedule: k8s.Cron.daily(),
28
+ containers: [{
29
+ image: 'job',
30
+ envVariables: {
31
+ // directly passing the value of the `TerraformOutput` containing
32
+ // the deploy time bucket name
33
+ BUCKET_NAME: kplus.EnvValue.fromValue(bucketName.value),
34
+ }
35
+ }]
36
+ });
37
+
38
+ awsApp.synth();
39
+ k8sApp.synth();
40
+ ```
41
+
42
+ During cdk8s synthesis, the custom resolver will detect that `bucketName.value` is not a concrete value,
43
+ but rather a value of a `TerraformOutput`. It will then perform `cdktf` CLI commands in order to fetch the
44
+ actual value from the deployed infrastructure in your account. This means that in order
45
+ for `cdk8s synth` to succeed, it must be executed *after* the CDKTF resources
46
+ have been deployed. So your deployment workflow should (conceptually) be:
47
+
48
+ 1. `cdktf deploy`
49
+ 2. `cdk8s synth`
50
+
51
+ > Note that the `CdkTfResolver` is **only** able to fetch tokens that have a `TerraformOutput` defined for them.
52
+
53
+ ##### Permissions
54
+
55
+ Since running `cdk8s synth` will now require reading terraform outputs, it must have permissions to do so.
56
+ In case a remote state file is used, this means providing a set of credentials for the account that have access
57
+ to where the state is stored. This will vary depending on your cloud provider, but in most cases will involve giving
58
+ read permissions on a blob storage device (e.g S3 bucket).
59
+
60
+ Note that the permissions cdk8s require are far more scoped down than those normally required for the
61
+ deployment of CDKTF applications. It is therefore recommended to not reuse the same set of credentials,
62
+ and instead create a scoped down `ReadOnly` role dedicated for cdk8s resolvers.
63
+
64
+ Following are the set of commands the resolver will execute:
65
+
66
+ - [`cdktf output`](https://developer.hashicorp.com/terraform/cdktf/cli-reference/commands#output)
67
+
68
+ ## Cross Repository Workflow
69
+
70
+ As we've seen, your `cdk8s` application needs access to the objects defined in your cloud application. If both applications
71
+ are defined within the same file, this is trivial to achieve. If they are in different files, a simple `import` statement will suffice.
72
+ However, what if the applications are managed in two separate repositories? This makes it a little trickier, but still possible.
73
+
74
+ In this scenario, `cdktf.ts` in the CDKTF application, stored in a dedicated repository.
75
+
76
+ ```ts
77
+ import * as tf from "cdktf";
78
+ import * as aws from "@cdktf/provider-aws";
79
+
80
+ import { CdkTfResolver } from '@cdk8s/cdktf-resolver';
81
+
82
+ const awsApp = new tf.App();
83
+ const stack = new tf.TerraformStack(awsApp, 'aws');
84
+
85
+ const bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');
86
+ const bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {
87
+ value: bucket.bucket,
88
+ });
89
+
90
+ awsApp.synth();
91
+ ```
92
+
93
+ In order for the `cdk8s` application to have cross repository access, the CDKTF object instances
94
+ that we want to expose need to be available via a package repository. To do this, break up the
95
+ CDKTF application into the following files:
96
+
97
+ `app.ts`
98
+
99
+ ```ts
100
+ import * as tf from "cdktf";
101
+ import * as aws from "@cdktf/provider-aws";
102
+
103
+ import { CdkTfResolver } from '@cdk8s/cdktf-resolver';
104
+
105
+ const awsApp = new tf.App();
106
+ const stack = new tf.TerraformStack(awsApp, 'aws');
107
+
108
+ const bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');
109
+ // export the thing we want to have available for cdk8s applications
110
+ export const bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {
111
+ value: bucket.bucket,
112
+ });
113
+
114
+ // note that we don't call awsApp.synth here
115
+ ```
116
+
117
+ `main.ts`
118
+
119
+ ```ts
120
+ import { awsApp } from './app.ts'
121
+
122
+ awsApp.synth();
123
+ ```
124
+
125
+ Now, publish the `app.ts` file to a package manager, so that your `cdk8s` application can install and import it.
126
+ This approach might be somewhat counter intuitive, because normally we only publish classes to the package manager,
127
+ not instances. Indeed, these types of applications introduce a new use-case that requires the sharing of instances.
128
+ Conceptually, this is no different than writing state<sup>*</sup> to an SSM parameter or an S3 bucket, and it allows us to remain
129
+ in the boundaries of our programming language, and the typing guarantees it provides.
130
+
131
+ > <sup>*</sup> Actually, we are only publishing instructions for fetching state, not the state itself.
132
+
133
+ Assuming `app.ts` was published as the `my-cdktf-app` package, our `cdk8s` application will now look like so:
134
+
135
+ ```ts
136
+ import * as k8s from 'cdk8s';
137
+ import * as kplus from 'cdk8s-plus-27';
138
+
139
+ // import the desired instance from the CDKTF app.
140
+ import { bucketName } from 'my-cdktf-app';
141
+
142
+ import { CdkTfResolver } from '@cdk8s/cdktf-resolver';
143
+
144
+ const k8sApp = new k8s.App({ resolvers: [new CdkTfResolver()] });
145
+ const manifest = new k8s.Chart(k8sApp, 'Manifest');
146
+
147
+ new kplus.CronJob(manifest, 'CronJob', {
148
+ schedule: k8s.Cron.daily(),
149
+ containers: [{
150
+ image: 'job',
151
+ envVariables: {
152
+ // directly passing the value of the `TerraformOutput` containing
153
+ // the deploy time bucket name
154
+ BUCKET_NAME: kplus.EnvValue.fromValue(bucketName.value),
155
+ }
156
+ }]
157
+ });
158
+
159
+ k8sApp.synth();
160
+ ```
161
+ # API Reference <a name="API Reference" id="api-reference"></a>
162
+
163
+
164
+ ## Structs <a name="Structs" id="Structs"></a>
165
+
166
+ ### CdktfResolverProps <a name="CdktfResolverProps" id="@cdk8s/cdktf-resolver.CdktfResolverProps"></a>
167
+
168
+ #### Initializer <a name="Initializer" id="@cdk8s/cdktf-resolver.CdktfResolverProps.Initializer"></a>
169
+
170
+ ```typescript
171
+ import { CdktfResolverProps } from '@cdk8s/cdktf-resolver'
172
+
173
+ const cdktfResolverProps: CdktfResolverProps = { ... }
174
+ ```
175
+
176
+ #### Properties <a name="Properties" id="Properties"></a>
177
+
178
+ | **Name** | **Type** | **Description** |
179
+ | --- | --- | --- |
180
+ | <code><a href="#@cdk8s/cdktf-resolver.CdktfResolverProps.property.app">app</a></code> | <code>cdktf.App</code> | The CDKTF App instance in which the outputs are deinfed in. |
181
+
182
+ ---
183
+
184
+ ##### `app`<sup>Required</sup> <a name="app" id="@cdk8s/cdktf-resolver.CdktfResolverProps.property.app"></a>
185
+
186
+ ```typescript
187
+ public readonly app: App;
188
+ ```
189
+
190
+ - *Type:* cdktf.App
191
+
192
+ The CDKTF App instance in which the outputs are deinfed in.
193
+
194
+ ---
195
+
196
+ ## Classes <a name="Classes" id="Classes"></a>
197
+
198
+ ### CdktfResolver <a name="CdktfResolver" id="@cdk8s/cdktf-resolver.CdktfResolver"></a>
199
+
200
+ - *Implements:* cdk8s.IResolver
201
+
202
+ #### Initializers <a name="Initializers" id="@cdk8s/cdktf-resolver.CdktfResolver.Initializer"></a>
203
+
204
+ ```typescript
205
+ import { CdktfResolver } from '@cdk8s/cdktf-resolver'
206
+
207
+ new CdktfResolver(props: CdktfResolverProps)
208
+ ```
209
+
210
+ | **Name** | **Type** | **Description** |
211
+ | --- | --- | --- |
212
+ | <code><a href="#@cdk8s/cdktf-resolver.CdktfResolver.Initializer.parameter.props">props</a></code> | <code><a href="#@cdk8s/cdktf-resolver.CdktfResolverProps">CdktfResolverProps</a></code> | *No description.* |
213
+
214
+ ---
215
+
216
+ ##### `props`<sup>Required</sup> <a name="props" id="@cdk8s/cdktf-resolver.CdktfResolver.Initializer.parameter.props"></a>
217
+
218
+ - *Type:* <a href="#@cdk8s/cdktf-resolver.CdktfResolverProps">CdktfResolverProps</a>
219
+
220
+ ---
221
+
222
+ #### Methods <a name="Methods" id="Methods"></a>
223
+
224
+ | **Name** | **Description** |
225
+ | --- | --- |
226
+ | <code><a href="#@cdk8s/cdktf-resolver.CdktfResolver.resolve">resolve</a></code> | This function is invoked on every property during cdk8s synthesis. |
227
+
228
+ ---
229
+
230
+ ##### `resolve` <a name="resolve" id="@cdk8s/cdktf-resolver.CdktfResolver.resolve"></a>
231
+
232
+ ```typescript
233
+ public resolve(context: ResolutionContext): void
234
+ ```
235
+
236
+ This function is invoked on every property during cdk8s synthesis.
237
+
238
+ To replace a value, implementations must invoke `context.replaceValue`.
239
+
240
+ ###### `context`<sup>Required</sup> <a name="context" id="@cdk8s/cdktf-resolver.CdktfResolver.resolve.parameter.context"></a>
241
+
242
+ - *Type:* cdk8s.ResolutionContext
243
+
244
+ ---
245
+
246
+
247
+
248
+
249
+
@@ -0,0 +1,3 @@
1
+ # Code of Conduct
2
+
3
+ The cdk8s project follows the [CNCF Community Code of Conduct](https://github.com/cncf/foundation/blob/master/code-of-conduct.md).
package/DCO ADDED
@@ -0,0 +1,34 @@
1
+ Developer Certificate of Origin
2
+ Version 1.1
3
+
4
+ Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
5
+
6
+ Everyone is permitted to copy and distribute verbatim copies of this
7
+ license document, but changing it is not allowed.
8
+
9
+
10
+ Developer's Certificate of Origin 1.1
11
+
12
+ By making a contribution to this project, I certify that:
13
+
14
+ (a) The contribution was created in whole or in part by me and I
15
+ have the right to submit it under the open source license
16
+ indicated in the file; or
17
+
18
+ (b) The contribution is based upon previous work that, to the best
19
+ of my knowledge, is covered under an appropriate open source
20
+ license and I have the right under that license to submit that
21
+ work with modifications, whether created in whole or in part
22
+ by me, under the same open source license (unless I am
23
+ permitted to submit under a different license), as indicated
24
+ in the file; or
25
+
26
+ (c) The contribution was provided directly to me by some other
27
+ person who certified (a), (b) or (c) and I have not modified
28
+ it.
29
+
30
+ (d) I understand and agree that this project and the contribution
31
+ are public and that a record of the contribution (including all
32
+ personal information I submit with it, including my sign-off) is
33
+ maintained indefinitely and may be redistributed consistent with
34
+ this project or the open source license(s) involved.