Skip to content

Commit

Permalink
Zookeeper cluster support (#73)
Browse files Browse the repository at this point in the history
* Zookeeper cluster support

Co-authored-by: Hendra Gunadi <[email protected]>
  • Loading branch information
h3nd24 and Hendra Gunadi authored Mar 23, 2021
1 parent 7572ec1 commit d4984a1
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

BIN_NAME="terraform-provider-instaclustr"
VERSION=v1.9.0
VERSION=v1.9.1

.PHONY: install clean all build test testacc testtarget

Expand Down
1 change: 1 addition & 0 deletions instaclustr/resource_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,7 @@ func formatCreateErrMsg(err error) error {
func checkIfBundleRequiresRackAllocation(bundles []Bundle) bool {
var noRackAllocationBundles = []string{
"REDIS",
"APACHE_ZOOKEEPER",
}

for i := 0; i < len(bundles); i++ {
Expand Down
26 changes: 13 additions & 13 deletions instaclustr/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ type OmitEmptyBool struct {


type BundleOptions struct {
AuthnAuthz *bool `json:"authnAuthz,omitempty" mapstructure:"auth_n_authz,omitempty"`
ClientEncryption *bool `json:"clientEncryption,omitempty" mapstructure:"client_encryption,omitempty"`
DedicatedMasterNodes *bool `json:"dedicatedMasterNodes,omitempty" mapstructure:"dedicated_master_nodes,omitempty"`
AuthnAuthz *bool `json:"authnAuthz,omitempty" mapstructure:"auth_n_authz,omitempty"`
ClientEncryption *bool `json:"clientEncryption,omitempty" mapstructure:"client_encryption,omitempty"`
DedicatedMasterNodes *bool `json:"dedicatedMasterNodes,omitempty" mapstructure:"dedicated_master_nodes,omitempty"`
MasterNodeSize string `json:"masterNodeSize,omitempty" mapstructure:"master_node_size,omitempty"`
SecurityPlugin *bool `json:"securityPlugin,omitempty" mapstructure:"security_plugin,omitempty"`
UsePrivateBroadcastRpcAddress *bool `json:"usePrivateBroadcastRPCAddress,omitempty" mapstructure:"use_private_broadcast_rpc_address,omitempty"`
LuceneEnabled *bool `json:"luceneEnabled,omitempty" mapstructure:"lucene_enabled,omitempty"`
ContinuousBackupEnabled *bool `json:"continuousBackupEnabled,omitempty" mapstructure:"continuous_backup_enabled,omitempty"`
NumberPartitions int `json:"numberPartitions,omitempty" mapstructure:"number_partitions,omitempty"`
AutoCreateTopics *bool `json:"autoCreateTopics,omitempty" mapstructure:"auto_create_topics,omitempty"`
DeleteTopics *bool `json:"deleteTopics,omitempty" mapstructure:"delete_topics,omitempty"`
PasswordAuthentication *bool `json:"passwordAuthentication,omitempty" mapstructure:"password_authentication,omitempty"`
SecurityPlugin *bool `json:"securityPlugin,omitempty" mapstructure:"security_plugin,omitempty"`
UsePrivateBroadcastRpcAddress *bool `json:"usePrivateBroadcastRPCAddress,omitempty" mapstructure:"use_private_broadcast_rpc_address,omitempty"`
LuceneEnabled *bool `json:"luceneEnabled,omitempty" mapstructure:"lucene_enabled,omitempty"`
ContinuousBackupEnabled *bool `json:"continuousBackupEnabled,omitempty" mapstructure:"continuous_backup_enabled,omitempty"`
NumberPartitions int `json:"numberPartitions,omitempty" mapstructure:"number_partitions,omitempty"`
AutoCreateTopics *bool `json:"autoCreateTopics,omitempty" mapstructure:"auto_create_topics,omitempty"`
DeleteTopics *bool `json:"deleteTopics,omitempty" mapstructure:"delete_topics,omitempty"`
PasswordAuthentication *bool `json:"passwordAuthentication,omitempty" mapstructure:"password_authentication,omitempty"`
TargetKafkaClusterId string `json:"targetKafkaClusterId,omitempty" mapstructure:"target_kafka_cluster_id,omitempty"`
VPCType string `json:"vpcType,omitempty" mapstructure:"vpc_type,omitempty"`
AWSAccessKeyId string `json:"aws.access.key.id,omitempty" mapstructure:"aws_access_key,omitempty"`
Expand All @@ -52,9 +52,9 @@ type BundleOptions struct {
Truststore string `json:"truststore,omitempty" mapstructure:"truststore,omitempty"`
RedisMasterNodes int `json:"masterNodes,omitempty" mapstructure:"master_nodes,omitempty"`
RedisReplicaNodes int `json:"replicaNodes,omitempty" mapstructure:"replica_nodes,omitempty"`
DedicatedZookeeper *bool `json:"dedicatedZookeeper,omitempty" mapstructure:"dedicated_zookeeper,omitempty"`
DedicatedZookeeper *bool `json:"dedicatedZookeeper,omitempty" mapstructure:"dedicated_zookeeper,omitempty"`
ZookeeperNodeSize string `json:"zookeeperNodeSize,omitempty" mapstructure:"zookeeper_node_size,omitempty"`
ZookeeperNodeCount int `json:"zookeeperNodeCount,omitempty" mapstructure:"zookeeper_node_count,omitempty"`
ZookeeperNodeCount int `json:"zookeeperNodeCount,omitempty" mapstructure:"zookeeper_node_count,omitempty"`
}

type ClusterProvider struct {
Expand Down
31 changes: 31 additions & 0 deletions test/data/valid_apache_zookeeper.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
provider "instaclustr" {
username = "%s"
api_key = "%s"
api_hostname = "%s"
}
resource "instaclustr_cluster" "validApacheZookeeper" {
cluster_name = "test_zookeeper_cluster"
node_size = "zookeeper-developer-t3.small-20"
data_centre = "US_WEST_2"
sla_tier = "NON_PRODUCTION"
cluster_network = "192.168.0.0/18"
private_network_cluster = false
pci_compliant_cluster = false

cluster_provider = {
name = "AWS_VPC"
}

rack_allocation = {
number_of_racks = 4
nodes_per_rack = 1
}

bundle {
bundle = "APACHE_ZOOKEEPER"
version = "apache-zookeeper:3.5.8"
options = {
zookeeper_node_count = 5
}
}
}
25 changes: 25 additions & 0 deletions test/resource_cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,31 @@ func TestValidRedisClusterCreate(t *testing.T) {
})
}

func TestValidApacheZookeeperClusterCreate(t *testing.T) {
testAccProvider := instaclustr.Provider()
testAccProviders := map[string]terraform.ResourceProvider{
"instaclustr": testAccProvider,
}
validConfig, _ := ioutil.ReadFile("data/valid_apache_zookeeper.tf")
username := os.Getenv("IC_USERNAME")
apiKey := os.Getenv("IC_API_KEY")
hostname := getOptionalEnv("IC_API_URL", instaclustr.DefaultApiHostname)
oriConfig := fmt.Sprintf(string(validConfig), username, apiKey, hostname)
resource.Test(t, resource.TestCase{
Providers: testAccProviders,
CheckDestroy: testCheckResourceDeleted("validApacheZookeeper", hostname, username, apiKey),
Steps: []resource.TestStep{
{
Config: oriConfig,
Check: resource.ComposeTestCheckFunc(
testCheckResourceValid("validApacheZookeeper"),
testCheckResourceCreated("validApacheZookeeper", hostname, username, apiKey),
),
},
},
})
}

func TestAccClusterCredentials(t *testing.T) {
testAccProviders := map[string]terraform.ResourceProvider{
"instaclustr": instaclustr.Provider(),
Expand Down

0 comments on commit d4984a1

Please sign in to comment.