cloudyaws

package module
v0.0.1-dev.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 30 Imported by: 0

README

cloudy-aws

AWS implementation of cloudy providers

Documentation

Index

Constants

View Source
const AWS = "azure"
View Source
const Attr_address = "address"
View Source
const Attr_birthdate = "birthdate"
View Source
const Attr_email = "email"
View Source
const Attr_familyName = "family name"
View Source
const Attr_gender = "gender"
View Source
const Attr_givenName = "given name"
View Source
const Attr_locale = "locale"
View Source
const Attr_middleName = "middle name"
View Source
const Attr_name = "name"
View Source
const Attr_nickname = "nickname"
View Source
const Attr_phoneNumber = "phone number"
View Source
const Attr_picture = "picture"
View Source
const Attr_preferredUsername = "preferred username"
View Source
const Attr_profile = "profile"
View Source
const Attr_updatedAt = "updated at"
View Source
const Attr_website = "website"
View Source
const Attr_zoneinfo = "zoneinfo"
View Source
const AwsCognito = "cognito"
View Source
const AwsEc2 = "aws-ec2"
View Source
const AwsSecreatManagerID = "aws-secretmanager"
View Source
const CognitoUserExtra_Enabled_B = "cognito-enabled"
View Source
const CognitoUserExtra_PoolID_S = "cogntio_poolid"
View Source
const CognitoUserExtra_PreferredMFA_S = "cogntio_mfa"

Variables

View Source
var DefaultUserAttributes = []string{
	Attr_email, Attr_name, Attr_givenName, Attr_familyName,
}

Functions

func CreateInstance

creates an instance with a given vm config

func InstanceStatusByID

func InstanceStatusByID(ctx context.Context, vmc *AwsEc2Controller, instanceID string) (*cloudyvm.VirtualMachineStatus, error)

func InstanceStatusByVmName

func InstanceStatusByVmName(ctx context.Context, vmc *AwsEc2Controller, vmName string) (*cloudyvm.VirtualMachineStatus, error)

given a VM Name, find the status of the underlying instance The instance will have a name tag matching the VM Name returns nil if no matching instance found

func ListInstancesWithTag

func ListInstancesWithTag(ctx context.Context, vmc *AwsEc2Controller, tag string) ([]*cloudyvm.VirtualMachineStatus, error)

func StartInstance

func StartInstance(ctx context.Context, vmc *AwsEc2Controller, vmName string, wait bool) error

func StopInstance

func StopInstance(ctx context.Context, vmc *AwsEc2Controller, vmName string, wait bool) error

func TerminateInstance

func TerminateInstance(ctx context.Context, vmc *AwsEc2Controller, vmName string, wait bool) error

Terminates an instance with a given name

Types

type AWSCloudFront

type AWSCloudFront struct {
	Client *cloudfront.CloudFront
	// contains filtered or unexported fields
}

func NewCloudFront

func NewCloudFront() *AWSCloudFront

func (*AWSCloudFront) AppendCNAME

func (awscf *AWSCloudFront) AppendCNAME(cname string, distId string) error

func (*AWSCloudFront) GetDNSName

func (awscf *AWSCloudFront) GetDNSName(cname string) (string, error)

func (*AWSCloudFront) GetDistribution

func (awscf *AWSCloudFront) GetDistribution(cname string) (*cloudfront.DistributionSummary, error)

GetDistribution looks up a distribution based on the cname or the distribution ID

type AWSRoute53

type AWSRoute53 struct {
	Client *route53.Route53
	// contains filtered or unexported fields
}

func NewRoute53

func NewRoute53() *AWSRoute53

func (*AWSRoute53) GetHostedZoneID

func (awsroute53 *AWSRoute53) GetHostedZoneID(name string) (string, error)

func (*AWSRoute53) UpsertARec

func (awsroute53 *AWSRoute53) UpsertARec(zoneId string, name string, DNSName string) error

type AwsEc2Controller

type AwsEc2Controller struct {
	Quotas    *servicequotas.ServiceQuotas
	Ec2Client *ec2.EC2
	Config    *AwsEc2ControllerConfig
}

func NewAwsEc2Controller

func NewAwsEc2Controller(ctx context.Context, config *AwsEc2ControllerConfig) (*AwsEc2Controller, error)

func (*AwsEc2Controller) CreateNIC

func (*AwsEc2Controller) DeleteNIC

func (*AwsEc2Controller) FindBestSubnet

func (vmc *AwsEc2Controller) FindBestSubnet(ctx context.Context, availableSubnets []string) (string, error)

Returns the first subnet found with IP availability out of availableSubnets

func (*AwsEc2Controller) FindNICsByName

func (vmc *AwsEc2Controller) FindNICsByName(ctx context.Context, nicName string) ([]*cloudyvm.VirtualMachineNetwork, error)

Finds EC2 Network Interfaces that have a matching name and returns a list of them in cloudy format

func (*AwsEc2Controller) FindNicByID

Finds an EC2 Network Interface that has a matching ID and returns it in cloudy format. Returns nil if no NIC found

func (*AwsEc2Controller) GetAllNICs

Calls getNICs with an empty filter to get all NICs

func (*AwsEc2Controller) GetAvailableIPs

func (vmc *AwsEc2Controller) GetAvailableIPs(ctx context.Context, subnetID string) (int, error)

Retrieves the number of available IPs in a subnet

func (*AwsEc2Controller) GetLimits

func (*AwsEc2Controller) GetVMSizes

func (vmc *AwsEc2Controller) GetVMSizes(ctx context.Context) (map[string]*cloudyvm.VmSize, error)

func (*AwsEc2Controller) GetVmNic

Finds the primary EC2 Network Interface for a given VM and returns it in cloudy format

func (*AwsEc2Controller) ListAll

func (*AwsEc2Controller) ListWithTag

func (vmc *AwsEc2Controller) ListWithTag(ctx context.Context, tag string) ([]*cloudyvm.VirtualMachineStatus, error)

func (*AwsEc2Controller) SetState

func (*AwsEc2Controller) Start

func (vmc *AwsEc2Controller) Start(ctx context.Context, vmName string, wait bool) error

func (*AwsEc2Controller) Status

func (*AwsEc2Controller) Stop

func (vmc *AwsEc2Controller) Stop(ctx context.Context, vmName string, wait bool) error

func (*AwsEc2Controller) Terminate

func (vmc *AwsEc2Controller) Terminate(ctx context.Context, vmName string, wait bool) error

type AwsEc2ControllerConfig

type AwsEc2ControllerConfig struct {

	// ??
	// NetworkResourceGroup     string   // From Environment Variable
	// SourceImageGalleryName   string   // From Environment Variable
	// Vnet                     string   // From Environment Variable
	AvailableSubnets []string // From Environment Variable

}

type AwsEc2ControllerFactory

type AwsEc2ControllerFactory struct{}

func (*AwsEc2ControllerFactory) Create

func (f *AwsEc2ControllerFactory) Create(cfg interface{}) (cloudyvm.VMController, error)

creates the AWS VM Controller Interface

func (*AwsEc2ControllerFactory) FromEnv

func (f *AwsEc2ControllerFactory) FromEnv(env *cloudy.Environment) (interface{}, error)

type AwsSecretManager

type AwsSecretManager struct {
	Region string
}

func (*AwsSecretManager) DeleteSecret

func (a *AwsSecretManager) DeleteSecret(ctx context.Context, key string) error

func (*AwsSecretManager) GetSecret

func (a *AwsSecretManager) GetSecret(ctx context.Context, key string) (string, error)

func (*AwsSecretManager) GetSecretBinary

func (a *AwsSecretManager) GetSecretBinary(ctx context.Context, key string) ([]byte, error)

func (*AwsSecretManager) SaveSecret

func (a *AwsSecretManager) SaveSecret(ctx context.Context, key string, secret string) error

func (*AwsSecretManager) SaveSecretBinary

func (a *AwsSecretManager) SaveSecretBinary(ctx context.Context, key string, secret []byte) error

type AwsSecretManagerFactory

type AwsSecretManagerFactory struct{}

func (*AwsSecretManagerFactory) Create

func (c *AwsSecretManagerFactory) Create(cfg interface{}) (secrets.SecretProvider, error)

func (*AwsSecretManagerFactory) FromEnv

func (c *AwsSecretManagerFactory) FromEnv(env *cloudy.Environment) (interface{}, error)

type Cognito

type Cognito struct {
	CognitoPoolID string
	Region        string

	Svc            *cognitoidentityprovider.CognitoIdentityProvider
	UserAttributes []string
	// contains filtered or unexported fields
}

func NewCognito

func NewCognito(region string, poolId string) *Cognito

func (*Cognito) AddCallbackUrl

func (c *Cognito) AddCallbackUrl(domain string, userpoolid string, clientId string) error

func (*Cognito) AddUserToGroup

func (c *Cognito) AddUserToGroup(groupName string, uid string) error

AddUserToGroup calls the cognitofunction

func (*Cognito) Attr

func (*Cognito) CreateGroup

func (c *Cognito) CreateGroup(group *models.Group) error

func (*Cognito) CreateUser

func (c *Cognito) CreateUser(user *models.User) error

func (*Cognito) DeleteGroup

func (c *Cognito) DeleteGroup(grp string) error

func (*Cognito) DeleteUser

func (c *Cognito) DeleteUser(uid string) error

func (*Cognito) DisableUser

func (c *Cognito) DisableUser(uid string) error

func (*Cognito) EnableUser

func (c *Cognito) EnableUser(uid string) error

func (*Cognito) GetGroup

func (c *Cognito) GetGroup(grpId string) (*models.Group, error)

func (*Cognito) GetUser

func (c *Cognito) GetUser(username string) (*models.User, error)

GetUser calls cognito to get a list of users. The filter and page token parameters are optional

func (*Cognito) GetUserFromEmail

func (c *Cognito) GetUserFromEmail(email string) (*models.User, error)

func (*Cognito) GetUserGroups

func (c *Cognito) GetUserGroups(username string) ([]*models.Group, error)

func (*Cognito) IsAttributeSupported

func (c *Cognito) IsAttributeSupported(field string) bool

func (*Cognito) ListAllUsersInGroup

func (c *Cognito) ListAllUsersInGroup(groupName string) ([]*models.User, error)

ListUsersInGroup calls the cognitofunction

func (*Cognito) ListGroups

func (c *Cognito) ListGroups() ([]*models.Group, error)

ListGroups calls the cognitofunction

func (*Cognito) ListUsers

func (c *Cognito) ListUsers(filter string, pageToken string) ([]*models.User, string, error)

ListUsers calls cognito to get a list of users. The filter and page token parameters are optional

func (*Cognito) ListUsersInGroup

func (c *Cognito) ListUsersInGroup(groupName string, pageToken string) ([]*models.User, string, error)

ListUsersInGroup calls the cognitofunction

func (*Cognito) RemoveUserFromGroup

func (c *Cognito) RemoveUserFromGroup(groupName string, uid string) error

RemoveUserFromGroup calls the cognitofunction

func (*Cognito) ResetUserPassword

func (c *Cognito) ResetUserPassword(uid string) error

func (*Cognito) SetUserGroups

func (c *Cognito) SetUserGroups(username string, groups []string) error

Overwrites all the groups that the user is in and sets them to the provided groups

func (*Cognito) SetUserPassword

func (c *Cognito) SetUserPassword(uid string, password string, permanent bool) error

func (*Cognito) ToUserAttributes

func (c *Cognito) ToUserAttributes(user *models.User) []*cognitoidentityprovider.AttributeType

func (*Cognito) UpdateUser

func (c *Cognito) UpdateUser(user *models.User) error

func (*Cognito) VerifyEmail

func (c *Cognito) VerifyEmail(uid string) error

type CognitoConfig

type CognitoConfig struct {
	PoolID         string
	Region         string
	UserAttributes []string
}

type CognitoGroupManager

type CognitoGroupManager struct {
	Client *Cognito
	Config *CognitoConfig
}

func NewCognitoGroupManager

func NewCognitoGroupManager(cfg *CognitoConfig) (*CognitoGroupManager, error)

func (*CognitoGroupManager) AddMembers

func (c *CognitoGroupManager) AddMembers(ctx context.Context, groupId string, userIds []string) error

func (*CognitoGroupManager) DeleteGroup

func (c *CognitoGroupManager) DeleteGroup(ctx context.Context, grpId string) error

func (*CognitoGroupManager) GetGroup

func (c *CognitoGroupManager) GetGroup(ctx context.Context, grpId string) (*models.Group, error)

func (*CognitoGroupManager) GetGroupMembers

func (c *CognitoGroupManager) GetGroupMembers(ctx context.Context, grpId string) ([]*models.User, error)

func (*CognitoGroupManager) GetUserGroups

func (c *CognitoGroupManager) GetUserGroups(ctx context.Context, uid string) ([]*models.Group, error)

func (*CognitoGroupManager) ListGroups

func (c *CognitoGroupManager) ListGroups(ctx context.Context) ([]*models.Group, error)

func (*CognitoGroupManager) NewGroup

func (c *CognitoGroupManager) NewGroup(ctx context.Context, grp *models.Group) (*models.Group, error)

func (*CognitoGroupManager) RemoveMembers

func (c *CognitoGroupManager) RemoveMembers(ctx context.Context, groupId string, userIds []string) error

func (*CognitoGroupManager) UpdateGroup

func (c *CognitoGroupManager) UpdateGroup(ctx context.Context, grp *models.Group) (bool, error)

type CognitoGroupManagerFactory

type CognitoGroupManagerFactory struct{}

func (*CognitoGroupManagerFactory) Create

func (c *CognitoGroupManagerFactory) Create(cfg interface{}) (cloudy.GroupManager, error)

func (*CognitoGroupManagerFactory) FromEnv

func (c *CognitoGroupManagerFactory) FromEnv(env *cloudy.Environment) (interface{}, error)

type CognitoUserManager

type CognitoUserManager struct {
	Client *Cognito
	Config *CognitoConfig
}

func NewCognitoUserManager

func NewCognitoUserManager(cfg *CognitoConfig) (*CognitoUserManager, error)

func (*CognitoUserManager) DeleteUser

func (c *CognitoUserManager) DeleteUser(ctx context.Context, uid string) error

func (*CognitoUserManager) Disable

func (c *CognitoUserManager) Disable(ctx context.Context, uid string) error

func (*CognitoUserManager) Enable

func (c *CognitoUserManager) Enable(ctx context.Context, uid string) error

func (*CognitoUserManager) ForceUserName

func (c *CognitoUserManager) ForceUserName(ctx context.Context, name string) (string, bool, error)

func (*CognitoUserManager) GetUser

func (c *CognitoUserManager) GetUser(ctx context.Context, uid string) (*models.User, error)

Retrieves a specific user.

func (*CognitoUserManager) ListUsers

func (c *CognitoUserManager) ListUsers(ctx context.Context, page interface{}, filter interface{}) ([]*models.User, interface{}, error)

func (*CognitoUserManager) NewUser

func (c *CognitoUserManager) NewUser(ctx context.Context, newUser *models.User) (*models.User, error)

NewUser creates a new user. A password is required. If a password is not specified then one will be generated. TODO: FIgure out user definition.. claims.. users attributes... etc.

func (*CognitoUserManager) UpdateUser

func (c *CognitoUserManager) UpdateUser(ctx context.Context, usr *models.User) error

type CognitoUserManagerFactory

type CognitoUserManagerFactory struct{}

func (*CognitoUserManagerFactory) Create

func (c *CognitoUserManagerFactory) Create(cfg interface{}) (cloudy.UserManager, error)

func (*CognitoUserManagerFactory) FromEnv

func (c *CognitoUserManagerFactory) FromEnv(env *cloudy.Environment) (interface{}, error)

type Dynamo

type Dynamo[T any] struct {
	Sess   *session.Session
	Client *dynamodb.DynamoDB
	Table  string
}

func NewDynamo

func NewDynamo[T any](tableName string) (*Dynamo[T], error)

func (*Dynamo[T]) Read

func (d *Dynamo[T]) Read(key string, attribute string) (*T, error)

func (*Dynamo[T]) Save

func (d *Dynamo[T]) Save(item *T) error

type EmailQuota

type EmailQuota struct {
	Max24HourSend   *float64 `type:"double"`
	MaxSendRate     *float64 `type:"double"`
	SentLast24Hours *float64 `type:"double"`
	Remaining       uint64
}

type Queue

type Queue struct {
	Client *sqs.SQS
}

Queue simple wrapper for SQS actions

func NewQueue

func NewQueue() *Queue

NewQueue creates a new Queue wrapper

func (*Queue) Delete

func (q *Queue) Delete(topic string, handle *string) error

Delete removes messages from the topic

func (*Queue) Recieve

func (q *Queue) Recieve(topic string) ([]*sqs.Message, error)

Recieve get messages off the topic queue

func (*Queue) Send

func (q *Queue) Send(topic string, message string) (*string, error)

Send sends a message

type SESEmailer

type SESEmailer struct {
	Client *ses.SES
}

Amazon Simple Email Service (SES) is a cost-effective, flexible, and scalable email service that enables developers to send mail from within any application. You can configure Amazon SES quickly to support several email use cases, including transactional, marketing, or mass email communications. Amazon SES's flexible IP deployment and email authentication options help drive higher deliverability and protect sender reputation, while sending analytics measure the impact of each email. With Amazon SES, you can send email securely, globally, and at scale. -- https://aws.amazon.com/ses/

## Usage Notes You need to make sure that you only send "from" your approved email addresses. Also, this mailer includes some capablities to check your email quota. Under the covers the send raw email method is being called to support attachements. https://docs.aws.amazon.com/ses/latest/APIReference/API_SendRawEmail.html

func NewSESEmailer

func NewSESEmailer() (*SESEmailer, error)

func (*SESEmailer) DecodeSendError

func (m *SESEmailer) DecodeSendError(err error) string

DecodeSendError turns the error into a status string

func (*SESEmailer) PauseSending

func (m *SESEmailer) PauseSending()

func (*SESEmailer) Quota

func (m *SESEmailer) Quota() (*EmailQuota, error)

Quota gets the quota for sending

func (*SESEmailer) ResumeSending

func (m *SESEmailer) ResumeSending()

func (*SESEmailer) Send

func (m *SESEmailer) Send(ctx context.Context, msg *gomail.Message) error

type SESEmailerConfig

type SESEmailerConfig struct{}

type SESEmailerFactory

type SESEmailerFactory struct{}

func (*SESEmailerFactory) Create

func (ses *SESEmailerFactory) Create(cfg interface{}) (cloudy.Emailer, error)

func (*SESEmailerFactory) FromEnv

func (ses *SESEmailerFactory) FromEnv(env *cloudy.Environment) (interface{}, error)

Jump to

Keyboard shortcuts

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