From 1fff73777f057a9f47e13cd2a14e82b2db0bd906 Mon Sep 17 00:00:00 2001 From: Jye Cusch Date: Tue, 10 Dec 2024 10:23:03 +1100 Subject: [PATCH] Update cloud/aws/deploytf/api.go Co-authored-by: Rak Siva --- cloud/aws/deploytf/api.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cloud/aws/deploytf/api.go b/cloud/aws/deploytf/api.go index 24012372f..23e055f5e 100644 --- a/cloud/aws/deploytf/api.go +++ b/cloud/aws/deploytf/api.go @@ -100,7 +100,10 @@ func (n *NitricAwsTerraformProvider) Api(stack cdktf.TerraformStack, name string for _, pathOperation := range apiPath.Operations() { if apiNitricTarget, ok := pathOperation.Extensions["x-nitric-target"]; ok { if targetMap, isMap := apiNitricTarget.(map[string]any); isMap { - serviceName := targetMap["name"].(string) + serviceName, ok := targetMap["name"].(string) + if !ok { + return fmt.Errorf("missing or invalid 'name' field in x-nitric-target for path %s on API %s", pathOperation.OperationID, name) + } nitricService, ok := n.Services[serviceName] if !ok {