Currently, using Fn::FindInMap results in the following error:
api-infra: Error: Invalid CloudFormation reference. Key must start with any of "Ref" or "Fn::GetAtt" or "Fn::Select". Got {"Fn::FindInMap":["DefaultMapping","responseTemplate","full"]}
api-infra: at addMarker (/Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/render-data.js:1:1336)
api-infra: at renderData (/Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/render-data.js:1:799)
api-infra: at Object.bind (/Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:1919)
api-infra: at Object.bind (/Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:2306)
api-infra: at /Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3768
api-infra: at Array.map (<anonymous>)
api-infra: at new BucketDeployment (/Users/vale/Workspace/api/node_modules/.pnpm/aws-cdk-lib@2.143.0_constructs@10.3.0/node_modules/aws-cdk-lib/aws-s3-deployment/lib/bucket-deployment.js:1:3749)
api-infra: at new TypeSafeRestApi (/Users/vale/Workspace/api/node_modules/.pnpm/file+..+..+..+lab+aws-pdk+packages+pdk+dist+js+package_@aws-cdk+aws-cognito-identitypool-alph_2yxqjbpf3vtng3yuse5lau2hn4/node_modules/@aws/pdk/type-safe-api/construct/type-safe-rest-api.ts:176:5)
api-infra: at new Api (/Users/vale/Workspace/api/packages/api/generated/infrastructure/typescript/src/api.ts:18:5)
api-infra: at new Api (/Users/vale/Workspace/api/packages/api/infra/src/constructs/apis/api.ts:468:5)
Use Case
In large APIs with custom response templates, such as code error mappings, it's necessary to use CfnMapping to avoid CloudFormation template size limits. Repeating the same mapping multiple times causes CloudFormation to raise an error due to template size constraints. By using CfnMapping, we can maintain a single instance of the mapping, reducing the overall template size.
Describe the feature
As discussed in https://github.com/aws/aws-cdk/issues/25504 and addressed partially in https://github.com/aws/aws-cdk/pull/27237, support for
Fn::FindInMap
in deploy time values forSource.jsonData
is still needed.Currently, using
Fn::FindInMap
results in the following error:Use Case
In large APIs with custom response templates, such as code error mappings, it's necessary to use
CfnMapping
to avoid CloudFormation template size limits. Repeating the same mapping multiple times causes CloudFormation to raise an error due to template size constraints. By usingCfnMapping
, we can maintain a single instance of the mapping, reducing the overall template size.This is discussed here https://github.com/aws/aws-pdk/issues/771
Proposed Solution
Extend the functionality introduced in https://github.com/aws/aws-cdk/pull/27237 to support
Fn::FindInMap
in deploy time values forSource.jsonData
.Other Information
No response
Acknowledgements
CDK version used
2.143.0
Environment details (OS name and version, etc.)
macOS Sonoma 14.5 Apple M1 Pro