diff --git a/Makefile b/Makefile index d709e990..549eb7b7 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ BIN_NAME="terraform-provider-instaclustr" -VERSION=v1.5.0 +VERSION=v1.6.0 .PHONY: install clean all build test testacc diff --git a/README.md b/README.md index 26b75620..a8cdd9b6 100644 --- a/README.md +++ b/README.md @@ -233,12 +233,13 @@ Property | Description | Default key_id|Internal ID of the KMS encryption key. Can be found via GET to `https://api.instaclustr.com/provisioning/v1/encryption-keys`|"" alias|KMS key alias, a human-readibly identifier specified alongside your KMS ARN|"" arn|KMS ARN, identifier specifying provider, location and key in a ':' value seperated string|"" +key_provider|For customers running in their own account. Value specifying the provider account’s name, similar to `instaclustr_cluster.cluster_provider.account_name`|INSTACLUSTR #### Example ``` resource "instaclustr_encryption_key" "example_encryption_key" { - alias: "virginia 1" - arn: "arn:aws:kms:us-east-1:123456789012:key12345678-1234-1234-1234-123456789abc" + alias = "virginia 1" + arn = "arn:aws:kms:us-east-1:123456789012:key12345678-1234-1234-1234-123456789abc" } ``` diff --git a/examples/main.tf b/examples/main.tf index 34a93ccc..b7b4ab79 100644 --- a/examples/main.tf +++ b/examples/main.tf @@ -6,6 +6,7 @@ provider "instaclustr" { resource "instaclustr_encryption_key" "add_ebs_key" { alias = "testkey" arn = "" + provider = "INSTACLUSTR" } resource "instaclustr_cluster" "example2" { @@ -18,6 +19,9 @@ resource "instaclustr_cluster" "example2" { cluster_provider = { name = "AWS_VPC", disk_encryption_key = "${instaclustr_encryption_key.add_ebs_key.key_id}" + tags = { + "myTag" = "myTagValue" + } } rack_allocation = { number_of_racks = 3 @@ -231,4 +235,4 @@ resource "instaclustr_cluster" "example-redis" { replica_nodes = 3 } } -} \ No newline at end of file +} diff --git a/instaclustr/resource_cluster.go b/instaclustr/resource_cluster.go index 11f1d3bc..88d77946 100644 --- a/instaclustr/resource_cluster.go +++ b/instaclustr/resource_cluster.go @@ -92,10 +92,6 @@ func resourceCluster() *schema.Resource { Type: schema.TypeString, Optional: true, }, - "tags": { - Type: schema.TypeString, - Optional: true, - }, "resource_group": { Type: schema.TypeString, Optional: true, @@ -108,6 +104,11 @@ func resourceCluster() *schema.Resource { }, }, + "tags": { + Type: schema.TypeMap, + Optional: true, + }, + "rack_allocation": { Type: schema.TypeMap, Optional: true, @@ -299,6 +300,8 @@ func resourceClusterCreate(d *schema.ResourceData, meta interface{}) error { return err } + clusterProvider.Tags = d.Get("tags").(map[string]interface{}) + createData := CreateRequest{ ClusterName: d.Get("cluster_name").(string), Bundles: bundles, diff --git a/instaclustr/resource_encryption_key.go b/instaclustr/resource_encryption_key.go index 3d72fb8a..5e497680 100644 --- a/instaclustr/resource_encryption_key.go +++ b/instaclustr/resource_encryption_key.go @@ -28,6 +28,11 @@ func resourceEncryptionKey() *schema.Resource { Type: schema.TypeString, Optional: true, }, + "key_provider": { + Type: schema.TypeString, + Optional: true, + Default: "INSTACLUSTR", + }, }, } } @@ -39,6 +44,7 @@ func resourceEncryptionKeyCreate(d *schema.ResourceData, meta interface{}) error createData := EncryptionKey{ Alias: d.Get("alias").(string), ARN: d.Get("arn").(string), + Provider: d.Get("key_provider").(string), } var jsonStr []byte @@ -70,6 +76,7 @@ func resourceEncryptionKeyRead(d *schema.ResourceData, meta interface{}) error { d.Set("key_id", keyResource.ID) d.Set("alias", keyResource.Alias) d.Set("arn", keyResource.ARN) + d.Set("key_provider", keyResource.Provider) log.Printf("[INFO] Read encyption key %s.", id) return nil } diff --git a/instaclustr/structs.go b/instaclustr/structs.go index e01ff433..f29dd01c 100644 --- a/instaclustr/structs.go +++ b/instaclustr/structs.go @@ -56,7 +56,7 @@ type ClusterProvider struct { Name *string `json:"name" mapstructure:"name"` AccountName *string `json:"accountName, omitempty" mapstructure:"account_name"` CustomVirtualNetworkId *string `json:"customVirtualNetworkId, omitempty" mapstructure:"custom_virtual_network_id"` - Tags *string `json:"tags,omitempty" mapstructure:"tags"` + Tags map[string]interface{} `json:"tags,omitempty"` ResourceGroup *string `json:"resourceGroup,omitempty" mapstructure:"resource_group"` DiskEncryptionKey *string `json:"diskEncryptionKey,omitempty" mapstructure:"disk_encryption_key"` } @@ -155,6 +155,7 @@ type EncryptionKey struct { ID string `json:"id,omitempty"` Alias string `json:"alias,omitempty"` ARN string `json:"arn,omitempty"` + Provider string `json:"provider,omitempty"` } type CreateKafkaUserRequest struct { diff --git a/test/data/valid_encryption_key.tf b/test/data/valid_encryption_key.tf index 9f1c0c06..192237c8 100644 --- a/test/data/valid_encryption_key.tf +++ b/test/data/valid_encryption_key.tf @@ -7,4 +7,5 @@ provider "instaclustr" { resource "instaclustr_encryption_key" "valid" { alias = "ic_test_key" arn = "%s" + key_provider = "INSTACLUSTR" }