-
Notifications
You must be signed in to change notification settings - Fork 415
160 lines (138 loc) · 4.88 KB
/
Copy pathe2e_aws_splunk_windows.yml
File metadata and controls
160 lines (138 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: E2E AWS Splunk Windows
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: e2e-aws-splunk-windows
cancel-in-progress: false
jobs:
e2e_splunk_windows:
runs-on: ubuntu-latest
# Reserve time after the test step for destroy cleanup (see step timeouts below).
timeout-minutes: 60
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Install system packages
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends wireguard-tools unzip curl
- name: Install Terraform
run: |
TERRAFORM_VERSION=1.14.4
curl -s "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o /tmp/terraform.zip
unzip -o /tmp/terraform.zip -d /tmp
sudo mv /tmp/terraform /usr/local/bin/
rm /tmp/terraform.zip
terraform version
- uses: actions/setup-python@v6
with:
python-version: '3.11'
architecture: 'x64'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: Install Python dependencies
run: |
pip install -r requirements.txt
pip install pytest "moto[s3]"
- name: Run E2E test (build, verify, destroy)
timeout-minutes: 45
env:
ATTACK_RANGE_E2E: "1"
ATTACK_RANGE_CI: "1"
OBJC_DISABLE_INITIALIZE_FORK_SAFETY: "YES"
run: |
pytest tests/e2e/test_splunk_windows_aws.py -v -s --log-cli-level=INFO
- name: Destroy attack range (cleanup)
if: always()
timeout-minutes: 10
env:
ATTACK_RANGE_CI: "1"
run: |
shopt -s nullglob
configs=(config/*.yml)
if [ ${#configs[@]} -eq 0 ]; then
echo "No config files to destroy."
exit 0
fi
for cfg in "${configs[@]}"; do
echo "Destroying attack range from ${cfg}"
python attack_range.py destroy --config "${cfg}" || \
echo "Destroy failed for ${cfg}; fallback job will retry."
done
- name: Upload config for destroy fallback
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-attack-range-config
path: config/
if-no-files-found: ignore
- name: Disconnect WireGuard (cleanup)
if: always()
run: |
CONF="terraform/ansible/client_configs/client1.conf"
if [ -f "$CONF" ]; then
sudo wg-quick down "$CONF" 2>/dev/null || true
fi
destroy_e2e_splunk_windows:
needs: e2e_splunk_windows
if: always()
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Install system packages
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends unzip curl
- name: Install Terraform
run: |
TERRAFORM_VERSION=1.14.4
curl -s "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -o /tmp/terraform.zip
unzip -o /tmp/terraform.zip -d /tmp
sudo mv /tmp/terraform /usr/local/bin/
rm /tmp/terraform.zip
terraform version
- uses: actions/setup-python@v6
with:
python-version: '3.11'
architecture: 'x64'
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v5
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Download E2E config artifact
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: e2e-attack-range-config
path: config
- name: Destroy attack range (timeout fallback)
env:
ATTACK_RANGE_CI: "1"
run: |
shopt -s nullglob
configs=(config/*.yml)
if [ ${#configs[@]} -eq 0 ]; then
echo "No config files to destroy (test likely cleaned up successfully)."
exit 0
fi
failed=0
for cfg in "${configs[@]}"; do
echo "Destroying attack range from ${cfg}"
if ! python attack_range.py destroy --config "${cfg}"; then
echo "Destroy failed for ${cfg} (manual cleanup may be required)"
failed=1
fi
done
exit "${failed}"