generated from hashicorp/terraform-provider-scaffolding-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
feature/CU 86c57xgjy Support for Landing Zones in meshStack Terraform Provider #55
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
Merged
nroi
merged 13 commits into
main
from
feature/CU-86c57xgjy_Support-for-Landing-Zones-in-meshStack-Terraform-Provider
Sep 23, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7d8437b
chore: add terraform-provider-meshstack to .gitignore
nroi 31fb73b
chore: fix typo in workspace.go (paylod)
nroi d2c2d65
feat: support meshLandingZones
nroi f75c401
chore: fix capitalization: AWS -> Aws etc.
nroi 15aa925
fix: add missing landing zone status
nroi d08525a
chore: remove redundant MeshLandingZoneCreateMetadata
nroi 04bcff1
chore: remove incorrect statement from docs
nroi 8767363
chore: simplify reading of metadata
nroi 08b7adf
fix: fix landing zone status
nroi 34c4eae
feat: automatically set `type` inside platform_properties
nroi 4c15a7b
chore: remove obsolete info about `type`
nroi 2ee3d5b
chore: make `type` a read-only property
nroi 61f62b1
chore: remove explicit `type` in landing zone example
nroi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,7 @@ website/node_modules | |
| *.iml | ||
| *.test | ||
| *.iml | ||
| /terraform-provider-meshstack | ||
|
|
||
| website/vendor | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| package client | ||
|
|
||
| import ( | ||
| "bytes" | ||
| "encoding/json" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "net/url" | ||
| ) | ||
|
|
||
| const CONTENT_TYPE_LANDINGZONE = "application/vnd.meshcloud.api.meshlandingzone.v1-preview.hal+json" | ||
|
|
||
| type MeshLandingZone struct { | ||
| ApiVersion string `json:"apiVersion" tfsdk:"api_version"` | ||
| Kind string `json:"kind" tfsdk:"kind"` | ||
| Metadata MeshLandingZoneMetadata `json:"metadata" tfsdk:"metadata"` | ||
| Spec MeshLandingZoneSpec `json:"spec" tfsdk:"spec"` | ||
| Status MeshLandingZoneStatus `json:"status" tfsdk:"status"` | ||
| } | ||
|
|
||
| type MeshLandingZoneMetadata struct { | ||
| Name string `json:"name" tfsdk:"name"` | ||
| Tags map[string][]string `json:"tags" tfsdk:"tags"` | ||
| } | ||
|
|
||
| type MeshLandingZoneSpec struct { | ||
| DisplayName string `json:"displayName" tfsdk:"display_name"` | ||
| Description string `json:"description" tfsdk:"description"` | ||
| AutomateDeletionApproval bool `json:"automateDeletionApproval" tfsdk:"automate_deletion_approval"` | ||
| AutomateDeletionReplication bool `json:"automateDeletionReplication" tfsdk:"automate_deletion_replication"` | ||
| InfoLink string `json:"infoLink" tfsdk:"info_link"` | ||
| PlatformRef PlatformRef `json:"platformRef" tfsdk:"platform_ref"` | ||
| PlatformProperties *PlatformProperties `json:"platformProperties,omitempty" tfsdk:"platform_properties"` | ||
| } | ||
|
|
||
| type MeshLandingZoneStatus struct { | ||
| Disabled bool `json:"disabled" tfsdk:"disabled"` | ||
| Restricted bool `json:"restricted" tfsdk:"restricted"` | ||
| } | ||
|
|
||
| type PlatformRef struct { | ||
| Uuid string `json:"uuid" tfsdk:"uuid"` | ||
| Kind string `json:"kind" tfsdk:"kind"` | ||
| } | ||
|
|
||
| type PlatformProperties struct { | ||
| Type string `json:"type" tfsdk:"type"` | ||
| Aws *AwsPlatformProperties `json:"aws" tfsdk:"aws"` | ||
| Aks *AksPlatformProperties `json:"aks" tfsdk:"aks"` | ||
| Azure *AzurePlatformProperties `json:"azure" tfsdk:"azure"` | ||
| AzureRg *AzureRgPlatformProperties `json:"azurerg" tfsdk:"azurerg"` | ||
| Gcp *GcpPlatformProperties `json:"gcp" tfsdk:"gcp"` | ||
| Kubernetes *KubernetesPlatformProperties `json:"kubernetes" tfsdk:"kubernetes"` | ||
| OpenShift *OpenShiftPlatformProperties `json:"openshift" tfsdk:"openshift"` | ||
| } | ||
|
|
||
| type MeshLandingZoneCreate struct { | ||
| ApiVersion string `json:"apiVersion" tfsdk:"api_version"` | ||
| Metadata MeshLandingZoneMetadata `json:"metadata" tfsdk:"metadata"` | ||
| Spec MeshLandingZoneSpec `json:"spec" tfsdk:"spec"` | ||
| } | ||
|
|
||
| func (c *MeshStackProviderClient) urlForLandingZone(name string) *url.URL { | ||
| return c.endpoints.LandingZones.JoinPath(name) | ||
| } | ||
|
|
||
| func (c *MeshStackProviderClient) ReadLandingZone(name string) (*MeshLandingZone, error) { | ||
| targetUrl := c.urlForLandingZone(name) | ||
| req, err := http.NewRequest("GET", targetUrl.String(), nil) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| req.Header.Set("Accept", CONTENT_TYPE_LANDINGZONE) | ||
|
|
||
| res, err := c.doAuthenticatedRequest(req) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| defer res.Body.Close() | ||
|
|
||
| if res.StatusCode == http.StatusNotFound { | ||
| return nil, nil // Not found is not an error | ||
| } | ||
|
|
||
| data, err := io.ReadAll(res.Body) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if !isSuccessHTTPStatus(res) { | ||
| return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, data) | ||
| } | ||
|
|
||
| var landingZone MeshLandingZone | ||
| err = json.Unmarshal(data, &landingZone) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &landingZone, nil | ||
| } | ||
|
|
||
| func (c *MeshStackProviderClient) CreateLandingZone(landingZone *MeshLandingZoneCreate) (*MeshLandingZone, error) { | ||
| payload, err := json.Marshal(landingZone) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| req, err := http.NewRequest("POST", c.endpoints.LandingZones.String(), bytes.NewBuffer(payload)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| req.Header.Set("Content-Type", CONTENT_TYPE_LANDINGZONE) | ||
| req.Header.Set("Accept", CONTENT_TYPE_LANDINGZONE) | ||
|
|
||
| res, err := c.doAuthenticatedRequest(req) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| defer res.Body.Close() | ||
|
|
||
| data, err := io.ReadAll(res.Body) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if !isSuccessHTTPStatus(res) { | ||
| return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, data) | ||
| } | ||
|
|
||
| var createdLandingZone MeshLandingZone | ||
| err = json.Unmarshal(data, &createdLandingZone) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &createdLandingZone, nil | ||
| } | ||
|
|
||
| func (c *MeshStackProviderClient) UpdateLandingZone(name string, landingZone *MeshLandingZoneCreate) (*MeshLandingZone, error) { | ||
| targetUrl := c.urlForLandingZone(name) | ||
|
|
||
| payload, err := json.Marshal(landingZone) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| req, err := http.NewRequest("PUT", targetUrl.String(), bytes.NewBuffer(payload)) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| req.Header.Set("Content-Type", CONTENT_TYPE_LANDINGZONE) | ||
| req.Header.Set("Accept", CONTENT_TYPE_LANDINGZONE) | ||
|
|
||
| res, err := c.doAuthenticatedRequest(req) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| defer res.Body.Close() | ||
|
|
||
| data, err := io.ReadAll(res.Body) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| if !isSuccessHTTPStatus(res) { | ||
| return nil, fmt.Errorf("unexpected status code: %d, %s", res.StatusCode, data) | ||
| } | ||
|
|
||
| var updatedLandingZone MeshLandingZone | ||
| err = json.Unmarshal(data, &updatedLandingZone) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| return &updatedLandingZone, nil | ||
| } | ||
|
|
||
| func (c *MeshStackProviderClient) DeleteLandingZone(name string) error { | ||
| targetUrl := c.urlForLandingZone(name) | ||
| return c.deleteMeshObject(*targetUrl, 204) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package client | ||
|
|
||
| type AksPlatformProperties struct { | ||
| KubernetesRoleMappings []KubernetesRoleMapping `json:"kubernetesRoleMappings" tfsdk:"kubernetes_role_mappings"` | ||
| } | ||
|
|
||
| type KubernetesRoleMapping struct { | ||
| MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"` | ||
| PlatformRoles []string `json:"platformRoles" tfsdk:"platform_roles"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package client | ||
|
|
||
| type AwsPlatformProperties struct { | ||
| AwsTargetOrgUnitId string `json:"awsTargetOrgUnitId" tfsdk:"aws_target_org_unit_id"` | ||
| AwsEnrollAccount bool `json:"awsEnrollAccount" tfsdk:"aws_enroll_account"` | ||
| AwsLambdaArn *string `json:"awsLambdaArn" tfsdk:"aws_lambda_arn"` | ||
| AwsRoleMappings []AwsRoleMapping `json:"awsRoleMappings" tfsdk:"aws_role_mappings"` | ||
| } | ||
|
|
||
| type AwsRoleMapping struct { | ||
| MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"` | ||
| PlatformRole string `json:"platformRole" tfsdk:"platform_role"` | ||
| Policies []string `json:"policies" tfsdk:"policies"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package client | ||
|
|
||
| type AzurePlatformProperties struct { | ||
| AzureRoleMappings []AzureRoleMapping `json:"azureRoleMappings" tfsdk:"azure_role_mappings"` | ||
| AzureManagementGroupId string `json:"azureManagementGroupId" tfsdk:"azure_management_group_id"` | ||
| } | ||
|
|
||
| type AzureRoleMapping struct { | ||
| MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"` | ||
| AzureGroupSuffix string `json:"azureGroupSuffix" tfsdk:"azure_group_suffix"` | ||
| AzureRoleDefinitions []AzureRoleDefinition `json:"azureRoleDefinitions" tfsdk:"azure_role_definitions"` | ||
| } | ||
|
|
||
| type AzureRoleDefinition struct { | ||
| AzureRoleDefinitionId string `json:"azureRoleDefinitionId" tfsdk:"azure_role_definition_id"` | ||
| AbacCondition *string `json:"abacCondition" tfsdk:"abac_condition"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package client | ||
|
|
||
| type AzureRgPlatformProperties struct { | ||
| AzureRgLocation string `json:"azureRgLocation" tfsdk:"azure_rg_location"` | ||
| AzureRgRoleMappings []AzureRgRoleMapping `json:"azureRgRoleMappings" tfsdk:"azure_rg_role_mappings"` | ||
| AzureFunction *AzureFunction `json:"azureFunction,omitempty" tfsdk:"azure_function"` | ||
| } | ||
|
|
||
| type AzureRgRoleMapping struct { | ||
| MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"` | ||
| AzureGroupSuffix string `json:"azureGroupSuffix" tfsdk:"azure_group_suffix"` | ||
| AzureRoleDefinitionIds []string `json:"azureRoleDefinitionIds" tfsdk:"azure_role_definition_ids"` | ||
| } | ||
|
|
||
| type AzureFunction struct { | ||
| AzureFunctionUrl string `json:"azureFunctionUrl" tfsdk:"azure_function_url"` | ||
| AzureFunctionScope string `json:"azureFunctionScope" tfsdk:"azure_function_scope"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| package client | ||
|
|
||
| type GcpPlatformProperties struct { | ||
| GcpCloudFunctionUrl *string `json:"gcpCloudFunctionUrl,omitempty" tfsdk:"gcp_cloud_function_url"` | ||
| GcpFolderId *string `json:"gcpFolderId,omitempty" tfsdk:"gcp_folder_id"` | ||
| GcpRoleMappings []GcpRoleMapping `json:"gcpRoleMappings" tfsdk:"gcp_role_mappings"` | ||
| } | ||
|
|
||
| type GcpRoleMapping struct { | ||
| MeshProjectRoleRef MeshProjectRoleRefV2 `json:"projectRoleRef" tfsdk:"project_role_ref"` | ||
| PlatformRoles []string `json:"platformRoles" tfsdk:"platform_roles"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package client | ||
|
|
||
| type KubernetesPlatformProperties struct { | ||
| KubernetesRoleMappings []KubernetesRoleMapping `json:"kubernetesRoleMappings" tfsdk:"kubernetes_role_mappings"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package client | ||
|
|
||
| type OpenShiftPlatformProperties struct { | ||
| OpenShiftTemplate *string `json:"openShiftTemplate,omitempty" tfsdk:"openshift_template"` | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.