alzlib

package module
v0.15.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 19 Imported by: 0

README

alzlib

Go test codecov

This module provides a go library for reading Azure Landing Zones Library definitions.

Installation

To install alzlib, use the following go get command:

go get -u github.com/Azure/alzlib

Usage

See the examples in the integrationtest/examples_test.go file for usage examples.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

Documentation

Overview

Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT License.

Package alzlib provides the data structures needed to deploy Azure Landing Zones. It contains the custom Azure policies and policy sets needed to deploy the reference architecture. It also gets the referenced built-in definitions from the Azure Policy service.

Internally the Azure SDK is used to store the resources in memory. It is up to the caller to transform this data into the required format for deployment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchAzureLandingZonesLibraryMember added in v0.14.0

func FetchAzureLandingZonesLibraryMember(ctx context.Context, member, tag, dst string) (fs.FS, error)

FetchAzureLandingZonesLibraryByTag is a convenience function to fetch the Azure Landing Zones library by member and tag. It calls FetchLibraryByGetterString with the appropriate URL. The destination directory will be appended to the .alzlib directory in the current working directory. To fetch the ALZ reference, supply "platform/alz" as the member, with the tag (e.g. 2024.03.03).

func FetchLibraryByGetterString added in v0.14.0

func FetchLibraryByGetterString(ctx context.Context, getterString, dstDir string) (fs.FS, error)

FetchLibraryByGetterString fetches a library from a URL using the go-getter library. The caller must supply a valid go-getter URL and a destination directory, which will be appended to the .alzlib directory in the current working directory. It returns an fs.FS interface to the fetched library to be used in the AlzLib.Init() method.

Types

type AlzLib

type AlzLib struct {
	Options *AlzLibOptions
	// contains filtered or unexported fields
}

AlzLib is the structure that gets built from the the library files do not create this directly, use NewAlzLib instead. Note: this is not thread safe, and should not be used concurrently without an external mutex.

func NewAlzLib

func NewAlzLib(opts *AlzLibOptions) *AlzLib

NewAlzLib returns a new instance of the alzlib library, optionally using the supplied directory for additional policy (set) definitions.

func (*AlzLib) AddPolicyAssignments added in v0.14.0

func (az *AlzLib) AddPolicyAssignments(pas ...*assets.PolicyAssignment) error

AddPolicyAssignments adds policy assignments to the AlzLib struct.

func (*AlzLib) AddPolicyClient

func (az *AlzLib) AddPolicyClient(client *armpolicy.ClientFactory)

AddPolicyClient adds an authenticated *armpolicy.ClientFactory to the AlzLib struct. This is needed to get policy objects from Azure.

func (*AlzLib) AddPolicyDefinitions added in v0.14.0

func (az *AlzLib) AddPolicyDefinitions(pds ...*assets.PolicyDefinition) error

AddPolicyDefinitions adds policy definitions to the AlzLib struct.

func (*AlzLib) AddPolicySetDefinitions added in v0.14.0

func (az *AlzLib) AddPolicySetDefinitions(psds ...*assets.PolicySetDefinition) error

AddPolicySetDefinitions adds policy set definitions to the AlzLib struct.

func (*AlzLib) AddRoleDefinitions added in v0.14.0

func (az *AlzLib) AddRoleDefinitions(rds ...*assets.RoleDefinition) error

AddRoleDefinitions adds role definitions to the AlzLib struct.

func (*AlzLib) Archetype added in v0.14.0

func (az *AlzLib) Archetype(name string) (*Archetype, error)

Archetype returns a copy of the requested archetype by name. The returned struct can be used as a parameter to the Deployment.AddManagementGroup method.

func (*AlzLib) Archetypes added in v0.14.0

func (az *AlzLib) Archetypes() []string

Archetypes returns a list of the archetypes in the AlzLib struct.

func (*AlzLib) Architecture added in v0.14.0

func (az *AlzLib) Architecture(name string) (*Architecture, error)

Architecture returns the requested architecture.

func (*AlzLib) GetDefinitionsFromAzure

func (az *AlzLib) GetDefinitionsFromAzure(ctx context.Context, pds []string) error

GetDefinitionsFromAzure takes a slice of strings containing Azure resource IDs of policy definitions and policy set definitions. It then fetches them from Azure if needed and adds them to the AlzLib struct. For set definitions we need to get all of them, even if they exist in AlzLib already because they can contain built-in definitions.

func (*AlzLib) Init

func (az *AlzLib) Init(ctx context.Context, libs ...fs.FS) error

Init processes ALZ libraries, supplied as fs.FS interfaces. Use FetchAzureLandingZonesLibraryMember to get the library from GitHub. It populates the struct with the results of the processing.

func (*AlzLib) PolicyAssignment added in v0.14.0

func (az *AlzLib) PolicyAssignment(name string) (*assets.PolicyAssignment, error)

GetPolicySetDefinition returns a deep copy of the requested policy set definition. This is safe to modify without affecting the original.

func (*AlzLib) PolicyAssignmentExists

func (az *AlzLib) PolicyAssignmentExists(name string) bool

PolicyAssignmentExists returns true if the policy assignment exists in the AlzLib struct.

func (*AlzLib) PolicyDefinition added in v0.14.0

func (az *AlzLib) PolicyDefinition(name string) (*assets.PolicyDefinition, error)

PolicyDefinition returns a deep copy of the requested policy definition. This is safe to modify without affecting the original.

func (*AlzLib) PolicyDefinitionExists

func (az *AlzLib) PolicyDefinitionExists(name string) bool

PolicyDefinitionExists returns true if the policy definition exists in the AlzLib struct.

func (*AlzLib) PolicySetDefinition added in v0.14.0

func (az *AlzLib) PolicySetDefinition(name string) (*assets.PolicySetDefinition, error)

PolicySetDefinition returns a deep copy of the requested policy set definition. This is safe to modify without affecting the original.

func (*AlzLib) PolicySetDefinitionExists

func (az *AlzLib) PolicySetDefinitionExists(name string) bool

PolicySetDefinitionExists returns true if the policy set definition exists in the AlzLib struct.

func (*AlzLib) RoleDefinition added in v0.14.0

func (az *AlzLib) RoleDefinition(name string) (*assets.RoleDefinition, error)

RoleDefinition returns a deep copy of the requested role definition. This is safe to modify without affecting the original.

func (*AlzLib) RoleDefinitionExists

func (az *AlzLib) RoleDefinitionExists(name string) bool

RoleDefinitionExists returns true if the role definition exists in the AlzLib struct.

type AlzLibOptions

type AlzLibOptions struct {
	AllowOverwrite bool // AllowOverwrite allows overwriting of existing policy assignments when processing additional libraries with AlzLib.Init()
	Parallelism    int  // Parallelism is the number of parallel requests to make to Azure APIs
}

AlzLibOptions are options for the AlzLib. This is created by NewAlzLib.

type Archetype

type Archetype struct {
	PolicyDefinitions    mapset.Set[string]
	PolicyAssignments    mapset.Set[string]
	PolicySetDefinitions mapset.Set[string]
	RoleDefinitions      mapset.Set[string]
	// contains filtered or unexported fields
}

Archetype represents the exported archetype definition that hasn't been assigned to a management group The contents of the sets represent the map keys of the corresponding AlzLib maps.

func NewArchetype added in v0.14.0

func NewArchetype(name string) *Archetype

func (*Archetype) Name added in v0.14.0

func (a *Archetype) Name() string

type Architecture added in v0.14.0

type Architecture struct {
	// contains filtered or unexported fields
}

func NewArchitecture added in v0.14.0

func NewArchitecture(name string, az *AlzLib) *Architecture

func (*Architecture) RootMgs added in v0.14.0

func (a *Architecture) RootMgs() (res []*ArchitectureManagementGroup)

type ArchitectureManagementGroup added in v0.14.0

type ArchitectureManagementGroup struct {
	// contains filtered or unexported fields
}

func (*ArchitectureManagementGroup) Archetypes added in v0.14.0

func (mg *ArchitectureManagementGroup) Archetypes() (res []*Archetype)

func (*ArchitectureManagementGroup) Children added in v0.14.0

func (*ArchitectureManagementGroup) DisplayName added in v0.14.0

func (mg *ArchitectureManagementGroup) DisplayName() string

func (*ArchitectureManagementGroup) Id added in v0.14.0

Directories

Path Synopsis
package assets provides the types used by the Alzlib library.
package assets provides the types used by the Alzlib library.
Package deployment contains the types and methods for managing the deployment of an Azure management group hierarchy using the supplied Alzlib.
Package deployment contains the types and methods for managing the deployment of an Azure management group hierarchy using the supplied Alzlib.
package processor is used to process the library files and read them into a result struct for Alzlib to use.
package processor is used to process the library files and read them into a result struct for Alzlib to use.
Package to contains various type-conversion helper functions.
Package to contains various type-conversion helper functions.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL