@cdk8s/cdktf-resolver 0.0.170 → 0.0.172
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 +4 -4
- package/README.md +3 -3
- package/lib/resolve.js +1 -1
- package/package.json +4 -4
package/.jsii
CHANGED
|
@@ -97,7 +97,7 @@
|
|
|
97
97
|
"stability": "stable"
|
|
98
98
|
},
|
|
99
99
|
"homepage": "https://github.com/cdk8s-team/cdk8s-cdktf-resolver.git",
|
|
100
|
-
"jsiiVersion": "5.8.
|
|
100
|
+
"jsiiVersion": "5.8.10 (build 41393fb)",
|
|
101
101
|
"license": "Apache-2.0",
|
|
102
102
|
"metadata": {
|
|
103
103
|
"jsii": {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
},
|
|
110
110
|
"name": "@cdk8s/cdktf-resolver",
|
|
111
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 resolver.CdktfResolver({ app: awsApp })] });\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
|
|
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 resolver.CdktfResolver({ app: awsApp })] });\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 have been deployed.\nSo 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\n// export the app so we can pass it to the cdk8s resolver\nexport const 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, awsApp } from 'my-cdktf-app';\n\nimport { CdkTfResolver } from '@cdk8s/cdktf-resolver';\n\nconst k8sApp = new k8s.App({ resolvers: [new resolver.CdktfResolver({ app: awsApp })] });\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```\n"
|
|
113
113
|
},
|
|
114
114
|
"repository": {
|
|
115
115
|
"type": "git",
|
|
@@ -231,6 +231,6 @@
|
|
|
231
231
|
"symbolId": "src/resolve:CdktfResolverProps"
|
|
232
232
|
}
|
|
233
233
|
},
|
|
234
|
-
"version": "0.0.
|
|
235
|
-
"fingerprint": "
|
|
234
|
+
"version": "0.0.172",
|
|
235
|
+
"fingerprint": "6b8KHHZBxvk/YhgOFEfk+FPuVq2y1Qd+MjT0y662E8I="
|
|
236
236
|
}
|
package/README.md
CHANGED
|
@@ -42,8 +42,8 @@ k8sApp.synth();
|
|
|
42
42
|
During cdk8s synthesis, the custom resolver will detect that `bucketName.value` is not a concrete value,
|
|
43
43
|
but rather a value of a `TerraformOutput`. It will then perform `cdktf` CLI commands in order to fetch the
|
|
44
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
|
-
|
|
45
|
+
for `cdk8s synth` to succeed, it must be executed *after* the CDKTF resources have been deployed.
|
|
46
|
+
So your deployment workflow should (conceptually) be:
|
|
47
47
|
|
|
48
48
|
1. `cdktf deploy`
|
|
49
49
|
2. `cdk8s synth`
|
|
@@ -158,4 +158,4 @@ new kplus.CronJob(manifest, 'CronJob', {
|
|
|
158
158
|
});
|
|
159
159
|
|
|
160
160
|
k8sApp.synth();
|
|
161
|
-
```
|
|
161
|
+
```
|
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.
|
|
94
|
+
CdktfResolver[_a] = { fqn: "@cdk8s/cdktf-resolver.CdktfResolver", version: "0.0.172" };
|
|
95
95
|
function copyDirectory(sourceDir, targetDir) {
|
|
96
96
|
if (!fs.existsSync(targetDir)) {
|
|
97
97
|
fs.mkdirSync(targetDir);
|
package/package.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"organization": false
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@cdk8s/projen-common": "0.0.
|
|
45
|
+
"@cdk8s/projen-common": "0.0.605",
|
|
46
46
|
"@cdktf/provider-aws": "^19.64.0",
|
|
47
47
|
"@stylistic/eslint-plugin": "^2",
|
|
48
48
|
"@types/fs-extra": "^11.0.4",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@typescript-eslint/eslint-plugin": "^8",
|
|
52
52
|
"@typescript-eslint/parser": "^8",
|
|
53
53
|
"cdk8s": "^2.68.91",
|
|
54
|
-
"cdk8s-cli": "^2.200.
|
|
54
|
+
"cdk8s-cli": "^2.200.83",
|
|
55
55
|
"cdktf": "^0.20.8",
|
|
56
56
|
"cdktf-cli": "^0.20.12",
|
|
57
57
|
"commit-and-tag-version": "^12",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"jsii-docgen": "^10.5.0",
|
|
68
68
|
"jsii-pacmak": "^1.112.0",
|
|
69
69
|
"jsii-rosetta": "^5",
|
|
70
|
-
"projen": "^0.92.
|
|
70
|
+
"projen": "^0.92.7",
|
|
71
71
|
"ts-jest": "^29",
|
|
72
72
|
"ts-node": "^10.9.2",
|
|
73
73
|
"typescript": "^5.8.3"
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"publishConfig": {
|
|
89
89
|
"access": "public"
|
|
90
90
|
},
|
|
91
|
-
"version": "0.0.
|
|
91
|
+
"version": "0.0.172",
|
|
92
92
|
"jest": {
|
|
93
93
|
"coverageProvider": "v8",
|
|
94
94
|
"testMatch": [
|