aws

package
v0.0.0-...-d0f8ddb Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Winrm port for https request
	WINRM_PORT = 5986
)

Constant value

Variables

This section is empty.

Functions

func GetMyIp

func GetMyIp() (string, error)

GetMyIp get the external IP of user's machine from https://checkip.amazonaws.com and returns an address or an error. The 'checkip' service is maintained by Amazon. This function is exposed for testing purpose.

Types

type AwsProvider

type AwsProvider struct {

	// A client for EC2.
	EC2 *ec2.EC2
	// A client for IAM.
	IAM *iam.IAM
	// contains filtered or unexported fields
}

awsProvider is a provider specific struct which contains clients for EC2, IAM, and the existing OpenShift cluster that is running on EC2. This is an implementation of the Cloud interface. TODO: Move this into top level `pkg/types` so that we will have all the types needed across all cloud providers instead of relying on importing individual packages

func New

func New(openShiftClient *client.OpenShift, imageID, instanceType, sshKey, credentialPath, credentialAccountID,
	resourceTrackerDir, privateKeyPath string) (*AwsProvider, error)

New returns the AWS implementations of the Cloud interface with AWS session in the same region as OpenShift Cluster. credentialPath is the file path the AWS credentials file. credentialAccountID is the account name the user uses to create VM instance. The credentialAccountID should exist in the AWS credentials file pointing at one specific credential. resourceTrackerDir is where created instance and security group information is stored. privateKeyPath is the path to private key which is used to decrypt the password for the Windows VM created

func (*AwsProvider) CreateWindowsVM

func (a *AwsProvider) CreateWindowsVM() (credentials *types.Credentials, err error)

CreateWindowsVM takes in imageId, instanceType, and sshKey name to create a Windows instance under the same VPC as the existing OpenShift cluster with the following: - attaches existing cloud-specific cluster worker security group and IAM to gain the same access as the linux workers, - uses public subnet, - attaches public ip to allow external access, - adds a security group that allows traffic from within the VPC range and RDP access from user's IP, - uses given image id, instance type, and sshKey name - creates a unique name tag for the instance using the same prefix as the OpenShift cluster name, and - logs id and security group information of the created instance in 'windows-node-installer.json' file at the resourceTrackerDir. On success, the function outputs RDP access information in the commandline interface. It also returns the the credentials to access the Windows VM created,

func (*AwsProvider) DeleteSG

func (a *AwsProvider) DeleteSG(sgID string) error

DeleteSG checks if security group is in use, deletes it if not in use based on sgID, and returns error if fails. This function is exposed for testing purpose.

func (*AwsProvider) DestroyWindowsVMs

func (a *AwsProvider) DestroyWindowsVMs() error

DestroyWindowsVMs destroys the created instances and security groups on AWS specified in the 'windows-node-installer.json' file. The security groups still in use by other instances will not be deleted.

func (*AwsProvider) GetClusterWorkerSGID

func (a *AwsProvider) GetClusterWorkerSGID(infraID string) (string, error)

GetClusterWorkerSGID gets worker security group id from the existing cluster or returns an error. This function is exposed for testing purpose.

func (*AwsProvider) GetIAMWorkerRole

func (a *AwsProvider) GetIAMWorkerRole(infraID string) (*ec2.IamInstanceProfileSpecification, error)

GetIAMWorkerRole gets worker IAM information from the existing cluster including IAM arn or an error. This function is exposed for testing purpose.

func (*AwsProvider) GetInfraID

func (a *AwsProvider) GetInfraID() (string, error)

GetInfraID returns the infrastructure ID associated with the OpenShift cluster. This is public for testing purposes as of now.

func (*AwsProvider) GetInstance

func (a *AwsProvider) GetInstance(instanceID string) (*ec2.Instance, error)

GetInstance gets instance ec2 instance object from the given instanceID. We're making this method public to use it in tests as of now.

func (*AwsProvider) GetPassword

func (a *AwsProvider) GetPassword(instanceID string) (string, error)

GetPassword returns the password associated with the string. Exposing this to be used in tests later

func (*AwsProvider) GetPublicIP

func (a *AwsProvider) GetPublicIP(instanceID string) (string, error)

GetPublicIP returns the public IP address associated with the instance. Make to sure to call this function after the instance is in running state. Exposing this function to be used in testing later.

func (*AwsProvider) GetVPCByInfrastructure

func (a *AwsProvider) GetVPCByInfrastructure(infraID string) (*ec2.Vpc, error)

GetVPCByInfrastructure finds the VPC of an infrastructure and returns the VPC struct or an error. This function is exposed for testing purpose.

func (*AwsProvider) IsPortOpen

func (a *AwsProvider) IsPortOpen(sgId string, port int64) (bool, error)

IsPort checks whether the given port is open in the given security group. Return boolean for the checking result.

func (*AwsProvider) TerminateInstance

func (a *AwsProvider) TerminateInstance(instanceID string) error

TerminateInstance will delete an AWS instance based on instance id and returns error if deletion fails. This function is exposed for testing purpose.

Jump to

Keyboard shortcuts

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