Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aws/lambda_function.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func ReduceUnAliasedVersions(svc *lambda.Lambda, maxVersions int, metadata deplo

drop := false

// $LATEST is a special poiter to the latest function
// $LATEST is a special pointer to the latest function
// helpfully it isn't returned in the list of aliases
// so we need a special case here
if *(version.Version) == "$LATEST" {
Expand Down
15 changes: 9 additions & 6 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ Automate the deployment of lambda functions easily from either a developers mach
Goals
-----

- secure by default
- upload and configure lambda functions with a minimum set of AWS permissions.
- sensitive configuration information e.g. database connection credentials are not exposed to either a CI system, developer machine or (shock horror) Github!
- easy to integrate CI or the developer workflow
- integrate cleanly with existing AWS environments
- Manage permissions and secrets :
- AWS permissions are managed centrally with a minimum set exposed
- Sensitive configuration information e.g. database connection credentials are not exposed to either a CI system, developer machine or (shock horror) Github!
- Easy to integrate CI or the developer workflow
- Integrate cleanly with existing AWS environments
- Ability to automatically delete unused functions

Usage
-----
Expand All @@ -38,6 +39,8 @@ module "auto_deployer" {
s3_bucket_arn = "${aws_s3_bucket.deployment_uploads.arn}" // arn of the AWS S3 bucket to monitor for uploads
s3_bucket_id = "${aws_s3_bucket.deployment_uploads.id}" // name of the AWS S3 bucket bucket to monitor for uploads

maximum_unaliased_versions = 10 // number of unused functions to be retained

env_vars = {
variables = {
FOO = "BAR" // variables to configure the lambda function with
Expand All @@ -61,7 +64,7 @@ export AWS_SECRET_ACCESS_KEY=***********************
lambda-uploader-linux-amd64 up -b myS3Bucket \
-a myAlias \
-d "AUTOMATED DEPLOY" \
-e handler.Handle \
-e myEntry.Point \
-r python2.7 \
-n myFunction /path/to/function.zip

Expand Down
4 changes: 2 additions & 2 deletions terraform/modules/lamda-deployer/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ resource "aws_lambda_function" "deployer" {

environment {
variables = {
DEPLOYER_FUNCTION_ROLE_ARN = "${var.function_role_arn}"
DEPLOYER_FUNCTION_ENV_VARS = "${jsonencode(var.env_vars["variables"])}"
DEPLOYER_FUNCTION_ROLE_ARN = "${var.function_role_arn}"
DEPLOYER_FUNCTION_ENV_VARS = "${jsonencode(var.env_vars["variables"])}"
DEPLOYER_POLICY_MAX_UNALIASED_VERSIONS = "${var.maximum_unaliased_versions}"
}
}
Expand Down
20 changes: 11 additions & 9 deletions terraform/modules/lamda-deployer/readme.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| application | The name of the application | string | - | yes |
| deployer_filepath | File path to a zip file containing the deployer | string | - | yes |
| env_vars | A map of variables to be passed to the lambda function on deployment | map | `<map>` | no |
| environment | The name of the environment | string | - | yes |
| function_role_arn | The arn of the role the function will be deployed with | string | - | yes |
| s3_bucket_arn | The arn of the S3 bucket to use for uploading applications from CI | string | - | yes |
| s3_bucket_id | The id of the S3 bucket to use for uploading applications from CI | string | - | yes |
| Name | Description | Type | Default | Required |
| ------ | ------------- | :----: | :-----: | :-----: |
| application | The name of the application | string | - | yes |
| deployer_filepath | File path to a zip file containing the deployer | string | - | yes |
| env_vars | A map of variables to be passed to the lambda function on deployment | map | `<map>` | no |
| environment | The name of the environment | string | - | yes |
| function_role_arn | The arn of the role the function will be deployed with | string | - | yes |
| maximum_unaliased_versions | The number of versions without an alias to keep. A function with an alias is a function in use. | string | `3` | no |
| s3_bucket_arn | The arn of the S3 bucket to use for uploading applications from CI | string | - | yes |
| s3_bucket_id | The id of the S3 bucket to use for uploading applications from CI | string | - | yes |

8 changes: 4 additions & 4 deletions terraform/modules/lamda-deployer/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ variable "function_role_arn" {
}

variable "env_vars" {
type = "map"
type = "map"
description = "A map of variables to be passed to the lambda function on deployment"
default = {}
default = {}
}

variable "maximum_unaliased_versions" {
description = "The number of versions without an alias to keep. A function with an alias is a function in use."
default = 3
description = "The number of versions without an alias to keep. A function with an alias is a function in use."
default = 3
}