Skip to content

Commit

Permalink
add exainfra only example and module with test automation
Browse files Browse the repository at this point in the history
  • Loading branch information
chanstev committed Sep 6, 2024
1 parent cd25342 commit 5921326
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/linters/terrascan.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# terrascan configuration file

# https://runterrascan.io/docs/policies/
[rules]
skip-rules = [
"accurics.azure.NS.272"
]
138 changes: 138 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: build

on:
push:
branches:
# - main
- steven/*
# pull_request:
# branches:
# - main

permissions: {}

jobs:
docs:
name: Generate terraform docs
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
statuses: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Render terraform docs and push changes back to PR
uses: terraform-docs/gh-actions@main
with:
working-dir: .
output-file: README.md
output-method: inject
git-push: true
recursive: true
recursive-path: modules
args: --recursive-include-main=false
lint:
name: Lint Code Base
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
statuses: write

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Super-linter
uses: github/super-linter@v6
env:
# To report GitHub Actions status checks
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_TERRAFORM_FMT: true
VALIDATE_TERRAFORM_TFLINT: true
VALIDATE_TERRAFORM_TERRASCAN: true
VALIDATE_CHECKOV: true

tofu_test_ubuntu:
name: Tofu Test (ubuntu)
environment: sandbox3
runs-on: ubuntu-latest
needs: lint
permissions:
contents: read
packages: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Azure login
uses: azure/login@v2
with:
creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTIONS_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}'
- name: setup opentofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: 1.8.1
# - name: Iterate over each module for tofu test
# run: |
# for dir in $(find ./modules -maxdepth 1 -mindepth 1 -type d); do
# echo "----- Testing $dir -----"
# cd $dir
# tofu init
# tofu validate
# tofu fmt -check
# # tofu test
# cd - # Go back to root directory
# done
- name: Iterate over each examples for tofu plan
run: |
# for dir in $(find ./examples -maxdepth 1 -mindepth 1 -type d); do
# echo "----- Testing $dir -----"
# cd $dir
cd ./examples/exainfra_only
tofu init
tofu validate
tofu fmt -check
tofu plan
cd - # Go back to root directory
done
# tofu_test_windows:
# name: Tofu Test (windows)
# environment: sandbox3
# runs-on: windows-latest
# needs: lint
# permissions:
# contents: read
# packages: read
# steps:
# - name: Checkout code
# uses: actions/checkout@v4
# with:
# fetch-depth: 0
# - name: Azure login
# uses: azure/login@v2
# with:
# creds: '{"clientId":"${{ secrets.ARM_CLIENT_ID }}","clientSecret":"${{ secrets.ARM_CLIENT_SECRET }}","subscriptionId":"${{ secrets.ARM_SUBSCRIPTIONS_ID }}","tenantId":"${{ secrets.ARM_TENANT_ID }}"}'
# - name: setup opentofu
# uses: opentofu/setup-opentofu@v1
# with:
# tofu_version: 1.8.1
# - name: Iterate over each module and test
# shell: powershell
# run: |
# $modules = Get-ChildItem -Path .\modules -Directory
# foreach ($module in $modules) {
# Write-Host "Testing module in $($module.FullName)"
# Set-Location -Path $module.FullName
# tofu init
# tofu validate
# tofu fmt -check
# tofu test
# Set-Location -Path $Env:GITHUB_WORKSPACE
# }
13 changes: 13 additions & 0 deletions examples/exainfra_only/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module "azure-exainfra" {
source = "../../modules/azure-exainfra"
resource_group = "tftest-01"
location = "eastus"
zones = "3"
exadata_infrastructure_resource_name = "tftest-01"
exadata_infrastructure_shape = "Exadata.X9M"
exadata_infrastructure_compute_cpu_count = 2
exadata_infrastructure_storage_count = 3
exadata_infrastructure_maintenance_window_lead_time_in_weeks = 0
exadata_infrastructure_maintenance_window_preference = "NoPreference"
exadata_infrastructure_maintenance_window_patching_mode = "Rolling"
}
33 changes: 33 additions & 0 deletions modules/azure-exainfra/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
resource "azurerm_resource_group" "az_rg" {
name = var.resource_group
location = var.location
}


resource "azapi_resource" "cloudExadataInfrastructure" {
type = "Oracle.Database/cloudExadataInfrastructures@2023-09-01"
parent_id = azurerm_resource_group.az_rg.id
name = var.exadata_infrastructure_resource_name
timeouts {
create = "1h30m"
delete = "20m"
}
body = {
"location" : var.location,
"zones" : [
var.zones
],
"properties" : {
"computeCount" : var.exadata_infrastructure_compute_cpu_count,
"displayName" : var.exadata_infrastructure_resource_name,
"maintenanceWindow" : {
"leadTimeInWeeks" : var.exadata_infrastructure_maintenance_window_lead_time_in_weeks,
"preference" : var.exadata_infrastructure_maintenance_window_preference,
"patchingMode" : var.exadata_infrastructure_maintenance_window_patching_mode
},
"shape" : var.exadata_infrastructure_shape,
"storageCount" : var.exadata_infrastructure_storage_count
}
}
schema_validation_enabled = false
}
3 changes: 3 additions & 0 deletions modules/azure-exainfra/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "exainfra_ocid" {
value = azapi_resource.cloudExadataInfrastructure.id
}
18 changes: 18 additions & 0 deletions modules/azure-exainfra/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
terraform {
required_providers {
# https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.99.0"
}
# https://registry.terraform.io/providers/Azure/azapi/latest/docs
azapi = {
source = "Azure/azapi"
}
}
}

provider "azurerm" {
features {
}
}
11 changes: 11 additions & 0 deletions modules/azure-exainfra/terraform.tfvars.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource_group = "tftest-01"
location="useast"
zones="2"
exadata_infrastructure_resource_name="tftest01"
exadata_infrastructure_compute_cpu_count=2
exadata_infrastructure_resource_display_name="tftest-01"
exadata_infrastructure_maintenance_window_lead_time_in_weeks=0
exadata_infrastructure_maintenance_window_preference="NoPreference"
exadata_infrastructure_maintenance_window_patching_mode="Rolling"
exadata_infrastructure_shape="Exadata.X9M"
exadata_infrastructure_storage_count=3
53 changes: 53 additions & 0 deletions modules/azure-exainfra/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
variable "location" {
description = "The location of the exadata infrastructure."
type = string
}

variable "zones" {
description = "The zone of the exadata infrastructure."
type = string
}

variable "resource_group" {
type = string
description = "Resource Group Name"
}

variable "exadata_infrastructure_resource_name" {
description = "The name of the exadata infrastructure on Azure."
type = string
}
# variable "exadata_infrastructure_resource_display_name" {
# description = "The display name of the exadata infrastructure."
# type = string
# }

variable "exadata_infrastructure_compute_cpu_count" {
description = "The number of compute servers for the cloud Exadata infrastructure."
type = number
}

variable "exadata_infrastructure_storage_count" {
description = "The number of storage servers for the Exadata infrastructure."
type = number
}

variable "exadata_infrastructure_shape" {
description = "The shape of the cloud Exadata infrastructure resource. e.g. Exadata.X9M"
type = string
}

variable "exadata_infrastructure_maintenance_window_lead_time_in_weeks" {
description = "Lead time window allows user to set a lead time to prepare for a down time. The lead time is in weeks and valid value is between 1 to 4."
type = number
}

variable "exadata_infrastructure_maintenance_window_preference" {
description = "The maintenance window scheduling preference.Allowed values are: NO_PREFERENCE, CUSTOM_PREFERENCE."
type = string
}

variable "exadata_infrastructure_maintenance_window_patching_mode" {
description = "Cloud Exadata infrastructure node patching method, either ROLLING or NONROLLING."
type = string
}

0 comments on commit 5921326

Please sign in to comment.