diff --git a/modules/terraform-zscc-workload-aws/README.md b/modules/terraform-zscc-workload-aws/README.md index f43be0da..00ed35e8 100644 --- a/modules/terraform-zscc-workload-aws/README.md +++ b/modules/terraform-zscc-workload-aws/README.md @@ -9,12 +9,14 @@ This module creates all AWS EC2 instance, IAM, and Security Group resources need |------|---------| | [terraform](#requirement\_terraform) | >= 0.13.7, < 2.0.0 | | [aws](#requirement\_aws) | >= 4.59, <= 5.17 | +| [local](#requirement\_local) | ~> 2.2.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 4.59, <= 5.17 | +| [local](#provider\_local) | ~> 2.2.0 | ## Modules @@ -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 diff --git a/modules/terraform-zscc-workload-aws/ZscalerRootCA.crt b/modules/terraform-zscc-workload-aws/ZscalerRootCA.crt new file mode 100755 index 00000000..45e3a29f --- /dev/null +++ b/modules/terraform-zscc-workload-aws/ZscalerRootCA.crt @@ -0,0 +1,28 @@ +-----BEGIN CERTIFICATE----- +MIIE0zCCA7ugAwIBAgIJANu+mC2Jt3uTMA0GCSqGSIb3DQEBCwUAMIGhMQswCQYD +VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTERMA8GA1UEBxMIU2FuIEpvc2Ux +FTATBgNVBAoTDFpzY2FsZXIgSW5jLjEVMBMGA1UECxMMWnNjYWxlciBJbmMuMRgw +FgYDVQQDEw9ac2NhbGVyIFJvb3QgQ0ExIjAgBgkqhkiG9w0BCQEWE3N1cHBvcnRA +enNjYW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QAw0NdJh8w3NsJu4KHuVZUrmZgIohnTm0j+ +RTmYQ9IKA/pvxAcA6K1i/LO+Bt+tCX+C0yxqB8qzuo+4vAzoY5JEBhyhBhf1uK+P +/WVWFZN/+hTgpSbZgzUEnWQG2gOVd24msex+0Sr7hyr9vn6OueH+jj+vCMiAm5+u +kd7lLvJsBu3AO3jGWVLyPkS3i6Gf+rwAp1OsRrv3WnbkYcFf9xjuaf4z0hRCrLN2 +xFNjavxrHmsH8jPHVvgc1VD0Opja0l/BRVauTrUaoW6tE+wFG5rEcPGS80jjHK4S +pB5iDj2mUZH1T8lzYtuZy0ZPirxmtsk3135+CKNa2OCAhhFjE0xd +-----END CERTIFICATE----- diff --git a/modules/terraform-zscc-workload-aws/main.tf b/modules/terraform-zscc-workload-aws/main.tf index 7740064b..cd46211e 100755 --- a/modules/terraform-zscc-workload-aws/main.tf +++ b/modules/terraform-zscc-workload-aws/main.tf @@ -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 = < /etc/pki/ca-trust/source/anchors/ZscalerRootCA.crt +# Update the CA trust store +update-ca-trust +WORKLOADUSERDATA +} + + ################################################################################ # Create workload EC2 instances ################################################################################ @@ -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" diff --git a/modules/terraform-zscc-workload-aws/versions.tf b/modules/terraform-zscc-workload-aws/versions.tf index e2afddda..13bb25f5 100755 --- a/modules/terraform-zscc-workload-aws/versions.tf +++ b/modules/terraform-zscc-workload-aws/versions.tf @@ -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" }