terraform

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 54 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// One hour is the maximum allowed by role chaining
	AWSRoleTokenDuration        = 1 * time.Hour
	AWSRoleTokenRefreshInterval = AWSRoleTokenDuration / 4
)

Durations for the expiry of the AWS Role credentials and for its refresh interval, which, out of an abundance of caution, is a quarter of the expiry duration of the role.

Variables

View Source
var (

	// Not found error
	ErrNotFound = fmt.Errorf("policy not found")
)

Functions

func Asset added in v1.28.0

func Asset(name string) ([]byte, error)

Asset returns the content of the embedded file

func AssetString added in v1.28.0

func AssetString(name string) (string, error)

AssetString returns the content of the embedded file as string

func MustAsset added in v1.28.0

func MustAsset(name string) []byte

MustAsset returns the content of the embedded file and panics on error

func MustAssetString added in v1.28.0

func MustAssetString(name string) string

MustAssetString returns the content of the embedded file as string and panics on error

func RestoreAssets added in v1.28.0

func RestoreAssets(dir, name string) error

RestoreAssets writes an embedded asset to the given directory

Types

type AlloyConfig added in v1.21.0

type AlloyConfig struct {
	Logging struct {
		Level string `alloy:"level,attr"`
	} `alloy:"logging,block"`

	PyroscopeWrite struct {
		Label    string `alloy:",label"`
		Endpoint struct {
			URL string `alloy:"url,attr"`
		} `alloy:"endpoint,block"`
	} `alloy:"pyroscope.write,block,optional"`

	PyroscopeScrape struct {
		Label           string                   `alloy:",label"`
		Targets         []PyroscopeTarget        `alloy:"targets,attr"`
		ForwardTo       []AlloyLiteralValue      `alloy:"forward_to,attr"`
		ProfilingConfig PyroscopeProfilingConfig `alloy:"profiling_config,block"`
	} `alloy:"pyroscope.scrape,block,optional"`
}

func NewAlloyConfig added in v1.21.0

func NewAlloyConfig(mmTargets, ltTargets []string) AlloyConfig

type AlloyLiteralValue added in v1.21.0

type AlloyLiteralValue string

func (AlloyLiteralValue) AlloyTokenize added in v1.21.0

func (s AlloyLiteralValue) AlloyTokenize() []builder.Token

type DBCluster

type DBCluster struct {
	Instances         []DBInstance `json:"instances"`
	ClusterIdentifier string       `json:"cluster_identifier"`
}

DBCluster defines a RDS cluster instance resource.

type DBInstance added in v1.22.0

type DBInstance struct {
	DBIdentifier string
	Endpoint     string
	IsWriter     bool
}

DBInstance defines an RDS instance resource.

type DashboardData added in v1.15.0

type DashboardData struct {
	Panels []PanelData
}

type EFSAccessPoint added in v1.29.0

type EFSAccessPoint struct {
	Id           string `json:"id"`
	FileSystemId string `json:"file_system_id"`
}

type ElasticSearchDomain

type ElasticSearchDomain struct {
	Endpoint string `json:"endpoint"`
	Tags     Tags   `json:"tags"`
}

ElasticSearchDomain is an AWS Elasticsearch domain.

type GeneratedValues added in v1.27.0

type GeneratedValues struct {
	GrafanaAdminPassword string `json:"GrafanaAdminPassword"`
}

GeneratedValues is a struct containing values generated automatically during the deployment, not user-defined.

func (GeneratedValues) Sanitize added in v1.27.0

func (v GeneratedValues) Sanitize() GeneratedValues

type IAMAccess

type IAMAccess struct {
	Id     string `json:"id"`
	Secret string `json:"secret"`
}

IAMAccess is a set of credentials that allow API requests to be made as an IAM user.

type Instance

type Instance struct {
	PrivateIP  string `json:"private_ip"`
	PublicIP   string `json:"public_ip"`
	PublicDNS  string `json:"public_dns"`
	PrivateDNS string `json:"private_dns"`
	Tags       Tags   `json:"tags"`
	// contains filtered or unexported fields
}

Instance is an AWS EC2 instance resource.

func (Instance) GetConnectionDNS added in v1.26.0

func (i Instance) GetConnectionDNS() string

GetConnectionDNS returns the DNS name to connect to the instance from the load-test runner which is either the public or private DNS name depending on the connection type set with `Instance.SetConnectionType`. Use this in pieces of the code the load-test deployer connects to the instance to perform deployment operations to ensure the correct one is used for both public and private deployments. For other usages where we know the kind of connection between the instance and other elements please use the specific DNS name needed (`PublicDNS`/`PrivateDNS`).

func (Instance) GetConnectionIP added in v1.26.0

func (i Instance) GetConnectionIP() string

GetConnectionIP returns the IP address to connect to the instance from the load-test runner which is either the public or private IP address depending on the connection type set with `Instance.SetConnectionType`. Use this in pieces of the code the load-test deployer connects to the instance to perform deployment operations to ensure the correct one is used for both public and private deployments. For other usages where we know the kind of connection between the instance and other elements please use the specific IP address needed (`PublicIP`/`PrivateIP`).

func (Instance) GetConnectionType added in v1.26.0

func (i Instance) GetConnectionType() string

func (*Instance) SetConnectionType added in v1.26.0

func (i *Instance) SetConnectionType(connType string)

type Output

type Output struct {
	ClusterName             string
	Proxies                 []Instance          `json:"proxies"`
	Instances               []Instance          `json:"instances"`
	DBCluster               DBCluster           `json:"dbCluster"`
	Agents                  []Instance          `json:"agents"`
	BrowserAgents           []Instance          `json:"browserAgents"`
	MetricsServer           Instance            `json:"metricsServer"`
	ElasticSearchServer     ElasticSearchDomain `json:"elasticServer"`
	ElasticSearchRoleARN    string              `json:"elasticRoleARN"`
	JobServers              []Instance          `json:"jobServers"`
	S3Bucket                S3Bucket            `json:"s3Bucket"`
	S3Key                   IAMAccess           `json:"s3Key"`
	DBSecurityGroup         []SecurityGroup     `json:"dbSecurityGroup"`
	KeycloakServer          Instance            `json:"keycloakServer"`
	KeycloakDatabaseCluster DBCluster           `json:"keycloakDatabaseCluster"`
	OpenLDAPServer          Instance            `json:"openldapServer"`
	RedisServer             RedisInstance       `json:"redisServer"`
	EFSAccessPoint          EFSAccessPoint      `json:"efsAccessPoint"`
	AMIUser                 string              `json:"amiUser"`
}

Output contains the output variables which are created after a deployment.

func (*Output) DBReaders added in v1.3.0

func (o *Output) DBReaders() []string

DBReaders returns the list of db reader endpoints.

func (*Output) DBWriter added in v1.3.0

func (o *Output) DBWriter() string

DBWriter returns the db writer endpoint.

func (*Output) HasAgents added in v1.10.0

func (o *Output) HasAgents() bool

HasAgents returns whether a deployment includes agent instances.

func (*Output) HasAppServers

func (o *Output) HasAppServers() bool

HasAppServers returns whether a deployment includes app server instances.

func (*Output) HasBrowserAgents added in v1.29.0

func (o *Output) HasBrowserAgents() bool

HasBrowserAgents returns whether a deployment includes browser agent instances.

func (*Output) HasDB added in v1.2.0

func (o *Output) HasDB() bool

HasDB returns whether a deployment has database installed in it or not.

func (*Output) HasEFS added in v1.29.0

func (o *Output) HasEFS() bool

func (*Output) HasElasticSearch

func (o *Output) HasElasticSearch() bool

HasElasticSearch returns whether a deployment has ElasticSaearch installed in it or not.

func (*Output) HasJobServer added in v1.3.0

func (o *Output) HasJobServer() bool

HasJobServer returns whether a deployment has a dedicated job server.

func (*Output) HasKeycloak added in v1.17.0

func (o *Output) HasKeycloak() bool

HasKeycloak returns whether a deployment has Keycloak installed in it or not.

func (*Output) HasMetrics

func (o *Output) HasMetrics() bool

HasMetrics returns whether a deployment includes the metrics instance.

func (*Output) HasOpenLDAP added in v1.29.0

func (o *Output) HasOpenLDAP() bool

HasOpenLDAP returns whether a deployment has OpenLDAP installed in it or not.

func (*Output) HasProxy

func (o *Output) HasProxy() bool

HasProxy returns whether a deployment has proxy installed in it or not.

func (*Output) HasRedis added in v1.20.0

func (o *Output) HasRedis() bool

HasRedis returns whether a deployment has Redis installed in it or not.

func (*Output) HasS3Bucket

func (o *Output) HasS3Bucket() bool

HasS3Bucket returns whether a deployment includes the S3 Bucket.

func (*Output) HasS3Key

func (o *Output) HasS3Key() bool

HasS3Key returns whether a deployment includes the S3 Key.

type PanelData added in v1.15.0

type PanelData struct {
	Id        int
	Title     string
	Legend    string
	Height    int
	Width     int
	PosX      int
	PosY      int
	Query     string
	Threshold float64
}

type PyroscopeConfig added in v1.11.0

type PyroscopeConfig struct {
	Server struct {
		HTTPListenPort int `yaml:"http_listen_port"`
	} `yaml:"server"`
	Limits struct {
		MaxQueryLookback model.Duration `yaml:"max_query_lookback"`
	} `yaml:"limits"`
	SelfProfiling struct {
		DisablePush bool `yaml:"disable_push"`
	} `yaml:"self_profiling"`
}

func NewPyroscopeConfig added in v1.11.0

func NewPyroscopeConfig() PyroscopeConfig

type PyroscopeProfilingConfig added in v1.21.0

type PyroscopeProfilingConfig struct {
	ProcessCPU struct {
		Enabled bool `alloy:"enabled,attr"`
	} `alloy:"profile.process_cpu,block"`
	Memory struct {
		Enabled bool `alloy:"enabled,attr"`
	} `alloy:"profile.memory,block"`
	Block struct {
		Enabled bool `alloy:"enabled,attr"`
	} `alloy:"profile.block,block"`
	Goroutine struct {
		Enabled bool `alloy:"enabled,attr"`
	} `alloy:"profile.goroutine,block"`
}

type PyroscopeTarget added in v1.21.0

type PyroscopeTarget struct {
	Address     string `alloy:"__address__,attr"`
	ServiceName string `alloy:"service_name,attr"`
}

type RedisInstance added in v1.20.0

type RedisInstance struct {
	Address string `json:"address"`
	Id      string `json:"id"`
	Port    int    `json:"port"`
}

type S3Bucket

type S3Bucket struct {
	Id     string `json:"id"`
	Region string `json:"region"`
}

S3Bucket defines a specific S3 bucket.

type SecurityGroup added in v1.10.0

type SecurityGroup struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

SecurityGroup is an AWS security group resource.

type Tags

type Tags struct {
	Name string `json:"Name"`
}

Tags are the values attached to resource.

type Terraform

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

Terraform manages all operations related to interacting with an AWS environment using Terraform.

func New

func New(id string, cfg deployment.Config) (*Terraform, error)

New returns a new Terraform instance.

func (*Terraform) ClearLicensesData added in v1.17.0

func (t *Terraform) ClearLicensesData() error

ClearLicensesData runs a SQL query to delete all data from old licenses in the database. It does it by first stopping the server, then running the query, then restarting the server again.

func (*Terraform) Config added in v1.3.0

func (t *Terraform) Config() *deployment.Config

Config returns the deployment config associated with the Terraform instance.

func (*Terraform) Create

func (t *Terraform) Create(extAgent *ssh.ExtAgent, initData bool) error

Create creates a new load test environment.

func (*Terraform) DBStatus added in v1.14.0

func (t *Terraform) DBStatus() (string, error)

DBStatus returns the status of the DB cluster.

func (*Terraform) Destroy

func (t *Terraform) Destroy() error

Destroy destroys the created load-test environment.

func (*Terraform) ExecuteCustomSQL added in v1.17.0

func (t *Terraform) ExecuteCustomSQL() error

ExecuteCustomSQL executes provided custom SQL files in the app instances.

func (*Terraform) ExpandWithUser added in v1.28.0

func (t *Terraform) ExpandWithUser(path string) string

ExpandWithUser replaces {{.Username}} in a path template with the provided username

func (*Terraform) GeneratedValues added in v1.27.0

func (t *Terraform) GeneratedValues() *GeneratedValues

func (*Terraform) GetAWSConfig added in v1.23.0

func (t *Terraform) GetAWSConfig() (aws.Config, error)

GetAWSConfig returns the AWS config, using the profile configured in the deployer if present, and defaulting to the default credential chain otherwise. If a role ARN is provided, it will assume that role.

func (*Terraform) GetAWSCreds added in v1.23.0

func (t *Terraform) GetAWSCreds() (aws.Credentials, error)

GetAWSCreds returns the AWS config, using the profile configured in the deployer if present, and defaulting to the default credential chain otherwise

func (*Terraform) GetCoordinatorStatus

func (t *Terraform) GetCoordinatorStatus() (coordinator.Status, error)

GetCoordinatorStatus returns information about the status of the coordinator in the current load-test deployment.

func (*Terraform) HasPendingRebootDBParams added in v1.25.0

func (t *Terraform) HasPendingRebootDBParams() (bool, error)

HasPendingRebootDBParams queries the deployed DB cluster and checks whether there is at least a DB instance whose status is "pending-reboot"

func (*Terraform) Info

func (t *Terraform) Info() error

Info displays information about the current load-test deployment.

func (*Terraform) IngestDump added in v1.10.0

func (t *Terraform) IngestDump() error

IngestDump works on an already deployed terraform setup and restores the DB dump file to the Mattermost server. It uses the deployment config for the dump URI.

func (*Terraform) IngestKeycloakDump added in v1.17.0

func (t *Terraform) IngestKeycloakDump() error

func (*Terraform) InitCreds added in v1.28.0

func (t *Terraform) InitCreds() error

InitCreds authenticates into AWS using the default credentials chain, optionally assuming the AWS role if its ARN is provided in the configuration. In that case, it also starts a goroutine that will refresh the credentials to maintain them updated.

func (*Terraform) InjectAction added in v1.10.0

func (t *Terraform) InjectAction(actionID string) (coordinator.Status, error)

InjectAction injects a named action for all agents that is run once.

func (*Terraform) OpenBrowserFor

func (t *Terraform) OpenBrowserFor(resource string) error

OpenBrowserFor opens a web browser for the resource

func (*Terraform) OpenSSHFor

func (t *Terraform) OpenSSHFor(resource string) error

OpenSSHFor starts a ssh connection to the resource

func (*Terraform) Output

func (t *Terraform) Output() (*Output, error)

Output reads the current terraform output and caches it internally for future use. The output is guaranteed to be up to date after calls to Create and Destroy.

func (*Terraform) PersistGeneratedValues added in v1.27.0

func (t *Terraform) PersistGeneratedValues() error

func (*Terraform) PostProcessDatabase added in v1.24.0

func (t *Terraform) PostProcessDatabase(extAgent *ssh.ExtAgent) error

func (*Terraform) ProvisionURL added in v1.30.0

func (t *Terraform) ProvisionURL(client *ssh.Client, url, filename string) (string, error)

ProvisionURL takes a URL pointing to a file to be provisioned. It works on both local files prefixed with file:// or remote files. In case of local files, they are uploaded to the server.

func (*Terraform) RebootDBInstances added in v1.25.0

func (t *Terraform) RebootDBInstances(extAgent *ssh.ExtAgent) error

RebootDBInstances reboots all deployed database instances, blocking the call until the status of each of them is back to "available"

func (*Terraform) RunSSHCommand added in v1.3.0

func (t *Terraform) RunSSHCommand(resource string, args []string) error

RunSSHCommand runs a command on a given machine.

func (*Terraform) StartCoordinator

func (t *Terraform) StartCoordinator(config *coordinator.Config) error

StartCoordinator starts the coordinator in the current load-test deployment.

func (*Terraform) StartDB added in v1.14.0

func (t *Terraform) StartDB() error

StartDB starts the DB cluster and syncs the changes.

func (*Terraform) StopCoordinator

func (t *Terraform) StopCoordinator() (coordinator.Status, error)

StopCoordinator stops the coordinator in the current load-test deployment.

func (*Terraform) StopDB added in v1.14.0

func (t *Terraform) StopDB() error

StopDB stops the DB cluster and syncs the changes.

func (*Terraform) Sync added in v1.3.0

func (t *Terraform) Sync() error

Sync runs a terraform sync with all the required parameters.

func (*Terraform) UploadDashboard added in v1.2.0

func (t *Terraform) UploadDashboard(dashboard string) (string, error)

UploadDashboard uploads the given dashboard to Grafana and returns its URL. Returns an error in case of failure.

Directories

Path Synopsis
Package ssh is a simple wrapper around an ssh.Client which implements utilities to be performed with a remote server.
Package ssh is a simple wrapper around an ssh.Client which implements utilities to be performed with a remote server.

Jump to

Keyboard shortcuts

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