-
Notifications
You must be signed in to change notification settings - Fork 459
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example usage on registry.terraform.io in multiple languages #1298
Comments
That's certainly something which is on our radar. However, there are no immediate plans to do this. |
@skorfmann thanks for the response. Until you have what I would classify like the best solution (i.e. code samples in all languages in registry.terraform.io), if you had an online page like "cdktf-online-converter.com" where people could:
Then, I think that it could remove some friction around the usage of cdktf. |
while we don't have a website for this (yet?), that's possible with /*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from "./.gen/providers/aws";
/*The following providers are missing schema information and might need manual adjustments to synthesize correctly: aws.
For a more precise conversion please use the --provider flag in convert.*/
const awsIamRoleIamForLambda = new aws.iam.IamRole(this, "iam_for_lambda", {
assumeRolePolicy:
'{\n "Version": "2012-10-17",\n "Statement": [\n {\n "Action": "sts:AssumeRole",\n "Principal": {\n "Service": "lambda.amazonaws.com"\n },\n "Effect": "Allow",\n "Sid": ""\n }\n ]\n}\n',
name: "iam_for_lambda",
});
new aws.lambdafunction.LambdaFunction(this, "test_lambda", {
environment: [
{
variables: [
{
foo: "bar",
},
],
},
],
filename: "lambda_function_payload.zip",
functionName: "lambda_function_name",
handler: "index.test",
role: awsIamRoleIamForLambda.arn,
runtime: "nodejs12.x",
sourceCodeHash: '${filebase64sha256("lambda_function_payload.zip")}',
}); |
Would even work with other language targets: # Provider bindings are generated by running cdktf get.
# See https://cdk.tf/provider-generation for more details.
import ...gen.providers.aws as aws
# The following providers are missing schema information and might need manual adjustments to synthesize correctly: aws.
# For a more precise conversion please use the --provider flag in convert.
aws_iam_role_iam_for_lambda = aws.iam.IamRole(self, "iam_for_lambda",
assume_role_policy="""{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
""",
name="iam_for_lambda"
)
aws.lambdafunction.LambdaFunction(self, "test_lambda",
environment=[{
"variables": [{
"foo": "bar"
}
]
}
],
filename="lambda_function_payload.zip",
function_name="lambda_function_name",
handler="index.test",
role=aws_iam_role_iam_for_lambda.arn,
runtime="nodejs12.x",
source_code_hash="${filebase64sha256(\"lambda_function_payload.zip\")}"
) |
@skorfmann thanks for the example that shows how to use |
@mabead Thanks for filing this issue! We do have this on our radar; because of the way the docs are currently generated for the Terraform Registry there are some technical hurdles that we need to work through to enable a language selector. But it's helpful to have issues like this to show the need and the value! |
@mabead would a hosted version of convert be a stepping stone to a proper solution or not help at all? Like a text area to past your code to and a button to convert it to CDK |
@DanielMSchmidt We're pretty aligned on that topic (see this comment). And if it's easy to do, maybe a button like "Convert to cdktf" could be added in registry.terraform.io. This button would post the code snippet to that online version of cdktf. |
Hi @skorfmann @schersh . Now that CDK TF is officially released, do you have more precise plans to make code snippets on registry.terraform.io available in multiple languages? |
I'm going to close this since we've begun rolling this out; see #3032 for more details. Feel free to add feedback in comments on that post, which has been pinned to allow everyone to find it more easily. |
I'm going to lock this issue because it has been closed for 30 days. This helps our maintainers find and focus on the active issues. If you've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
Community Note
Description
When we look at the CDK documentation (the AWS CDK, not CDK TF), we always have the code snippets in all supported languages. For example, here is the documentation for an AWS lambda in multiple languages:
Unfortunately, the terraform documentation does not have code snippets for CDK TF supported languages. All the code snippets are only in HCL. Example from https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function:
It therefore makes it hard for developers to use the CDK-TF because most of the available examples are not in the same language they are using. It requires a mental mapping. Note that I am aware aware that I could use
cdktf convert
to manually convert all the HCL snippets that I see. But I don't see myself trying to convince my colleagues that it's a fun workflow.All that being said, do you have plans to update registry.terraform.io to show code snippets in all languages that are supported by CDK TF? I think it would significantly help in the adoption of cdktf.
The text was updated successfully, but these errors were encountered: