Feat/mssql alpha instance (#7)
* chore: add missing resources --------- Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
This commit is contained in:
parent
08afbcf574
commit
70db08f43f
8 changed files with 129 additions and 30 deletions
2
Makefile
2
Makefile
|
|
@ -25,7 +25,7 @@ generate-docs:
|
||||||
@$(SCRIPTS_BASE)/tfplugindocs.sh
|
@$(SCRIPTS_BASE)/tfplugindocs.sh
|
||||||
|
|
||||||
build:
|
build:
|
||||||
@go build -o bin/terraform-provider-stackitalpha
|
@go build -o bin/terraform-provider-stackitprivatepreview
|
||||||
|
|
||||||
fmt:
|
fmt:
|
||||||
@gofmt -s -w .
|
@gofmt -s -w .
|
||||||
|
|
|
||||||
|
|
@ -1,43 +1,90 @@
|
||||||
# Copyright (c) STACKIT
|
resource "stackit_kms_keyring" "keyring" {
|
||||||
|
|
||||||
resource "stackitalpha_kms_keyring" "keyring" {
|
|
||||||
project_id = var.project_id
|
project_id = var.project_id
|
||||||
display_name = "keyring01"
|
display_name = "msh-keyring01"
|
||||||
description = "This is a test keyring for private endpoints"
|
description = "This is a test keyring for private endpoints"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "stackitalpha_kms_key" "key" {
|
resource "stackit_kms_key" "key" {
|
||||||
project_id = var.project_id
|
project_id = var.project_id
|
||||||
keyring_id = stackitalpha_kms_keyring.keyring.keyring_id
|
keyring_id = stackit_kms_keyring.keyring.keyring_id
|
||||||
display_name = "key01"
|
display_name = "msh-key01"
|
||||||
protection = "software"
|
protection = "software"
|
||||||
algorithm = "aes_256_gcm"
|
algorithm = "aes_256_gcm"
|
||||||
purpose = "symmetric_encrypt_decrypt"
|
purpose = "symmetric_encrypt_decrypt"
|
||||||
access_scope = "SNA"
|
access_scope = "SNA"
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "stackitalpha_postgresflexalpha_instance" "ptlsdbsrv" {
|
output "keyid" {
|
||||||
|
value = stackit_kms_key.key.key_id
|
||||||
|
}
|
||||||
|
|
||||||
|
# resource "stackitalpha_postgresflexalpha_instance" "ptlsdbsrv" {
|
||||||
|
# project_id = var.project_id
|
||||||
|
# name = "example-instance"
|
||||||
|
# acl = ["0.0.0.0/0"]
|
||||||
|
# backup_schedule = "0 0 * * *"
|
||||||
|
# flavor = {
|
||||||
|
# cpu = 2
|
||||||
|
# ram = 4
|
||||||
|
# }
|
||||||
|
# replicas = 1
|
||||||
|
# storage = {
|
||||||
|
# class = "premium-perf2-stackit"
|
||||||
|
# size = 5
|
||||||
|
# }
|
||||||
|
# version = 14
|
||||||
|
# encryption = {
|
||||||
|
# key_id = stackitalpha_kms_key.key.id
|
||||||
|
# key_ring_id = stackitalpha_kms_keyring.keyring.keyring_id
|
||||||
|
# key_version = "1"
|
||||||
|
# service_account = var.sa_email
|
||||||
|
# }
|
||||||
|
# network = {
|
||||||
|
# access_scope = "SNA"
|
||||||
|
# }
|
||||||
|
# }
|
||||||
|
|
||||||
|
resource "stackitprivatepreview_sqlserverflexalpha_instance" "ptlsdbsqlsrv" {
|
||||||
project_id = var.project_id
|
project_id = var.project_id
|
||||||
name = "example-instance"
|
name = "msh-example-instance-002"
|
||||||
acl = ["0.0.0.0/0"]
|
backup_schedule = "0 3 * * *"
|
||||||
backup_schedule = "0 0 * * *"
|
retention_days = 31
|
||||||
flavor = {
|
flavor = {
|
||||||
cpu = 2
|
cpu = 4
|
||||||
ram = 4
|
ram = 16
|
||||||
|
node_type = "Single"
|
||||||
}
|
}
|
||||||
replicas = 3
|
|
||||||
storage = {
|
storage = {
|
||||||
class = "premium-perf12-stackit"
|
class = "premium-perf2-stackit"
|
||||||
size = 5
|
size = 50
|
||||||
}
|
}
|
||||||
version = 14
|
version = 2022
|
||||||
encryption = {
|
encryption = {
|
||||||
key_id = stackitalpha_kms_key.key.id
|
key_id = stackit_kms_key.key.key_id
|
||||||
key_ring_id = stackitalpha_kms_keyring.keyring.keyring_id
|
keyring_id = stackit_kms_keyring.keyring.keyring_id
|
||||||
key_version = "1"
|
# key_id = var.key_id
|
||||||
|
# keyring_id = var.keyring_id
|
||||||
|
key_version = var.key_version
|
||||||
service_account = var.sa_email
|
service_account = var.sa_email
|
||||||
}
|
}
|
||||||
network = {
|
network = {
|
||||||
|
acl = ["0.0.0.0/0", "193.148.160.0/19"]
|
||||||
access_scope = "SNA"
|
access_scope = "SNA"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# data "stackitalpha_sqlserverflexalpha_instance" "test" {
|
||||||
|
# project_id = var.project_id
|
||||||
|
# instance_id = var.instance_id
|
||||||
|
# region = "eu01"
|
||||||
|
# }
|
||||||
|
|
||||||
|
# output "test" {
|
||||||
|
# value = data.stackitalpha_sqlserverflexalpha_instance.test
|
||||||
|
# }
|
||||||
|
|
||||||
|
# data "stackitalpha_sqlserverflexalpha_user" "testuser" {
|
||||||
|
# project_id = var.project_id
|
||||||
|
# instance_id = var.instance_id
|
||||||
|
# region = "eu01"
|
||||||
|
# }
|
||||||
|
|
|
||||||
|
|
@ -2,14 +2,24 @@
|
||||||
|
|
||||||
terraform {
|
terraform {
|
||||||
required_providers {
|
required_providers {
|
||||||
stackitalpha = {
|
stackit = {
|
||||||
source = "registry.terraform.io/stackitcloud/stackitalpha"
|
source = "registry.terraform.io/stackitcloud/stackit"
|
||||||
|
#version = "~> 0.70"
|
||||||
|
}
|
||||||
|
stackitprivatepreview = {
|
||||||
|
source = "registry.terraform.io/stackitcloud/stackitprivatepreview"
|
||||||
version = "~> 0.1"
|
version = "~> 0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
provider "stackitalpha" {
|
provider "stackit" {
|
||||||
|
default_region = "eu01"
|
||||||
|
enable_beta_resources = true
|
||||||
|
service_account_key_path = "./service_account.json"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "stackitprivatepreview" {
|
||||||
default_region = "eu01"
|
default_region = "eu01"
|
||||||
enable_beta_resources = true
|
enable_beta_resources = true
|
||||||
service_account_key_path = "./service_account.json"
|
service_account_key_path = "./service_account.json"
|
||||||
|
|
|
||||||
18
sample/tf.sh
18
sample/tf.sh
|
|
@ -2,8 +2,24 @@
|
||||||
# Copyright (c) STACKIT
|
# Copyright (c) STACKIT
|
||||||
|
|
||||||
|
|
||||||
|
# ./tf.sh apply > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)
|
||||||
|
|
||||||
# copy or rename sample.tfrc.example and adjust it
|
# copy or rename sample.tfrc.example and adjust it
|
||||||
TERRAFORM_CONFIG=$(pwd)/sample.tfrc
|
TERRAFORM_CONFIG=$(pwd)/sample.tfrc
|
||||||
export TERRAFORM_CONFIG
|
export TERRAFORM_CONFIG
|
||||||
|
|
||||||
terraform "$1"
|
parsed_options=$(
|
||||||
|
getopt -n "$0" -o l -- "$@"
|
||||||
|
) || exit
|
||||||
|
eval "set -- $parsed_options"
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
(-l) TF_LOG=TRACE
|
||||||
|
export TF_LOG
|
||||||
|
shift;;
|
||||||
|
(--) shift; break;;
|
||||||
|
(*) echo "Unknown option ${1}" # should never be reached.
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
terraform "$*"
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,24 @@
|
||||||
# Copyright (c) STACKIT
|
# Copyright (c) STACKIT
|
||||||
|
|
||||||
|
|
||||||
|
# ./tofu.sh apply > >(tee -a stdout.log) 2> >(tee -a stderr.log >&2)
|
||||||
|
|
||||||
# copy or rename sample.tfrc.example and adjust it
|
# copy or rename sample.tfrc.example and adjust it
|
||||||
TERRAFORM_CONFIG=$(pwd)/sample.tfrc
|
TERRAFORM_CONFIG=$(pwd)/sample.tfrc
|
||||||
export TERRAFORM_CONFIG
|
export TERRAFORM_CONFIG
|
||||||
|
|
||||||
tofu "$1"
|
parsed_options=$(
|
||||||
|
getopt -n "$0" -o l -- "$@"
|
||||||
|
) || exit
|
||||||
|
eval "set -- $parsed_options"
|
||||||
|
while [ "$#" -gt 0 ]; do
|
||||||
|
case $1 in
|
||||||
|
(-l) TF_LOG=TRACE
|
||||||
|
export TF_LOG
|
||||||
|
shift;;
|
||||||
|
(--) shift; break;;
|
||||||
|
(*) echo "Unknown option ${1}" # should never be reached.
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
tofu "$*"
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,16 @@ func StringValueToPointer(s basetypes.StringValue) *string {
|
||||||
return &value
|
return &value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Int32ValueToPointer converts basetypes.Int64Value to a pointer to int64.
|
||||||
|
// It returns nil if the value is null or unknown.
|
||||||
|
func Int32ValueToPointer(s basetypes.Int32Value) *int32 {
|
||||||
|
if s.IsNull() || s.IsUnknown() {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
value := s.ValueInt32()
|
||||||
|
return &value
|
||||||
|
}
|
||||||
|
|
||||||
// Int64ValueToPointer converts basetypes.Int64Value to a pointer to int64.
|
// Int64ValueToPointer converts basetypes.Int64Value to a pointer to int64.
|
||||||
// It returns nil if the value is null or unknown.
|
// It returns nil if the value is null or unknown.
|
||||||
func Int64ValueToPointer(s basetypes.Int64Value) *int64 {
|
func Int64ValueToPointer(s basetypes.Int64Value) *int64 {
|
||||||
|
|
|
||||||
|
|
@ -723,9 +723,9 @@ func mapFields(ctx context.Context, resp *postgresflexalpha.GetInstanceResponse,
|
||||||
// TODO
|
// TODO
|
||||||
//flavorValues = map[string]attr.Value{
|
//flavorValues = map[string]attr.Value{
|
||||||
// "id": types.StringValue(*instance.FlavorId),
|
// "id": types.StringValue(*instance.FlavorId),
|
||||||
// "description": types.StringValue(*instance.Flavor.Description),
|
// "description": types.StringValue(*instance.FlavorId.Description),
|
||||||
// "cpu": types.Int64PointerValue(instance.Flavor.Cpu),
|
// "cpu": types.Int64PointerValue(instance.FlavorId.Cpu),
|
||||||
// "ram": types.Int64PointerValue(instance.Flavor.Memory),
|
// "ram": types.Int64PointerValue(instance.FlavorId.Memory),
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
flavorObject, diags := types.ObjectValue(flavorTypes, flavorValues)
|
flavorObject, diags := types.ObjectValue(flavorTypes, flavorValues)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
|
"github.com/stackitcloud/terraform-provider-stackit/pkg/postgresflexalpha"
|
||||||
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
"github.com/stackitcloud/terraform-provider-stackit/stackit/internal/conversion"
|
||||||
postgresflexalphaUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
|
postgresflexUtils "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/services/postgresflexalpha/utils"
|
||||||
|
|
||||||
"github.com/hashicorp/terraform-plugin-framework/attr"
|
"github.com/hashicorp/terraform-plugin-framework/attr"
|
||||||
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
"github.com/hashicorp/terraform-plugin-framework/datasource"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue