hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.83k stars 449 forks source link

[Notice] Moving pre-built providers to the `cdktf` Github organization #2146

Open mutahhir opened 1 year ago

mutahhir commented 1 year ago

All existing pre-built providers will be relocating to our new Github organization cdktf (see #2135).

For the vast majority of CDKTF users, this won’t affect how you reference the providers, as you’re consuming them through your language-specific package manager: NPM, PyPI, Maven, etc. However, for Golang users of CDKTF, this is something to be aware of. Soon, the module naming will switch from:

github.com/hashicorp/cdktf-provider-{provider name}-go 

to

github.com/cdktf/cdktf-provider-{provider name}-go 

There is no need for any immediate action, but over the course of the next few days if you see the Go CLI complain about:

go: github.com/hashicorp/cdktf-provider-hashicups-go/hashicups@v0.0.3: parsing go.mod:
        module declares its path as: github.com/cdktf/cdktf-provider-hashicups-go/hashicups
                but was required as: github.com/hashicorp/cdktf-provider-hashicups-go/hashicups

Regarding one or more of the pre-built providers, change the module path to the one with github.com/cdktf.

You could also use Go tools to do the replace for you (replace hashicups with your provider):

$ gofmt -w -r '"github.com/hashicorp/cdktf-provider-hashicups-go/hashicups" -> "github.com/cdktf/cdktf-provider-hashicups-go/hashicups"' ./
$ go get # Fetch the prebuilt provider from the new module path
$ go mod tidy # Remove old module path

As another example, if you were using the AWS provider, the first command above becomes:

$ gofmt -w -r '"github.com/hashicorp/cdktf-provider-aws-go/aws/v9" -> "github.com/cdktf/cdktf-provider-aws-go/aws/v9"' ./
RazaGR commented 1 year ago

docs need to be updated https://learn.hashicorp.com/tutorials/terraform/cdktf-install?in=terraform/cdktf

ps. I am also getting node error when running cdk-go with default example:

 $ go run main.go
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!                                                                            !!
!!  Node 17 has reached end-of-life on 2022-06-01 and is not supported.       !!
!!  Please upgrade to a supported node version as soon as possible.           !!
!!                                                                            !!
!!  This software is currently running on node v17.4.0.                       !!
!!  As of the current release of this software, supported node releases are:  !!
!!  - ^18.0.0 (Planned end-of-life: 2025-04-30)                               !!
!!  - ^16.3.0 (Planned end-of-life: 2023-09-11)                               !!
!!  - ^14.6.0 (Planned end-of-life: 2023-04-30)                               !!
!!                                                                            !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
dzeediscoveryzone commented 1 year ago

Hi All,

I was hoping to get some assistance because I'm not able to get Go to work with 0.13.0 due to the provider organization change. I started from scratch with a vanilla project:

cdktf init --template=go --cdktf-version 0.13.0 --project-name ec2 --project-description "A demo cdktf project using Go which deploys an EC2 instance"

Then I went ahead and added the provider cdktf provider add "aws@~>4.0" which as expected adds the old provider:

cdktf provider add "aws@~>4.0"
Checking whether pre-built provider exists for the following constraints:
  provider: aws
  version : ~>4.0
  language: go
  cdktf   : 0.13.0

Found pre-built provider.
Adding package github.com/hashicorp/cdktf-provider-aws-go/aws @ 10.0.1
[2022-10-04T13:35:25.152] [ERROR] default - go: upgraded github.com/aws/constructs-go/constructs/v10 v10.1.113 => v10.1.121
go: upgraded github.com/aws/jsii-runtime-go v1.68.0 => v1.69.0
go: added github.com/hashicorp/cdktf-provider-aws-go/aws/v10 v10.0.1

go: upgraded github.com/aws/constructs-go/constructs/v10 v10.1.113 => v10.1.121
go: upgraded github.com/aws/jsii-runtime-go v1.68.0 => v1.69.0
go: added github.com/hashicorp/cdktf-provider-aws-go/aws/v10 v10.0.1
Package installed.

Everything looks good so far except when I try to replace the org from hashicorp -> cdktf (I have tried both via gofmt, manually, as well running go get -u github.com/cdktf/cdktf-provider-aws-go/aws/v10, see below following the above instructions:

All of the above results in nothing being changed and when manually changing and running go get it fails with the error you presented in your wiki. Maybe I am missing something but I have been unsuccessful.

I also attempted manually installing it:

go get -u github.com/cdktf/cdktf-provider-aws-go/aws/v10
go: github.com/cdktf/cdktf-provider-aws-go/aws/v10@v10.0.1: parsing go.mod:
        module declares its path as: github.com/hashicorp/cdktf-provider-aws-go/aws/v10
                but was required as: github.com/cdktf/cdktf-provider-aws-go/aws/v10
mutahhir commented 1 year ago

@dzeediscoveryzone Sorry, this was a bit of a timing issue on our part, but v10.0.2 of the AWS provider should work out of the box for your use case. v10.0.1 was still referencing the old Github repo path in it's go.mod file, which caused issues.

Can you try again with v10.0.2 and see if it works? I believe just running cdktf provider add "aws@~>4.0" would pull in the new version

dzeediscoveryzone commented 1 year ago

@mutahhir no problem at all and thank you for the quick turnaround! My issue is now resolved. 🎉