diff --git a/cloud/gcp/common/config.go b/cloud/gcp/common/config.go index d14d580fe..c38fd8655 100644 --- a/cloud/gcp/common/config.go +++ b/cloud/gcp/common/config.go @@ -33,6 +33,7 @@ type GcpImports struct { } type GcpCloudRunConfig struct { + Cpus float64 Memory int Timeout int MinInstances int `mapstructure:"min-instances"` @@ -49,6 +50,7 @@ type GcpConfig struct { } var defaultCloudRunConfig = &GcpCloudRunConfig{ + Cpus: 0.25, Memory: 512, Timeout: 300, MinInstances: 0, diff --git a/cloud/gcp/deploy/service.go b/cloud/gcp/deploy/service.go index 172d152d7..ee0ed186e 100644 --- a/cloud/gcp/deploy/service.go +++ b/cloud/gcp/deploy/service.go @@ -211,6 +211,7 @@ func (p *NitricGcpPulumiProvider) Service(ctx *pulumi.Context, parent pulumi.Res }, Resources: cloudrun.ServiceTemplateSpecContainerResourcesArgs{ Limits: pulumi.StringMap{ + "cpu": pulumi.Sprintf("%2f", unitConfig.CloudRun.Cpus), "memory": pulumi.Sprintf("%dMi", unitConfig.CloudRun.Memory), }, }, diff --git a/cloud/gcp/deploytf/.nitric/modules/service/main.tf b/cloud/gcp/deploytf/.nitric/modules/service/main.tf index 336401f73..ea199e675 100644 --- a/cloud/gcp/deploytf/.nitric/modules/service/main.tf +++ b/cloud/gcp/deploytf/.nitric/modules/service/main.tf @@ -103,8 +103,7 @@ resource "google_cloud_run_service" "service" { } resources { limits = { - # TODO: enable cpu configuration - # cpu = "1000m" + cpu = "${var.cpus}" memory = "${var.memory_mb}Mi" } } diff --git a/cloud/gcp/deploytf/.nitric/modules/service/variables.tf b/cloud/gcp/deploytf/.nitric/modules/service/variables.tf index 0a97de4c3..28423ff00 100644 --- a/cloud/gcp/deploytf/.nitric/modules/service/variables.tf +++ b/cloud/gcp/deploytf/.nitric/modules/service/variables.tf @@ -31,6 +31,12 @@ variable "memory_mb" { default = 512 } +variable "cpus" { + description = "The amount of cpus to allocate to the CloudRun service" + type = number + default = 0.25 +} + variable "container_concurrency" { description = "The number of concurrent requests the CloudRun service can handle" type = number diff --git a/cloud/gcp/deploytf/generated/api/jsii/api-0.0.0.tgz b/cloud/gcp/deploytf/generated/api/jsii/api-0.0.0.tgz index fbcbd3dba..02e9b14dd 100644 Binary files a/cloud/gcp/deploytf/generated/api/jsii/api-0.0.0.tgz and b/cloud/gcp/deploytf/generated/api/jsii/api-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/bucket/jsii/bucket-0.0.0.tgz b/cloud/gcp/deploytf/generated/bucket/jsii/bucket-0.0.0.tgz index 3a043c221..98799c790 100644 Binary files a/cloud/gcp/deploytf/generated/bucket/jsii/bucket-0.0.0.tgz and b/cloud/gcp/deploytf/generated/bucket/jsii/bucket-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/http_proxy/jsii/http_proxy-0.0.0.tgz b/cloud/gcp/deploytf/generated/http_proxy/jsii/http_proxy-0.0.0.tgz index 89011fbc3..22ddf51b0 100644 Binary files a/cloud/gcp/deploytf/generated/http_proxy/jsii/http_proxy-0.0.0.tgz and b/cloud/gcp/deploytf/generated/http_proxy/jsii/http_proxy-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/policy/jsii/policy-0.0.0.tgz b/cloud/gcp/deploytf/generated/policy/jsii/policy-0.0.0.tgz index a236d117a..ee65ac2a8 100644 Binary files a/cloud/gcp/deploytf/generated/policy/jsii/policy-0.0.0.tgz and b/cloud/gcp/deploytf/generated/policy/jsii/policy-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/queue/jsii/queue-0.0.0.tgz b/cloud/gcp/deploytf/generated/queue/jsii/queue-0.0.0.tgz index 520999f19..91283a838 100644 Binary files a/cloud/gcp/deploytf/generated/queue/jsii/queue-0.0.0.tgz and b/cloud/gcp/deploytf/generated/queue/jsii/queue-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/schedule/jsii/schedule-0.0.0.tgz b/cloud/gcp/deploytf/generated/schedule/jsii/schedule-0.0.0.tgz index da6c116e0..5f644fa5f 100644 Binary files a/cloud/gcp/deploytf/generated/schedule/jsii/schedule-0.0.0.tgz and b/cloud/gcp/deploytf/generated/schedule/jsii/schedule-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/secret/jsii/secret-0.0.0.tgz b/cloud/gcp/deploytf/generated/secret/jsii/secret-0.0.0.tgz index 6148d9f48..7271ffd94 100644 Binary files a/cloud/gcp/deploytf/generated/secret/jsii/secret-0.0.0.tgz and b/cloud/gcp/deploytf/generated/secret/jsii/secret-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/service/Service.go b/cloud/gcp/deploytf/generated/service/Service.go index f0aaf3e18..d94756ddc 100644 --- a/cloud/gcp/deploytf/generated/service/Service.go +++ b/cloud/gcp/deploytf/generated/service/Service.go @@ -22,6 +22,8 @@ type Service interface { ConstructNodeMetadata() *map[string]interface{} ContainerConcurrency() *float64 SetContainerConcurrency(val *float64) + Cpus() *float64 + SetCpus(val *float64) // Experimental. DependsOn() *[]*string // Experimental. @@ -138,6 +140,16 @@ func (j *jsiiProxy_Service) ContainerConcurrency() *float64 { return returns } +func (j *jsiiProxy_Service) Cpus() *float64 { + var returns *float64 + _jsii_.Get( + j, + "cpus", + &returns, + ) + return returns +} + func (j *jsiiProxy_Service) DependsOn() *[]*string { var returns *[]*string _jsii_.Get( @@ -414,6 +426,14 @@ func (j *jsiiProxy_Service) SetContainerConcurrency(val *float64) { ) } +func (j *jsiiProxy_Service) SetCpus(val *float64) { + _jsii_.Set( + j, + "cpus", + val, + ) +} + func (j *jsiiProxy_Service) SetDependsOn(val *[]*string) { _jsii_.Set( j, diff --git a/cloud/gcp/deploytf/generated/service/ServiceConfig.go b/cloud/gcp/deploytf/generated/service/ServiceConfig.go index dc2b5f8e2..7942e4c85 100644 --- a/cloud/gcp/deploytf/generated/service/ServiceConfig.go +++ b/cloud/gcp/deploytf/generated/service/ServiceConfig.go @@ -29,6 +29,8 @@ type ServiceConfig struct { StackId *string `field:"required" json:"stackId" yaml:"stackId"` // 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 0.25. + Cpus *float64 `field:"optional" json:"cpus" yaml:"cpus"` // The amount of memory to allocate to the CloudRun service in MB 512. MemoryMb *float64 `field:"optional" json:"memoryMb" yaml:"memoryMb"` // The timeout for the CloudRun service in seconds 10. diff --git a/cloud/gcp/deploytf/generated/service/jsii/service-0.0.0.tgz b/cloud/gcp/deploytf/generated/service/jsii/service-0.0.0.tgz index a32ebb7df..beaac40d5 100644 Binary files a/cloud/gcp/deploytf/generated/service/jsii/service-0.0.0.tgz and b/cloud/gcp/deploytf/generated/service/jsii/service-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/service/main.go b/cloud/gcp/deploytf/generated/service/main.go index f8a6e65d3..022ab8841 100644 --- a/cloud/gcp/deploytf/generated/service/main.go +++ b/cloud/gcp/deploytf/generated/service/main.go @@ -18,6 +18,7 @@ func init() { _jsii_.MemberProperty{JsiiProperty: "cdktfStack", GoGetter: "CdktfStack"}, _jsii_.MemberProperty{JsiiProperty: "constructNodeMetadata", GoGetter: "ConstructNodeMetadata"}, _jsii_.MemberProperty{JsiiProperty: "containerConcurrency", GoGetter: "ContainerConcurrency"}, + _jsii_.MemberProperty{JsiiProperty: "cpus", GoGetter: "Cpus"}, _jsii_.MemberProperty{JsiiProperty: "dependsOn", GoGetter: "DependsOn"}, _jsii_.MemberProperty{JsiiProperty: "environment", GoGetter: "Environment"}, _jsii_.MemberProperty{JsiiProperty: "eventTokenOutput", GoGetter: "EventTokenOutput"}, diff --git a/cloud/gcp/deploytf/generated/stack/jsii/stack-0.0.0.tgz b/cloud/gcp/deploytf/generated/stack/jsii/stack-0.0.0.tgz index 26bc31ea4..be966771f 100644 Binary files a/cloud/gcp/deploytf/generated/stack/jsii/stack-0.0.0.tgz and b/cloud/gcp/deploytf/generated/stack/jsii/stack-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/generated/topic/jsii/topic-0.0.0.tgz b/cloud/gcp/deploytf/generated/topic/jsii/topic-0.0.0.tgz index cfbc3696e..3824f8ce6 100644 Binary files a/cloud/gcp/deploytf/generated/topic/jsii/topic-0.0.0.tgz and b/cloud/gcp/deploytf/generated/topic/jsii/topic-0.0.0.tgz differ diff --git a/cloud/gcp/deploytf/service.go b/cloud/gcp/deploytf/service.go index 6b1e9c1bc..7e525edbe 100644 --- a/cloud/gcp/deploytf/service.go +++ b/cloud/gcp/deploytf/service.go @@ -63,6 +63,7 @@ func (a *NitricGcpTerraformProvider) Service(stack cdktf.TerraformStack, name st Image: jsii.String(imageId), Environment: &jsiiEnv, StackId: a.Stack.StackIdOutput(), + Cpus: jsii.Number(typeConfig.CloudRun.Cpus), MemoryMb: jsii.Number(typeConfig.CloudRun.Memory), TimeoutSeconds: jsii.Number(typeConfig.CloudRun.Timeout), BaseComputeRole: a.Stack.BaseComputeRoleOutput(),