mirror of
https://github.com/kittywitch/nixfiles.git
synced 2026-02-09 04:19:19 -08:00
feat(oci): add
This commit is contained in:
parent
7f6562ea70
commit
1e79f4f23c
29 changed files with 308 additions and 34 deletions
24
tf/oci_compartment_bootstrap/api_key.tf
Normal file
24
tf/oci_compartment_bootstrap/api_key.tf
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
resource "oci_identity_api_key" "this" {
|
||||
key_value = local.child_compartment_public_key
|
||||
user_id = local.child_compartment_user
|
||||
}
|
||||
|
||||
locals {
|
||||
child_compartment_api_key = oci_identity_api_key.this
|
||||
}
|
||||
|
||||
output "child_compartment_key_fingerprint" {
|
||||
value = local.child_compartment_api_key.fingerprint
|
||||
}
|
||||
|
||||
output "child_compartment_key_id" {
|
||||
value = local.child_compartment_api_key.id
|
||||
}
|
||||
|
||||
output "child_compartment_key_value" {
|
||||
value = local.child_compartment_api_key.key_value
|
||||
}
|
||||
|
||||
output "child_compartment_key_state" {
|
||||
value = local.child_compartment_api_key.state
|
||||
}
|
||||
15
tf/oci_compartment_bootstrap/compartment.tf
Normal file
15
tf/oci_compartment_bootstrap/compartment.tf
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
resource "oci_identity_compartment" "this" {
|
||||
# Compartment ID is Tenancy ID for this case
|
||||
compartment_id = var.tenancy_ocid
|
||||
description = "Compartment for Terraform usage"
|
||||
name = "kittywitch-tf"
|
||||
|
||||
}
|
||||
|
||||
locals {
|
||||
child_compartment_id = oci_identity_compartment.this.compartment_id
|
||||
}
|
||||
|
||||
output "child_compartment_id" {
|
||||
value = local.child_compartment_id
|
||||
}
|
||||
28
tf/oci_compartment_bootstrap/oci_provider.tf
Normal file
28
tf/oci_compartment_bootstrap/oci_provider.tf
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
variable "tenancy_ocid" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "user_ocid" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "private_key" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "region" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "fingerprint" {
|
||||
type = string
|
||||
}
|
||||
|
||||
# https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformgettingstarted.htm
|
||||
provider "oci" {
|
||||
tenancy_ocid = var.tenancy_ocid
|
||||
user_ocid = var.user_ocid
|
||||
private_key = var.private_key
|
||||
region = var.region
|
||||
fingerprint = var.fingerprint
|
||||
}
|
||||
14
tf/oci_compartment_bootstrap/providers.tf
Normal file
14
tf/oci_compartment_bootstrap/providers.tf
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
# Vendor: Hashicorp
|
||||
tls = {
|
||||
source = "hashicorp/tls"
|
||||
version = "4.0.5"
|
||||
}
|
||||
# Vendor: Oracle
|
||||
oci = {
|
||||
source = "oracle/oci"
|
||||
version = "5.45.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
11
tf/oci_compartment_bootstrap/tls.tf
Normal file
11
tf/oci_compartment_bootstrap/tls.tf
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
resource "tls_private_key" "this" {
|
||||
# https://registry.terraform.io/providers/oracle/oci/latest/docs/resources/identity_api_key#key_value
|
||||
# "The public key. Must be an RSA key in PEM format."
|
||||
algorithm = "RSA"
|
||||
rsa_bits = 4096
|
||||
}
|
||||
|
||||
locals {
|
||||
child_compartment_private_key = tls_private_key.this.private_key_pem
|
||||
child_compartment_public_key = tls_private_key.this.public_key_pem
|
||||
}
|
||||
13
tf/oci_compartment_bootstrap/user.tf
Normal file
13
tf/oci_compartment_bootstrap/user.tf
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
resource "oci_identity_user" "this" {
|
||||
compartment_id = local.child_compartment_id
|
||||
description = "The user for Terraform to use"
|
||||
name = "terraform"
|
||||
}
|
||||
|
||||
locals {
|
||||
child_compartment_user = oci_identity_user.this.id
|
||||
}
|
||||
|
||||
output "child_user_id" {
|
||||
value = local.child_compartment_user
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue