Is there an easy path to get something like this <...
# general
f
Is there an easy path to get something like this https://www.terraform.io/docs/providers/datadog/index.html to work with Pulumi?
b
Hey @full-dress-10026 There is currently is no datadog provider but you will be able to help to make one of you want? :) Paul
w
See https://github.com/pulumi/pulumi-tf-provider-boilerplate for details on creating a new Pulumi provider from an existing Terraform provider.
f
Having never done work in Go, this may be a bit rough. I can give it a go though. It sounds like almost all of the process is automated?
b
@full-dress-10026 yes, there are a few steps of mapping and it's then generated under the hood
let me know if you need something
f
The installation steps sound tailored to a Mac. Any idea if Linux will work?
If this really is almost all automated, it'd be cool to be able to simply have a list in a CI config that will automatically generate the Pulumi providers.
If the pulumi provider name differs from the Terraform provider name, set TF_NAME in Makefile to the Terraform name, leaving PACK set to the Pulumi name.
How would I tell if the pulumi provider name is different than the Terraform name? It appears that everything with the Datadog provider is named datadog.
The README mentions go 1.12.1. Will go 1.12.6 work?
Found the older go tar download. I'll just use that to be safe.
Everything went smooth until the go get terraform provider step. Here's the console output: https://gist.github.com/kennyjwilli/8a59c1e886ee60ec226008c6e1cb62a3
Tried installing. Getting this from `apt-get update`:
Copy code
Err:9 <http://ppa.launchpad.net/bzr/ppa/ubuntu> bionic Release                                                        
  404  Not Found [IP: 91.189.95.83 80]
and
Copy code
E: The repository '<http://ppa.launchpad.net/bzr/ppa/ubuntu> bionic Release' does not have a Release file.
Is there a recommended way to install this tool?
Hmm, a regular
apt-get install bzr
appeared to install it. Never heard of bazaar vcs.
Alright all the go get steps appear to have succeeded. No getting this:
Copy code
make ensure
ENSURE:
GO111MODULE=on go mod vendor
/bin/bash: line 1: gomod-doccopy: command not found
build/common.mk:182: recipe for target 'ensure' failed
make: *** [ensure] Error 127
gmod-doccopy appears to be a pulumi tool. Do I need that installed somehow?
Hmm, the first step in the list does this:
go get <http://github.com/pulumi/scripts/gomod-doccopy|github.com/pulumi/scripts/gomod-doccopy>
. Perhaps I need to expose something else in my path?
Ah, I need
$HOME/go/bin
on my PATH.
At Build the provider step! I'm fairly certain required configuration needs to be set here: https://github.com/pulumi/pulumi-tf-provider-boilerplate/blob/b0e45da159f0233f0a41772026b1aa833fd82188/resources.go#L102-L109. I added these:
Copy code
"api_key": {
				Type: makeType("api_key", "ApiKey"),
				Default: &tfbridge.DefaultInfo{
					EnvVars: []string{"DATADOG_API_KEY"},
				},
			},
			"app_key": {
				Type: makeType("app_key", "AppKey"),
				Default: &tfbridge.DefaultInfo{
					EnvVars: []string{"DATADOG_APP_KEY"},
				},
			},
Does that look correct?
Also, how do you add an optional config parameter? It looks like the Datadog provider can optionally take in an `api_url`: https://www.terraform.io/docs/providers/datadog/index.html#argument-reference
w
There is a
Config
block you can provide which maps these - see one of the other providers for an example of what that looks like.
👍 1
Btw - would be great to collect all your feedback here on the process of applying the boilerplate repo and open an issue so we can improve the documentation around this.
f
Yep - can move this info into a GH issue once I'm done.
👍 1
I know
aws:profile
is optional. There's nothing here to indicate that it is optional: https://github.com/pulumi/pulumi-aws/blob/6a78b9008cf552324391f994a2c493da0d67e5db/resources.go#L223-L227. Does the terraform provider handle setting defaults?
w
Yes - optional vs required comes fundamentally from the Terraform provider schema.
👍 1
f
What is the difference between
Resources
and
DataSources
?
w
Those are Terraform concepts. See their docs for examples - such as: https://www.terraform.io/docs/providers/aws/index.html
f
Ah. Looks like Datadog doesn't have any of those.
Alright I think it's ready to test. How would I test it? I tried running
make
and got:
Copy code
make
===============
datadog Package
===============
BUILD:
go install -ldflags "-X <http://github.com/pulumi/pulumi-datadog/pkg/version.Version=v0.0.1-dev.1560791809+gb0e45da.dirty|github.com/pulumi/pulumi-datadog/pkg/version.Version=v0.0.1-dev.1560791809+gb0e45da.dirty>" <http://github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog|github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog>
can't load package: package <http://github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog|github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog>: cannot find package "<http://github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog|github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog>" in any of:
	/usr/local/go/src/github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog (from $GOROOT)
	/home/kenny/go/src/github.com/pulumi/pulumi-datadog/cmd/pulumi-tfgen-datadog (from $GOPATH)
Makefile:43: recipe for target 'tfgen' failed
make: *** [tfgen] Error 1
It sounds like it's trying to do something with a Github repo that doesn't exist.
w
These instructions are normally followed for a package in the GitHub.com/Pulumi org. If you are doing it outside of that, you may have to make additional changes
f
Ah. There's pulumi github references all over the place.
b
@full-dress-10026 FYI, I am fixing up that work on the Datadog provider now - there was a few small things that tripped you up
all aroundshared files.. 😞
e.g. build/common.mk
f
Thanks for fixing that up! Excited to get this in.