Skip to content

Commit 9669c89

Browse files
Simplify console image handling for AutoMQ BYOC (#1)
* Simplify console image configuration * terraform-docs: automated action --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent bd2a477 commit 9669c89

File tree

4 files changed

+19
-34
lines changed

4 files changed

+19
-34
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,14 @@ output "automq_byoc_google_service_account" {
196196
|------|---------|
197197
| <a name="requirement_terraform"></a> [terraform](#requirement_terraform) | >= 1.0 |
198198
| <a name="requirement_google"></a> [google](#requirement_google) | >= 5, < 7 |
199+
| <a name="requirement_random"></a> [random](#requirement_random) | >= 3.0.0 |
199200

200201
## Providers
201202

202203
| Name | Version |
203204
|------|---------|
204-
| <a name="provider_google"></a> [google](#provider_google) | 6.11.0 |
205+
| <a name="provider_random"></a> [random](#provider_random) | >= 3.0.0 |
206+
| <a name="provider_google"></a> [google](#provider_google) | >= 5, < 7 |
205207

206208
## Modules
207209

@@ -216,6 +218,7 @@ No modules.
216218
| [google_compute_disk.data_volume](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_disk) | resource |
217219
| [google_compute_firewall.allow_googleapis_ipv4](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall) | resource |
218220
| [google_compute_firewall.automq_byoc_console_sg](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall) | resource |
221+
| [google_compute_firewall.subnet_allow-internal](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_firewall) | resource |
219222
| [google_compute_instance.automq_byoc_console](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance) | resource |
220223
| [google_compute_network.automq_network](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_network) | resource |
221224
| [google_compute_route.route_ipv4_googleapi](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_route) | resource |
@@ -227,6 +230,7 @@ No modules.
227230
| [google_project_iam_binding.automq_byoc_gke_sa_binding](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_binding) | resource |
228231
| [google_project_iam_binding.automq_byoc_resource_sa_binding](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_binding) | resource |
229232
| [google_project_iam_binding.automq_byoc_storage_sa_binding](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_binding) | resource |
233+
| [google_project_iam_binding.gke_permission_binding0](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_binding) | resource |
230234
| [google_project_iam_custom_role.automq_byoc_compute_role](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_custom_role) | resource |
231235
| [google_project_iam_custom_role.automq_byoc_dns_role](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_custom_role) | resource |
232236
| [google_project_iam_custom_role.automq_byoc_gke_role](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_custom_role) | resource |
@@ -240,7 +244,7 @@ No modules.
240244
| [google_tags_tag_key.automqVendorKey](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/tags_tag_key) | resource |
241245
| [google_tags_tag_value.automqEnvValue](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/tags_tag_value) | resource |
242246
| [google_tags_tag_value.automqVendorValue](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/tags_tag_value) | resource |
243-
| [google_compute_image.console_image](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_image) | data source |
247+
| [random_id.deployment_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource |
244248
| [google_compute_network.vpc](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/compute_network) | data source |
245249
| [google_project.project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/project) | data source |
246250
| [google_storage_bucket.ops_bucket](https://registry.terraform.io/providers/hashicorp/google/latest/docs/data-sources/storage_bucket) | data source |
@@ -259,9 +263,8 @@ No modules.
259263
| <a name="input_automq_byoc_env_console_cidr"></a> [automq_byoc_env_console_cidr](#input_automq_byoc_env_console_cidr) | Set CIDR block to restrict the source IP address range for accessing the AutoMQ environment console. If not set, the default is 0.0.0.0/0. | `string` | `"0.0.0.0/0"` | no |
260264
| <a name="input_automq_byoc_ops_bucket_name"></a> [automq_byoc_ops_bucket_name](#input_automq_byoc_ops_bucket_name) | Set the existed GCS bucket used to store AutoMQ system logs and metrics data for system monitoring and alerts. If this parameter is not set, a new GCS bucket will be automatically created. This Bucket does not contain any application business data. | `string` | `""` | no |
261265
| <a name="input_automq_byoc_machine_type"></a> [automq_byoc_machine_type](#input_automq_byoc_machine_type) | Set the Compute Engine machine type; this parameter is used only for deploying the AutoMQ environment console. You need to provide a machine type with at least 2 cores and 8 GB of memory. | `string` | `"e2-standard-2"` | no |
262-
| <a name="input_automq_byoc_env_version"></a> [automq_byoc_env_version](#input_automq_byoc_env_version) | Set the version for the AutoMQ BYOC environment console. It is recommended to keep the default value, which is the latest version. | `string` | `"1.4.0"` | no |
263-
| <a name="input_use_custom_image"></a> [use_custom_image](#input_use_custom_image) | The parameter defaults to false, which means a specific custom image is not specified. If you wish to use a custom image, set this parameter to true and specify the automq_byoc_env_console_image parameter. | `bool` | `false` | no |
264-
| <a name="input_automq_byoc_env_console_image"></a> [automq_byoc_env_console_image](#input_automq_byoc_env_console_image) | When the use_custom_image parameter is set to true, this parameter must be set with a custom image name to deploy the AutoMQ console. | `string` | `""` | no |
266+
| <a name="input_use_custom_image"></a> [use_custom_image](#input_use_custom_image) | Set to true to use a custom image for the AutoMQ environment console and provide the image self link via automq_byoc_env_console_image. | `bool` | `false` | no |
267+
| <a name="input_automq_byoc_env_console_image"></a> [automq_byoc_env_console_image](#input_automq_byoc_env_console_image) | The custom image self link used when use_custom_image is true. | `string` | `""` | no |
265268
| <a name="input_ssh_public_key"></a> [ssh_public_key](#input_ssh_public_key) | Set the SSH public key for the AutoMQ environment console. The public key is used to access the AutoMQ environment console via SSH. | `string` | `""` | no |
266269

267270
## Outputs
@@ -275,4 +278,5 @@ No modules.
275278
| <a name="output_automq_byoc_vpc_id"></a> [automq_byoc_vpc_id](#output_automq_byoc_vpc_id) | The VPC ID for the AutoMQ environment deployment. |
276279
| <a name="output_automq_byoc_instance_id"></a> [automq_byoc_instance_id](#output_automq_byoc_instance_id) | The EC2 instance id for AutoMQ Console. |
277280
| <a name="output_automq_byoc_google_service_account"></a> [automq_byoc_google_service_account](#output_automq_byoc_google_service_account) | The Google Service Account for the AutoMQ environment deployment. |
278-
<!-- END_TF_DOCS -->
281+
| <a name="output_automq_byoc_console_subnet"></a> [automq_byoc_console_subnet](#output_automq_byoc_console_subnet) | The subnet for the AutoMQ environment console. |
282+
<!-- END_TF_DOCS -->

google.tf

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ locals {
1313

1414
automq_env_tag_key = "automqEnvironmentId"
1515
automq_env_tag_value = var.automq_byoc_env_id
16+
17+
console_image_self_link = var.use_custom_image ? var.automq_byoc_env_console_image : "projects/automq-public/global/images/automq-control-center-prod-7-7-4-x86-64"
1618
}
1719

1820
data "google_project" "project" {
@@ -252,7 +254,7 @@ resource "google_project_iam_custom_role" "automq_byoc_gke_role" {
252254
"container.storageClasses.update",
253255
"container.deployments.get",
254256
"container.deployments.create",
255-
"container.deployments.delete",
257+
"container.deployments.delete",
256258
"container.deployments.list",
257259
"container.deployments.getScale",
258260
"container.deployments.getStatus",
@@ -303,10 +305,6 @@ resource "google_project_iam_binding" "automq_byoc_gke_sa_binding" {
303305
members = [
304306
"serviceAccount:${google_service_account.automq_byoc_sa.email}"
305307
]
306-
condition {
307-
title = "AutoMQ BYOC ${var.automq_byoc_env_id} GKE Role Condition"
308-
expression = "resource.matchTag(\"${var.cloud_project_id}/automqAssigned\", \"automq\")"
309-
}
310308
}
311309

312310
resource "google_project_iam_binding" "automq_byoc_storage_sa_binding" {
@@ -348,23 +346,13 @@ resource "google_compute_address" "web_ip" {
348346
}
349347

350348

351-
locals {
352-
console_image_name = var.use_custom_image ? var.automq_byoc_env_console_image : "Automq-control-center-Prod-${var.automq_byoc_env_version}-x86_64"
353-
}
354-
data "google_compute_image" "console_image" {
355-
name = lower(
356-
replace(replace(local.console_image_name,
357-
"_", "-"),
358-
".", "-"))
359-
}
360-
361349
data "google_compute_network" "vpc" {
362350
depends_on = [google_compute_network.automq_network]
363351
name = local.automq_byoc_vpc_name
364352
}
365353

366354
resource "google_compute_route" "route_ipv4_googleapi" {
367-
count = var.create_new_vpc ? 1 : 0
355+
count = var.create_new_vpc ? 1 : 0
368356
name = "route-to-gapis-ipv4-${var.automq_byoc_env_id}"
369357
network = data.google_compute_network.vpc.name
370358
dest_range = "199.36.153.8/30"
@@ -374,7 +362,7 @@ resource "google_compute_route" "route_ipv4_googleapi" {
374362
}
375363

376364
resource "google_compute_route" "route_ipv4_googleapi_additional" {
377-
count = var.create_new_vpc ? 1 : 0
365+
count = var.create_new_vpc ? 1 : 0
378366
name = "route-to-gapis-ipv4-additional-${var.automq_byoc_env_id}"
379367
network = data.google_compute_network.vpc.name
380368
dest_range = "34.126.0.0/18"
@@ -410,7 +398,7 @@ resource "google_compute_firewall" "subnet_allow-internal" {
410398
}
411399

412400
resource "google_compute_firewall" "allow_googleapis_ipv4" {
413-
count = var.create_new_vpc ? 1 : 0
401+
count = var.create_new_vpc ? 1 : 0
414402
name = "allow-out-gapis-ipv4-${var.automq_byoc_env_id}"
415403
network = data.google_compute_network.vpc.name
416404

@@ -426,4 +414,3 @@ resource "google_compute_firewall" "allow_googleapis_ipv4" {
426414

427415
direction = "EGRESS"
428416
}
429-

main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resource "google_compute_instance" "automq_byoc_console" {
55

66
boot_disk {
77
initialize_params {
8-
image = data.google_compute_image.console_image.self_link
8+
image = local.console_image_self_link
99
size = 20
1010
type = "pd-balanced"
1111
}

variables.tf

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,14 @@ variable "automq_byoc_machine_type" {
5858
default = "e2-standard-2" # GCP equivalent of t3.large
5959
}
6060

61-
variable "automq_byoc_env_version" {
62-
description = "Set the version for the AutoMQ BYOC environment console. It is recommended to keep the default value, which is the latest version."
63-
type = string
64-
default = "1.4.0"
65-
}
66-
6761
variable "use_custom_image" {
68-
description = "The parameter defaults to false, which means a specific custom image is not specified. If you wish to use a custom image, set this parameter to true and specify the automq_byoc_env_console_image parameter."
62+
description = "Set to true to use a custom image for the AutoMQ environment console and provide the image self link via automq_byoc_env_console_image."
6963
type = bool
7064
default = false
7165
}
7266

7367
variable "automq_byoc_env_console_image" {
74-
description = "When the use_custom_image parameter is set to true, this parameter must be set with a custom image name to deploy the AutoMQ console."
68+
description = "The custom image self link used when use_custom_image is true."
7569
type = string
7670
default = ""
7771
}

0 commit comments

Comments
 (0)