Skip to content

modified-connector #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions azure_static/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
data "azuread_client_config" "current" {}
data "azurerm_subscription" "current" {}

# Create Azure AD application
resource "azuread_application" "app_registration" {
display_name = var.AD_name
owners = [data.azuread_client_config.current.object_id]
}

# Create the Service Principal
resource "azuread_service_principal" "sg_sp" {
client_id = azuread_application.app_registration.client_id
owners = [data.azuread_client_config.current.object_id]
app_role_assignment_required = false
}

# Assign Contributor role to the Service Principal at the subscription level
resource "azurerm_role_assignment" "example" {
principal_id = azuread_service_principal.sg_sp.object_id
role_definition_name = "Contributor"
scope = data.azurerm_subscription.current.id
}

# Step 3: Create a Client Secret for the Service Principal
resource "azuread_service_principal_password" "client_secret" {
service_principal_id = azuread_service_principal.sg_sp.id
}

# Step 4: Output the Client Secret Value (ID will be available in the Service Principal)
output "client_secret_value" {
value = azuread_service_principal_password.client_secret.value
sensitive = true
}

# Step 5: Output the Client ID (Application ID)
output "client_id" {
value = azuread_application.app_registration.client_id
}

# Step 6: Output the Client Secret ID (from the service principal password)
output "client_secret_id" {
value = azuread_service_principal_password.client_secret.id
}
26 changes: 26 additions & 0 deletions azure_static/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "=4.6.0"
}
azuread = {
source = "hashicorp/azuread"
version = "=3.0.2"
}
}
}

provider "azurerm" {
features {

}
subscription_id = var.subscription_id
client_id = var.client_id
client_secret = var.client_secret
tenant_id = var.tenant_id
}

provider "azuread" {
tenant_id = var.tenant_id
}
20 changes: 20 additions & 0 deletions azure_static/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
variable "subscription_id" {
type = string
}

variable "client_id" {
type = string
}

variable "client_secret" {
type = string
}

variable "tenant_id" {
type = string
}

variable "AD_name" {
type = string
description = "name of the azure active directory"
}
26 changes: 26 additions & 0 deletions stackguardian_connector_cloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,29 @@ resource "stackguardian_connector" "sg_azure_static_connector" {
}]
}
}

resource "stackguardian_connector" "sg_azure_oidc_connector" {
count = (var.connector_type == "AZURE_OIDC") ? 1 : 0
resource_name = var.cloud_connector_name
description = "Onboarding example of terraform-provider-stackguardian for AzureConnectorCloud"
settings = {
kind = var.connector_type,
config = [{
armTenantId = var.armTenantId,
armSubscriptionId = var.armSubscriptionId,
armClientId = var.armClientId,
}]
}
}

resource "stackguardian_connector" "sg_gcp_oidc_connector" {
count = (var.connector_type == "GCP_OIDC") ? 1 : 0
resource_name = var.cloud_connector_name
description = "Onboarding example of terraform-provider-stackguardian for AzureConnectorCloud"
settings = {
kind = var.connector_type,
config = [{
gcp_config_file_content = var.gcp_config_file_content
}]
}
}
8 changes: 8 additions & 0 deletions stackguardian_connector_cloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,11 @@ variable "role_external_id" {
description = "external id of the aws rbac role"
#default = "<org_name>:<random_string>"
}

################
# GCP_OIDC Credentials + GCP_STATIC Credentials
################
variable "gcp_config_file_content" {
type = string
description = "the gco config content gor the connector"
}