- Terraform >= 1.0
- Go >= 1.23
- Nacos, version must be compatible with api v1
- v2.1.x
- v2.2.x
- v2.3.x
- v2.4.x
- v2.5.x
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
go install
This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
HCL example:
provider "nacos" {
host = "https://<nacos-url>"
username = "<nacos username>"
password = "<nacos password>"
}
resource "nacos_namespace" "example" {
namespace_id = "some-id"
name = "some-name"
description = "managed by terraform"
}
resource "nacos_configuration" "example" {
namespace_id = resource.nacos_namespace.example.namespace_id
data_id = "configreation-test"
group = "DEFAULT_GROUP"
content = <<EOF
server:
port: 8080
address: 0.0.0.0
EOF
type = "yaml"
description = "test terraform"
tags = ["terraform"]
application = "terraform-nacos"
}
resource "nacos_user" "test" {
username = "user1"
password = "abcd2"
}
resource "nacos_role" "test" {
name = "role1"
username = nacos_user.test.username
}
resource "nacos_permission" "test" {
role_name = nacos_role.test.name
resource = "${resource.nacos_namespace.example.namespace_id}:*:*"
action = "r"
}
more examples can be found in examples directory.
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
To generate or update documentation, run make generate
.
In order to run the full suite of Acceptance tests, run make testacc
.
Note: Acceptance tests create real resources, and often cost money to run.
make testacc