Skip to content

Commit c67a0a1

Browse files
authored
Update modules, support base64-encoded SSH key (#587)
* Update modules: vcn 3.5.2, bastion 3.1.3, operator 3.1.2 Signed-off-by: Devon Crouse <[email protected]> * Support base64-encoded SSH key Signed-off-by: Devon Crouse <[email protected]> * Support ORM current_user_ocid, base64-encoded API key and add provider.tf.example Signed-off-by: Devon Crouse <[email protected]> * Update modules: operator 3.1.3 Signed-off-by: Devon Crouse <[email protected]> Signed-off-by: Devon Crouse <[email protected]>
1 parent 6b84a48 commit c67a0a1

File tree

6 files changed

+38
-8
lines changed

6 files changed

+38
-8
lines changed

docs/terraformoptions.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ See {uri-oci-provider-config}[Terraform OCI Provider] or {uri-oci-rm-config}[Res
5050
|none
5151

5252
|api_private_key
53-
|The contents of the private key file to use with OCI API. This takes precedence over private_key_path if both are specified in the provider. *Maybe required depending on your authentication method.* Use the heredoc format if you are specifying the key with this variable.
53+
|The contents of the private key file to use with OCI API. This takes precedence over private_key_path if both are specified in the provider. *Maybe required depending on your authentication method.* Use the heredoc format if you are specifying the key with this variable. This value may be optionally base64-encoded.
5454
|<<EOT
5555
-----BEGIN RSA PRIVATE KEY-----
5656
content+of+api+key
@@ -123,7 +123,7 @@ region = "ap-sydney-1"
123123
|Default
124124

125125
|ssh_private_key
126-
|The contents of the private ssh key file. Use the heredoc format if you are specifying the private key.
126+
|The contents of the private ssh key file. Use the heredoc format if you are specifying the private key. This value may be optionally base64-encoded.
127127
|
128128
<<EOT
129129
-----BEGIN RSA PRIVATE KEY-----

locals.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ locals {
77
var.compartment_id, var.compartment_ocid,
88
var.tenancy_id, var.tenancy_ocid,
99
)
10+
user_id = coalesce(var.user_id, var.current_user_ocid)
11+
12+
api_private_key = (
13+
var.api_private_key != ""
14+
? try(base64decode(var.api_private_key), var.api_private_key)
15+
: var.api_private_key_path != ""
16+
? file(var.api_private_key_path)
17+
: null)
1018

1119
bastion_public_ip = var.create_bastion_host == true ? module.bastion[0].bastion_public_ip : var.bastion_public_ip != "" ? var.bastion_public_ip: ""
1220
operator_private_ip = var.create_operator == true ? module.operator[0].operator_private_ip : var.operator_private_ip !="" ? var.operator_private_ip: ""

main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
module "vcn" {
55
source = "oracle-terraform-modules/vcn/oci"
6-
version = "3.5.1"
6+
version = "3.5.2"
77

88
# general oci parameters
99
compartment_id = local.compartment_id
@@ -59,7 +59,7 @@ module "drg" {
5959

6060
module "bastion" {
6161
source = "oracle-terraform-modules/bastion/oci"
62-
version = "3.1.2"
62+
version = "3.1.3"
6363

6464
tenancy_id = local.tenancy_id
6565
compartment_id = local.compartment_id
@@ -108,7 +108,7 @@ module "bastion" {
108108

109109
module "operator" {
110110
source = "oracle-terraform-modules/operator/oci"
111-
version = "3.1.1"
111+
version = "3.1.3"
112112

113113

114114
# general oci parameters

modules/extensions/locals.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl
33

44
locals {
5-
ssh_private_key = var.ssh_private_key != "" ? var.ssh_private_key : var.ssh_private_key_path != "none" ? file(var.ssh_private_key_path) : null
5+
ssh_private_key = (
6+
var.ssh_private_key != ""
7+
? try(base64decode(var.ssh_private_key), var.ssh_private_key)
8+
: var.ssh_private_key_path != "none"
9+
? file(var.ssh_private_key_path)
10+
: null)
11+
612
node_pools_size_list = [
713
for node_pool in data.oci_containerengine_node_pools.all_node_pools.node_pools :
814
node_pool.node_config_details[0].size

provider.tf.example

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
provider "oci" {
2+
fingerprint = var.api_fingerprint
3+
private_key = var.api_private_key
4+
region = var.region
5+
tenancy_ocid = local.tenancy_id
6+
user_ocid = local.user_id
7+
}
8+
9+
provider "oci" {
10+
fingerprint = var.api_fingerprint
11+
private_key = var.api_private_key
12+
region = var.home_region
13+
tenancy_ocid = local.tenancy_id
14+
user_ocid = local.user_id
15+
alias = "home"
16+
}

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ variable "api_fingerprint" {
1010

1111
variable "api_private_key" {
1212
default = ""
13-
description = "The contents of the private key file to use with OCI API. This takes precedence over private_key_path if both are specified in the provider."
13+
description = "The contents of the private key file to use with OCI API, optionally base64-encoded. This takes precedence over private_key_path if both are specified in the provider."
1414
sensitive = true
1515
type = string
1616
}
@@ -93,7 +93,7 @@ variable "label_prefix" {
9393
# ssh keys
9494
variable "ssh_private_key" {
9595
default = ""
96-
description = "The contents of the private ssh key file."
96+
description = "The contents of the private ssh key file, optionally base64-encoded."
9797
sensitive = true
9898
type = string
9999
}

0 commit comments

Comments
 (0)