Im deploying my infrastructure on AWS using terraform and Ive been having this problem :
When I try to deploy my APIGW :
module my_api_gateway {
...
body = templatefile(./api.tpl, local.apigw_vars)
...
}
I have this error :
runtime: out of memory: cannot allocate 650117120-byte block (309133312 in use)
fatal error: out of memory
goroutine 38 [running]:
runtime.throw({0x30794b5, 0xd})
/opt/hostedtoolcache/go/1.19.6/x64/src/runtime/panic.go:1047 +0x4d fp=0x18a82e6c sp=0x18a82e58 pc=0xf289cd
I think it's due to my api.tpl file which is too large (529 Ko) ? I tried splitting the file into different sections and using a join to join different templatefiles but I still get the same error.
Any ideas how I can fix this ?
Edit : Here are the local variables :
body = templatefile(local.swagger_file, {
name = "api-gateway-private-api-${var.id}",
description = "API Gateway for ${var.application_name} API",
version = "1.0.0",
contact_name = var.api_contact_name,
contact_email = var.api_contact_email,
nlb_dns_name = aws_lb.this.dns_name,
swagger_sha = sha256(local.swagger_file),
api_gateway_vpc_link_id = aws_api_gateway_vpc_link.this.id,
env = local.dns_env,
project = var.project,
policy = data.aws_iam_policy_document.access_policy.json,
vpc_endpoint = var.vpc_endpoint_apigateway_id,
api_uri = "${var.api_protocol}://${var.api_uri}",
api_header_aca_origin = var.api_header_aca_origin,
api_header_sts = var.api_header_sts
lambda_1 = "arn:aws:lambda:eu-west-3:${data.aws_caller_identity.current.account_id}:function:${local.lambda1.name}"
lambda_2 = "arn:aws:lambda:eu-west-3:${data.aws_caller_identity.current.account_id}:function:lambda2"
sqs_1 = "${data.aws_caller_identity.current.account_id}/${var.project}-${var.env}-sqs-1"
})