diff --git a/.github/workflows/readme.yml b/.github/workflows/readme.yml index 3646f9f..18bbb4e 100644 --- a/.github/workflows/readme.yml +++ b/.github/workflows/readme.yml @@ -10,37 +10,37 @@ jobs: runs-on: ubuntu-latest steps: - name: 'Checkout' - uses: actions/checkout@master + uses: actions/checkout@v2.3.4 - - name: Set up Python 3.7. + - 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@v9.0' with: actions_subcommand: 'readme' - github_token: '${{ secrets.GITHUB}}' + github_token: '${{ secrets.GITHUB }}' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + GITHUB_TOKEN: ${{ secrets.CLOUDDROVE_GITHUB_TOKEN }} - - name: pre-commit check errors + - name: 'pre-commit check errors' uses: pre-commit/action@v2.0.0 continue-on-error: true - - name: pre-commit fix erros + - name: 'pre-commit fix errors' uses: pre-commit/action@v2.0.0 continue-on-error: true - name: 'push readme' - uses: 'clouddrove/github-actions@v4.0' + uses: 'clouddrove/github-actions@v9.0' continue-on-error: true with: actions_subcommand: 'push' env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: 'Slack Notification' uses: clouddrove/action-slack@v2 @@ -51,4 +51,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required - if: always() \ No newline at end of file + if: always() diff --git a/.github/workflows/terraform.yml b/.github/workflows/terraform.yml index a2f78bc..ad21dd5 100644 --- a/.github/workflows/terraform.yml +++ b/.github/workflows/terraform.yml @@ -13,18 +13,18 @@ jobs: uses: actions/checkout@master - name: 'Terraform Format' - uses: 'clouddrove/github-actions@v4.0' + uses: 'clouddrove/github-actions@v9.0.1' with: actions_subcommand: 'fmt' - name: 'Terraform init' - uses: 'clouddrove/github-actions@v4.0' + uses: 'clouddrove/github-actions@v9.0.1' with: actions_subcommand: 'init' tf_actions_working_dir: ./_example - name: 'Terraform validate' - uses: 'clouddrove/github-actions@v4.0' + uses: 'clouddrove/github-actions@v9.0.1' with: actions_subcommand: 'validate' tf_actions_working_dir: ./_example diff --git a/.github/workflows/terratest.yml b/.github/workflows/terratest.yml new file mode 100644 index 0000000..8041f79 --- /dev/null +++ b/.github/workflows/terratest.yml @@ -0,0 +1,42 @@ +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@master + + - name: Install doctl + uses: digitalocean/action-doctl@v2 + with: + token: ${{ secrets.DO_TOKEN }} + + - name: 'Terratest' + if: ${{ github.event.label.name == 'terratest' }} + uses: 'clouddrove/github-actions@v9.0.1' + with: + actions_subcommand: 'terratest' + tf_actions_working_dir: '_test' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DO_TOKEN: ${{ secrets.DO_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() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9a789cb..9e713a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,13 +1,21 @@ 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 + - id: tflint - - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.2.0 + - 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 - - id: trailing-whitespace \ No newline at end of file diff --git a/README.yaml b/README.yaml index 47de5db..517f60b 100644 --- a/README.yaml +++ b/README.yaml @@ -16,7 +16,7 @@ github_repo: clouddrove/terraform-digitalocean-firewall # Badges to display badges: - name: "Terraform" - image: "https://img.shields.io/badge/Terraform-v0.13-green" + 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" @@ -37,11 +37,10 @@ usage : |- ```hcl module "firewall" { source = "clouddrove/firewall/digitalocean" - version = "0.13.0" + version = "0.15.0" name = "firewall" - application = "clouddrove" environment = "test" - label_order = ["environment", "application", "name"] + label_order = ["environment", "name"] enable_firewall = true allowed_ip = ["0.0.0.0/0"] allowed_ports = [22, 80] diff --git a/_example/example.tf b/_example/example.tf index ad7eb3f..44671da 100644 --- a/_example/example.tf +++ b/_example/example.tf @@ -6,20 +6,21 @@ provider "digitalocean" { } module "vpc" { - source = "clouddrove/vpc/digitalocean" - version = "0.13.0" + source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-vpc.git?ref=0.15" + #version = "0.15.0" name = "vpc" - application = "clouddrove" environment = "test" - label_order = ["environment", "application", "name"] + label_order = ["environment", "name"] enable_vpc = true region = "bangalore-1" + ip_range = "10.0.0.0/16" + } module "ssh_key" { - source = "clouddrove/ssh-key/digitalocean" - version = "0.13.0" + source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-ssh-key.git?ref=0.15" + #version = "0.15.0" key_path = "~/.ssh/id_rsa.pub" key_name = "devops" enable_ssh_key = true @@ -27,12 +28,11 @@ module "ssh_key" { module "droplet" { - source = "clouddrove/droplet/digitalocean" - version = "0.13.0" + source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-droplet.git?ref=0.15" + #version = "0.15.0" name = "droplet" - application = "clouddrove" environment = "test" - label_order = ["environment", "application", "name"] + label_order = ["environment", "name"] droplet_count = 2 region = "bangalore-1" ssh_keys = [module.ssh_key.fingerprint] @@ -49,9 +49,8 @@ module "droplet" { module "firewall" { source = "./../" name = "firewall" - application = "clouddrove" environment = "test" - label_order = ["environment", "application", "name"] + label_order = ["environment", "name"] enable_firewall = true allowed_ip = ["0.0.0.0/0"] allowed_ports = [22, 80] diff --git a/main.tf b/main.tf index 31c5540..1e01c79 100644 --- a/main.tf +++ b/main.tf @@ -8,10 +8,9 @@ # tags for resources. You can use terraform-labels to implement a strict # naming convention. module "labels" { - source = "clouddrove/labels/digitalocean" - version = "0.13.0" + source = "git::https://github.com/terraform-do-modules/terraform-digitalocean-labels.git?ref=0.15" + #version = "0.15.0" name = var.name - application = var.application environment = var.environment label_order = var.label_order } @@ -52,9 +51,7 @@ resource "digitalocean_firewall" "default" { tags = [ module.labels.name, - module.labels.application, module.labels.environment, - module.labels.createdby, module.labels.managedby ] } diff --git a/variables.tf b/variables.tf index 112a43b..ddd7899 100644 --- a/variables.tf +++ b/variables.tf @@ -6,11 +6,6 @@ variable "name" { description = "Name (e.g. `app` or `cluster`)." } -variable "application" { - type = string - default = "" - description = "Application (e.g. `cd` or `clouddrove`)." -} variable "environment" { type = string @@ -19,7 +14,7 @@ variable "environment" { } variable "label_order" { - type = list + type = list(any) default = [] description = "Label order, e.g. `name`,`application`." } @@ -37,13 +32,13 @@ variable "enable_firewall" { } variable "allowed_ip" { - type = list + type = list(any) default = [] description = "List of allowed ip." } variable "allowed_ports" { - type = list + type = list(any) default = [] description = "List of allowed ingress ports." } @@ -55,7 +50,7 @@ variable "protocol" { } variable "droplet_ids" { - type = list + type = list(any) default = [] description = "The ID of the VPC that the instance security group belongs to." }