Skip to content

Commit

Permalink
refactor: add workload ZS Root CA install
Browse files Browse the repository at this point in the history
  • Loading branch information
jmolnar-zscaler committed Nov 6, 2023
1 parent e9702dd commit 21507cf
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/terraform-zscc-workload-aws/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ This module creates all AWS EC2 instance, IAM, and Security Group resources need
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.7, < 2.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.59, <= 5.17 |
| <a name="requirement_local"></a> [local](#requirement\_local) | ~> 2.2.0 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.59, <= 5.17 |
| <a name="provider_local"></a> [local](#provider\_local) | ~> 2.2.0 |

## Modules

Expand All @@ -34,6 +36,7 @@ No modules.
| [aws_partition.workload_current_partition](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
| [aws_ssm_parameter.amazon_linux_latest](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source |
| [aws_vpc.selected](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/vpc) | data source |
| [local_sensitive_file.zscaler_root_cert](https://registry.terraform.io/providers/hashicorp/local/latest/docs/data-sources/sensitive_file) | data source |

## Inputs

Expand Down
28 changes: 28 additions & 0 deletions modules/terraform-zscc-workload-aws/ZscalerRootCA.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIE0zCCA7ugAwIBAgIJANu+mC2Jt3uTMA0GCSqGSIb3DQEBCwUAMIGhMQswCQYD
VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2Ux
FTATBgNVBAoTDFpzY2FsZXIgSW5jLjEVM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gBgkqhkiG
9w0BCQEWE3N1cHBvcnRAenNjYWxlci5jb22CCQDbvpgtibd7kzAMBgNVHRMEBTAD
AQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAw0NdJh8w3NsJu4KHuVZUrmZgIohnTm0j+
RTmYQ9IKA/pvxAcA6K1i/LO+Bt+tCX+C0yxqB8qzuo+4vAzoY5JEBhyhBhf1uK+P
/WVWFZN/+hTgpSbZgzUEnWQG2gOVd24msex+0Sr7hyr9vn6OueH+jj+vCMiAm5+u
kd7lLvJsBu3AO3jGWVLyPkS3i6Gf+rwAp1OsRrv3WnbkYcFf9xjuaf4z0hRCrLN2
xFNjavxrHmsH8jPHVvgc1VD0Opja0l/BRVauTrUaoW6tE+wFG5rEcPGS80jjHK4S
pB5iDj2mUZH1T8lzYtuZy0ZPirxmtsk3135+CKNa2OCAhhFjE0xd
-----END CERTIFICATE-----
21 changes: 21 additions & 0 deletions modules/terraform-zscc-workload-aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,26 @@ resource "aws_security_group_rule" "server_node_ingress_ssh" {
}


################################################################################
# Generate user data script to install Zscaler Root Certificate in
# Amazon Linux 2 Workload Trust Store for SSL inspection
################################################################################
data "local_sensitive_file" "zscaler_root_cert" {
filename = "${path.module}/ZscalerRootCA.crt"
}

locals {
workloaduserdata = <<WORKLOADUSERDATA
#!/bin/bash
# Create ZscalerRootCA.crt file in /etc/pki/ca-trust/source/anchors/
echo "${data.local_sensitive_file.zscaler_root_cert.content}" > /etc/pki/ca-trust/source/anchors/ZscalerRootCA.crt
# Update the CA trust store
update-ca-trust
WORKLOADUSERDATA
}


################################################################################
# Create workload EC2 instances
################################################################################
Expand All @@ -112,6 +132,7 @@ resource "aws_instance" "server_host" {
subnet_id = element(var.subnet_id, count.index)
iam_instance_profile = aws_iam_instance_profile.server_host_profile.name
vpc_security_group_ids = [aws_security_group.node_sg.id]
user_data = local.workloaduserdata

metadata_options {
http_endpoint = "enabled"
Expand Down
4 changes: 4 additions & 0 deletions modules/terraform-zscc-workload-aws/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ terraform {
source = "hashicorp/aws"
version = ">= 4.59, <= 5.17"
}
local = {
source = "hashicorp/local"
version = "~> 2.2.0"
}
}
required_version = ">= 0.13.7, < 2.0.0"
}

0 comments on commit 21507cf

Please sign in to comment.