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.
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 AzureClients
- type Clients
- type GCPSQLAdminClient
- 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) 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) GetAzureCredential() (azcore.TokenCredential, error)
- func (c *TestCloudClients) GetAzureKubernetesClient(subscription string) (azure.AKSClient, 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) GetAzureSubscriptionClient() (*azure.SubscriptionClient, error)
- func (c *TestCloudClients) GetAzureVirtualMachinesClient(subscription string) (azure.VirtualMachinesClient, error)
- func (c *TestCloudClients) GetGCPIAMClient(ctx context.Context) (*gcpcredentials.IamCredentialsClient, error)
- func (c *TestCloudClients) GetGCPSQLAdminClient(ctx context.Context) (GCPSQLAdminClient, 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 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) }
AzureClients is an interface for Azure-specific API clients
type Clients ¶
type Clients interface { // GetAWSSession returns AWS session for the specified region. GetAWSSession(region 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) // 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) // GetGCPIAMClient returns GCP IAM client. GetGCPIAMClient(context.Context) (*gcpcredentials.IamCredentialsClient, error) // GetGCPSQLAdminClient returns GCP Cloud SQL Admin client. GetGCPSQLAdminClient(context.Context) (GCPSQLAdminClient, error) // GetInstanceMetadataClient returns instance metadata client based on which // cloud provider Teleport is running on, if any. GetInstanceMetadataClient(ctx context.Context) (InstanceMetadata, error) // 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 GCPSQLAdminClient ¶
type GCPSQLAdminClient interface { // UpdateUser updates an existing user for the project/instance configured in a session. UpdateUser(ctx context.Context, db types.Database, dbUser string, user *sqladmin.User) error // GetDatabaseInstance returns database instance details for the project/instance // configured in a session. GetDatabaseInstance(ctx context.Context, db types.Database) (*sqladmin.DatabaseInstance, error) // GenerateEphemeralCert returns a new client certificate with RSA key for the // project/instance configured in a session. GenerateEphemeralCert(ctx context.Context, db types.Database, identity tlsca.Identity) (*tls.Certificate, error) }
GCPSQLAdminClient defines an interface providing access to the GCP Cloud SQL API.
func NewGCPSQLAdminClient ¶
func NewGCPSQLAdminClient(ctx context.Context) (GCPSQLAdminClient, error)
NewGCPSQLAdminClient returns a GCPSQLAdminClient interface wrapping sqladmin.Service.
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 ElastiCache elasticacheiface.ElastiCacheAPI MemoryDB memorydbiface.MemoryDBAPI SecretsManager secretsmanageriface.SecretsManagerAPI IAM iamiface.IAMAPI STS stsiface.STSAPI GCPSQL GCPSQLAdminClient 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 }
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) 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) 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) 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) 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) 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) (GCPSQLAdminClient, 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.