Skip to content

Commit

Permalink
Merge pull request #1 from clouddrove/0.15
Browse files Browse the repository at this point in the history
add github-action,pre-coomit,readme.yml
  • Loading branch information
Om Sharma authored Jul 7, 2021
2 parents 6c51d13 + 0b8a2e0 commit de62e74
Show file tree
Hide file tree
Showing 20 changed files with 512 additions and 40 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: 'Create README.md file'
on:
push:
branches:
- master

jobs:
readme-create:
name: 'readme-create'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@master

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

- name: 'create readme'
uses: 'clouddrove/github-actions@v7.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

- name: pre-commit fix erros
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: 'push readme'
uses: 'clouddrove/github-actions@v7.0'
continue-on-error: true
with:
actions_subcommand: 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove Inc.'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
116 changes: 116 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
name: 'Terraform GitHub Actions'
on:
pull_request:
branches:
- master

jobs:
fmt:
name: 'terraform fmt'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

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

event_bus_archive:
name: 'event_bus_archive'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- 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: 'Terraform init'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/event_bus_archive

- name: 'Terraform validate for event_bus_archive'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/event_bus_archive

- name: 'Terraform plan for event_bus_archive'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/event_bus_archive

event_rule_target:
name: 'secure_example'
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- 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: 'Terraform init'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/event_rule_target

- name: 'Terraform validate for event_rule_target'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/event_rule_target

- name: 'Terraform plan for event_rule_target'
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/event_rule_target

pre-commit:
name: 'Pre-Commit'
needs:
- fmt
- event_bus_archive
- event_rule_target
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4

- name: 'Install Tflint'
run: |
curl https://github.com/raw/terraform-linters/tflint/master/install_linux.sh | bash
- name: 'Pre-Commit 🔎'
uses: pre-commit/action@v2.0.3
continue-on-error: true

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

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@v2.3.4

- 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 for event_bus_archive'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v8.0'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/event_bus_archive'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove Inc.'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
*.iml
_example/.terraform.tfstate.lock.info
*.terrafrom.lock.hcl
.terraform.lock.hcl
.terraform.lock.hcl
/_test/event_bus_archive/go.mod
/_test/event_bus_archive/go.sum
/_test/event_rule_target/go.sum
/_test/event_rule_target/go.sum
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:

- 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: shellcheck
- id: tflint

- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1 # 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
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

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
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export GENIE_PATH ?= $(shell 'pwd')/../../../genie
include $(GENIE_PATH)/Makefile
Empty file added README.md
Empty file.
111 changes: 111 additions & 0 deletions README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
#
# This is the canonical configuration for the `README.md`
# Run `make readme` to rebuild the `README.md`
#


# Name of this project
name: Terraform AWS eventbridge

# License of this project
license: "MIT"

# Canonical GitHub repo
github_repo: clouddrove/terraform-aws-eventbridge

# Badges to display
badges:
- name: "Terraform"
image: "https://img.shields.io/badge/Terraform-v0.15-green"
url: "https://www.terraform.io"
- name: "Licence"
image: "https://img.shields.io/badge/License-MIT-blue.svg"
url: "LICENSE.md"

# description of this project
# yamllint disable rule:line-length

description: |-
Terraform module is used to create eventbridge resource on AWS for network connectivity..
# extra content
include:
- "terraform.md"

# How to use this project
# yamllint disable rule:line-length
usage: |-
### event_bus_archive
Here is an example of how you can use this module in your inventory structure:
```hcl
module "eventbridge_archive" {
create_bus = true
create_archives = true
name = "bus"
environment = "test"
label_order = ["name", "environment"]
archives = {
"launch-archive-existing-bus" = {
description = "launch-archive",
retention_days = 1
event_pattern = jsonencode(
{
"source" : ["aws.autoscaling"],
"detail-type" : ["EC2 Instance Launch Successful"]
}
)
}
}
}
```
### event_rule_target
```hcl
module "eventbridge" {
name = "subnets"
environment = "test"
label_order = ["name", "environment"]
rules = {
orders = {
description = "Capture all order data"
event_pattern = jsonencode({ "source" : ["myapp.orders"] })
enabled = true
role_arn = module.iam-role.arn
}
emails = {
description = "Capture all emails data"
event_pattern = jsonencode({ "source" : ["myapp.emails"] })
enabled = true
}
}
targets = {
orders = [
{
name = "send-orders-to-sqs-wth-dead-letter"
arn = aws_sqs_queue.queue.arn
dead_letter_arn = aws_sqs_queue.dlq.arn
},
{
name = "send-orders-to-sqs"
arn = aws_sqs_queue.queue.arn
}
]
emails = [
{
name = "send-orders-to-kinesis"
dead_letter_arn = aws_sqs_queue.dlq.arn
arn = aws_sqs_queue.dlq.arn
}
]
}
}
```
Loading

0 comments on commit de62e74

Please sign in to comment.