Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws-s3-deployment: Support CfnMapping (Fn::FindInMap) in deploy time values for Source.jsonData #30369

Open
2 tasks
valebedu opened this issue May 29, 2024 · 1 comment
Labels
@aws-cdk/aws-s3-deployment effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Comments

@valebedu
Copy link

valebedu commented May 29, 2024

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/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.

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

@valebedu valebedu added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels May 29, 2024
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels May 29, 2024
@khushail khushail self-assigned this May 29, 2024
@khushail
Copy link
Contributor

Right now. these are the supported functions -

function addMarker(part: Ref | GetAtt | FnSelect) {

Fn:FindInMap function support makes sense given the usecase. Marking it as appropriate.
Thanks @valebedu for the FR!

@khushail khushail added p2 p3 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. p2 labels May 29, 2024
@khushail khushail removed their assignment May 29, 2024
@khushail khushail added p2 and removed p3 labels May 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-s3-deployment effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2
Projects
None yet
Development

No branches or pull requests

2 participants