@cdk8s/cdktf-resolver 0.0.103 → 0.0.104

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/.jsii CHANGED
@@ -231,6 +231,6 @@
231
231
  "symbolId": "src/resolve:CdktfResolverProps"
232
232
  }
233
233
  },
234
- "version": "0.0.103",
235
- "fingerprint": "4H+D37FBKC3Ry3x73hS2PZg2LjE/oPPyAksmXupDkbs="
234
+ "version": "0.0.104",
235
+ "fingerprint": "BIr4WBG7L9bWlNwj/bHogNZk7705z1LCoGBoXNnqXRY="
236
236
  }
package/API.md CHANGED
@@ -1,164 +1,3 @@
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 resolver.CdktfResolver({ app: awsApp })] });
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
- // export the app so we can pass it to the cdk8s resolver
106
- export const awsApp = new tf.App();
107
- const stack = new tf.TerraformStack(awsApp, 'aws');
108
-
109
- const bucket = new aws.s3Bucket.S3Bucket(stack, 'Bucket');
110
- // export the thing we want to have available for cdk8s applications
111
- export const bucketName = new tf.TerraformOutput(constrcut, 'BucketName', {
112
- value: bucket.bucket,
113
- });
114
-
115
- // note that we don't call awsApp.synth here
116
- ```
117
-
118
- `main.ts`
119
-
120
- ```ts
121
- import { awsApp } from './app.ts'
122
-
123
- awsApp.synth();
124
- ```
125
-
126
- Now, publish the `app.ts` file to a package manager, so that your `cdk8s` application can install and import it.
127
- This approach might be somewhat counter intuitive, because normally we only publish classes to the package manager,
128
- not instances. Indeed, these types of applications introduce a new use-case that requires the sharing of instances.
129
- Conceptually, this is no different than writing state<sup>*</sup> to an SSM parameter or an S3 bucket, and it allows us to remain
130
- in the boundaries of our programming language, and the typing guarantees it provides.
131
-
132
- > <sup>*</sup> Actually, we are only publishing instructions for fetching state, not the state itself.
133
-
134
- Assuming `app.ts` was published as the `my-cdktf-app` package, our `cdk8s` application will now look like so:
135
-
136
- ```ts
137
- import * as k8s from 'cdk8s';
138
- import * as kplus from 'cdk8s-plus-27';
139
-
140
- // import the desired instance from the CDKTF app.
141
- import { bucketName, awsApp } from 'my-cdktf-app';
142
-
143
- import { CdkTfResolver } from '@cdk8s/cdktf-resolver';
144
-
145
- const k8sApp = new k8s.App({ resolvers: [new resolver.CdktfResolver({ app: awsApp })] });
146
- const manifest = new k8s.Chart(k8sApp, 'Manifest');
147
-
148
- new kplus.CronJob(manifest, 'CronJob', {
149
- schedule: k8s.Cron.daily(),
150
- containers: [{
151
- image: 'job',
152
- envVariables: {
153
- // directly passing the value of the `TerraformOutput` containing
154
- // the deploy time bucket name
155
- BUCKET_NAME: kplus.EnvValue.fromValue(bucketName.value),
156
- }
157
- }]
158
- });
159
-
160
- k8sApp.synth();
161
- ```
162
1
  # API Reference <a name="API Reference" id="api-reference"></a>
163
2
 
164
3
 
package/lib/resolve.js CHANGED
@@ -91,7 +91,7 @@ class CdktfResolver {
91
91
  }
92
92
  exports.CdktfResolver = CdktfResolver;
93
93
  _a = JSII_RTTI_SYMBOL_1;
94
- CdktfResolver[_a] = { fqn: "@cdk8s/cdktf-resolver.CdktfResolver", version: "0.0.103" };
94
+ CdktfResolver[_a] = { fqn: "@cdk8s/cdktf-resolver.CdktfResolver", version: "0.0.104" };
95
95
  function copyDirectory(sourceDir, targetDir) {
96
96
  if (!fs.existsSync(targetDir)) {
97
97
  fs.mkdirSync(targetDir);
package/package.json CHANGED
@@ -50,23 +50,23 @@
50
50
  "@typescript-eslint/eslint-plugin": "^7",
51
51
  "@typescript-eslint/parser": "^7",
52
52
  "cdk8s": "^2.68.91",
53
- "cdk8s-cli": "^2.198.200",
53
+ "cdk8s-cli": "^2.198.202",
54
54
  "cdktf": "^0.19.1",
55
55
  "cdktf-cli": "^0.20.8",
56
+ "commit-and-tag-version": "^12",
56
57
  "constructs": "^10.3.0",
57
58
  "eslint": "^8",
58
- "eslint-import-resolver-typescript": "^3.6.1",
59
+ "eslint-import-resolver-typescript": "^3.6.3",
59
60
  "eslint-plugin-import": "^2.29.1",
60
61
  "fs-extra": "^11.2.0",
61
62
  "jest": "^27",
62
63
  "jest-junit": "^15",
63
64
  "jsii": "^5",
64
- "jsii-diff": "^1.102.0",
65
- "jsii-docgen": "^9.2.2",
66
- "jsii-pacmak": "^1.102.0",
65
+ "jsii-diff": "^1.103.0",
66
+ "jsii-docgen": "^10.5.0",
67
+ "jsii-pacmak": "^1.103.0",
67
68
  "jsii-rosetta": "^5",
68
- "projen": "^0.86.0",
69
- "standard-version": "^9",
69
+ "projen": "^0.86.5",
70
70
  "ts-jest": "^27",
71
71
  "ts-node": "^10.9.2",
72
72
  "typescript": "^5.5.4"
@@ -87,7 +87,7 @@
87
87
  "publishConfig": {
88
88
  "access": "public"
89
89
  },
90
- "version": "0.0.103",
90
+ "version": "0.0.104",
91
91
  "jest": {
92
92
  "coverageProvider": "v8",
93
93
  "testMatch": [