Skip to content

Commit d8759c9

Browse files
authored
Merge pull request #59 from meshcloud/feature/CU-86c55h4xp_meshPlatforms-via-Terraform-Provider
feat: implement support for meshPlatforms
2 parents b06c666 + de66100 commit d8759c9

File tree

14 files changed

+4581
-30
lines changed

14 files changed

+4581
-30
lines changed

client/client.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ type endpoints struct {
4343
Tenants *url.URL `json:"meshtenants"`
4444
TagDefinitions *url.URL `json:"meshtagdefinitions"`
4545
LandingZones *url.URL `json:"meshlandingzones"`
46+
Platforms *url.URL `json:"meshplatforms"`
4647
}
4748

4849
type loginResponse struct {
@@ -73,6 +74,7 @@ func NewClient(rootUrl *url.URL, apiKey string, apiSecret string) (*MeshStackPro
7374
Tenants: rootUrl.JoinPath(apiMeshObjectsRoot, "meshtenants"),
7475
TagDefinitions: rootUrl.JoinPath(apiMeshObjectsRoot, "meshtagdefinitions"),
7576
LandingZones: rootUrl.JoinPath(apiMeshObjectsRoot, "meshlandingzones"),
77+
Platforms: rootUrl.JoinPath(apiMeshObjectsRoot, "meshplatforms"),
7678
}
7779

7880
return client, nil

client/platform.go

Lines changed: 503 additions & 0 deletions
Large diffs are not rendered by default.

docs/data-sources/landingzone.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Read a single landing zone by identifier.
2424
- `api_version` (String) Landing Zone API version.
2525
- `kind` (String) meshObject type, always `meshLandingZone`.
2626
- `spec` (Attributes) (see [below for nested schema](#nestedatt--spec))
27+
- `status` (Attributes) Current Landing Zone status. (see [below for nested schema](#nestedatt--status))
2728

2829
<a id="nestedatt--metadata"></a>
2930
### Nested Schema for `metadata`
@@ -65,7 +66,7 @@ Optional:
6566

6667
Read-Only:
6768

68-
- `type` (String) Type of the platform. One of `aws`, `aks`, `azure`, `azurerg`, `gcp`, `kubernetes`, `openshift`.
69+
- `type` (String) Type of the platform. This field is automatically inferred from which platform configuration is provided and cannot be set manually.
6970

7071
<a id="nestedatt--spec--platform_properties--aks"></a>
7172
### Nested Schema for `spec.platform_properties.aks`
@@ -298,3 +299,13 @@ Read-Only:
298299

299300
- `kind` (String) Must always be set to meshPlatform
300301
- `uuid` (String) UUID of the platform.
302+
303+
304+
305+
<a id="nestedatt--status"></a>
306+
### Nested Schema for `status`
307+
308+
Read-Only:
309+
310+
- `disabled` (Boolean) True if the landing zone is disabled.
311+
- `restricted` (Boolean) If true, users will be unable to select this landing zone in meshPanel. Only Platform teams can create tenants using restricted landing zones with the meshObject API.

docs/data-sources/platform.md

Lines changed: 675 additions & 0 deletions
Large diffs are not rendered by default.

docs/resources/platform.md

Lines changed: 853 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
data "meshstack_platform" "example" {
2+
metadata = {
3+
uuid = "d32951fc-6589-412f-b8bd-50c78fe2cb79"
4+
}
5+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# import via platform uuid (= meshStack Platform ID)
2+
terraform import meshstack_platform.example 09631015-0f06-4f6a-b459-03047fbd89d1
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
resource "meshstack_platform" "example" {
2+
metadata = {
3+
name = "my-azure-platform"
4+
owned_by_workspace = "my-workspace"
5+
}
6+
7+
spec = {
8+
display_name = "Azure"
9+
description = "Azure is the Public Cloud Service provided by Microsoft."
10+
endpoint = "https://azure.microsoft.com"
11+
documentation_url = "https://azure.microsoft.com"
12+
13+
location_ref = {
14+
name = "meshcloud-azure-dev"
15+
}
16+
17+
availability = {
18+
restriction = "PUBLIC"
19+
publication_state = "PUBLISHED"
20+
restricted_to_workspaces = []
21+
}
22+
23+
config = {
24+
azure = {
25+
entra_tenant = "dev-mycompany.onmicrosoft.com"
26+
27+
replication = {
28+
service_principal = {
29+
client_id = "58d6f907-7b0e-4fd8-b328-3e8342dddc8d"
30+
auth_type = "CREDENTIALS"
31+
credentials_auth_client_secret = "mesh/hidden-secret"
32+
object_id = "3c305efe-625d-4eaf-9bfa-b981ddbcc99f"
33+
}
34+
35+
provisioning = {
36+
subscription_owner_object_ids = [
37+
"2af5651f-bfa2-45b8-8780-f63dd51f515f"
38+
]
39+
40+
pre_provisioned = {
41+
unused_subscription_name_prefix = "unused-"
42+
}
43+
}
44+
45+
b2b_user_invitation = {
46+
redirect_url = "https://portal.azure.com/#home"
47+
send_azure_invitation_mail = false
48+
}
49+
50+
subscription_name_pattern = "#{workspaceIdentifier}.#{projectIdentifier}"
51+
group_name_pattern = "#{workspaceIdentifier}.#{projectIdentifier}-#{platformGroupAlias}"
52+
blueprint_service_principal = "ce0c3688-3247-4083-b49f-33fdbac1ea65"
53+
blueprint_location = "westeurope"
54+
55+
azure_role_mappings = [
56+
{
57+
project_role_ref = {
58+
name = "admin"
59+
}
60+
azure_role = {
61+
alias = "admin"
62+
id = "b69d42fd-1e97-47d0-958d-3ce50d18af71"
63+
}
64+
},
65+
{
66+
project_role_ref = {
67+
name = "reader"
68+
}
69+
azure_role = {
70+
alias = "reader"
71+
id = "9c4cbbde-f2da-479e-9709-0f9ca8fa69df"
72+
}
73+
},
74+
{
75+
project_role_ref = {
76+
name = "user"
77+
}
78+
azure_role = {
79+
alias = "user"
80+
id = "7eeffa89-84ca-4106-9677-c9206b2fc14d"
81+
}
82+
}
83+
]
84+
85+
tenant_tags = {
86+
namespace_prefix = "meshstack_"
87+
88+
tag_mappers = [
89+
{
90+
key = "wident"
91+
value_pattern = "$${workspaceIdentifier}"
92+
},
93+
{
94+
key = "pident"
95+
value_pattern = "prefix-$${projectIdentifier}"
96+
},
97+
{
98+
key = "pname"
99+
value_pattern = "$${projectName}"
100+
},
101+
{
102+
key = "wname"
103+
value_pattern = "$${workspaceName}"
104+
},
105+
{
106+
key = "paymentIdentifier"
107+
value_pattern = "$${paymentIdentifier}"
108+
},
109+
{
110+
key = "paymentName"
111+
value_pattern = "$${paymentName}"
112+
},
113+
{
114+
key = "paymentExpirationDate"
115+
value_pattern = "$${paymentExpirationDate}"
116+
}
117+
]
118+
}
119+
120+
user_look_up_strategy = "UserByMailLookupStrategy"
121+
skip_user_group_permission_cleanup = false
122+
allow_hierarchical_management_group_assignment = false
123+
}
124+
}
125+
}
126+
127+
contributing_workspaces = []
128+
}
129+
}

internal/provider/landingzone_data_source.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,24 +109,37 @@ func (d *landingZoneDataSource) Schema(_ context.Context, _ datasource.SchemaReq
109109
MarkdownDescription: "Platform-specific configuration options.",
110110
Computed: true,
111111
Attributes: map[string]schema.Attribute{
112-
"type": schema.StringAttribute{
113-
MarkdownDescription: "Type of the platform. One of `aws`, `aks`, `azure`, `azurerg`, `gcp`, `kubernetes`, `openshift`.",
114-
Computed: true,
115-
Validators: []validator.String{
116-
stringvalidator.OneOf([]string{"aws", "aks", "azure", "azurerg", "gcp", "kubernetes", "openshift"}...),
117-
},
118-
},
119112
"aws": awsPlatformConfigSchema(),
120113
"aks": aksPlatformConfigSchema(),
121114
"azure": azurePlatformConfigSchema(),
122115
"azurerg": azureRgPlatformConfigSchema(),
123116
"gcp": gcpPlatformConfigSchema(),
124117
"kubernetes": kubernetesPlatformConfigSchema(),
125118
"openshift": openShiftPlatformConfigSchema(),
119+
"type": schema.StringAttribute{
120+
MarkdownDescription: "Type of the platform. This field is automatically inferred from which platform configuration is provided and cannot be set manually.",
121+
Computed: true,
122+
},
126123
},
127124
},
128125
},
129126
},
127+
128+
"status": schema.SingleNestedAttribute{
129+
MarkdownDescription: "Current Landing Zone status.",
130+
Computed: true,
131+
Attributes: map[string]schema.Attribute{
132+
"disabled": schema.BoolAttribute{
133+
MarkdownDescription: "True if the landing zone is disabled.",
134+
Computed: true,
135+
},
136+
"restricted": schema.BoolAttribute{
137+
MarkdownDescription: "If true, users will be unable to select this landing zone in meshPanel. " +
138+
"Only Platform teams can create tenants using restricted landing zones with the meshObject API.",
139+
Computed: true,
140+
},
141+
},
142+
},
130143
},
131144
}
132145
}

internal/provider/landingzone_resource.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -438,28 +438,6 @@ func openShiftPlatformConfigSchema() schema.Attribute {
438438
}
439439
}
440440

441-
func meshProjectRoleAttribute() schema.SingleNestedAttribute {
442-
return schema.SingleNestedAttribute{
443-
MarkdownDescription: "the meshProject role",
444-
Required: true,
445-
Attributes: map[string]schema.Attribute{
446-
"name": schema.StringAttribute{
447-
Required: true,
448-
MarkdownDescription: "The identifier of the meshProjectRole",
449-
},
450-
"kind": schema.StringAttribute{
451-
MarkdownDescription: "meshObject type, always `meshProjectRole`.",
452-
Computed: true,
453-
Default: stringdefault.StaticString("meshProjectRole"),
454-
Validators: []validator.String{
455-
stringvalidator.OneOf([]string{"meshProjectRole"}...),
456-
},
457-
PlanModifiers: []planmodifier.String{stringplanmodifier.UseStateForUnknown()},
458-
},
459-
},
460-
}
461-
}
462-
463441
func (r *landingZoneResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) {
464442
landingZone := client.MeshLandingZoneCreate{
465443
Metadata: client.MeshLandingZoneMetadata{},

0 commit comments

Comments
 (0)