APIM
main.tf
# Module for Azure API Management
module "apim" {
source = "../modules/apim"
# Pass any required variables to the APIM module
apim_service_name = var.apim_service_name
publisher_name = var.publisher_name
publisher_email = var.publisher_email
resource_group_name = var.resource_group_name
location = var.location
sku_name = var.sku_name
# Add any other required variables here
}
# Define a data source for the existing resource group
data "azurerm_resource_group" "cg" {
name = var.resource_group_name
}
# Define a data source for the existing virtual network
data "azurerm_virtual_network" "dev_neogenomics_rg_vnet" {
name = var.vnet_name
resource_group_name = data.azurerm_resource_group.dev_neogenomics_rg.name
}
# Define a data source for the existing subnet within the virtual network
data "azurerm_subnet" "dev_neogenomics_subnet" {
name = var.subnet_name
virtual_network_name = data.azurerm_virtual_network.dev_neogenomics_rg_vnet.name
resource_group_name = data.azurerm_resource_group.dev_neogenomics_rg.name
}
# Example resource within the existing subnet
resource "azurerm_network_interface" "dev-network-nic" {
name = "dev-neogenomics-nic"
location = data.azurerm_resource_group.dev_neogenomics_rg.location
resource_group_name = data.azurerm_resource_group.dev_neogenomics_rg.name
ip_configuration {
name = "internal"
subnet_id = data.azurerm_subnet.dev_neogenomics_subnet.id
private_ip_address_allocation = "Dynamic"
}
}
# Run the script to set the credentials from environment variables
resource "null_resource" "set_credentials" {
provisioner "local-exec" {
command = "${path.module}/set_credentials.ps1"
}
}
output.tf
output "apim_endpoint" {
description = "The endpoint URL of the Azure API Management service"
value = module.apim.endpoint
}
output "apim_sku_name" {
description = "The SKU name of the Azure API Management service"
value = module.apim.sku_name
}
# output "apim_sku_capacity" {
# description = "The SKU capacity of the Azure API Management service"
# value = module.apim.sku_capacity
# }
# Add more outputs as needed
backend.tf
# Azure Storage Account
resource "azurerm_storage_account" "tf_state" {
#name = "stesptfstatedevsrj"
name = "stesptfstatedev"
resource_group_name = azurerm_resource_group.dev_neogenomics_rg.name
location = azurerm_resource_group.dev_neogenomics_rg.location
account_tier = "Standard"
account_replication_type = "LRS"
tags = {
environment = var.environment
}
}
# Blob Container
resource "azurerm_storage_container" "tf_state" {
#name = "stesptfbolbdevsrj"
name = "statecontainer"
storage_account_name = azurerm_storage_account.tf_state.name
container_access_type = "private"
}
# Backend Configuration
terraform {
backend "azurerm" {
resource_group_name = var.resource_group_name
storage_account_name = "tesptfstatedev"
container_name = "statecontainer"
key = "terraform.tfstate"
}
}
provider.tf
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=3.0.0"
}
}
}
# provider "azurerm" {
# features {}
# }
# Configure the Azure provider
provider "azurerm" {
features {}
subscription_id = var.subscription_id
client_id = data.azurerm_key_vault_secret.client_id.value
client_secret = data.azurerm_key_vault_secret.client_secret.value
tenant_id = var.tenant_id
}
# # Retrieve client ID and client secret from Azure Key Vault
# data "azurerm_key_vault_secret" "client_id" {
# name = var.key_vault_client_id_secret_name
# key_vault_id = var.key_vault_id
# }
# data "azurerm_key_vault_secret" "client_secret" {
# name = var.key_vault_client_secret_secret_name
# key_vault_id = var.key_vault_id
# }
terraform.tfvars
vnet_name = "VNET-Dev-10.117.128.0-17"
resource_group_name = "rg-esp-dev"
subnet_name = "PrivateEndpointDev-Subnet"
location = "East US 2"
environment = "dev"
apim_service_name = "dev_apim_service"
publisher_name = "Michael Million - NeoGenomics"
publisher_email = "michael.million@neogenomics.com"
sku_name = "Developer_1"
subscription_id = "e5090f19-cf39-4d4d-8ac9-5f8bf17b1cc7"
variables.tf
variable "subscription_id" {
description = "Name of the virtual network"
}
variable "tenant_id" {
description = "Name of the virtual network"
}
variable "vnet_name" {
description = "Name of the virtual network"
}
variable "resource_group_name" {
description = "Name of the resource group"
}
variable "subnet_name" {
description = "Name of the subnet"
}
variable "location" {
description = "Location for Azure resources"
default = "East US 2"
}
# variable "address_space" {
# description = "Address space for the virtual network"
# type = list(string)
# }
# variable "subnet_address_prefixes" {
# description = "Address prefixes for the subnet"
# type = list(string)
# }
variable "environment" {
description = "Environment Name"
type = string
default = "dev"
}
variable "apim_service_name" {
description = "Name of the Azure API Management service"
type = string
default = "dev_apim_service"
}
variable "publisher_name" {
description = "Name of the publisher for the APIM service"
type = string
default = "Michael Million - NeoGenomics"
}
variable "publisher_email" {
description = "Name of the publisher for the APIM service"
type = string
default = "michael.million@neogenomics.com"
}
variable "sku_name" {
description = "SKU name for the APIM service"
type = string
}
Comments
Post a Comment