Documentation ¶
Index ¶
- type RecipeParams
- type RequiredProviderInfo
- type TFModuleConfig
- type TerraformConfig
- func (cfg *TerraformConfig) AddOutputs(localModuleName string) error
- func (cfg *TerraformConfig) AddProviders(ctx context.Context, requiredProviders map[string]*RequiredProviderInfo, ...) error
- func (cfg *TerraformConfig) AddRecipeContext(ctx context.Context, moduleName string, recipeCtx *recipecontext.Context) error
- func (cfg *TerraformConfig) AddTerraformBackend(resourceRecipe *recipes.ResourceMetadata, backend backends.Backend) (map[string]any, error)
- func (cfg *TerraformConfig) Save(ctx context.Context, workingDir string) error
- type TerraformDefinition
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RecipeParams ¶
RecipeParams is the map of recipe parameters and its values.
type RequiredProviderInfo ¶ added in v0.34.0
type RequiredProviderInfo struct { Source string `json:"source,omitempty"` // The source of the provider. Version string `json:"version,omitempty"` // The version of the provider. ConfigurationAliases []string `json:"configuration_aliases,omitempty"` // The configuration aliases for the provider. }
RequiredProviderInfo represents details for a provider listed under the required_providers block in a Terraform module. The json serialised json field names reflect the fieldnames expected in the terraform configuration file. ref: https://developer.hashicorp.com/terraform/language/providers/configuration
type TFModuleConfig ¶
TFModuleConfig is the type of Terraform module configuration.
func (TFModuleConfig) SetParams ¶
func (tf TFModuleConfig) SetParams(params RecipeParams)
SetParams sets the recipe parameters in the Terraform module configuration.
type TerraformConfig ¶
type TerraformConfig struct { // Terraform represents number of settings related to Terraform's behavior. Terraform *TerraformDefinition `json:"terraform"` // Provider represents the the configuration for Terraform providers. // The key of the map is a string that represents the name of the provider. // The value is a slice of maps, where each map represents a specific configuration for the provider. // Each configuration map has string keys and values of any type. // This structure allows for multiple configurations per provider. // // For example: // { // "aws": [ // { // "region": "us-west-2", // "version": "3.0" // }, // { // "alias": "east", // "region": "us-east-1" // } // ], // "azurerm": [ // { // "tenant": "my-tenantId", // "subscription_id": "my-subscriptionId" // } // ] // } // // In this example, there are two providers: "aws" and "azurerm". // The "aws" provider has two configurations: one for the "us-west-2" region and another for the "us-east-1" region with an alias "east". // The "azurerm" provider has one configuration. // // For more information on Terraform provider configuration, refer to: // https://developer.hashicorp.com/terraform/language/providers/configuration // https://developer.hashicorp.com/terraform/language/syntax/json#provider-blocks Provider map[string][]map[string]any `json:"provider,omitempty"` // Module is the Terraform module configuration. // https://developer.hashicorp.com/terraform/language/modules/syntax Module map[string]TFModuleConfig `json:"module"` // Output is the Terraform output configuration. // https://developer.hashicorp.com/terraform/language/values/outputs Output map[string]any `json:"output,omitempty"` }
TerraformConfig represents the Terraform configuration file structure for properties populated in the configuration by Radius.
func New ¶
func New(ctx context.Context, moduleName string, envRecipe *recipes.EnvironmentDefinition, resourceRecipe *recipes.ResourceMetadata) (*TerraformConfig, error)
New creates TerraformConfig with the given module name and its inputs (module source, version, parameters) Parameters are populated from environment recipe and resource recipe metadata.
func (*TerraformConfig) AddOutputs ¶
func (cfg *TerraformConfig) AddOutputs(localModuleName string) error
Add outputs to the config file referencing module outputs to populate expected Radius resource outputs. Outputs of modules are accessible through this format: module.<MODULE NAME>.<OUTPUT NAME> https://developer.hashicorp.com/terraform/language/modules/syntax#accessing-module-output-values This function only updates config in memory, Save() must be called to persist the updated config.
func (*TerraformConfig) AddProviders ¶
func (cfg *TerraformConfig) AddProviders(ctx context.Context, requiredProviders map[string]*RequiredProviderInfo, ucpConfiguredProviders map[string]providers.Provider, envConfig *recipes.Configuration, secrets map[string]recipes.SecretData) error
AddProviders adds provider configurations to Terraform configuration file based on input of environment recipe configuration, requiredProviders and ucpConfiguredProviders. It also updates module provider block if aliases exist and required_provider configuration to the file. Save() must be called to save the generated providers config. requiredProviders contains a list of provider names that are required for the module.
func (*TerraformConfig) AddRecipeContext ¶
func (cfg *TerraformConfig) AddRecipeContext(ctx context.Context, moduleName string, recipeCtx *recipecontext.Context) error
AddRecipeContext adds RecipeContext to TerraformConfig module parameters if recipeCtx is not nil. Save() must be called after adding recipe context to the module config.
func (*TerraformConfig) AddTerraformBackend ¶
func (cfg *TerraformConfig) AddTerraformBackend(resourceRecipe *recipes.ResourceMetadata, backend backends.Backend) (map[string]any, error)
AddTerraformBackend adds backend configurations to store Terraform state file for the deployment. Save() must be called to save the generated backend config. Currently, the supported backend for Terraform Recipes is Kubernetes secret. https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes
type TerraformDefinition ¶
type TerraformDefinition struct { // Backend defines where Terraform stores its state. // https://developer.hashicorp.com/terraform/language/state Backend map[string]interface{} `json:"backend"` // RequiredProviders is the list of required Terraform providers. // The json serialised json field name reflects the fieldname "required_providers" expected // in the terraform configuration file. // ref: https://developer.hashicorp.com/terraform/language/providers/configuration RequiredProviders map[string]*RequiredProviderInfo `json:"required_providers,omitempty"` }