Skip to content

Commit 89e79d1

Browse files
author
iru
authored
chore(refact): module and permission optionals (#35)
* refact. module optionals for examples/single-account-k8s * refact. permissions/single-account-user into several modules > iam-credentials, general cloud-connector, * refact. /permissions/org-management-role to /permissions/ecs-org-rolecloud-scanning * test: added test with minikube kind
1 parent a500181 commit 89e79d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+865
-1319
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
> PR template
22
>
33
> * for a cleaner PR, **delete whatever is not required**
4-
> * use pull-request **drafts for visiblity on WIP branches**
4+
> * use pull-request **drafts for visibility on WIP branches**
55
> * unless a revision is desired in order to validate, or gather some feedback, **you are free to merge it as long as**
66
> * validation checkers are all green-lighted
77
> * pre-merge checklist has been reviewed. for more detail check **`/CONTRIBUTE.md`**

.github/workflows/ci-integration-tests.yaml

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ on:
1515
concurrency: terraform
1616

1717
jobs:
18-
integration_test:
19-
name: Test-Kitchen
18+
integration_test_ecs:
19+
concurrency: terraform-account
20+
21+
name: Test-Kitchen-ECS
2022
runs-on: ubuntu-latest
2123
env:
2224
TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
@@ -36,25 +38,23 @@ jobs:
3638
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
3739
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
3840
AWS_REGION: ${{ secrets.AWS_REGION }}
39-
run: bundle exec kitchen test single-account
41+
run: bundle exec kitchen test "single-account-aws"
4042

4143
- name: Destroy single-account resources
4244
env:
4345
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
4446
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
4547
AWS_REGION: ${{ secrets.AWS_REGION }}
4648
if: ${{ failure() }}
47-
run: bundle exec kitchen destroy single-account
48-
49-
49+
run: bundle exec kitchen destroy "single-account-aws"
5050

5151
- name: Run organizational test
5252
env:
5353
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
5454
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
5555
AWS_REGION: ${{ secrets.AWS_REGION }}
5656
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
57-
run: bundle exec kitchen test organizational
57+
run: bundle exec kitchen test "organizational-aws"
5858

5959
- name: Destroy organizational resources
6060
env:
@@ -63,4 +63,53 @@ jobs:
6363
AWS_REGION: ${{ secrets.AWS_REGION }}
6464
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
6565
if: ${{ failure() }}
66-
run: bundle exec kitchen destroy organizational
66+
run: bundle exec kitchen destroy "organizational-aws"
67+
68+
integration_test-eks:
69+
concurrency: terraform-account
70+
continue-on-error: true
71+
72+
name: Test-Kitchen-EKS
73+
runs-on: ubuntu-latest
74+
env:
75+
TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
76+
TF_VAR_sysdig_secure_api_token: ${{secrets.KUBELAB_SECURE_API_TOKEN}}
77+
78+
steps:
79+
- name: Checkout
80+
uses: actions/checkout@v2
81+
82+
- uses: ruby/setup-ruby@v1
83+
with:
84+
ruby-version: 2.7
85+
bundler-cache: true
86+
87+
- name: Create kind cluster
88+
uses: helm/kind-action@v1.2.0
89+
with:
90+
wait: 120s
91+
92+
- name: Run single-account-k8s test
93+
env:
94+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
95+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
96+
AWS_REGION: ${{ secrets.AWS_REGION }}
97+
run: bundle exec kitchen test "single-account-k8s-aws"
98+
99+
- name: Inspect k8s failures
100+
if: ${{ failure() }}
101+
run: |
102+
kubectl get namespaces
103+
kubectl get deployments -n sfc-tests-kitchen-singlek8s
104+
kubectl describe deployment cloud-connector -n sfc-tests-kitchen-singlek8s
105+
kubectl logs deployment.apps/cloud-connector -n sfc-tests-kitchen-singlek8s
106+
kubectl logs deployment.apps/cloud-scanning -n sfc-tests-kitchen-singlek8s
107+
108+
109+
- name: Destroy single-account-k8s resources
110+
env:
111+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
112+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}}}
113+
AWS_REGION: ${{ secrets.AWS_REGION }}
114+
if: ${{ failure() }}
115+
run: bundle exec kitchen destroy "single-account-k8s-aws"

.github/workflows/ci-test-cleanup.yaml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,40 @@ name: CI - Test Cleanup
22
on:
33
workflow_dispatch
44

5+
concurrency: terraform
6+
57
jobs:
6-
test_cleanup:
8+
cleanup-cloudnative:
79
name: Test Cleanup
810
runs-on: ubuntu-latest
911
env:
10-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_ACCESS_KEY_ID }}
11-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_SECRET_ACCESS_KEY }}
12+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCESS_KEY_ID }}
13+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_CLOUDNATIVE_SECRET_ACCESS_KEY }}
1214
AWS_REGION: ${{ secrets.AWS_REGION }}
1315
TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
1416
TF_VAR_sysdig_secure_api_token: ${{secrets.KUBELAB_SECURE_API_TOKEN}}
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
21+
- uses: ruby/setup-ruby@v1
22+
with:
23+
ruby-version: 2.7
24+
bundler-cache: true
1525

26+
- name: Destroy resources
27+
run: bundle exec kitchen destroy
28+
29+
cleanup-org:
30+
name: Test Cleanup Org
31+
runs-on: ubuntu-latest
32+
env:
33+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_QA_MANAGED_ACCESS_KEY_ID }}
34+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_QA_MANAGED_SECRET_ACCESS_KEY }}
35+
AWS_REGION: ${{ secrets.AWS_REGION }}
36+
TF_VAR_sysdig_secure_for_cloud_member_account_id: ${{ secrets.AWS_QA_CLOUDNATIVE_ACCOUNT_ID }}
37+
TF_VAR_sysdig_secure_endpoint: https://secure.sysdig.com
38+
TF_VAR_sysdig_secure_api_token: ${{secrets.KUBELAB_SECURE_API_TOKEN}}
1639
steps:
1740
- name: Checkout
1841
uses: actions/checkout@v2
@@ -23,5 +46,4 @@ jobs:
2346
bundler-cache: true
2447

2548
- name: Destroy resources
26-
if: ${{ failure() }}
2749
run: bundle exec kitchen destroy

.kitchen.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ suites:
1414
- name: single-account
1515
driver:
1616
root_module_directory: test/fixtures/single-account
17+
- name: single-account-k8s
18+
driver:
19+
root_module_directory: test/fixtures/single-account-k8s
1720
- name: organizational
1821
driver:
1922
root_module_directory: test/fixtures/organizational

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
args:
2828
- '--args=--sort-by required'
2929
- id: terraform_tflint
30-
exclude: test\/.*$
30+
exclude: (test)|(examples-internal)\/.*$
3131
args:
3232
- '--args=--only=terraform_deprecated_interpolation'
3333
- '--args=--only=terraform_deprecated_index'

CONTRIBUTE.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616

1717
# Pull Request
1818

19+
Should any pre-merge test fail, check `/.github/workflows/ci-integration-test.yaml` to identify what's required
20+
1921
## 1. Check::Pre-Commit
2022

2123
Technical validation for terraform **lint**, **validation**, and **documentation**
2224

2325
We're using **pre-commit** | https://pre-commit.com
2426
- Defined in `/.pre-commit-config.yaml`
2527
- custom configuration | https://github.com/sysdiglabs/terraform-google-secure-for-cloud/blob/master/.pre-commit-config.yaml
26-
- current `terraform-docs` requires developer to create `README.md` file, with the enclosure tags for docs to insert the automated content
28+
- current `terraform-docs` version, requires developer to create `README.md` file, with the enclosure tags for docs to insert the automated content
2729
```markdown
2830
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2931
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
@@ -35,8 +37,6 @@ Final user validation. Checks that the snippets for the usage, stated in the off
3537

3638
Implemented vía **Terraform Kitchen** | https://newcontext-oss.github.io/kitchen-terraform
3739

38-
- Defined in `/.github/workflows/ci-integration-test.yaml`.
39-
4040
### Kitchen
4141

4242
- Kitchen configuration can be found in `/.kitchen.yml`
@@ -59,20 +59,18 @@ $ bundle exec kitchen tests
5959

6060
```
6161

62-
63-
64-
6562
### Terraform Backend
6663

6764
Because CI/CD sometimes fail, we setup the Terraform state to be handled in backend (s3+dynamo) within the Sysdig AWS backend (sysdig-test-account).
6865
In order to be able to use this Terraform backend AWS credentials are configured as Github project secret
6966

67+
If you need to handle the remote state on your local for any cleanup, please do it using `kitchen destroy`, not `terraform destroy`
68+
7069

7170
### Deployed infrastructure resources
7271

7372
Check project github secrets for clarification
7473

75-
7674
# Release
7775

7876
- Use **semver** for releases https://semver.org

Gemfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
source "https://rubygems.org/"
22

33
gem "kitchen-terraform", "~> 6.0.0"
4-
gem 'aws-sdk', '~> 3.0.1'
5-
gem 'awspec', '~> 1.24.0'
6-
gem 'kitchen-verifier-awspec', '~> 0.2.0'
4+
#gem 'aws-sdk', '~> 3.0.1'
5+
#gem 'awspec', '~> 1.24.0'
6+
#gem 'kitchen-verifier-awspec', '~> 0.2.0'

0 commit comments

Comments
 (0)