From 4f08c2290547f9a4dbcb9ac85e4b7968bc812723 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:29:34 -0700 Subject: [PATCH 01/13] build lambda --- .github/workflows/lambda.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/lambda.yml diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml new file mode 100644 index 0000000..304c440 --- /dev/null +++ b/.github/workflows/lambda.yml @@ -0,0 +1,31 @@ +name: Lambda +on: + push: + branches: + - master + pull_request: + types: [opened, synchronize, reopened] + +jobs: + build: + runs-on: ubuntu-latest + steps: + # Checkout the pull request branch + - name: Checkout code + uses: actions/checkout@v2 + + # Rebuild README + - name: Prepare + shell: bash + run: | + set -ex + make terraform/install + make terraform/get-plugins + make terraform/get-modules + make terraform/lint + make terraform/validate + + - name: Build + run: make build + + From 51d231c510b7656aa13772459a9e6d6a35e2b941 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:32:34 -0700 Subject: [PATCH 02/13] fix yaml --- .github/workflows/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index 304c440..7a7fe04 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -25,7 +25,7 @@ jobs: make terraform/lint make terraform/validate - - name: Build - run: make build + - name: Build + run: make build From 3e919be9a7b4b41efc33c590f5fb7c0567d580f2 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:34:23 -0700 Subject: [PATCH 03/13] make init --- .github/workflows/lambda.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index 7a7fe04..ee58e06 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -19,6 +19,7 @@ jobs: shell: bash run: | set -ex + make init make terraform/install make terraform/get-plugins make terraform/get-modules From 8083d57e2d166c6c2c6556a0e15d2e752b3739a1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:36:37 -0700 Subject: [PATCH 04/13] non interactive --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e458558..50f93d7 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ endef ## Install dependencies dependencies: @echo "==> Installing Lambda function dependencies..." - @$(call docker, apk add --update py-pip && \ + @$(call docker, apk add -y --update py-pip && \ pip install virtualenv && \ virtualenv venv --always-copy && \ source ./venv/bin/activate && \ From 20e57852515e050b711334309eb8632fa1b9c576 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:38:18 -0700 Subject: [PATCH 05/13] get rid of tty --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 50f93d7..3f3fdfb 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ lint: $(SELF) terraform/install terraform/get-modules terraform/get-plugins terraform/lint terraform/validate define docker -docker run -it -v $(PWD)/$(LAMBDA_DIR)/:/code -w /code $(DEPS_CONTAINER) /bin/sh -c '$(1)' +docker run -i -v $(PWD)/$(LAMBDA_DIR)/:/code -w /code $(DEPS_CONTAINER) /bin/sh -c '$(1)' endef ## Install dependencies From d62e9dd9431becf9bbaf3b1b829055d8c985ed44 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:40:35 -0700 Subject: [PATCH 06/13] list artifact zip --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3f3fdfb..3b514bd 100644 --- a/Makefile +++ b/Makefile @@ -28,4 +28,5 @@ dependencies: build: dependencies @echo "==> Building Lambda function zip..." @mkdir -p artifacts - @cd $(LAMBDA_DIR) && zip -r ../artifacts/lambda.zip * && cd ../ + @cd $(LAMBDA_DIR) && zip -r ../artifacts/lambda.zip * + @ls -l artifacts/lambda.zip From 411e27ac2c1b53af274eb4e06f5c1d3e78062fd5 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:47:40 -0700 Subject: [PATCH 07/13] deploy --- .github/workflows/lambda.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index ee58e06..f45193c 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -29,4 +29,8 @@ jobs: - name: Build run: make build - + - name: Deploy + - run: aws s3 cp artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secret.AWS_SECRET_ACCESS_KEY }} From e44c9ab09da5515de0797b9a28cc722a272343c6 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:48:49 -0700 Subject: [PATCH 08/13] fix yaml --- .github/workflows/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index f45193c..57fa816 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -30,7 +30,7 @@ jobs: run: make build - name: Deploy - - run: aws s3 cp artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip + run: aws s3 cp artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secret.AWS_SECRET_ACCESS_KEY }} From 21921c5a87bfbeb3957db8bd2e7c040aefaa3dc8 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:51:00 -0700 Subject: [PATCH 09/13] rebuild readme --- .github/workflows/lambda.yml | 2 +- README.md | 2 +- README.yaml | 3 +++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index 57fa816..d4f6146 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -33,4 +33,4 @@ jobs: run: aws s3 cp artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secret.AWS_SECRET_ACCESS_KEY }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} diff --git a/README.md b/README.md index f285c4f..f7f85de 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ # terraform-aws-lambda-elasticsearch-cleanup - [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) + [![Codefresh Build Status](https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1)](https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905) [![GitHub Action Build Status](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/workflows/Lambda/badge.svg?branch=master)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/actions?query=workflow%3ALambda) [![Latest Release](https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg)](https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest) [![Slack Community](https://slack.cloudposse.com/badge.svg)](https://slack.cloudposse.com) Terraform module to provision a scheduled Lambda function which will diff --git a/README.yaml b/README.yaml index 2e4bb7e..c66dbb8 100644 --- a/README.yaml +++ b/README.yaml @@ -21,6 +21,9 @@ badges: - name: "Codefresh Build Status" image: "https://g.codefresh.io/api/badges/pipeline/cloudposse/terraform-modules%2Fterraform-aws-lambda-elasticsearch-cleanup?type=cf-1" url: "https://g.codefresh.io/public/accounts/cloudposse/pipelines/5eaa33ff1dc82bb99faa3905" + - name: "GitHub Action Build Status" + image: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/workflows/Lambda/badge.svg?branch=master" + url: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/actions?query=workflow%3ALambda" - name: "Latest Release" image: "https://img.shields.io/github/release/cloudposse/terraform-aws-lambda-elasticsearch-cleanup.svg" url: "https://github.com/cloudposse/terraform-aws-lambda-elasticsearch-cleanup/releases/latest" From d49900c4e1b0cbc1e15784d37797d93f1af9cb86 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:51:54 -0700 Subject: [PATCH 10/13] remove flag --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3b514bd..0f5ff64 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ endef ## Install dependencies dependencies: @echo "==> Installing Lambda function dependencies..." - @$(call docker, apk add -y --update py-pip && \ + @$(call docker, apk add --update py-pip && \ pip install virtualenv && \ virtualenv venv --always-copy && \ source ./venv/bin/activate && \ From 62d3b73b8254d628d149eac39b2cdc7c27cd7bb1 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 16:58:32 -0700 Subject: [PATCH 11/13] upload with public readability; --- .github/workflows/lambda.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index d4f6146..30689e7 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -30,7 +30,7 @@ jobs: run: make build - name: Deploy - run: aws s3 cp artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip + run: aws s3 cp --acl public-read artifacts/lambda.zip s3://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} From 10684c955c08dda3d1c4178812345243cf136eac Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 17:00:56 -0700 Subject: [PATCH 12/13] test download --- .github/workflows/lambda.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index 30689e7..8b7ac8f 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -34,3 +34,6 @@ jobs: env: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + + - name: Test Download + run: curl -fsSL -o /dev/null https://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip From fca298afa72ced428d7071f45899bf01de3c9843 Mon Sep 17 00:00:00 2001 From: Erik Osterman Date: Tue, 9 Jun 2020 17:02:03 -0700 Subject: [PATCH 13/13] fix action --- .github/workflows/lambda.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lambda.yml b/.github/workflows/lambda.yml index 8b7ac8f..626c2f4 100644 --- a/.github/workflows/lambda.yml +++ b/.github/workflows/lambda.yml @@ -35,5 +35,5 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - - name: Test Download - run: curl -fsSL -o /dev/null https://artifacts.prod.cloudposse.org/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip + - name: Test Download from CDN + run: curl -fsSL -o /dev/null https://artifacts.cloudposse.com/${{ github.event.repository.name }}/${{ github.sha }}/lambda.zip