Description
Describe the feature
As discussed in #25504 and addressed partially in #27237, support for Fn::FindInMap
in deploy time values for Source.jsonData
is still needed.
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/[email protected][email protected]/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/[email protected][email protected]/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/[email protected][email protected]/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/[email protected][email protected]/node_modules/aws-cdk-lib/aws-s3-deployment/lib/source.js:1:2306)
api-infra: at /Users/vale/Workspace/api/node_modules/.pnpm/[email protected][email protected]/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/[email protected][email protected]/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.
This is discussed here aws/aws-pdk#771
Proposed Solution
Extend the functionality introduced in #27237 to support Fn::FindInMap
in deploy time values for Source.jsonData
.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
2.143.0
Environment details (OS name and version, etc.)
macOS Sonoma 14.5 Apple M1 Pro