Skip to content

Commit d2c6afa

Browse files
authored
added mechanism to detect when instance_principal for admin host is ready (#47)
Signed-off-by: Ali Mukadam <[email protected]>
1 parent 28bd1d6 commit d2c6afa

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

CHANGELOG.adoc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ All notable changes to this project are documented in this file.
77

88
The format is based on {uri-changelog}[Keep a Changelog].
99

10+
== 1.1.3 (April 7, 2020)
11+
* Added a file (ip.finish) on admin host to allow solution stacks to detect when the instance_principal for admin host is ready (#46)
12+
13+
== 1.1.2 (February 28, 2020)
14+
* Fixed broken links in README.md (#43)
15+
* Renamed examples/db to database and removed the submodule since it's not rendering properly on the registry page
16+
1017
== 1.1.1 (February 28, 2020)
1118
* New release for hashicorp registry (#38, #40)
1219
* Fixed broken links in README.md (#43)

locals.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ locals {
6161
admin_shape = var.oci_base_admin.admin_shape
6262
admin_upgrade = var.oci_base_admin.admin_upgrade
6363
enable_instance_principal = var.oci_base_admin.enable_instance_principal
64+
ssh_private_key_path = var.oci_base_admin.ssh_private_key_path
6465
ssh_public_key_path = var.oci_base_admin.ssh_public_key_path
6566
timezone = var.oci_base_admin.timezone
6667
}
@@ -72,8 +73,13 @@ locals {
7273
notification_topic = var.oci_base_admin.notification_topic
7374
}
7475

76+
oci_admin_bastion = {
77+
bastion_ip = module.bastion.bastion_public_ip
78+
ssh_private_key_path = var.oci_base_bastion.ssh_private_key_path
79+
}
80+
7581
tagging = {
76-
computetag = var.tagging.computetag
77-
networktag = var.tagging.networktag
82+
computetag = var.tagging.computetag
83+
networktag = var.tagging.networktag
7884
}
7985
}

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ module "admin" {
2424
oci_admin_network = local.oci_admin_network
2525
oci_admin = local.oci_admin
2626
oci_admin_notification = local.oci_admin_notification
27+
oci_admin_bastion = local.oci_admin_bastion
2728
tagging = local.tagging
2829
}

modules/admin/instance_principal.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,27 @@ resource "oci_identity_policy" "admin_instance_principal" {
4343

4444
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
4545
}
46+
47+
resource null_resource "instance_principal_complete" {
48+
connection {
49+
host = oci_core_instance.admin[0].private_ip
50+
private_key = file(var.oci_admin.ssh_private_key_path)
51+
timeout = "40m"
52+
type = "ssh"
53+
user = "opc"
54+
55+
bastion_host = var.oci_admin_bastion.bastion_ip
56+
bastion_user = "opc"
57+
bastion_private_key = file(var.oci_admin_bastion.ssh_private_key_path)
58+
}
59+
60+
depends_on = [oci_identity_dynamic_group.admin_instance_principal, oci_identity_policy.admin_instance_principal]
61+
62+
provisioner "remote-exec" {
63+
inline = [
64+
"touch $HOME/ip.finish",
65+
]
66+
}
67+
68+
count = var.oci_admin.admin_enabled == true && var.oci_admin.enable_instance_principal == true ? 1 : 0
69+
}

modules/admin/variables.tf

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ variable "oci_admin" {
3232
admin_upgrade = bool
3333
admin_enabled = bool
3434
enable_instance_principal = bool
35+
ssh_private_key_path = string
3536
ssh_public_key_path = string
3637
timezone = string
3738
})
@@ -64,8 +65,15 @@ variable "oci_admin_notification" {
6465
#tagging
6566
variable "tagging" {
6667
type = object({
67-
computetag = map(any)
68-
networktag = map(any)
69-
})
68+
computetag = map(any)
69+
networktag = map(any)
70+
})
7071
}
7172

73+
# bastion
74+
variable "oci_admin_bastion" {
75+
type = object({
76+
bastion_ip = string
77+
ssh_private_key_path = string
78+
})
79+
}

0 commit comments

Comments
 (0)