feat(oci): add

This commit is contained in:
Kat Inskip 2024-06-08 17:25:08 -07:00
parent 7f6562ea70
commit 1e79f4f23c
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
29 changed files with 308 additions and 34 deletions

View 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
}

View 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
}

View 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
}

View 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"
}
}
}

View 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
}

View 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
}