diff --git a/.gitignore b/.gitignore
index 7a3e2fd..0223c76 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,3 +27,4 @@ override.tf.json
# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*
+.terraform.lock.hcl
\ No newline at end of file
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..86802d0
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,7 @@
+---
+
+repos:
+- repo: https://github.com/antonbabenko/pre-commit-terraform
+ rev: v1.77.0
+ hooks:
+ - id: terraform_fmt
diff --git a/CODEOWNERS b/CODEOWNERS
new file mode 100644
index 0000000..f606d7b
--- /dev/null
+++ b/CODEOWNERS
@@ -0,0 +1 @@
+* @superblocksteam/engineering
diff --git a/CONTRIBUTING.txt b/CONTRIBUTING.txt
new file mode 100644
index 0000000..4a73815
--- /dev/null
+++ b/CONTRIBUTING.txt
@@ -0,0 +1,83 @@
+Superblocks Contribution License Agreement
+
+This Contribution License Agreement (the “CLA”) is between the individual set forth in the signature
+block (“You” and “Your”) and DayZero Software, Inc. d/b/a Superblocks, (“Superblocks”), effective as of
+the date of you accept this CLA (as set forth herein) and sets forth the terms pursuant to which You provides
+Contributions to Superblocks. BY MAKING OR SUBMITTING ANY CONTRIBUTION TO
+SUPERBLOCKS, YOU ACKNOWLEDGE AND AGREE THAT YOU ARE BOUND BY THE TERMS OF
+THIS CLA AND THAT SUPERBLOCKS MAY CHOOSE TO USE YOUR CONTRIBUTION UNDER
+THE TERMS SET FORTH HEREIN.
+
+You accept and agree to the following terms and conditions for Your present and future Contributions
+submitted to Superblocks. In return, Superblocks will not use Your Contributions in a way that is contrary to
+Superblocks’s business objectives. Except for the license granted herein to Superblocks and recipients of
+software distributed by Superblocks, You reserve all right, title, and interest in and to Your Contributions.
+
+1. Definitions. “Contribution” means any original work of authorship, including any modifications or
+additions to an existing work, that You intentionally submit to Superblocks for inclusion in, or documentation
+of, any of the products owned or managed by Superblocks (the “Work”). “Submit” means any form of
+electronic, verbal, or written communication sent to Superblocks or its representatives, including but not
+limited to communication on electronic mailing lists, source code control systems, and issue tracking systems
+that are managed by, or on behalf of, Superblocks for the purpose of discussing and improving the Work, but
+excluding communication that is conspicuously marked or otherwise designated in writing by You as “Not a
+Contribution.”
+
+2. Copyright License. Subject to the terms and conditions of this CLA, You hereby grant to Superblocks
+and to recipients of software distributed by Superblocks a perpetual, worldwide, non-exclusive, no-charge,
+royalty-free, irrevocable copyright license to reproduce, prepare derivative works of, publicly display,
+publicly perform, sublicense, and distribute Your Contributions and such derivative works.
+
+3. Patent License. Subject to the terms and conditions of this CLA, You hereby grant to Superblocks and
+to recipients of software distributed by Superblocks a perpetual, worldwide, non-exclusive, no-charge,
+royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell,
+sell, import, and otherwise transfer the Work, where such license applies only to those patent claims
+licensable by You that are necessarily infringed by Your Contribution(s) alone or by combination of Your
+Contribution(s) with the Work to which such Contribution(s) was submitted. If any entity institutes patent
+litigation against You or any other entity (including a cross-claim or counterclaim in a lawsuit) alleging that
+Your Contribution, or the Work to which You have contributed, constitutes direct or contributory patent
+infringement, then any patent licenses granted to that entity under this CLA for that Contribution or Work will
+terminate as of the date such litigation is filed.
+
+4. Representations and Warranties. You represent and warrant to Superblocks that:
+
+ a. You are legally entitled to grant the above license, and if Your employer(s) has rights to
+ intellectual property that You create that includes Your Contributions, then You represent and warrant that
+ You have received permission to make Contributions on behalf of that employer, that Your employer has
+ waived such rights for Your Contributions to Superblocks, or that Your employer has executed a separate
+ CLA with Superblocks;
+
+ b. Each of Your Contributions is Your original creation (see section 6 for submissions on behalf
+
+ of others); and
+
+ c. Your Contribution submissions include complete details of any third-party license or other
+ restriction (including, but not limited to, related patents and trademarks) of which You are personally aware
+ and which are associated with any part of Your Contributions.
+
+5. Support; Disclaimer. You are not expected to provide support for Your Contributions, except to the
+extent You desire to do so. You may provide support for free, for a fee, or not at all. Unless required by
+applicable law or agreed to in writing, You provide Your Contributions on an “AS IS” BASIS, WITHOUT
+WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation,
+any warranties or conditions of TITLE, NON- INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR
+A PARTICULAR PURPOSE.
+
+6. Third Party Works. If You wish to submit work that is not Your original creation, then You may
+submit it to Superblocks separately from any Contribution, identifying the complete details of its source and
+of any license or other restriction (including, but not limited to, related patents, trademarks, and license
+agreements) of which You are personally aware, and conspicuously marking the work as “Submitted on
+behalf of a third-party: [named here]”.
+
+7. Inaccuracies. You agree to notify Superblocks of any facts or circumstances of which You become
+aware that would make Your representations in this CLA inaccurate in any respect.
+
+8. General. This CLA is the entire understanding and agreement with respect to the subject matter
+hereof, and supersedes any and all prior or contemporaneous representations, understandings, and agreements,
+between the parties regarding same. If any part of this CLA is found to be unenforceable, the remaining
+portions of this CLA will remain in full force and effect. No modification of or amendment to this CLA, nor
+any waiver of any rights under this CLA, will be effective unless in writing signed by the party to be charged,
+and the waiver of any breach or default will not constitute a waiver of any other right under this CLA or any
+subsequent breach or default. Nothing in this CLA creates and the parties do not intend to create, any
+partnership or joint venture between themselves. Either party may freely assign this CLA. This CLA is
+binding upon and will inure to the benefit of a party’s successors and permitted assigns. This CLA will be
+governed by the laws of the State of California. Exclusive jurisdiction of any and all disputes hereunder will
+be in the state and federal courts in San Mateo County, California.
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..805d9bf
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,87 @@
+Superblocks Community Software License
+
+This Superblocks Community License Agreement (the “Agreement”) sets forth the terms on which DayZero
+Software, Inc. d/b/a Superblocks (“Superblocks”) makes available certain software made available by Superblocks
+under this Agreement (the “Software”). BY INSTALLING, DOWNLOADING, ACCESSING, USING OR
+DISTRIBUTING ANY OF THE SOFTWARE, YOU AGREE TO THE TERMS AND CONDITIONS OF THIS
+AGREEMENT.IF YOU DO NOT AGREE TO SUCH TERMS AND CONDITIONS, YOU MUST NOT USE THE
+SOFTWARE. IF YOU ARE RECEIVING THE SOFTWARE ON BEHALF OF A LEGAL ENTITY, YOU
+REPRESENT AND WARRANT THAT YOU HAVE THE ACTUAL AUTHORITY TO AGREE TO THE
+TERMS AND CONDITIONS OF THIS AGREEMENT ON BEHALF OF SUCH ENTITY. “Licensee” means you,
+an individual, or the entity on whose behalf you are receiving the Software.
+
+1. LICENSE GRANT AND CONDITIONS.
+
+1.1 License. Subject to the terms and conditions of this Agreement, Superblocks hereby grants to Licensee a
+non-exclusive, royalty-free, worldwide, non-transferable, non-sublicenseable license during the term of this
+Agreement to: (a) use the Software; (b) prepare modifications and derivative works of the Software; (c)
+distribute the Software (including without limitation in source code or object code form); and (d) reproduce
+copies of the Software (the “License”). Licensee is not granted the right to, and Licensee shall not, exercise the
+License for an Excluded Purpose. For purposes of this Agreement, “Excluded Purpose” means making
+available any software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar online
+service that competes with Superblocks’ products or services.
+
+1.2 Conditions. In consideration of the License, Licensee’s distribution of the Software is subject to the
+following conditions:
+
+ a. Licensee must cause any Software modified by Licensee to carry prominent notices stating that Licensee
+ modified the Software.
+ b. On each Software copy, Licensee shall reproduce and not remove or alter all Superblocks or third party
+ copyright or other proprietary notices contained in the Software, and Licensee must provide the notice
+ below with each copy.
+
+ “This software is made available by DayZero Software, Inc. d/b/a Superblocks, under the terms of the
+ Superblocks Community License Agreement. © 2022 DayZero Software, Inc.”
+
+1.3 Licensee Modifications. Licensee may add its own copyright notices to modifications made by Licensee
+and may provide additional or different license terms and conditions for use, reproduction, or distribution of
+Licensee’s modifications. While redistributing the Software or modifications thereof, Licensee may choose to
+offer, for a fee or free of charge, support, warranty, indemnity, or other obligations. Licensee, and not
+Superblocks, will be responsible for any such obligations.
+
+1.4 No Sublicensing. The License does not include the right to sublicense the Software, however, each recipient
+to which Licensee provides the Software may exercise the Licenses so long as such recipient agrees to the terms
+and conditions of this Agreement.
+
+2. TERM AND TERMINATION. This Agreement will continue unless and until earlier terminated as set forth
+herein. If Licensee breaches any of its conditions or obligations under this Agreement, this Agreement will
+terminate automatically and the License will terminate automatically and permanently.
+
+3. INTELLECTUAL PROPERTY. As between the parties, Superblocks will retain all right, title, and interest in
+the Software, and all intellectual property rights therein. Superblocks hereby reserves all rights not expressly
+granted to Licensee in this Agreement. Superblocks hereby reserves all rights in its trademarks and service
+marks, and no licenses therein are granted in this Agreement.
+
+4. DISCLAIMER. SUPERBLOCKS HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND
+CONDITIONS, EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, AND SPECIFICALLY
+DISCLAIMS ANY WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
+PURPOSE, WITH RESPECT TO THE SOFTWARE.
+
+5. LIMITATION OF LIABILITY. SUPERBLOCKS WILL NOT BE LIABLE FOR ANY DAMAGES OF
+ANY KIND, INCLUDING BUT NOT LIMITED TO, LOST PROFITS OR ANY CONSEQUENTIAL,
+SPECIAL, INCIDENTAL, INDIRECT, OR DIRECT DAMAGES, HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, ARISING OUT OF THIS AGREEMENT. THE FOREGOING SHALL APPLY TO
+THE EXTENT PERMITTED BY APPLICABLE LAW.
+
+6. GENERAL.
+
+6.1 Governing Law. This Agreement will be governed by and interpreted in accordance with the laws of the
+state of California, without reference to its conflict of laws principles. If Licensee is located within the United
+States, all disputes arising out of this Agreement are subject to the exclusive jurisdiction of courts located in San
+Mateo County, California. USA. If Licensee is located outside of the United States, any dispute, controversy or
+claim arising out of or relating to this Agreement will be referred to and finally determined by arbitration in
+accordance with the JAMS International Arbitration Rules. The tribunal will consist of one neutral arbitrator.
+The place of arbitration will be Palo Alto, California. The language to be used in the arbitral proceedings will be
+English. Judgment upon the award rendered by the arbitrator may be entered in any court having jurisdiction
+thereof.
+
+6.2. Assignment. Licensee may not assign its rights under this Agreement to any third party. Superblocks may
+freely assign its rights under this Agreement to any third party.
+
+6.3. Other. This Agreement is the entire agreement between the parties regarding the subject matter hereof.
+No amendment or modification of this Agreement will be valid or binding upon the parties unless made in
+writing and signed by the duly authorized representatives of both parties. In the event that any provision,
+including without limitation any condition, of this Agreement is held to be unenforceable, this Agreement and
+all licenses and rights granted hereunder will immediately terminate. Waiver by Superblocks of a breach of any
+provision of this Agreement or the failure by Superblocks to exercise any right hereunder will not be construed
+as a waiver of any subsequent breach of that right or as a waiver of any other right.
diff --git a/README.md b/README.md
index 51d53d6..4b86a4f 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,114 @@
-# terraform-google-superblocks
\ No newline at end of file
+
+
+
+
+Superblocks Terraform Module - Google
+
+
+
+This document contains configuration and deployment details for deploying the Superblocks agent to Google Cloud.
+
+## Deploy with Terraform
+
+### Install Terraform
+
+To install Terraform on MacOS
+```
+brew tap hashicorp/tap
+brew install hashicorp/tap/terraform
+```
+
+Terraform officially supports `MacOS|Windows|Linux|FreeBSD|OpenBSD|Solaris`
+Check out this https://developer.hashicorp.com/terraform/downloads for more details
+
+### Deploy Superblocks On-Premise-Agent
+
+#### Create your Terraform file
+To get started, you'll need a `superblocks_agent_key`. To generate an agent key, go to the [Superblocks On-Premise Agent Setup Wizard](https://app.superblocks.com/opas)
+```
+module "terraform_google_superblocks" {
+ source = "superblocksteam/terraform-google-superblocks"
+ version = ">=1.0"
+
+ project_id = ""
+ region = ""
+
+ superblocks_agent_key = ""
+
+ # Subdomain & domain in you Superblocks agent host url, for example superblocks.example.com
+ sudomain = ""
+ domain = ""
+
+ # Google Cloud DNS Zone Name
+ zone_name = ""
+}
+```
+If you use Google Cloud DNS, find the `zone_name` for your `domain` by running `gcloud dns managed-zones list --filter "dns_name ~ ${domain}`. If you don't use Google Cloud DNS, see the [Custom Domain Mapping](https://cloud.google.com/run/docs/mapping-custom-domains) section for how you can manually configure the DNS for your agent.
+
+#### Deploy
+```
+terraform init
+terraform apply
+```
+
+### Advanced Configuration
+#### Private Networking
+The Terraform module configures your Cloud Run service's ingress to "Allow all traffic." You can update the ingress rules to "Only allow internal traffic" by adding the following to the Terraform module
+
+```
+internal = true
+```
+
+#### Custom Domain Mapping
+By default, this module will try to configure a **custom domain** for your Cloud Run service, for example `subdomain.example.com`. This configures both the [Cloud Run Domain Mapping](https://cloud.google.com/run/docs/mapping-custom-domains#map) and a CNAME DNS record for your `domain`.
+
+For this to work successfully, you must verify ownership of your `domain` with Google, and have a Cloud DNS Zone configured for the domain. To verify domain ownership, use the Google CLI command `gcloud domains verify ${domain}`. Find the Cloud DNS Zone Name for your domain by running `gcloud dns managed-zones list --filter "dns_name ~ ${domain}`.
+
+If you don't use Google Cloud DNS, or want to manually configure the Domain Mapping, just disable DNS creation by adding the following to the Terraform module
+
+```
+create_dns = false
+```
+
+If you decide to manually set up a custom domain for your Cloud Run service, follow Google's instructions for [Mapping customer domains](https://cloud.google.com/run/docs/mapping-custom-domains#run)
+
+#### Instance Sized
+Configure the CPU & memory limits for your Cloud Run instances by adding the following variables to your Terraform module
+```
+container_requests_cpu = "512m"
+container_requests_memory = "1024Mi"
+container_limits_cpu = "1.0"
+container_limits_memory = "2048Mi"
+
+```
+
+#### Scaling
+Google will automatically scale your Cloud Run instances based on traffic. To configure the minimum and maximum number of instances the agent can scale to, add these variables to your Terraform module
+```
+container_min_capacity = "1"
+container_max_capacity = "5"
+```
+
+#### Other Configurable Options
+```
+variable "superblocks_agent_environment" {
+ type = string
+ default = "*"
+ description = <.json")
+ project = var.project_id
+ region = var.region
+}
+
+variable "project_id" {
+ type = string
+ default = ""
+}
+
+variable "region" {
+ type = string
+ default = "us-central1"
+}
+
+variable "superblocks_agent_key" {
+ type = string
+ default = ""
+ sensitive = true
+}
+
+module "cloud_run" {
+ source = "../../modules/cloud-run"
+
+ project_id = var.project_id
+ region = var.region
+ name_prefix = "superblocks"
+ internal = false
+
+ container_image = "us-east1-docker.pkg.dev/superblocks-registry/superblocks/agent"
+ container_port = "8020"
+
+ container_env = {
+ "__SUPERBLOCKS_AGENT_SERVER_URL" = "https://app.superblocks.com",
+ "__SUPERBLOCKS_WORKER_LOCAL_ENABLED" = "true",
+ "SUPERBLOCKS_WORKER_TLS_INSECURE" = "true",
+ "SUPERBLOCKS_AGENT_KEY" = var.superblocks_agent_key,
+ "SUPERBLOCKS_CONTROLLER_DISCOVERY_ENABLED" = "false",
+ "SUPERBLOCKS_AGENT_HOST_URL" = "https://example-complete.koalitytools.com",
+ "SUPERBLOCKS_AGENT_ENVIRONMENT" = "*",
+ "SUPERBLOCKS_AGENT_PORT" = "8020"
+ }
+
+ container_requests_cpu = "512m"
+ container_requests_memory = "1024Mi"
+ container_limits_cpu = "1.0"
+ container_limits_memory = "2048Mi"
+ container_min_capacity = "1"
+ container_max_capacity = "5"
+}
+
+# Once Superblocks Agent is deployed to Cloud Run, create the DNS record manually.
+# Go to "Cloud Run -> Manage Custom Domains -> Add Mappings"
+# follow the instructions to
+# 1. verify your domain
+# 2. create the mapping
+# 3. update DNS record
diff --git a/examples/custom-url/main.tf b/examples/custom-url/main.tf
new file mode 100644
index 0000000..34e1bc7
--- /dev/null
+++ b/examples/custom-url/main.tf
@@ -0,0 +1,41 @@
+provider "google" {
+ #credentials = file(".json")
+ project = var.project_id
+ region = var.region
+}
+
+variable "project_id" {
+ type = string
+ default = ""
+}
+
+variable "region" {
+ type = string
+ default = "us-central1"
+}
+
+variable "superblocks_agent_key" {
+ type = string
+ default = ""
+ sensitive = true
+}
+
+module "terraform_google_superblocks" {
+ source = "../../"
+
+ project_id = var.project_id
+ region = var.region
+
+ superblocks_agent_key = var.superblocks_agent_key
+
+ subdomain = "custom-url"
+ domain = "koalitytools.com"
+ create_dns = false
+}
+
+# Once Superblocks Agent is deployed to Cloud Run, create the DNS record manually.
+# Go to "Cloud Run -> Manage Custom Domains -> Add Mappings"
+# follow the instructions to
+# 1. verify your domain
+# 2. create the mapping
+# 3. update DNS record
diff --git a/examples/simple-public-agent/main.tf b/examples/simple-public-agent/main.tf
new file mode 100644
index 0000000..ea9cbbb
--- /dev/null
+++ b/examples/simple-public-agent/main.tf
@@ -0,0 +1,34 @@
+provider "google" {
+ #credentials = file(".json")
+ project = var.project_id
+ region = var.region
+}
+
+variable "project_id" {
+ type = string
+ default = ""
+}
+
+variable "region" {
+ type = string
+ default = "us-central1"
+}
+
+variable "superblocks_agent_key" {
+ type = string
+ default = ""
+ sensitive = true
+}
+
+module "terraform_google_superblocks" {
+ source = "../../"
+
+ project_id = var.project_id
+ region = var.region
+
+ superblocks_agent_key = var.superblocks_agent_key
+
+ subdomain = "example-simple-public-agent"
+ domain = "koalitytools.com"
+ zone_name = "koalitytools-com"
+}
diff --git a/main.tf b/main.tf
new file mode 100644
index 0000000..2f9e243
--- /dev/null
+++ b/main.tf
@@ -0,0 +1,45 @@
+#################################################################
+# Cloud Run
+#################################################################
+module "cloud_run" {
+ count = var.deploy_in_cloud_run ? 1 : 0
+ source = "./modules/cloud-run"
+
+ project_id = var.project_id
+ region = var.region
+ internal = var.internal
+ name_prefix = var.name_prefix
+
+ container_port = var.superblocks_agent_port
+ container_image = var.superblocks_agent_image
+ container_env = {
+ "__SUPERBLOCKS_AGENT_SERVER_URL" = var.superblocks_server_url,
+ "__SUPERBLOCKS_WORKER_LOCAL_ENABLED" = "true",
+ "SUPERBLOCKS_WORKER_TLS_INSECURE" = "true",
+ "SUPERBLOCKS_AGENT_KEY" = var.superblocks_agent_key,
+ "SUPERBLOCKS_CONTROLLER_DISCOVERY_ENABLED" = "false",
+ "SUPERBLOCKS_AGENT_HOST_URL" = "https://${var.subdomain}.${var.domain}",
+ "SUPERBLOCKS_AGENT_ENVIRONMENT" = var.superblocks_agent_environment,
+ "SUPERBLOCKS_AGENT_PORT" = var.superblocks_agent_port
+ }
+ container_requests_cpu = var.container_requests_cpu
+ container_requests_memory = var.container_requests_memory
+ container_limits_cpu = var.container_limits_cpu
+ container_limits_memory = var.container_limits_memory
+ container_max_capacity = var.container_max_capacity
+ container_min_capacity = var.container_min_capacity
+}
+
+#################################################################
+# DNS
+#################################################################
+module "dns" {
+ count = var.create_dns ? 1 : 0
+ source = "./modules/dns"
+
+ project_id = var.project_id
+ region = var.region
+ zone_name = var.zone_name
+ record_name = var.subdomain
+ route_name = module.cloud_run[0].route_name
+}
diff --git a/modules/cloud-run/locals.tf b/modules/cloud-run/locals.tf
new file mode 100644
index 0000000..bde03e0
--- /dev/null
+++ b/modules/cloud-run/locals.tf
@@ -0,0 +1,3 @@
+locals {
+ ingress_rule = var.internal == true ? "internal" : "all"
+}
diff --git a/modules/cloud-run/main.tf b/modules/cloud-run/main.tf
new file mode 100644
index 0000000..a54d01a
--- /dev/null
+++ b/modules/cloud-run/main.tf
@@ -0,0 +1,58 @@
+resource "google_cloud_run_service" "superblocks" {
+ name = "${var.name_prefix}-cloud-run-service"
+ location = var.region
+
+ metadata {
+ namespace = var.project_id
+ annotations = {
+ "run.googleapis.com/ingress" = "${local.ingress_rule}"
+ }
+ }
+
+ template {
+ spec {
+ containers {
+ image = var.container_image
+ resources {
+ requests = {
+ cpu = "${var.container_requests_cpu}"
+ memory = "${var.container_requests_memory}"
+ }
+ limits = {
+ cpu = "${var.container_limits_cpu}"
+ memory = "${var.container_limits_memory}"
+ }
+ }
+ ports {
+ container_port = var.container_port
+ }
+ dynamic "env" {
+ for_each = var.container_env
+ content {
+ name = env.key
+ value = env.value
+ }
+ }
+ }
+ }
+ metadata {
+ annotations = {
+ "autoscaling.knative.dev/minScale" = "${var.container_min_capacity}"
+ "autoscaling.knative.dev/maxScale" = "${var.container_max_capacity}"
+ }
+ }
+ }
+
+ traffic {
+ percent = 100
+ latest_revision = true
+ }
+
+}
+
+resource "google_cloud_run_service_iam_member" "superblocks" {
+ service = google_cloud_run_service.superblocks.name
+ location = google_cloud_run_service.superblocks.location
+ role = var.cloud_run_role
+ member = var.cloud_run_member
+}
diff --git a/modules/cloud-run/outputs.tf b/modules/cloud-run/outputs.tf
new file mode 100644
index 0000000..1ae3205
--- /dev/null
+++ b/modules/cloud-run/outputs.tf
@@ -0,0 +1,3 @@
+output "route_name" {
+ value = google_cloud_run_service.superblocks.name
+}
diff --git a/modules/cloud-run/provider.tf b/modules/cloud-run/provider.tf
new file mode 100644
index 0000000..0cafcf4
--- /dev/null
+++ b/modules/cloud-run/provider.tf
@@ -0,0 +1,10 @@
+terraform {
+ required_version = ">= 1.0"
+
+ required_providers {
+ google = {
+ source = "hashicorp/google"
+ version = ">= 3.5.0"
+ }
+ }
+}
diff --git a/modules/cloud-run/variables.tf b/modules/cloud-run/variables.tf
new file mode 100644
index 0000000..3b396e2
--- /dev/null
+++ b/modules/cloud-run/variables.tf
@@ -0,0 +1,84 @@
+variable "project_id" {
+ type = string
+ validation {
+ condition = length(var.project_id) > 0
+ error_message = "Variable `project_id` cannot be null."
+ }
+}
+
+variable "region" {
+ type = string
+ validation {
+ condition = length(var.region) > 0
+ error_message = "Variable `region` cannot null."
+ }
+}
+
+variable "name_prefix" {
+ type = string
+ default = "superblocks"
+}
+
+variable "internal" {
+ type = bool
+ default = false
+}
+
+variable "container_image" {
+ type = string
+ default = "us-east1-docker.pkg.dev/superblocks-registry/superblocks/agent"
+}
+
+variable "container_port" {
+ type = number
+ default = "8020"
+}
+
+variable "container_env" {
+ type = map(any)
+ default = {}
+}
+
+variable "container_requests_cpu" {
+ type = string
+ default = "512m"
+ description = "Amount of CPU millicores."
+}
+
+variable "container_requests_memory" {
+ type = string
+ default = "1024Mi"
+ description = "Amount of memory in MiB"
+}
+
+variable "container_limits_cpu" {
+ type = string
+ default = "1.0"
+ description = "CPU limit, must be equal to one of [.08-1], 1.0, 2.0, 4.0, 6.0, 8.0"
+}
+
+variable "container_limits_memory" {
+ type = string
+ default = "2048Mi"
+ description = "Amount of memory in MiB"
+}
+
+variable "container_min_capacity" {
+ type = number
+ default = "1"
+}
+
+variable "container_max_capacity" {
+ type = number
+ default = "5"
+}
+
+variable "cloud_run_role" {
+ type = string
+ default = "roles/run.invoker"
+}
+
+variable "cloud_run_member" {
+ type = string
+ default = "allUsers"
+}
diff --git a/modules/dns/main.tf b/modules/dns/main.tf
new file mode 100644
index 0000000..ab6bebb
--- /dev/null
+++ b/modules/dns/main.tf
@@ -0,0 +1,29 @@
+data "google_dns_managed_zone" "superblocks" {
+ name = var.zone_name
+}
+
+locals {
+ dns_name = data.google_dns_managed_zone.superblocks.dns_name
+ dns_name_no_dot = substr(local.dns_name, 0, length(local.dns_name) - 1)
+}
+
+resource "google_cloud_run_domain_mapping" "superblocks" {
+ name = "${var.record_name}.${local.dns_name_no_dot}"
+ location = var.region
+
+ metadata {
+ namespace = var.project_id
+ }
+
+ spec {
+ route_name = var.route_name
+ }
+}
+
+resource "google_dns_record_set" "superblocks" {
+ managed_zone = data.google_dns_managed_zone.superblocks.name
+ name = "${var.record_name}.${local.dns_name}"
+ ttl = 300
+ type = "CNAME"
+ rrdatas = ["${var.record_name}.${local.dns_name}"]
+}
diff --git a/modules/dns/variables.tf b/modules/dns/variables.tf
new file mode 100644
index 0000000..a56a4c2
--- /dev/null
+++ b/modules/dns/variables.tf
@@ -0,0 +1,38 @@
+variable "project_id" {
+ type = string
+ validation {
+ condition = length(var.project_id) > 0
+ error_message = "Variable `project_id` cannot be null."
+ }
+}
+
+variable "region" {
+ type = string
+ validation {
+ condition = length(var.region) > 0
+ error_message = "Variable `region` cannot be null."
+ }
+}
+
+variable "zone_name" {
+ type = string
+ default = null
+ description = "This is the name of Google DNS Managed Zone that in the same project"
+}
+
+variable "record_name" {
+ type = string
+ default = "agent"
+ description = "This is the record that will be created in Google DNS Managed Zone"
+}
+
+variable "route_name" {
+ type = string
+ default = ""
+ description = "This is route of Cloud Run service. New DNS record will be mapped to it"
+}
+
+variable "namespace" {
+ type = string
+ default = "superblocks"
+}
diff --git a/provider.tf b/provider.tf
new file mode 100644
index 0000000..0cafcf4
--- /dev/null
+++ b/provider.tf
@@ -0,0 +1,10 @@
+terraform {
+ required_version = ">= 1.0"
+
+ required_providers {
+ google = {
+ source = "hashicorp/google"
+ version = ">= 3.5.0"
+ }
+ }
+}
diff --git a/variables.tf b/variables.tf
new file mode 100644
index 0000000..0dc26d1
--- /dev/null
+++ b/variables.tf
@@ -0,0 +1,142 @@
+#################################################################
+# Common
+#################################################################
+variable "project_id" {
+ type = string
+ validation {
+ condition = length(var.project_id) > 0
+ error_message = "Variable `project_id` cannot be null."
+ }
+}
+
+variable "region" {
+ type = string
+ validation {
+ condition = length(var.region) > 0
+ error_message = "Variable `region` cannot be null."
+ }
+}
+
+variable "superblocks_agent_key" {
+ type = string
+ sensitive = true
+ validation {
+ condition = length(var.superblocks_agent_key) > 10
+ error_message = "The agent key is invalid."
+ }
+}
+
+variable "superblocks_agent_environment" {
+ type = string
+ default = "*"
+ description = <