This message was deleted.
# general
s
This message was deleted.
w
it generates output, but output is invalid go source code
and the "docs/guilds/adopting/from_terraform" doc says
At the moment, TypeScript and Python are the only language targets. Let us know if your desired language isn't available.
i mean, its not gibberish. its useful, and close to correct, but not valid with go1.14.2
b
Can you check Pulumi.com/tf2pulumi and see if you get the same incorrect output?
Can you then show us what you are passing in and getting back
w
with Pulumi.com/tf2pulumi i get teh correct output!
Copy code
/home/tomj/go/tf-kube-certs-two > tf2pulumi version
v0.9.0
(docker-desktop:default)LOGIC-1019: /home/tomj/go/tf-kube-certs-two > tf2pulumi --target-language go
panic: invalid Go source code:

package main

import (

"<http://github.com/pulumi/pulumi/sdk/v2/go/pulumi|github.com/pulumi/pulumi/sdk/v2/go/pulumi>"
"<http://github.com/pulumi/pulumi-tls/sdk/v2/go/tls/|github.com/pulumi/pulumi-tls/sdk/v2/go/tls/>"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
clusterCaKey, err := .NewPrivateKey(ctx, "clusterCaKey", &.PrivateKeyArgs{
Algorithm: pulumi.String("RSA"),
RsaBits: <http://pulumi.Int|pulumi.Int>(2048),
})
if err != nil {
return err
}
clusterCaCert, err := .NewSelfSignedCert(ctx, "clusterCaCert", &.SelfSignedCertArgs{
KeyAlgorithm: pulumi.String("RSA"),
PrivateKeyPem: clusterCaKey.PrivateKeyPem,
IsCaCertificate: pulumi.Bool(true),
Subjects: index.SelfSignedCertSubjectArray{
&index.SelfSignedCertSubjectArgs{
CommonName: pulumi.String("kubernetes"),
Organization: pulumi.String("Cloud Team - Kubernetes"),
},
},
AllowedUses: pulumi.StringArray{
pulumi.String("digital_signature"),
pulumi.String("cert_signing"),
pulumi.String("key_encipherment"),
pulumi.String("server_auth"),
pulumi.String("client_auth"),
},
ValidityPeriodHours: <http://pulumi.Int|pulumi.Int>(8760),
})
if err != nil {
return err
}
return nil
})
}


goroutine 1 [running]:
<http://github.com/pulumi/pulumi/pkg/v2/codegen/go.GenerateProgram(0xc0000b5440|github.com/pulumi/pulumi/pkg/v2/codegen/go.GenerateProgram(0xc0000b5440>, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        /home/runner/go/pkg/mod/github.com/pulumi/pulumi/pkg/v2@v2.3.1-0.20200610172153-45a901d3e77c/codegen/go/gen_program.go:52 +0x4e9
<http://github.com/pulumi/tf2pulumi/convert.Convert(0x10000|github.com/pulumi/tf2pulumi/convert.Convert(0x10000>, 0x0, 0x0, 0x1919e40, 0xc0003737a0, 0x0, 0x0, 0x0, 0x18dd200, 0x2366be0, ...)
        /home/runner/work/tf2pulumi/tf2pulumi/convert/convert.go:133 +0xcce
main.main.func1(0xc000135600, 0xc000373740, 0x0, 0x2, 0x0, 0x0)
        /home/runner/work/tf2pulumi/tf2pulumi/main.go:52 +0xe6
<http://github.com/spf13/cobra.(*Command).execute(0xc000135600|github.com/spf13/cobra.(*Command).execute(0xc000135600>, 0xc00003a190, 0x2, 0x2, 0xc000135600, 0xc00003a190)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:842 +0x453
<http://github.com/spf13/cobra.(*Command).ExecuteC(0xc000135600|github.com/spf13/cobra.(*Command).ExecuteC(0xc000135600>, 0xc00063ff50, 0x1, 0x1)
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:950 +0x349
<http://github.com/spf13/cobra.(*Command).Execute(...)|github.com/spf13/cobra.(*Command).Execute(...)>
        /home/runner/go/pkg/mod/github.com/spf13/cobra@v1.0.0/command.go:887
main.main()
        /home/runner/work/tf2pulumi/tf2pulumi/main.go:117 +0x588
Copy code
> cat <http://main.tf|main.tf>
# -----------------------------------------------------------------------------
# Create CA key
#    openssl genrsa -out build/$cluster_name/secrets/default/ca.key 2048
# -----------------------------------------------------------------------------
resource "tls_private_key" "cluster_ca_key" {
  algorithm = "RSA"
  rsa_bits  = 2048
}

# -----------------------------------------------------------------------------
# Create cluster CA cert
# -----------------------------------------------------------------------------
resource "tls_self_signed_cert" "cluster_ca_cert" {
  key_algorithm     = "RSA"
  private_key_pem   = tls_private_key.cluster_ca_key.private_key_pem
  is_ca_certificate = true

  subject {
    common_name  = "kubernetes"
    organization = "Cloud Team - Kubernetes"
  }

  allowed_uses = [
    "digital_signature",
    "cert_signing",
    "key_encipherment",
    "server_auth",
    "client_auth"
  ]

  validity_period_hours = 8760 # 1 year in hours
}
b
Ah so then can you check what version of the tf2pulumi binary you are using?
w
yeah, that's at the top of the first output above
v0.9.0
@broad-dog-22463, should i file a bug for this?
b
yes please! Sorry, I thought I had said that last night but evidently not 😕 It was late for me