Skip to content

Commit 4f4d124

Browse files
committed
Work in progress
1 parent 3390096 commit 4f4d124

File tree

23 files changed

+140
-29
lines changed

23 files changed

+140
-29
lines changed

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@Noamstrauss

.github/workflows/pr-checks.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: PR Checks
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
pr-checks:
8+
name: Terraform Validation
9+
runs-on: ubuntu-20.04
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Setup Terraform
15+
uses: hashicorp/setup-terraform@v3
16+
with:
17+
terraform_version: ${{ vars.TERRAFORM_VERSION }}
18+
19+
- name: Run tests for each example folder
20+
run: |
21+
TEST_CASES=(
22+
examples/dedicated-project
23+
examples/same-project
24+
)
25+
26+
for tcase in ${TEST_CASES[@]}; do
27+
echo "--> Running tests at $tcase"
28+
(
29+
cd $tcase || exit 1
30+
echo "Terraform Format Check"
31+
terraform fmt -check
32+
echo "Terraform Init"
33+
terraform init
34+
echo "Terraform Validate"
35+
terraform validate
36+
) || exit 1
37+
done
38+
39+
- name: Comment PR with Terraform status
40+
uses: actions/github-script@v7
41+
env:
42+
FORMAT_CHECK: "Terraform Format Check"
43+
INIT_CHECK: "Terraform Init"
44+
VALIDATE_CHECK: "Terraform Validate"
45+
with:
46+
github-token: ${{ secrets.GITHUB_TOKEN }}
47+
script: |
48+
const output = `#### Terraform Validation Results:
49+
50+
${{ env.FORMAT_CHECK }} ✅
51+
${{ env.INIT_CHECK }} ✅
52+
${{ env.VALIDATE_CHECK }} ✅
53+
54+
*Pusher: @${{ github.actor }}, Action: \`${{ github.event_name }}\`, Working Directory: \`${{ env.tf_actions_working_dir }}\`, Workflow: \`${{ github.workflow }}\`*`;
55+
56+
github.rest.issues.createComment({
57+
issue_number: context.issue.number,
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
body: output
61+
})

.github/workflows/terraform-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
docs:
66
runs-on: ubuntu-20.04
77
steps:
8-
- uses: actions/checkout@v3
8+
- uses: actions/checkout@v4
99
with:
1010
ref: ${{ github.event.pull_request.head.ref }}
1111

.github/workflows/trivy-scan.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,14 @@ jobs:
66
runs-on: ubuntu-20.04
77
steps:
88
- name: Checkout code
9-
uses: actions/checkout@v2
9+
uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
13+
- uses: gitleaks/gitleaks-action@v2
14+
env:
15+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}}
1017

1118
- name: Run Aqua scanner
1219
uses: docker://aquasec/aqua-scanner

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
# Terraform-gcp-onboarding
44

5-
[![Version](https://img.shields.io/badge/version-1.0.0-blue)](https://github.com/aquasecurity/terraform-gcp-onboarding)
5+
![Trivy](https://github.com/aquasecurity/terraform-gcp-onboarding/actions/workflows/trivy-scan.yaml/badge.svg)
6+
[![Release](https://img.shields.io/github/v/release/aquasecurity/terraform-gcp-onboarding)](https://github.com/aquasecurity/terraform-gcp-onboarding/releases)
67
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
78

89
This Terraform module provides an easy way
@@ -175,8 +176,6 @@ It's important to note that the dedicated project ID should follow the naming co
175176

176177
For example, if your Aqua tenant ID is `12345` and the first six characters of the SHA1 hash of your organization name are `12a456`, the dedicated project ID should be `aqua-agentless-12345-12a456`.
177178

178-
You will also need to ensure that the existing dedicated project has the label `"aqua-agentless-scanner" = "true"` applied.
179-
180179

181180
<!-- BEGIN_TF_DOCS -->
182181
## Requirements
@@ -220,6 +219,7 @@ You will also need to ensure that the existing dedicated project has the label `
220219
| <a name="input_aqua_volscan_api_url"></a> [aqua\_volscan\_api\_url](#input\_aqua\_volscan\_api\_url) | Aqua volume scanning API URL | `string` | n/a | yes |
221220
| <a name="input_create_network"></a> [create\_network](#input\_create\_network) | Toggle to create network resources | `bool` | `true` | no |
222221
| <a name="input_create_role_name"></a> [create\_role\_name](#input\_create\_role\_name) | The name of the role to be created for Aqua | `string` | `"AquaAutoConnectAgentlessRole"` | no |
222+
| <a name="input_dedicated_project"></a> [dedicated\_project](#input\_dedicated\_project) | Indicates whether dedicated project is enabled | `bool` | `true` | no |
223223
| <a name="input_delete_role_name"></a> [delete\_role\_name](#input\_delete\_role\_name) | The name of the role used for deleting Aqua resources | `string` | `"AutoConnectDeleteRole"` | no |
224224
| <a name="input_identity_pool_name"></a> [identity\_pool\_name](#input\_identity\_pool\_name) | Name of the identity pool. If not provided, the default value is set to 'aqua-agentless-pool-<aqua\_tenant\_id>' in the 'identity\_pool\_name' local | `string` | `null` | no |
225225
| <a name="input_identity_pool_provider_name"></a> [identity\_pool\_provider\_name](#input\_identity\_pool\_provider\_name) | Name of the identity pool provider. If not provided, the default value is set to 'agentless-provider-<aqua\_tenant\_id>' in the 'identity\_pool\_provider\_name' local | `string` | `null` | no |

data.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# Retrieve information about the Google Cloud organization
44
data "google_organization" "organization" {
5+
count = var.dedicated_project ? 1 : 0
56
domain = var.org_name
67
}
78

examples/dedicated-project/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ module "aqua_gcp_onboarding" {
5858
}
5959
type = local.type
6060
project_id = module.aqua_gcp_dedicated_project.project_id
61+
dedicated_project = local.dedicated
6162
region = local.region
6263
org_name = local.org_name
6364
aqua_tenant_id = local.aqua_tenant_id

examples/same-project/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ module "aqua_gcp_onboarding" {
4141
}
4242
type = local.type
4343
project_id = local.project_id
44+
dedicated_project = local.dedicated
4445
region = local.region
4546
org_name = local.org_name
4647
aqua_tenant_id = local.aqua_tenant_id

locals.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
locals {
44
# Organization-related locals
5-
org_id = data.google_organization.organization.org_id
5+
org_id = var.dedicated_project ? data.google_organization.organization[0].org_id : null # Using null because same-project does not use org_id
66

77
# Project-related locals
88
project_number = data.google_project.project.number

main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module "onboarding" {
77
google.onboarding = google.onboarding
88
}
99
enabled = var.type == "single" ? true : false # Currently only single onboarding type is supported
10+
dedicated_project = var.dedicated_project
1011
aqua_volscan_api_url = var.aqua_volscan_api_url
1112
aqua_aws_account_id = var.aqua_aws_account_id
1213
org_id = local.org_id

0 commit comments

Comments
 (0)