Documentation ¶
Overview ¶
Package deploy is purely for organization, the deploy.go command file was getting absurdly long
Index ¶
- type Deployer
- func (d *Deployer) AddAPIPermission(apiID string, lambdaArn string)
- func (d *Deployer) AddBinaryMediaTypes(apiID string)
- func (d *Deployer) AddLambdaInvokePermission(sourceArn string, principal string, statementID string)
- func (d *Deployer) AddQueues()
- func (d *Deployer) AddS3BucketNotifications()
- func (d *Deployer) AddSESPermission(lambdaArn *string)
- func (d *Deployer) AddSESPolicyForS3Bucket(bucketName string) error
- func (d *Deployer) AddSESRules()
- func (d *Deployer) AddTasks()
- func (d *Deployer) CreateFunction(zipBytes []byte) *string
- func (d *Deployer) DeployAPI(apiID string, stage config.DeploymentStage) string
- func (d *Deployer) GetSecretsKeyValue(secretName string, keyName string) string
- func (d *Deployer) ImportAPI(lambdaArn string) string
- func (d *Deployer) LookupSecretsForAPIGWStageVars(vars map[string]*string) map[string]*string
- func (d *Deployer) LookupSecretsForLambdaEnvVars(vars map[string]*string) map[string]*string
- func (d *Deployer) LookupSecretsForVars(vars map[string]*string) map[string]*string
- func (d *Deployer) SetSESRuleSetActive(ruleSetName *string) error
- func (d *Deployer) UpdateAPI(apiID string, lambdaArn string)
- func (d *Deployer) UpdateFunctionCode(zipBytes []byte) error
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 ¶
AddAPIPermission will add proper permissions to the API so that it can invoke the Lambda
func (*Deployer) AddBinaryMediaTypes ¶
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 ¶
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 ¶
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 ¶
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 ¶
GetSecretsKeyValue will look up a secret from AWS Secrets Manager
func (*Deployer) LookupSecretsForAPIGWStageVars ¶
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 ¶
LookupSecretsForLambdaEnvVars will look up variables from AWS Secrets Manager for use with Lambda environment variables.
func (*Deployer) LookupSecretsForVars ¶
LookupSecretsForVars will look up variables from AWS Secrets Manager, replacing values in a given map.
func (*Deployer) SetSESRuleSetActive ¶
SetSESRuleSetActive will set a given rule set as the active set, only one can be active at a time with SES.
func (*Deployer) UpdateAPI ¶
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 ¶
UpdateFunctionCode updates the Lambda function code and publishes a new version - no configuration changes