Skip to content

(amplify-alpha): customResponseHeaders does not support monorepo structures #31758

@georeeve

Description

@georeeve

Describe the bug

Firstly, I can't tell if this is a CDK or Amplify issue. aws-amplify/amplify-hosting#1995 seems related, but someone in that issue was using customHttp.yml which we can't do on CDK.

I've tried to condense this into a simple example app below. It works without the customResponseHeaders property. However, when I add customResponseHeaders, it still deploys via CloudFormation, but when the Amplify build runs I get the errors below.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Version

No response

Expected Behavior

The app deploys successfully on Amplify.

Current Behavior

The app errors on Amplify deploy:

!!!Monorepo spec provided without "applications" key
!!!Unable to save headers: CustomerError: Monorepo spec provided without "applications" key

Reproduction Steps

Example Amplify app:

const amplifyApp = new AmplifyApp(this, `AmplifyApp`, {
  buildSpec: BuildSpec.fromObjectToYaml({
    version: "1.0",
    applications: [
      {
        appRoot: "frontend",
        frontend: {
          phases: {
            preBuild: {
              commands: [
                "npm install -g pnpm",
                "pnpm install --frozen-lockfile",
              ],
            },
            build: {
              commands: ["pnpm run build"],
            },
          },
          artifacts: {
            baseDirectory: ".next",
            files: ["**/*"],
          },
          cache: {
            paths: [".next/cache/**/*"],
          },
        },
      },
    ],
  }),
  customResponseHeaders: [
    {
      pattern: "**",
      headers: {
        Test: "test",
      },
    },
  ],
});

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.162.1 (build 10aa526)

Framework Version

2.162.1-alpha.0

Node.js Version

v22.9.0

OS

macOS 14.7 (23H124)

Language

TypeScript

Language Version

TypeScript 5.6.3

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-amplifyRelated to AWS AmplifybugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions