Documentation ¶
Overview ¶
Package cloud contains common methods and utilities for integrations with various cloud providers such as AWS, GCP or Azure.
Copyright 2022 Gravitational, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- type AWSClients
- type AzureClients
- type Clients
- type InstanceMetadata
- type TestCloudClients
- func (c *TestCloudClients) Close() error
- func (c *TestCloudClients) GetAWSEC2Client(region string) (ec2iface.EC2API, error)
- func (c *TestCloudClients) GetAWSEKSClient(region string) (eksiface.EKSAPI, error)
- func (c *TestCloudClients) GetAWSElastiCacheClient(region string) (elasticacheiface.ElastiCacheAPI, error)
- func (c *TestCloudClients) GetAWSIAMClient(region string) (iamiface.IAMAPI, error)
- func (c *TestCloudClients) GetAWSMemoryDBClient(region string) (memorydbiface.MemoryDBAPI, error)
- func (c *TestCloudClients) GetAWSRDSClient(region string) (rdsiface.RDSAPI, error)
- func (c *TestCloudClients) GetAWSRedshiftClient(region string) (redshiftiface.RedshiftAPI, error)
- func (c *TestCloudClients) GetAWSRedshiftServerlessClient(region string) (redshiftserverlessiface.RedshiftServerlessAPI, error)
- func (c *TestCloudClients) GetAWSRedshiftServerlessClientForRole(ctx context.Context, region, roleARN string) (redshiftserverlessiface.RedshiftServerlessAPI, error)
- func (c *TestCloudClients) GetAWSSSMClient(region string) (ssmiface.SSMAPI, error)
- func (c *TestCloudClients) GetAWSSTSClient(region string) (stsiface.STSAPI, error)
- func (c *TestCloudClients) GetAWSSecretsManagerClient(region string) (secretsmanageriface.SecretsManagerAPI, error)
- func (c *TestCloudClients) GetAWSSession(region string) (*awssession.Session, error)
- func (c *TestCloudClients) GetAWSSessionForRole(ctx context.Context, region, roleARN string) (*awssession.Session, error)
- func (c *TestCloudClients) GetAzureCredential() (azcore.TokenCredential, error)
- func (c *TestCloudClients) GetAzureKubernetesClient(subscription string) (azure.AKSClient, error)
- func (c *TestCloudClients) GetAzureManagedSQLServerClient(subscription string) (azure.ManagedSQLServerClient, error)
- func (c *TestCloudClients) GetAzureMySQLClient(subscription string) (azure.DBServersClient, error)
- func (c *TestCloudClients) GetAzurePostgresClient(subscription string) (azure.DBServersClient, error)
- func (c *TestCloudClients) GetAzureRedisClient(subscription string) (azure.RedisClient, error)
- func (c *TestCloudClients) GetAzureRedisEnterpriseClient(subscription string) (azure.RedisEnterpriseClient, error)
- func (c *TestCloudClients) GetAzureSQLServerClient(subscription string) (azure.SQLServerClient, error)
- func (c *TestCloudClients) GetAzureSubscriptionClient() (*azure.SubscriptionClient, error)
- func (c *TestCloudClients) GetAzureVirtualMachinesClient(subscription string) (azure.VirtualMachinesClient, error)
- func (c *TestCloudClients) GetGCPGKEClient(ctx context.Context) (gcp.GKEClient, error)
- func (c *TestCloudClients) GetGCPIAMClient(ctx context.Context) (*gcpcredentials.IamCredentialsClient, error)
- func (c *TestCloudClients) GetGCPSQLAdminClient(ctx context.Context) (gcp.SQLAdminClient, error)
- func (c *TestCloudClients) GetInstanceMetadataClient(ctx context.Context) (InstanceMetadata, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AWSClients ¶
type AWSClients interface { // GetAWSSession returns AWS session for the specified region. GetAWSSession(region string) (*awssession.Session, error) // GetAWSSessionForRole returns AWS session for the specified role ARN. GetAWSSessionForRole(ctx context.Context, region, roleARN string) (*awssession.Session, error) // GetAWSRDSClient returns AWS RDS client for the specified region. GetAWSRDSClient(region string) (rdsiface.RDSAPI, error) // GetAWSRedshiftClient returns AWS Redshift client for the specified region. GetAWSRedshiftClient(region string) (redshiftiface.RedshiftAPI, error) // GetAWSRedshiftServerlessClient returns AWS Redshift Serverless client for the specified region. GetAWSRedshiftServerlessClient(region string) (redshiftserverlessiface.RedshiftServerlessAPI, error) // GetAWSRedshiftServerlessClientForRole returns AWS Redshift Serverless client for the specified region and role ARN. GetAWSRedshiftServerlessClientForRole(ctx context.Context, region, roleARN string) (redshiftserverlessiface.RedshiftServerlessAPI, error) // GetAWSElastiCacheClient returns AWS ElastiCache client for the specified region. GetAWSElastiCacheClient(region string) (elasticacheiface.ElastiCacheAPI, error) // GetAWSMemoryDBClient returns AWS MemoryDB client for the specified region. GetAWSMemoryDBClient(region string) (memorydbiface.MemoryDBAPI, error) // GetAWSSecretsManagerClient returns AWS Secrets Manager client for the specified region. GetAWSSecretsManagerClient(region string) (secretsmanageriface.SecretsManagerAPI, error) // GetAWSIAMClient returns AWS IAM client for the specified region. GetAWSIAMClient(region string) (iamiface.IAMAPI, error) // GetAWSSTSClient returns AWS STS client for the specified region. GetAWSSTSClient(region string) (stsiface.STSAPI, error) // GetAWSEC2Client returns AWS EC2 client for the specified region. GetAWSEC2Client(region string) (ec2iface.EC2API, error) // GetAWSSSMClient returns AWS SSM client for the specified region. GetAWSSSMClient(region string) (ssmiface.SSMAPI, error) // GetAWSEKSClient returns AWS EKS client for the specified region. GetAWSEKSClient(region string) (eksiface.EKSAPI, error) }
AWSClients is an interface for providing AWS API clients.
type AzureClients ¶
type AzureClients interface { // GetAzureCredential returns Azure default token credential chain. GetAzureCredential() (azcore.TokenCredential, error) // GetAzureMySQLClient returns Azure MySQL client for the specified subscription. GetAzureMySQLClient(subscription string) (azure.DBServersClient, error) // GetAzurePostgresClient returns Azure Postgres client for the specified subscription. GetAzurePostgresClient(subscription string) (azure.DBServersClient, error) // GetAzureSubscriptionClient returns an Azure Subscriptions client GetAzureSubscriptionClient() (*azure.SubscriptionClient, error) // GetAzureRedisClient returns an Azure Redis client for the given subscription. GetAzureRedisClient(subscription string) (azure.RedisClient, error) // GetAzureRedisEnterpriseClient returns an Azure Redis Enterprise client for the given subscription. GetAzureRedisEnterpriseClient(subscription string) (azure.RedisEnterpriseClient, error) // GetAzureKubernetesClient returns an Azure AKS client for the specified subscription. GetAzureKubernetesClient(subscription string) (azure.AKSClient, error) // GetAzureVirtualMachinesClient returns an Azure Virtual Machines client for the given subscription. GetAzureVirtualMachinesClient(subscription string) (azure.VirtualMachinesClient, error) // GetAzureSQLServerClient returns an Azure SQL Server client for the // specified subscription. GetAzureSQLServerClient(subscription string) (azure.SQLServerClient, error) // GetAzureManagedSQLServerClient returns an Azure ManagedSQL Server client // for the specified subscription. GetAzureManagedSQLServerClient(subscription string) (azure.ManagedSQLServerClient, error) }
AzureClients is an interface for Azure-specific API clients
type Clients ¶
type Clients interface { // GetGCPIAMClient returns GCP IAM client. GetGCPIAMClient(context.Context) (*gcpcredentials.IamCredentialsClient, error) // GetGCPSQLAdminClient returns GCP Cloud SQL Admin client. GetGCPSQLAdminClient(context.Context) (gcp.SQLAdminClient, error) // GetInstanceMetadataClient returns instance metadata client based on which // cloud provider Teleport is running on, if any. GetInstanceMetadataClient(ctx context.Context) (InstanceMetadata, error) // GetGCPGKEClient returns GKE client. GetGCPGKEClient(context.Context) (gcp.GKEClient, error) // AWSClients is an interface for providing AWS API clients. AWSClients // AzureClients is an interface for Azure-specific API clients AzureClients // Closer closes all initialized clients. io.Closer }
Clients provides interface for obtaining cloud provider clients.
func NewClients ¶
func NewClients() Clients
NewClients returns a new instance of cloud clients retriever.
type InstanceMetadata ¶
type InstanceMetadata interface { // IsAvailable checks if instance metadata is available. IsAvailable(ctx context.Context) bool // GetTags gets all of the instance's tags. GetTags(ctx context.Context) (map[string]string, error) // GetHostname gets the hostname set by the cloud instance that Teleport // should use, if any. GetHostname(ctx context.Context) (string, error) // GetType gets the cloud instance type. GetType() types.InstanceMetadataType // GetID gets the cloud instance ID. GetID(ctx context.Context) (string, error) }
InstanceMetadata is an interface for fetching information from a cloud service's instance metadata.
func DiscoverInstanceMetadata ¶
func DiscoverInstanceMetadata(ctx context.Context) (InstanceMetadata, error)
DiscoverInstanceMetadata checks which cloud instance type Teleport is running on, if any.
type TestCloudClients ¶
type TestCloudClients struct { RDS rdsiface.RDSAPI RDSPerRegion map[string]rdsiface.RDSAPI Redshift redshiftiface.RedshiftAPI RedshiftServerless redshiftserverlessiface.RedshiftServerlessAPI ElastiCache elasticacheiface.ElastiCacheAPI MemoryDB memorydbiface.MemoryDBAPI SecretsManager secretsmanageriface.SecretsManagerAPI IAM iamiface.IAMAPI STS stsiface.STSAPI GCPSQL gcp.SQLAdminClient GCPGKE gcp.GKEClient EC2 ec2iface.EC2API SSM ssmiface.SSMAPI InstanceMetadata InstanceMetadata EKS eksiface.EKSAPI AzureMySQL azure.DBServersClient AzureMySQLPerSub map[string]azure.DBServersClient AzurePostgres azure.DBServersClient AzurePostgresPerSub map[string]azure.DBServersClient AzureSubscriptionClient *azure.SubscriptionClient AzureRedis azure.RedisClient AzureRedisEnterprise azure.RedisEnterpriseClient AzureAKSClientPerSub map[string]azure.AKSClient AzureAKSClient azure.AKSClient AzureVirtualMachines azure.VirtualMachinesClient AzureSQLServer azure.SQLServerClient AzureManagedSQLServer azure.ManagedSQLServerClient }
TestCloudClients are used in tests.
func (*TestCloudClients) Close ¶
func (c *TestCloudClients) Close() error
Close closes all initialized clients.
func (*TestCloudClients) GetAWSEC2Client ¶
func (c *TestCloudClients) GetAWSEC2Client(region string) (ec2iface.EC2API, error)
GetAWSEC2Client returns AWS EC2 client for the specified region.
func (*TestCloudClients) GetAWSEKSClient ¶
func (c *TestCloudClients) GetAWSEKSClient(region string) (eksiface.EKSAPI, error)
GetAWSEKSClient returns AWS EKS client for the specified region.
func (*TestCloudClients) GetAWSElastiCacheClient ¶
func (c *TestCloudClients) GetAWSElastiCacheClient(region string) (elasticacheiface.ElastiCacheAPI, error)
GetAWSElastiCacheClient returns AWS ElastiCache client for the specified region.
func (*TestCloudClients) GetAWSIAMClient ¶
func (c *TestCloudClients) GetAWSIAMClient(region string) (iamiface.IAMAPI, error)
GetAWSIAMClient returns AWS IAM client for the specified region.
func (*TestCloudClients) GetAWSMemoryDBClient ¶
func (c *TestCloudClients) GetAWSMemoryDBClient(region string) (memorydbiface.MemoryDBAPI, error)
GetAWSMemoryDBClient returns AWS MemoryDB client for the specified region.
func (*TestCloudClients) GetAWSRDSClient ¶
func (c *TestCloudClients) GetAWSRDSClient(region string) (rdsiface.RDSAPI, error)
GetAWSRDSClient returns AWS RDS client for the specified region.
func (*TestCloudClients) GetAWSRedshiftClient ¶
func (c *TestCloudClients) GetAWSRedshiftClient(region string) (redshiftiface.RedshiftAPI, error)
GetAWSRedshiftClient returns AWS Redshift client for the specified region.
func (*TestCloudClients) GetAWSRedshiftServerlessClient ¶
func (c *TestCloudClients) GetAWSRedshiftServerlessClient(region string) (redshiftserverlessiface.RedshiftServerlessAPI, error)
GetAWSRedshiftServerlessClient returns AWS Redshift Serverless client for the specified region.
func (*TestCloudClients) GetAWSRedshiftServerlessClientForRole ¶
func (c *TestCloudClients) GetAWSRedshiftServerlessClientForRole(ctx context.Context, region, roleARN string) (redshiftserverlessiface.RedshiftServerlessAPI, error)
GetAWSRedshiftServerlessClientForRole returns AWS Redshift Serverless client for the specified region and role ARN.
func (*TestCloudClients) GetAWSSSMClient ¶
func (c *TestCloudClients) GetAWSSSMClient(region string) (ssmiface.SSMAPI, error)
GetAWSSSMClient returns an AWS SSM client
func (*TestCloudClients) GetAWSSTSClient ¶
func (c *TestCloudClients) GetAWSSTSClient(region string) (stsiface.STSAPI, error)
GetAWSSTSClient returns AWS STS client for the specified region.
func (*TestCloudClients) GetAWSSecretsManagerClient ¶
func (c *TestCloudClients) GetAWSSecretsManagerClient(region string) (secretsmanageriface.SecretsManagerAPI, error)
GetAWSSecretsManagerClient returns AWS Secrets Manager client for the specified region.
func (*TestCloudClients) GetAWSSession ¶
func (c *TestCloudClients) GetAWSSession(region string) (*awssession.Session, error)
GetAWSSession returns AWS session for the specified region.
func (*TestCloudClients) GetAWSSessionForRole ¶
func (c *TestCloudClients) GetAWSSessionForRole(ctx context.Context, region, roleARN string) (*awssession.Session, error)
GetAWSSessionForRole returns AWS session for the specified role ARN.
func (*TestCloudClients) GetAzureCredential ¶
func (c *TestCloudClients) GetAzureCredential() (azcore.TokenCredential, error)
GetAzureCredential returns default Azure token credential chain.
func (*TestCloudClients) GetAzureKubernetesClient ¶
func (c *TestCloudClients) GetAzureKubernetesClient(subscription string) (azure.AKSClient, error)
GetAzureKubernetesClient returns an AKS client for the specified subscription
func (*TestCloudClients) GetAzureManagedSQLServerClient ¶
func (c *TestCloudClients) GetAzureManagedSQLServerClient(subscription string) (azure.ManagedSQLServerClient, error)
GetAzureManagedSQLServerClient returns an Azure client for listing managed SQL servers.
func (*TestCloudClients) GetAzureMySQLClient ¶
func (c *TestCloudClients) GetAzureMySQLClient(subscription string) (azure.DBServersClient, error)
GetAzureMySQLClient returns an AzureMySQLClient for the specified subscription
func (*TestCloudClients) GetAzurePostgresClient ¶
func (c *TestCloudClients) GetAzurePostgresClient(subscription string) (azure.DBServersClient, error)
GetAzurePostgresClient returns an AzurePostgresClient for the specified subscription
func (*TestCloudClients) GetAzureRedisClient ¶
func (c *TestCloudClients) GetAzureRedisClient(subscription string) (azure.RedisClient, error)
GetAzureRedisClient returns an Azure Redis client for the given subscription.
func (*TestCloudClients) GetAzureRedisEnterpriseClient ¶
func (c *TestCloudClients) GetAzureRedisEnterpriseClient(subscription string) (azure.RedisEnterpriseClient, error)
GetAzureRedisEnterpriseClient returns an Azure Redis Enterprise client for the given subscription.
func (*TestCloudClients) GetAzureSQLServerClient ¶
func (c *TestCloudClients) GetAzureSQLServerClient(subscription string) (azure.SQLServerClient, error)
GetAzureSQLServerClient returns an Azure client for listing SQL servers.
func (*TestCloudClients) GetAzureSubscriptionClient ¶
func (c *TestCloudClients) GetAzureSubscriptionClient() (*azure.SubscriptionClient, error)
GetAzureSubscriptionClient returns an Azure SubscriptionClient
func (*TestCloudClients) GetAzureVirtualMachinesClient ¶
func (c *TestCloudClients) GetAzureVirtualMachinesClient(subscription string) (azure.VirtualMachinesClient, error)
GetAzureVirtualMachinesClient returns an Azure Virtual Machines client for the given subscription.
func (*TestCloudClients) GetGCPGKEClient ¶
GetGCPGKEClient returns GKE client.
func (*TestCloudClients) GetGCPIAMClient ¶
func (c *TestCloudClients) GetGCPIAMClient(ctx context.Context) (*gcpcredentials.IamCredentialsClient, error)
GetGCPIAMClient returns GCP IAM client.
func (*TestCloudClients) GetGCPSQLAdminClient ¶
func (c *TestCloudClients) GetGCPSQLAdminClient(ctx context.Context) (gcp.SQLAdminClient, error)
GetGCPSQLAdminClient returns GCP Cloud SQL Admin client.
func (*TestCloudClients) GetInstanceMetadataClient ¶
func (c *TestCloudClients) GetInstanceMetadataClient(ctx context.Context) (InstanceMetadata, error)
GetInstanceMetadata returns the instance metadata.