deploy

package
Version: v0.0.0-...-473356e Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2019 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

Package deploy is purely for organization, the deploy.go command file was getting absurdly long

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deployer

type Deployer struct {
	Cfg        *config.DeploymentConfig
	AWSSession *session.Session
	LambdaArn  *string
	TasksPath  string
}

Deployer will hold a DeploymentConfig to use with its various functions for deployment

func NewDeployer

func NewDeployer(cfg *config.DeploymentConfig, session *session.Session) *Deployer

NewDeployer takes a cfg argument to set the config needed for its various functions

func (*Deployer) AddAPIPermission

func (d *Deployer) AddAPIPermission(apiID string, lambdaArn string)

AddAPIPermission will add proper permissions to the API so that it can invoke the Lambda

func (*Deployer) AddBinaryMediaTypes

func (d *Deployer) AddBinaryMediaTypes(apiID string)

AddBinaryMediaTypes will update the API to specify valid binary media types

func (*Deployer) AddLambdaInvokePermission

func (d *Deployer) AddLambdaInvokePermission(sourceArn string, principal string, statementID string)

AddLambdaInvokePermission will add permission to trigger Lambda (could be for a CloudWatch event rule or S3 bucket notification, etc.) Principal for CloudWatch event rules should be: "events.amazonaws.com" for S3 bucket notifications: "s3.amazonaws.com"

func (*Deployer) AddQueues

func (d *Deployer) AddQueues()

AddQueues will add SQS queues, if they don't exist, and apply trigger to the lambda NOTE: Apparently only one SQS can be associated with a Lambda at a time (at least the CLI doesn't let you trigger multiple) Though a Lambda can be triggered by multiple different queues

func (*Deployer) AddS3BucketNotifications

func (d *Deployer) AddS3BucketNotifications()

AddS3BucketNotifications loops the buckets in configuration and sets appropriate notifications to trigger the Lambda

func (*Deployer) AddSESPermission

func (d *Deployer) AddSESPermission(lambdaArn *string)

AddSESPermission allows SES to invoke the Lambda See: https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-permissions.html Note that no permissions are required for SNS Topic unless it's outside the current account. The permissions for Lambda invocation is also by account, using `SourceAccount` unlike other some triggers like API Gateway which is by API GW ARN. So this only needs to be called once.

func (*Deployer) AddSESPolicyForS3Bucket

func (d *Deployer) AddSESPolicyForS3Bucket(bucketName string) error

AddSESPolicyForS3Bucket will add a policy on the given S3 bucket to allow SES to store messages in it A policy allowing SES to put objects into S3 looks like this:

{
	"Version": "2012-10-17",
	"Statement": [
		{
			"Sid": "AllowSESPuts",
			"Effect": "Allow",
			"Principal": {
				"Service": "ses.amazonaws.com"
			},
			"Action": "s3:PutObject",
			"Resource": "arn:aws:s3:::BUCKET-NAME/*",
			"Condition": {
				"StringEquals": {
					"aws:Referer": "AWSACCOUNTID"
				}
			}
		}
	]
}

func (*Deployer) AddSESRules

func (d *Deployer) AddSESRules()

AddSESRules will add SES rules from configuration

func (*Deployer) AddTasks

func (d *Deployer) AddTasks()

AddTasks will add CloudWatch event rules to trigger the Lambda on set intervals with JSON messages from a `tasks` directory

func (*Deployer) CreateFunction

func (d *Deployer) CreateFunction(zipBytes []byte) *string

CreateFunction will create a Lambda function in AWS and return its ARN

func (*Deployer) DeployAPI

func (d *Deployer) DeployAPI(apiID string, stage config.DeploymentStage) string

DeployAPI will create a stage and deploy the API

func (*Deployer) GetSecretsKeyValue

func (d *Deployer) GetSecretsKeyValue(secretName string, keyName string) string

GetSecretsKeyValue will look up a secret from AWS Secrets Manager

func (*Deployer) ImportAPI

func (d *Deployer) ImportAPI(lambdaArn string) string

ImportAPI will import an API using Swagger

func (*Deployer) LookupSecretsForAPIGWStageVars

func (d *Deployer) LookupSecretsForAPIGWStageVars(vars map[string]*string) map[string]*string

LookupSecretsForAPIGWStageVars will look up variables from AWS Secrets Manager for use with API Gateway stage variables. API Gateway stage variable limitations: Variable names can have alphanumeric and underscore characters, and the values must match [A-Za-z0-9-._~:/?#&=,]+.

func (*Deployer) LookupSecretsForLambdaEnvVars

func (d *Deployer) LookupSecretsForLambdaEnvVars(vars map[string]*string) map[string]*string

LookupSecretsForLambdaEnvVars will look up variables from AWS Secrets Manager for use with Lambda environment variables.

func (*Deployer) LookupSecretsForVars

func (d *Deployer) LookupSecretsForVars(vars map[string]*string) map[string]*string

LookupSecretsForVars will look up variables from AWS Secrets Manager, replacing values in a given map.

func (*Deployer) SetSESRuleSetActive

func (d *Deployer) SetSESRuleSetActive(ruleSetName *string) error

SetSESRuleSetActive will set a given rule set as the active set, only one can be active at a time with SES.

func (*Deployer) UpdateAPI

func (d *Deployer) UpdateAPI(apiID string, lambdaArn string)

UpdateAPI will update an API's settings that are not configured in the demployment/stage. There is no real need to update the resources or integrations of course, but things like the description, name, binary content types, etc. will need to be updated if changed. TODO: Unused. Maybe implement this.

func (*Deployer) UpdateFunctionCode

func (d *Deployer) UpdateFunctionCode(zipBytes []byte) error

UpdateFunctionCode updates the Lambda function code and publishes a new version - no configuration changes

Jump to

Keyboard shortcuts

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