Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
0b1b5f6
first CI test
ofiriro3 Jan 25, 2023
36fa1b9
changing the CI
ofiriro3 Jan 25, 2023
6c76938
changing the CI
ofiriro3 Jan 25, 2023
ea3aa89
adding log message
ofiriro3 Jan 25, 2023
429be71
adding log message
ofiriro3 Jan 25, 2023
b2faace
fixing message to have a proper emoji
ofiriro3 Jan 25, 2023
0b5b599
adding working directory
ofiriro3 Jan 25, 2023
ea4fb23
adding working directory
ofiriro3 Jan 25, 2023
011b3b0
adding working directory
ofiriro3 Jan 25, 2023
b972dfe
skip-ci-tag
ofiriro3 Jan 25, 2023
4c86c2b
skip-ci-tag
ofiriro3 Jan 25, 2023
464ff80
updating job
ofiriro3 Jan 25, 2023
082469e
remove all ci
ofiriro3 Jan 25, 2023
f89148f
update ci to work with the correct working directory
ofiriro3 Jan 25, 2023
1ad1d5a
add run on demand
ofiriro3 Jan 25, 2023
65aec6e
remove all workflows
ofiriro3 Jan 25, 2023
a9995b4
update workflow
ofiriro3 Jan 25, 2023
4c57305
update workflow
ofiriro3 Jan 25, 2023
4693c7a
update workflow
ofiriro3 Jan 25, 2023
c3d921a
update workflow
ofiriro3 Jan 25, 2023
939140a
update enviroment with choices
ofiriro3 Jan 25, 2023
2e62231
adding terraform init
ofiriro3 Jan 25, 2023
e8bdf48
adding terraform plan
ofiriro3 Jan 25, 2023
03bcb1c
updating job with plan target
ofiriro3 Jan 26, 2023
3b20d5a
updating job with plan target
ofiriro3 Jan 26, 2023
dcbc1bb
updating terraform
ofiriro3 Jan 26, 2023
b4d6579
updating terraform
ofiriro3 Jan 26, 2023
9910093
adding terraform apply
ofiriro3 Jan 26, 2023
2e6d40a
updating github actions variables
ofiriro3 Jan 26, 2023
a4a9f42
adding terraform output
ofiriro3 Jan 26, 2023
08f17ff
adding terraform output
ofiriro3 Jan 26, 2023
ed05aed
adding terraform setup
ofiriro3 Jan 26, 2023
7c1c919
using the latest hasicorp teraform github action package
ofiriro3 Jan 26, 2023
d7bff99
using the latest hasicorp teraform github action package
ofiriro3 Jan 26, 2023
b041ac8
using the latest hasicorp teraform github action package
ofiriro3 Jan 26, 2023
fcbe9ba
updating terraform output
ofiriro3 Jan 26, 2023
3b167dd
updating output
ofiriro3 Jan 26, 2023
1043ea1
updating comment message
ofiriro3 Jan 26, 2023
755569a
updating comment message
ofiriro3 Jan 30, 2023
83fcf35
updating comment message
ofiriro3 Jan 30, 2023
a6e4156
updating comment message
ofiriro3 Jan 30, 2023
60552c2
updating comment message
ofiriro3 Jan 30, 2023
ea82c38
updating comment message
ofiriro3 Jan 30, 2023
7b42273
updating comment message
ofiriro3 Jan 30, 2023
4919b25
updating comment message
ofiriro3 Jan 30, 2023
fee8efe
updating slack message
ofiriro3 Jan 30, 2023
80fa310
updating slack message
ofiriro3 Jan 30, 2023
4198fbc
updating slack message
ofiriro3 Jan 30, 2023
4504c58
updating slack message
ofiriro3 Jan 30, 2023
568b193
updating slack message
ofiriro3 Jan 30, 2023
75dd2fb
updating slack message
ofiriro3 Jan 30, 2023
24e979e
adding slack message file
ofiriro3 Jan 30, 2023
252b88a
adding payload json to env
ofiriro3 Jan 30, 2023
421c277
updating slack message
ofiriro3 Jan 30, 2023
ed8a506
updating slack message
ofiriro3 Jan 30, 2023
7e3c050
updating slack message
ofiriro3 Jan 30, 2023
10d0b6b
updating slack message
ofiriro3 Jan 30, 2023
1a1afc5
updating slack message
ofiriro3 Jan 30, 2023
8e5a720
updating slack message
ofiriro3 Jan 30, 2023
fc0818d
updating slack message
ofiriro3 Jan 30, 2023
ed5d393
updating slack message
ofiriro3 Jan 30, 2023
81aa3c5
updating slack message
ofiriro3 Jan 30, 2023
e7a6114
updating slack message
ofiriro3 Jan 30, 2023
10d31b1
updating slack message
ofiriro3 Jan 30, 2023
482f335
updating slack message
ofiriro3 Jan 30, 2023
118c5e8
updating slack message
ofiriro3 Jan 30, 2023
515d87e
updating slack message
ofiriro3 Jan 30, 2023
6cb5d67
updating slack message
ofiriro3 Jan 30, 2023
55794c0
updating slack message
ofiriro3 Jan 30, 2023
3648f60
updating slack message
ofiriro3 Jan 30, 2023
6a70430
updating slack message
ofiriro3 Jan 30, 2023
01965e9
updating slack message
ofiriro3 Jan 30, 2023
e9e5538
updating slack message
ofiriro3 Jan 30, 2023
24fa4f5
updating slack message
ofiriro3 Jan 30, 2023
1e24990
updating slack message
ofiriro3 Jan 30, 2023
4aac1f9
updating slack message
ofiriro3 Jan 30, 2023
b42aea7
updating slack message
ofiriro3 Jan 30, 2023
e28b21a
updating slack message
ofiriro3 Jan 30, 2023
f8b4b6e
updating slack message
ofiriro3 Jan 30, 2023
5a83206
updating slack message
ofiriro3 Jan 30, 2023
f138853
updating slack message
ofiriro3 Jan 30, 2023
e8a2b53
updating slack message
ofiriro3 Jan 30, 2023
5a18516
updating slack message
ofiriro3 Jan 30, 2023
580e0e6
updating slack message
ofiriro3 Jan 30, 2023
4dbfcd6
updating slack message
ofiriro3 Jan 30, 2023
a1eed7d
updating slack message
ofiriro3 Jan 30, 2023
8b69d4b
updating slack message
ofiriro3 Jan 30, 2023
dd8c198
updating slack message
ofiriro3 Jan 30, 2023
b0786e5
updating slack message
ofiriro3 Jan 30, 2023
8dad967
updating slack message
ofiriro3 Jan 30, 2023
9a657c6
updating slack message
ofiriro3 Jan 30, 2023
9ad7e0d
updating slack message
ofiriro3 Jan 30, 2023
d66da1b
updating slack message
ofiriro3 Jan 30, 2023
b0cd8cf
updating slack message
ofiriro3 Jan 30, 2023
f38ffb7
updating slack message
ofiriro3 Jan 30, 2023
523d894
updating slack message
ofiriro3 Jan 31, 2023
581296c
adding the EC2 machine
ofiriro3 Jan 31, 2023
931d336
adding the EC2 machine
ofiriro3 Jan 31, 2023
e27e35a
Adding SSH key to the slack message
ofiriro3 Feb 2, 2023
dcef233
Adding Environment variable
ofiriro3 Feb 2, 2023
802a1a1
Adding enviroment tag
ofiriro3 Feb 2, 2023
ec09a97
updating region for the job
ofiriro3 Feb 2, 2023
a0bd081
remove output.json
ofiriro3 Feb 2, 2023
b8861b5
Refactoring
ofiriro3 Feb 2, 2023
0008067
Trying to use environment variables in the outer scope of the flow
ofiriro3 Feb 2, 2023
c47917a
Trying to follow the readme
ofiriro3 Feb 2, 2023
2cb05c1
updating ami for the job
ofiriro3 Feb 3, 2023
3b6b0f5
updating private key for the job
ofiriro3 Feb 3, 2023
0505d3a
fixing slack message
ofiriro3 Feb 3, 2023
bdb8b1f
adding private key to message
ofiriro3 Feb 3, 2023
403421c
adding eks region and eks cluster name to the slack message
ofiriro3 Feb 3, 2023
f4771b7
Upgrade all providers
ofiriro3 Feb 4, 2023
d50501a
fixing terraform
ofiriro3 Feb 4, 2023
c071a70
Revert "Upgrade all providers"
ofiriro3 Feb 4, 2023
01658a0
Revert "fixing terraform"
ofiriro3 Feb 4, 2023
16911dd
adding base64 encoding to ssh key
ofiriro3 Feb 5, 2023
6fc0c48
trying to fix slack message
ofiriro3 Feb 5, 2023
9eeb08e
removing fields from slack message
ofiriro3 Feb 5, 2023
6b6f6c3
editing fields from slack message
ofiriro3 Feb 5, 2023
d7dfe06
adding the ssh command
ofiriro3 Feb 5, 2023
885cc0b
Update policies to 1.1.1
ofiriro3 Feb 6, 2023
3a611c4
Adding EC2 key to slack message
ofiriro3 Feb 6, 2023
3a02b26
remove short from fields
ofiriro3 Feb 6, 2023
6b36d81
Adding instance ID
ofiriro3 Feb 6, 2023
9a9c4f7
base64 encryption
ofiriro3 Feb 7, 2023
a83cd3c
Reverting the rest of the CI files
ofiriro3 Feb 7, 2023
e57f103
Reverting the rest of the CI files
ofiriro3 Feb 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
177 changes: 177 additions & 0 deletions .github/workflows/weekly-enviroment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: Weekly environment deployment

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to run tests against'
type: choice
options:
- weekly environment
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- TRACE
- DEBUG
- INFO
- WARN
- ERROR

env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
GITHUB_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONTAINER_SUFFIX: ${{ github.run_id }}
AWS_REGION: eu-north-1
KUBE_NAMESPACE: kube-system
WORKING_DIR: deploy/cloud
ENVIRONMENT: "weekly-environment"
TF_VAR_ec_api_key: ${{ secrets.TF_VAR_EC_API_KEY }}
TF_VAR_environment: ${{ github.event.inputs.logLevel }}
TF_VAR_eks_region: eu-north-1
TF_LOG: ${{ github.event.inputs.logLevel }}

jobs:
terraform:
name: Deploy KSPM/CSPM cloud environment
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIR }}
steps:
- name: Check out the repo
uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.5
terraform_wrapper: false

# - name: Terraform fmt
# id: fmt
# run: terraform fmt -check
# continue-on-error: true
#
# - name: Terraform Validate
# id: validate
# run: terraform validate -no-color
- name: Terraform Init
id: init
run: terraform init -no-color

- name: Deploy EKS cluster and Elastic Cloud
id: apply
run: terraform apply --auto-approve -target "module.ec_deployment" -target "null_resource.rules" -target "null_resource.store_local_dashboard" -target "module.eks"

- name: Create IAM role for EKS
id: kspm
run: terraform apply --auto-approve -target "module.api" -target "module.iam_eks_role"

- name : Deploy EC2 instance to run Cloudbeat on vanilla cluster
id: ec2
run: terraform apply --auto-approve -target "module.aws_ec2_with_agent"

- name: Deploy agent on EKS
id: eks
run: terraform apply --auto-approve

- name: Set terraform output as env variable
id: kibana_url
run: |
echo "KIBANA_URL=$(terraform output kibana_url)" >> $GITHUB_ENV
echo "EKS_CLUSTER_NAME=$(terraform output eks_cluster_name)" >> $GITHUB_ENV
echo "EKS_REGION=$(terraform output eks_region)" >> $GITHUB_ENV
echo "EC2_INSTANCE_ID=$(terraform output ec2_instance_id)" >> $GITHUB_ENV

- name: Set sensitive terraform output as env variable
id: set_sensitive_output
run: |
export ELASTICSEARCH_USERNAME=$(terraform output elasticsearch_username)
echo "::add-mask::$ELASTICSEARCH_USERNAME"
echo "ELASTICSEARCH_USERNAME=$ELASTICSEARCH_USERNAME" >> $GITHUB_ENV

export ELASTICSEARCH_PASSWORD=$(terraform output elasticsearch_password)
echo "::add-mask::$ELASTICSEARCH_PASSWORD"
echo "ELASTICSEARCH_PASSWORD=$ELASTICSEARCH_PASSWORD" >> $GITHUB_ENV

export EC2_PRIVATE_KEY=$(echo $(terraform output cloudbeat_private_key) | base64)
echo "::add-mask::$EC2_PRIVATE_KEY"
echo "EC2_PRIVATE_KEY=$EC2_PRIVATE_KEY" >> $GITHUB_ENV

export SSH_CMD=$(terraform output cloudbeat_ssh_cmd)
echo "::add-mask::$SSH_CMD"
echo "SSH_CMD=$SSH_CMD" >> $GITHUB_ENV

- name: Deploy Agents
id: deploy_ec2_instance
run: |
terraform apply -auto-approve -no-color

# Once https://github.com/slackapi/slack-github-action/issues/84 will be resolved we can push the payload to a different file
- name: Send custom JSON data to Slack workflow
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
payload: |
{
"text": "A new deployment job has been triggered",
"attachments": [
{
"color": "#36a64f",
"fields": [
{
"title": "Environment",
"value": "${{ github.event.inputs.environment }}",
"short": true
},
{
"title": "Log level",
"value": "${{ github.event.inputs.logLevel }}",
"short": true
},
{
"title": "Kibana URL",
"value": ${{ env.KIBANA_URL }},
"short": false
},
{
"title": "ElasticSearch username",
"value": ${{ env.ELASTICSEARCH_USERNAME }},
"short": false
},
{
"title": "ElasticSearch password",
"value": ${{ env.ELASTICSEARCH_PASSWORD }},
"short": false
},
{
"title": "EKS region",
"value": ${{ env.EKS_REGION }},
"short": true
},
{
"title": "EKS cluster name",
"value": ${{ env.EKS_CLUSTER_NAME }},
"short": true
},
{
"title": "Instance ID",
"value": "${{ env.EC2_INSTANCE_ID }}",
"short": false
},
{
"title": "EC2 private key",
"value": "${{ env.EC2_PRIVATE_KEY }}",
"short": false
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
9 changes: 2 additions & 7 deletions deploy/cloud/data/package_policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@
],
"package": {
"name": "cloud_security_posture",
"title": "Kubernetes Security Posture Management",
"version": "1.0.5"
},
"vars": {
"runtimeCfg": {
"type": "yaml"
}
"title": "Kubernetes Security Posture Management (KSPM)",
"version": "1.1.1"
}
}
11 changes: 3 additions & 8 deletions deploy/cloud/data/package_policy_vanilla.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,7 @@
],
"package": {
"name": "cloud_security_posture",
"title": "Kubernetes Security Posture Management",
"version": "1.0.5"
},
"vars": {
"runtimeCfg": {
"type": "yaml"
}
"title": "Kubernetes Security Posture Management (KSPM)",
"version": "1.1.1"
}
}
}
3 changes: 3 additions & 0 deletions deploy/cloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,9 @@ module "aws_ec2_with_agent" {
source = "./modules/ec2"
providers = { aws : aws }
yml = module.api.yaml_vanilla
environment_tag_name = var.environment_tag_name
aws_ami = "ami-03260a5267db32f55"

depends_on = [
module.ec_deployment,
module.api,
Expand Down
1 change: 1 addition & 0 deletions deploy/cloud/modules/ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ locals {
common_tags = {
id = "${random_id.id.hex}"
provisioner = "terraform"
environment = var.environment_tag_name
}
}
resource "tls_private_key" "cloudbeat_key" {
Expand Down
11 changes: 11 additions & 0 deletions deploy/cloud/modules/ec2/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ output "cloudbeat_ssh_cmd" {
value = "ssh -i ${local.cloudbeat_private_key_file} ${local.ec2_username}@${aws_instance.cloudbeat.public_ip}"
}

output "ec2_private_key" {
description = "Use this private key to SSH into the ec2 instance"
value = tls_private_key.cloudbeat_key.private_key_pem
sensitive = true
}

output "ec2_instance_id" {
description = "Use this private key to SSH into the ec2 instance"
value = aws_instance.cloudbeat.id
sensitive = true
}
5 changes: 5 additions & 0 deletions deploy/cloud/modules/ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ variable "yml" {
type = string

}

variable "environment_tag_name" {
description = "Environment tag name to be used"
type = string
}
15 changes: 14 additions & 1 deletion deploy/cloud/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,18 @@ output "role_arn" {
}

output "cloudbeat_ssh_cmd" {
value = module.aws_ec2_with_agent.cloudbeat_ssh_cmd
value = module.aws_ec2_with_agent.cloudbeat_ssh_cmd
sensitive = true
}

output "ec2_private_key" {
value = module.aws_ec2_with_agent.ec2_private_key
sensitive = true
}

output "ec2_instance_id" {
description = "EC2 instance ID"
value = module.aws_ec2_with_agent.ec2_instance_id
}


6 changes: 6 additions & 0 deletions deploy/cloud/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,9 @@ variable "eks_region" {
type = string
}

variable "environment_tag_name" {
default = "local environment"
description = "Environment tag name to be used"
type = string
}