Skip to content

Commit

Permalink
Merge pull request #13 from clouddrove/0.14
Browse files Browse the repository at this point in the history
Upgrade module with Terraform 0.14
  • Loading branch information
Sohan Yadav committed Jan 21, 2021
2 parents b4e5d6c + c755f7d commit 9ed1824
Show file tree
Hide file tree
Showing 25 changed files with 177 additions and 155 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@master
uses: actions/checkout@v2.3.4

- name: Set up Python 3.7.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: 'create readme'
uses: 'clouddrove/github-actions@v4.0'
uses: 'clouddrove/github-actions@v6.0'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB}}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}


- name: pre-commit check errors
uses: pre-commit/action@v2.0.0
continue-on-error: true
Expand All @@ -35,7 +34,7 @@ jobs:
continue-on-error: true

- name: 'push readme'
uses: 'clouddrove/github-actions@v4.0'
uses: 'clouddrove/github-actions@v6.0'
continue-on-error: true
with:
actions_subcommand: 'push'
Expand Down
70 changes: 24 additions & 46 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,70 +3,48 @@ on:
pull_request:
branches:
- master

jobs:
terraform:
name: 'Terraform'
fmt:
name: 'Terraform fmt'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@master

- name: Configure AWS Credentials
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2
uses: actions/checkout@v2.3.4

- name: 'Terraform Format'
uses: 'clouddrove/github-actions@v4.0'
uses: 'clouddrove/github-actions@v6.0'
with:
actions_subcommand: 'fmt'

- name: 'Terraform init basic-s3_example'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/basic-s3-function
basic-function:
name: 'Init Plan & Validate'
needs: fmt
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- name: 'Terraform validate basic-s3_example'
uses: 'clouddrove/github-actions@v4.0'
- name: 'Configure AWS Credentials'
uses: clouddrove/configure-aws-credentials@v1
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/basic-s3-function
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2

- name: 'Terraform init basic_function'
uses: 'clouddrove/github-actions@v4.0'
- name: 'Terraform init for basic-function'
uses: 'clouddrove/github-actions@v6.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/basic-function

- name: 'Terraform validate basic_function'
uses: 'clouddrove/github-actions@v4.0'
- name: 'Terraform validate for basic-function'
uses: 'clouddrove/github-actions@v6.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/basic-function

- name: 'Terraform init complete_example'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/complete-function

- name: 'Terraform validate complete_example'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/complete-function

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
- name: 'Terraform plan for basic-function'
uses: 'clouddrove/github-actions@v6.0'
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/basic-function
42 changes: 42 additions & 0 deletions .github/workflows/terratest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: 'Terratest GitHub Actions'
on:
pull_request:
branches:
- master
types: [labeled]

jobs:
Terratest:
name: 'Terratest'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@master

- name: Configure AWS Credentials
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2

- name: 'Terratest basic-function'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v6.0'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: _test/basic-function
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
.terraform
.idea
*.iml
*.zip
*.zip
*.terraform.lock.hcl
19 changes: 13 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.43.0

- repo: https://github.com/gruntwork-io/pre-commit
rev: v0.1.12 # Get the latest from: https://github.com/gruntwork-io/pre-commit/releases
hooks:
- id: terraform_fmt
- id: terraform-fmt
- id: shellcheck

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 # Use the ref you want to point at
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
- id: mixed-line-ending
- id: check-byte-order-marker
- id: check-executables-have-shebangs
- id: check-merge-conflict
- id: debug-statements
- id: check-yaml
- id: check-added-large-files
- id: trailing-whitespace
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Cloud Drove
Copyright (c) 2021 Cloud Drove

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie

include $(GENIE_PATH)/Makefile
include $(GENIE_PATH)/Makefile
19 changes: 8 additions & 11 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ github_repo: clouddrove/terraform-aws-lambda
# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v0.13-green"
image: "https://img.shields.io/badge/Terraform-v0.14-green"
url: "https://www.terraform.io"
- name: "Licence"
image: "https://img.shields.io/badge/License-MIT-blue.svg"
Expand All @@ -40,11 +40,10 @@ usage: |-
```hcl
module "lambda" {
source = "clouddrove/lambda/aws"
version = "0.13.0"
version = "0.14.0"
name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["name","environment"]
enabled = true
filename = "./../../../lambda_function_payload"
handler = "index.handler"
Expand All @@ -58,13 +57,12 @@ usage: |-
```hcl
module "lambda" {
source = "clouddrove/lambda/aws"
version = "0.13.0"
version = "0.14.0"
name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["name","environment"]
enabled = true
s3_bucket = "test-mysql-backups"
s3_bucket = "test-s3-backups"
s3_key = "lambda_function_payload.zip"
handler = "index.handler"
runtime = "nodejs8.10"
Expand All @@ -77,12 +75,11 @@ usage: |-
```hcl
module "lambda" {
source = "clouddrove/lambda/aws"
version = "0.13.0"
version = "0.14.0"
name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
label_order = ["name","environment"]
enabled = true
timeout = 60
Expand Down
15 changes: 7 additions & 8 deletions _example/basic-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ provider "aws" {
module "lambda" {
source = "../../"

name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
name = "lambda"
environment = "test"
label_order = ["name", "environment"]

enabled = true
enabled_cloudwatch_logging = true

filename = "../../lambda_packages"
handler = "index.lambda_handler"
runtime = "python3.7"
filename = "../../lambda_packages"
handler = "index.lambda_handler"
runtime = "python3.7"
variables = {
foo = "bar"
}
Expand Down
2 changes: 1 addition & 1 deletion _example/basic-function/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ output "arn" {
output "tags" {
value = module.lambda.tags
description = "A mapping of tags to assign to the resource."
}
}
7 changes: 3 additions & 4 deletions _example/basic-s3-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ module "lambda" {
source = "../../"

name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
enabled = true
label_order = ["name", "environment"]

s3_bucket = "test-mysql-backups"
enabled = true
s3_bucket = "test-s3-backups"
s3_key = "lambda_function_payload.zip"
handler = "index.handler"
runtime = "nodejs8.10"
Expand Down
2 changes: 1 addition & 1 deletion _example/basic-s3-function/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ output "arn" {
output "tags" {
value = module.lambda.tags
description = "A mapping of tags to assign to the resource."
}
}
7 changes: 3 additions & 4 deletions _example/complete-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ module "lambda" {
source = "../../"

name = "lambda"
application = "clouddrove"
environment = "test"
label_order = ["environment", "name", "application"]
enabled = true
timeout = 60
label_order = ["name", "environment"]

enabled = true
timeout = 60
filename = "../../lambda_packages"
handler = "index.lambda_handler"
runtime = "python3.8"
Expand Down
2 changes: 1 addition & 1 deletion _example/complete-function/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ output "arn" {
output "tags" {
value = module.lambda.tags
description = "A mapping of tags to assign to the resource."
}
}
8 changes: 0 additions & 8 deletions _test/basic-function/go.mod

This file was deleted.

4 changes: 2 additions & 2 deletions _test/basic-function/lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func Test(t *testing.T) {
Arn := strings.Join(terraform.OutputList(t, terraformOptions, "arn"),"")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-lambda-clouddrove", Tags["Name"])
assert.Equal(t, "lambda-test", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:lambda")
}
}
3 changes: 0 additions & 3 deletions _test/basic-s3-function/go.mod

This file was deleted.

4 changes: 2 additions & 2 deletions _test/basic-s3-function/lambda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ func Test(t *testing.T) {
Arn := strings.Join(terraform.OutputList(t, terraformOptions, "arn"),"")

// Check that we get back the outputs that we expect
assert.Equal(t, "test-lambda-clouddrove", Tags["Name"])
assert.Equal(t, "lambda-test", Tags["Name"])
assert.Contains(t, Arn, "arn:aws:lambda")
}
}
8 changes: 0 additions & 8 deletions _test/complete-function/go.mod

This file was deleted.

Loading

0 comments on commit 9ed1824

Please sign in to comment.