Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[instruqt-setup-script] support install for cloudVision Terraform installer + isolate option to set region for track's sysdig tab #76

Merged
merged 21 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
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
38 changes: 38 additions & 0 deletions common/prepare-track/cloud/aws/cloud-connector-aws.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
terraform {
required_providers {
sysdig = {
source = "sysdiglabs/sysdig"
}
}
}

variable "training_secure_api_token" {
type = string
description = "The Sysdig API token"
}

variable "training_secure_url" {
type = string
description = "The Sysdig Secure URL"
}

variable "training_aws_region" {
type = string
description = "The AWS Region"
}

provider "sysdig" {
sysdig_secure_url = var.training_secure_url
sysdig_secure_api_token = var.training_secure_api_token
}

provider "aws" {
region = var.training_aws_region
}

module "secure-for-cloud_example_single-account" {
source = "sysdiglabs/secure-for-cloud/aws//examples/single-account"
pabloopez marked this conversation as resolved.
Show resolved Hide resolved

# deploy_beta_image_scanning_ecr=true
pabloopez marked this conversation as resolved.
Show resolved Hide resolved

}
40 changes: 40 additions & 0 deletions common/prepare-track/cloud/azure/cloud-connector-azure.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
terraform {
required_providers {
sysdig = {
source = "sysdiglabs/sysdig"
}
}
}

variable "training_secure_api_token" {
type = string
description = "The Sysdig API token"
}

variable "training_secure_url" {
type = string
description = "The Sysdig Secure URL"
}

variable "training_azure_subscription" {
type = string
description = "Azure Subscription ID"
}

provider "sysdig" {
sysdig_secure_url = var.training_secure_url
sysdig_secure_api_token = var.training_secure_api_token
}

provider "azurerm" {
features { }
subscription_id = var.training_azure_subscription
}

module "secure_for_cloud_example_single_subscription" {
source = "sysdiglabs/secure-for-cloud/azurerm//examples/single-subscription"

deploy_scanning = false

deploy_active_directory=false
}
55 changes: 55 additions & 0 deletions common/prepare-track/cloud/gcp/cloud-connector-gcp.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
terraform {
required_providers {
sysdig = {
source = "sysdiglabs/sysdig"
}
}
}

variable "training_secure_api_token" {
type = string
description = "The Sysdig API token"
}

variable "training_secure_url" {
type = string
description = "The Sysdig Secure URL"
}

variable "training_gcp_region" {
type = string
description = "The Sysdig Secure Region"
}

variable "training_gcp_project" {
type = string
description = "The Sysdig Secure Region"
}

variable "gcp_creds" {
type = string
description = "Auth credentials for the GCP SA from Instruqt"
}

provider "sysdig" {
sysdig_secure_url = var.training_secure_url
sysdig_secure_api_token = var.training_secure_api_token
}

provider "google" {
project = var.training_gcp_project
region = var.training_gcp_region
credentials = var.gcp_creds
}

provider "google-beta" {
project = var.training_gcp_project
region = var.training_gcp_region
credentials = var.gcp_creds
}

module "secure-for-cloud_example_single-project" {
source = "sysdiglabs/secure-for-cloud/google//examples/single-project"

deploy_scanning = true
pabloopez marked this conversation as resolved.
Show resolved Hide resolved
}
60 changes: 60 additions & 0 deletions common/prepare-track/cloud/install_with_terraform.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env bash
##
# Deploy the Sysdig Cloud Connector for Sysdig Secure for Cloud in AWS
pabloopez marked this conversation as resolved.
Show resolved Hide resolved
#
# Usage:
# install_with_terraform.sh $PROVIDER $SYSDIG_SECURE_API_TOKEN $SECURE_URL $CLOUD_REGION $CLOUD_ACCOUNT_ID
##

# logs
OUTPUT=/opt/sysdig/cloud/terraform_install.out
pabloopez marked this conversation as resolved.
Show resolved Hide resolved
mkdir -p /opt/sysdig/cloud/
touch $OUTPUT

PROVIDER=$1
SYSDIG_SECURE_API_TOKEN=$2
SECURE_URL=$3
CLOUD_REGION=$4
CLOUD_ACCOUNT_ID=$5

cd /root/prepare-track/cloud

if [ "$PROVIDER" == "aws" ]
then
cd aws
echo " Initializing Terraform modules, backend and provider plugins" \
&& terraform init >> ${OUTPUT} 2>&1 \
&& echo " Terraform has been successfully initialized. Applying... (this will take a few minutes)" \
&& terraform apply -auto-approve \
-var="training_secure_api_token=$SYSDIG_SECURE_API_TOKEN" \
-var="training_secure_url=$SECURE_URL" \
-var="training_aws_region=$CLOUD_REGION" \
>> ${OUTPUT} 2>&1 \
&& echo " Terraform apply completed! Check all TF deployment logs at: $OUTPUT"
fi

if [ "$PROVIDER" == "gcp" ]
then
cd gcp
echo " Initializing Terraform modules, backend and provider plugins" \
&& terraform init >> ${OUTPUT} 2>&1 \
&& echo " Terraform has been successfully initialized. Applying... (this will take a few minutes)" \
&& terraform apply -auto-approve \
-var="training_secure_api_token=$SYSDIG_SECURE_API_TOKEN" \
-var="training_secure_url=$SECURE_URL" \
-var="training_gcp_region=$CLOUD_REGION" \
-var="training_gcp_project=$CLOUD_ACCOUNT_ID" \
-var="gcp_creds=$GOOGLE_CREDENTIALS" \
>> ${OUTPUT} 2>&1 \
&& echo " Terraform apply completed! Check all TF deployment logs at: $OUTPUT"
fi

if [ "$PROVIDER" == "azure" ]
pabloopez marked this conversation as resolved.
Show resolved Hide resolved
then
cd azure
terraform init && terraform apply -auto-approve \
-var="training_secure_api_token=$SYSDIG_SECURE_API_TOKEN" \
-var="training_secure_url=$SECURE_URL" \
-var="training_azure_subscription=$CLOUD_ACCOUNT_ID" #\
#-y >> ${OUTPUT} 2>&1
fi
Loading