Skip to content
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
17 changes: 13 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ function findPlatforms(): Platform[] {
const platformDir: string = path.join(repoRoot, dir.name);
const platformLogo = getPlatformLogoOrThrow(platformDir, dir.name);
const platformReadme = getPlatformReadmeOrThrow(platformDir);
const { name, description, content } = extractReadmeFrontMatter(platformReadme);
const { name, description, category, content } = extractReadmeFrontMatter(platformReadme);
const terraformSnippet = getTerraformSnippet(platformDir);

return {
platformType: dir.name,
name,
description,
category,
logo: platformLogo,
readme: content,
terraformSnippet
Expand All @@ -81,11 +82,11 @@ function getPlatformReadmeOrThrow(platformDir: string) {
try {
return fs.readFileSync(path.join(platformDir, "README.md"), "utf-8");
} catch {
throw new Error('Platform README.md not found. Each platform should have a README.md file.');
throw new Error(`Platform README.md not found for ${platformDir}. Each platform should have a README.md file.`);
}
}

function extractReadmeFrontMatter(platformReadme: string): { name: string; description: string; content: string } {
function extractReadmeFrontMatter(platformReadme: string): { name: string; description: string; category?: string; content: string } {
const { data, content } = matter(platformReadme);

const name = data.name;
Expand All @@ -98,10 +99,13 @@ function extractReadmeFrontMatter(platformReadme: string): { name: string; descr
throw new Error('Property "description" is missing in the front matter of the platform README.md. Each platform README.md should have a description defined in the front matter.');
}

const category = data.category;

return {
name,
description,
content
content,
category
}
}

Expand Down Expand Up @@ -169,12 +173,16 @@ function parseReadme(filePath) {
? getBuildingBlockFolderUrl(backplaneDir)
: null;

const terraformSnippetDir = path.join(buildingBlockDir, "..");
const terraformSnippet = getTerraformSnippet(terraformSnippetDir);

return {
id,
platformType: platform,
logo: buildingBlockLogoPath,
buildingBlockUrl,
backplaneUrl,
terraformSnippet,
...data,
howToUse: extractSection(/## How to Use([\s\S]*?)(##|$)/),
resources: parseTable(body.match(/## Resources([\s\S]*)/)),
Expand Down Expand Up @@ -224,5 +232,6 @@ export interface Platform {
description: string;
logo: string;
readme: string;
category?: string;
terraformSnippet?: string;
}
66 changes: 66 additions & 0 deletions modules/azure/storage-account/meshstack_integration.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# TODO: this is actual not a correct file but just acts as an example for now

locals {
name = "azure-storage-account"
scope = "/subscriptions/00000000-0000-0000-0000-000000000000"
existing_principal_ids = [
"00000000-0000-0000-0000-000000000000"
]
service_principal_name = "storage-account-deployer"

workspace_identifier = "my-workspace"
}

provider "meshstack" {
# Configure meshStack API credentials here or use environment variables.
# endpoint = "https://api.my.meshstack.io"
# apikey = "00000000-0000-0000-0000-000000000000"
# apisecret = "uFOu4OjbE4JiewPxezDuemSP3DUrCYmw"
}

provider "azurerm" {
features {}
}

# Import the backplane module to get IAM and other required outputs
module "backplane" {
source = "./backplane"
name = local.name
scope = local.scope
existing_principal_ids = local.existing_principal_ids
create_service_principal_name = local.service_principal_name
workload_identity_federation = {} # TODO this should come from data_source
}

# Import the building block definition into meshStack
# NOTE: meshstack_buildingblock_definition is a placeholder for demonstration. Replace with the actual resource if available.
resource "meshstack_buildingblock_definition" "storage_account" {
metadata = {
name = "azure-storage-account"
owned_by_workspace = local.workspace_identifier
}

spec = {
display_name = "Azure Storage Account"
description = "Provision Azure Storage Accounts with encryption and access control"

supported_platforms = ["azure"]

source = {
git = {
url = "https://github.com/meshcloud/meshstack-hub.git"
ref = "main"
path = "modules/azure/storage-account/buildingblock"
}
}

implementation_type = "Terraform"
# Pass IAM outputs as inputs if required by your building block
role_definition_id = module.backplane.role_definition_id
role_assignment_ids = module.backplane.role_assignment_ids
principal_ids = module.backplane.role_assignment_principal_ids
service_principal = module.backplane.created_service_principal
application = module.backplane.created_application
scope = module.backplane.scope
}
}
6 changes: 6 additions & 0 deletions modules/meshstack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: meshStack
description: meshStack is a cloud management platform that provides a unified interface for managing and governing cloud environments
---


1 change: 1 addition & 0 deletions website/src/app/core/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ export interface Template {
buildingBlockUrl: string;
backplaneUrl: string | null;
supportedPlatforms: string[];
terraformSnippet?: string;
}
Loading
Loading