Skip to content

Commit

Permalink
fix clashing resources.
Browse files Browse the repository at this point in the history
  • Loading branch information
tjholm committed Dec 10, 2024
1 parent ae5e8f7 commit 0c15363
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cloud/gcp/deploytf/.nitric/modules/api/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
resource "google_api_gateway_api" "api" {
provider = google-beta
api_id = var.name
api_id = "${var.name}-${random_string.api_config_id.result}"
labels = {
"x-nitric-${var.stack_id}-name" = var.name
"x-nitric-${var.stack_id}-type" = "api"
Expand All @@ -21,7 +21,7 @@ resource "random_string" "api_config_id" {

resource "google_service_account" "service_account" {
provider = google-beta
account_id = "${var.name}-api"
account_id = "${var.name}-api-${random_string.api_config_id.result}"
}

# Get the current service account email and ensure it has service account user role on the service account
Expand Down Expand Up @@ -82,7 +82,7 @@ resource "google_api_gateway_api_config" "api_config" {

resource "google_api_gateway_gateway" "gateway" {
provider = google-beta
gateway_id = "${var.name}-gateway"
gateway_id = "${var.name}-gateway-${random_string.api_config_id.result}"
api_config = google_api_gateway_api_config.api_config.id

labels = {
Expand Down
10 changes: 8 additions & 2 deletions cloud/gcp/deploytf/.nitric/modules/queue/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@

resource "random_string" "unique_id" {
length = 4
special = false
upper = false
}

# Deploy a PubSub topic to serve as the queue
resource "google_pubsub_topic" "queue" {
name = "${var.queue_name}-nitricqueue"
name = "${var.queue_name}-nitricqueue-${random_string.unique_id.result}"

kms_key_name = var.kms_key != "" ? var.kms_key : null
labels = {
Expand All @@ -12,7 +18,7 @@ resource "google_pubsub_topic" "queue" {

# Create a pull subscription for the topic to emulate a queue
resource "google_pubsub_subscription" "queue_subscription" {
name = "${var.queue_name}-nitricqueue"
name = "${var.queue_name}-nitricqueue-${random_string.unique_id.result}"
topic = google_pubsub_topic.queue.name
expiration_policy {
# TODO: this is blank in the Pulumi provider - verify this is still correct
Expand Down
12 changes: 11 additions & 1 deletion cloud/gcp/deploytf/.nitric/modules/service/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ locals {
ids_prefix = "nitric-"
}

resource "random_string" "unique_id" {
length = 4
special = false
upper = false
}

# Create a random ID for the service name, so that it confirms to regex restrictions
resource "random_string" "service_account_id" {
length = 30 - length(local.ids_prefix)
Expand All @@ -57,9 +63,13 @@ resource "random_password" "event_token" {
}
}

locals{
service_name = replace(var.service_name, "_", "-")
}

# Create a cloud run service
resource "google_cloud_run_v2_service" "service" {
name = replace(var.service_name, "_", "-")
name = "${local.service_name}-${random_string.unique_id.result}"

location = var.region
project = var.project_id
Expand Down
1 change: 1 addition & 0 deletions cloud/gcp/deploytf/.nitric/modules/service/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ variable "kms_key" {
variable "vpc" {
description = "cloud run service directvpc config"
nullable = true
default = null
type = object({
network = string
subnet = string
Expand Down
8 changes: 7 additions & 1 deletion cloud/gcp/deploytf/.nitric/modules/topic/main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
resource "random_string" "unique_id" {
length = 4
special = false
upper = false
}

# Create a new pubsub topic
resource "google_pubsub_topic" "topic" {
name = var.topic_name
name = "${var.topic_name}-${random_string.unique_id.result}"

kms_key_name = var.kms_key != "" ? var.kms_key : null

Expand Down
Binary file modified cloud/gcp/deploytf/generated/api/jsii/api-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/bucket/jsii/bucket-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/http_proxy/jsii/http_proxy-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/policy/jsii/policy-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/queue/jsii/queue-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/schedule/jsii/schedule-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/secret/jsii/secret-0.0.0.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions cloud/gcp/deploytf/generated/service/ServiceConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ type ServiceConfig struct {
ServiceName *string `field:"required" json:"serviceName" yaml:"serviceName"`
// The ID of the Nitric stack.
StackId *string `field:"required" json:"stackId" yaml:"stackId"`
// cloud run service directvpc config.
Vpc interface{} `field:"required" json:"vpc" yaml:"vpc"`
// The number of concurrent requests the CloudRun service can handle 80.
ContainerConcurrency *float64 `field:"optional" json:"containerConcurrency" yaml:"containerConcurrency"`
// The amount of cpus to allocate to the CloudRun service 1.
Expand All @@ -47,5 +45,7 @@ type ServiceConfig struct {
MinInstances *float64 `field:"optional" json:"minInstances" yaml:"minInstances"`
// The timeout for the CloudRun service in seconds 10.
TimeoutSeconds *float64 `field:"optional" json:"timeoutSeconds" yaml:"timeoutSeconds"`
// cloud run service directvpc config.
Vpc interface{} `field:"optional" json:"vpc" yaml:"vpc"`
}

Binary file modified cloud/gcp/deploytf/generated/service/jsii/service-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/stack/jsii/stack-0.0.0.tgz
Binary file not shown.
Binary file modified cloud/gcp/deploytf/generated/topic/jsii/topic-0.0.0.tgz
Binary file not shown.

0 comments on commit 0c15363

Please sign in to comment.