Skip to content

Commit

Permalink
Merge pull request #52 from imperva/dev
Browse files Browse the repository at this point in the history
Dev to master
  • Loading branch information
Linda Nasredin authored Jan 11, 2023
2 parents c13be73 + 75b58fc commit 5396f52
Show file tree
Hide file tree
Showing 100 changed files with 175 additions and 279 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/terraform_apply.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:

- name: Change the modules source to local
run: |
find . -type f -exec sed -i 's/source *= \"github.com\/imperva\/dsfkit\//source = \"..\/..\/../' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//deploy/modules'
find . -type f -exec sed -i -e 's/source *= \"github.com\/imperva\/dsfkit\/\/deploy\/modules/source = \"..\/..\/..\/modules\/aws/' -e 's/?ref=.*/"/' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//modules'
- name: Sets env vars for environment
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/terraform_apply_hadr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:

- name: Change the modules source to local
run: |
find . -type f -exec sed -i 's/source *= \"github.com\/imperva\/dsfkit\//source = \"..\/..\/../' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//deploy/modules'
find . -type f -exec sed -i -e 's/source *= \"github.com\/imperva\/dsfkit\/\/deploy\/modules/source = \"..\/..\/..\/modules\/aws/' -e 's/?ref=.*/"/' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//modules'
- name: Sets env vars for environment
run: |
Expand Down
140 changes: 0 additions & 140 deletions .github/workflows/terraform_apply_hadr_cli.yml

This file was deleted.

28 changes: 22 additions & 6 deletions .github/workflows/terraform_apply_simple_cli.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Terraform Apply Cli (simple)'
name: 'Terraform Apply Cli'

on:
workflow_dispatch: {}
Expand All @@ -19,7 +19,7 @@ env:
TF_CLI_ARGS: "-no-color"
TF_INPUT: 0
TF_VAR_gw_count: 2
EXAMPLE_DIR: ./deploy/examples/se_demo
EXAMPLE_DIR: ./examples/poc/basic_deployment
TF_WORKSPACE: simple_cli
AWS_REGION: eu-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
Expand All @@ -30,8 +30,24 @@ permissions:

jobs:
terraform:
name: 'Terraform'

strategy:
matrix:
workspace: [simple_cli]
include:
- workspace: simple_cli
example_dir: ./examples/poc/basic_deployment
aws_region: eu-west-2
- workspace: hadr_cli
example_dir: ./examples/poc/hadr_deployment
aws_region: eu-west-1

name: 'Terraform ${{ matrix.workspace }}'
runs-on: ubuntu-latest
env:
EXAMPLE_DIR: ${{ matrix.example_dir }}
TF_WORKSPACE: ${{ matrix.workspace }}
AWS_REGION: ${{ matrix.aws_region }}
environment: test

# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
Expand All @@ -45,8 +61,8 @@ jobs:

- name: Change the modules source to local
run: |
find . -type f -exec sed -i 's/source *= \"github.com\/imperva\/dsfkit\//source = \"..\/..\/../' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//deploy/modules'
find . -type f -exec sed -i -e 's/source *= \"github.com\/imperva\/dsfkit\/\/deploy\/modules/source = \"..\/..\/..\/modules\/aws/' -e 's/?ref=.*/"/' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//modules'
- name: Sets env vars for environment
run: |
Expand Down Expand Up @@ -107,7 +123,7 @@ jobs:

- name: Set Environment Variables
run: |
echo hub_ip=$(terraform -chdir=$EXAMPLE_DIR output -json | jq -r '.dsf_hubs.value.primary_hub.public_address') >> $GITHUB_ENV
echo hub_ip=$(terraform -chdir=$EXAMPLE_DIR output -json | jq -r '.dsf_hubs.value.primary.public_address') >> $GITHUB_ENV
echo gw_ip=$(terraform -chdir=$EXAMPLE_DIR output -json | jq -r '.dsf_agentless_gw_group.value."gw-0".private_address') >> $GITHUB_ENV
echo dsf_ssh_key_file_name=$EXAMPLE_DIR/$(terraform -chdir=$EXAMPLE_DIR output -json | jq -r '.dsf_private_ssh_key_file_name.value') >> $GITHUB_ENV
Expand Down
58 changes: 31 additions & 27 deletions .github/workflows/terraform_plan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ on:

env:
TF_WARN_OUTPUT_ERRORS: 1
TF_WORKSPACE: dsfkit-ci-cd
TF_CLI_ARGS: "-no-color"
TF_INPUT: 0
AWS_REGION: us-west-2
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

permissions:
contents: read
Expand All @@ -28,37 +30,39 @@ jobs:
run:
shell: bash

strategy:
matrix:
example: ['./examples/poc/basic_deployment', './examples/poc/hadr_deployment']

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3

- name: Change the modules source to local
run: |
find . -type f -exec sed -i 's/source *= \"github.com\/imperva\/dsfkit\//source = \"..\/..\/../' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//deploy/modules'
- name: Change the modules source to local
run: |
find . -type f -exec sed -i -e 's/source *= \"github.com\/imperva\/dsfkit\/\/deploy\/modules/source = \"..\/..\/..\/modules\/aws/' -e 's/?ref=.*/"/' {} \;
! grep -rnw '.' -e 'github\.com/imperva/dsfkit//modules'
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform -chdir=${{ matrix.example }} init

- name: Terraform Validate
run: terraform validate
- name: Terraform Validate
run: terraform -chdir=${{ matrix.example }} validate

# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check
continue-on-error: true
# Checks that all Terraform configuration files adhere to a canonical format
- name: Terraform Format
run: terraform fmt -check
continue-on-error: true

# Generates an execution plan for Terraform
- name: Terraform Plan (simple)
run: terraform plan
# Generates an execution plan for Terraform
- name: Terraform Plan (simple)
run: terraform -chdir=${{ matrix.example }} plan

- name: Terraform Plan (hadr)
run: TF_WORKSPACE=dsfkit-ci-cd-hadr terraform plan
Loading

0 comments on commit 5396f52

Please sign in to comment.