Weekly environment - Vanilla POC#746
Conversation
oren-zohar
left a comment
There was a problem hiding this comment.
Only went over the workflow
| TF_VAR_ec_api_key: ${{ secrets.WEEKLY_ENVIRONMENT_EC_API_KEY }} | ||
| TF_VAR_environment: ${{ github.event.inputs.logLevel }} | ||
| TF_LOG: ${{ github.event.inputs.logLevel }} | ||
| TF_VAR: 8.6.1 |
There was a problem hiding this comment.
is it hard coded by design? can we use the branch version instead?
There was a problem hiding this comment.
Yes, we would like the weekly environment to load a specific version every time it runs.
We would like it to run the latest SNAPSHOT version available. But we would like to change it manually every time since we would like to update the integration and the relevant rules.
There was a problem hiding this comment.
I'm not sure I understand the logic behind it. Why not use the branch version as a default value?
There was a problem hiding this comment.
So just to verify that I understood you, you meant for example if the Cloudbeat version is 8.8.0, so deploy 8.8.0-SNAPSHOT?
So that is a great idea, but for the matter of this PR, we wanted to start with a POC that will use a hard-coded version.
In the future we would like even to support multiple versions:
But for this POC, we assumed that it uses a hard-coded version 8.6.1 as the current Terraform default value suggests.
| - name: Setup Terraform | ||
| uses: hashicorp/setup-terraform@v2 | ||
| with: | ||
| terraform_version: 1.3.5 |
There was a problem hiding this comment.
don't we have the terraform version as part of hermit? I think we need to work with it in the CI, as it will make sure it will work properly locally for everyone in the future. What do you think?
There was a problem hiding this comment.
There was a problem hiding this comment.
Tested it, good advice! I removed the Terraform setup step and added a Init Hermit step
| - name: Terraform fmt | ||
| id: fmt | ||
| run: terraform fmt -check | ||
| continue-on-error: true | ||
|
|
||
| - name: Terraform Init | ||
| id: init | ||
| run: terraform init -no-color | ||
|
|
||
| - name: Terraform Validate | ||
| id: validate | ||
| run: terraform validate -no-color |
There was a problem hiding this comment.
Nice! but I think the linting should be in a separate step, as it is not part of the deployment logic, can run in parallel, and on failure, easier to understand what part failed and when.
There was a problem hiding this comment.
I still think it's valuable to have it - just in a separate step, maybe in one of the other workflows where we run linters?
|
Do we plan to consolidate it to the other terraform module at some point? what are the requirementes? |
Currently, the weekly environment job uses terraform to create a new Elastic cloud environment and does not require any other terraform modules from our solutions. Other actions are done by ssh to the relevant EC2 machine and applying the specific operations there. For the first deliverable solution, we decided that the job won't create a new EC2 machine and its infrastructure, and instead will use an existing machine. This assumption was made to enable us to move fast with a reliable solution and not be dependent on the rest of the terraform modules. So in this case, I thought that doing the ssh will be done much easier in a bash script. As I see it, in the future we will might decide to consolidate it with other terraform modules.
|
|
Thank you for a detailed explanation, @ofiriro3.
Imo, this is not ideal to have multiple scripts doing practically the same thing. I think a consolidation should be added to #622, not to DOD but to something that we want to track and achieve when possible. Otherwise, it would be hard to maintain two scripts. |
Done. I commented on the ticket |
olegsu
left a comment
There was a problem hiding this comment.
Looks good!
What happens if the machine does not exist?
Does the slack message still goes to ofir-personal-channel ?
| - name: Init Hermit | ||
| run: ./bin/hermit env -r >> $GITHUB_ENV | ||
|
|
||
| - name: Terraform fmt |
There was a problem hiding this comment.
Lets have it atm only on the weekly env dir
There was a problem hiding this comment.
I don't mind changing it, but why we wouldn't want it to run on the entire solution?
The CI passes, and it will keep all the terraform in format.
| env: | ||
| WORKING_DIR: deploy/weekly-environment | ||
| SCRIPTS_DIR: deploy/weekly-environment/scripts/benchmarks/kspm_vanilla | ||
| TF_VAR_ec_api_key: ${{ secrets.WEEKLY_ENVIRONMENT_EC_API_KEY }} |
There was a problem hiding this comment.
Who is the user behind this key?
There was a problem hiding this comment.
Currently its my user, we have two tickets related:
-
Short term solution - https://github.com/elastic/security-team/issues/6017, add the entire team to have permission on my account.
-
Long term solution - Create a team account - https://github.com/elastic/security-team/issues/5921
If the machine does not exist, no message is sent to the slack channel, but the job fails. |
Summary of your changes
This is the first item in the development of the Daily-environment epic.
In this task, we created a job that deploys a vanilla KSPM integration on an Elastic cloud environment.
The job currently uses a pre-exited EC2 machine and it deploys an agent there (no new EC2 machines will be created).
The expected behavior is:
ofir-personal-channelwith the relevant credentials for this environment.How to check the daily job

Currently, the flow is deployed using a dispatch workflow, meaning - you will need to apply it using GitHub actions.
You can apply the flow from my fork, using actions.
Please set the branch to
vanilla_pocbefore running the dispatch workflow.It should look like this:
The flow will deploy the integration to https://cloud.elastic.co/home, in the next PRs we will change it to a staging environment and replace the latest image with the SNAPSHOT version.
Related Issues
Related https://github.com/elastic/security-team/issues/5903
Checklist