Skip to content

Commit 2a9cdc4

Browse files
authored
Use artifacts (#8)
* build artifacts * lint * Deploy artifacts to s3 bucket * add region * test improve-errors * pin to a release * Fix bundler
1 parent 914096a commit 2a9cdc4

File tree

7 files changed

+43
-51
lines changed

7 files changed

+43
-51
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,6 @@
1212
**/package-lock.json
1313

1414
.build-harness
15-
build-harness
15+
build-harness
16+
17+
*.zip

.travis.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ addons:
55
- make
66
- curl
77

8+
env:
9+
global:
10+
- TERRAFORM_MODULE_NAME="$(basename $TRAVIS_REPO_SLUG)"
11+
812
install:
913
- make init
1014

@@ -13,4 +17,20 @@ script:
1317
- make terraform/get-plugins
1418
- make terraform/get-modules
1519
- make terraform/lint
16-
- make terraform/validate
20+
- make terraform/validate
21+
- make build
22+
23+
deploy:
24+
# Deploy artifacts to S3
25+
- provider: s3
26+
region: "us-west-2"
27+
access_key_id: $AWS_ACCESS_KEY_ID
28+
secret_access_key: $AWS_SECRET_ACCESS_KEY
29+
bucket: artifacts.prod.cloudposse.org
30+
skip_cleanup: true
31+
upload-dir: $TERRAFORM_MODULE_NAME/$TRAVIS_COMMIT
32+
local-dir: artifacts
33+
on:
34+
all_branches: true
35+
36+

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@ export README_DEPS ?= docs/targets.md docs/terraform.md
77
lint:
88
$(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate
99

10-
include Makefile.helpers
11-
include Makefile.ses
10+
include Makefile.ses

Makefile.helpers

Lines changed: 0 additions & 42 deletions
This file was deleted.

Makefile.ses

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
NPM ?= docker run -it -v $(pwd)/lambda/:/code -w /code --entrypoint=npm node:8.10-alpine
1+
NPM ?= docker run -it -v $(shell pwd)/lambda/:/code -w /code --entrypoint=npm node:8.10-alpine
2+
3+
# Ensures that a variable is defined
4+
define assert-set
5+
@[ -n "$($1)" ] || (echo "$(1) not defined in $(@)"; exit 1)
6+
endef
27

38
## Build lambda package
49
build:
510
$(NPM) update
611
sudo chmod -R 777 lambda
7-
cd lambda && zip -r ../lambda.zip * && cd ../
12+
mkdir -p artifacts
13+
cd lambda && zip -r ../artifacts/lambda.zip *
814

915
## Verify $EMAIL used as gateway for forwarding
10-
verify_gateway_email:
16+
verify-gateway-email:
1117
$(call assert-set,REGION)
1218
$(call assert-set,EMAIL)
1319
aws --region=$(REGION) ses verify-email-identity --email-address $(EMAIL)

lambda.tf

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,19 @@ resource "aws_iam_role_policy_attachment" "lambda" {
6666
policy_arn = "${aws_iam_policy.lambda.arn}"
6767
}
6868

69+
module "artifact" {
70+
source = "git::https://github.com/cloudposse/terraform-external-module-artifact.git?ref=tags/0.1.1"
71+
filename = "lambda.zip"
72+
module_name = "terraform-aws-ses-lambda-forwarder"
73+
module_path = "${path.module}"
74+
}
75+
6976
resource "aws_lambda_function" "default" {
70-
filename = "${join("/", list(path.module, "lambda.zip"))}"
77+
filename = "${module.artifact.file}"
7178
function_name = "${module.label.id}"
7279
role = "${aws_iam_role.lambda.arn}"
7380
handler = "index.handler"
74-
source_code_hash = "${base64sha256(file(join("/", list(path.module, "lambda.zip"))))}"
81+
source_code_hash = "${module.artifact.base64sha256}"
7582
runtime = "nodejs8.10"
7683

7784
environment {

lambda.zip

-3.47 MB
Binary file not shown.

0 commit comments

Comments
 (0)