Skip to content
New issue

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

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

Already on GitHub? # to your account

AmplifyGraphqlApi: Validation error deploying AmplifyGraphqlApi CDK construct #27526

Closed
AnilMaktala opened this issue Oct 12, 2023 · 15 comments
Closed
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. p2

Comments

@AnilMaktala
Copy link

Describe the bug

I am following the walkthrough in the CDK construct announcement blog post found here: https://aws.amazon.com/blogs/mobile/announcing-aws-amplifys-graphql-api-cdk-construct-deploy-real-time-graphql-api-and-data-stack-on-aws/. The only difference is I am deploying from a package in a pnpm monorepo, however, everything else is identical. During the cdk deploy logs I see the following error message:

Error occurred while monitoring stack: Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]|arn:[-a-zA-Z0-9:/._+]; Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1
at Request.extractError (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:46430)
at Request.callListeners (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:90083)
at Request.emit (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:89531)
at Request.emit (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:196289)
at Request.transition (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:189841)
at AcceptorStateMachine.runTo (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:154713)
at C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:155043
at Request. (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:190133)
at Request. (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:196364)
at Request.callListeners (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:90251) {
code: 'ValidationError',
time: 2023-10-12T14:16:28.072Z,
requestId: 'e828bd70-e9db-4173-8924-3dec501fccf6',
statusCode: 400,
retryable: false,
retryDelay: 142.81362092100824
}
Following deploy, the generated resources appear to work correctly.

Expected Behavior

No errors during cdk deploy

Current Behavior

During the cdk deploy logs I see the following error message:

Error occurred while monitoring stack: Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]|arn:[-a-zA-Z0-9:/._+]; Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1
at Request.extractError (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:46430)
at Request.callListeners (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:90083)
at Request.emit (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:89531)
at Request.emit (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:196289)
at Request.transition (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:189841)
at AcceptorStateMachine.runTo (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:154713)
at C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:155043
at Request. (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:190133)
at Request. (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:196364)
at Request.callListeners (C:...\AppData\Local\pnpm\global\5.pnpm\aws-cdk@2.100.0\node_modules\aws-cdk\lib\index.js:362:90251) {
code: 'ValidationError',
time: 2023-10-12T14:16:28.072Z,
requestId: 'e828bd70-e9db-4173-8924-3dec501fccf6',
statusCode: 400,
retryable: false,
retryDelay: 142.81362092100824
}

Reproduction Steps

Follow instructions found here: https://aws.amazon.com/blogs/mobile/announcing-aws-amplifys-graphql-api-cdk-construct-deploy-real-time-graphql-api-and-data-stack-on-aws/

Possible Solution

No response

Additional Information/Context

No response

CDK CLI Version

2.100.0

Framework Version

No response

Node.js Version

18.18.0

OS

windows

Language

TypeScript

Language Version

No response

Other information

No response

@AnilMaktala AnilMaktala added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 12, 2023
@github-actions github-actions bot added the @aws-cdk/aws-logs Related to Amazon CloudWatch Logs label Oct 12, 2023
@dpilch
Copy link
Contributor

dpilch commented Oct 12, 2023

To add some additional details. Sometimes the PhysicalResourceId of a StackEvent is an empty string.

await this.readNewEvents(event.PhysicalResourceId);

This causes an describeStackEvents to be called with { stackName: '' }.

const response = await this.cfn.describeStackEvents({ StackName: stackToPollForEvents, NextToken: nextToken }).promise();

@awudarowicz
Copy link

awudarowicz commented Oct 14, 2023

I have similar issue and it looks that it is not the graphql api problem but something else.
I'm creating HttpApi with ApiGateway and I have the same error. I've tried everything.. changing ids, providing stackNames etc. Nothing helps.
The error occurs only when I'm creating nested stack. When I will cut out the new ApiStack then there is no error.
Here is the dumbest and shortest example I could prepare:

main.stack.ts

import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import { ApiStack } from "./api.stack";

export class MainStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props?: cdk.StackProps) {
    super(scope, id, props);

    new ApiStack(this, 'SuperTestApi');
  }
}

api.stack.ts

import {Construct} from "constructs";
import {NestedStack} from "aws-cdk-lib";

export class ApiStack extends NestedStack {
    constructor(scope: Construct, id: string) {
        super(scope, id);
    }
}

Currently in ApiStack the props are not set because they are optional and stackName should be taken from stack id.
Even if I provide stackName then error still exists:

Error occurred while monitoring stack: Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1; Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*

@eduborto
Copy link

Same problem here with CDK code in Python.

Node 18.18.1
aws-cdk == 2.101.1

@indrora indrora added p1 jsii This issue originates in jsii, or this feature must be implemented in jsii. needs-review and removed needs-triage This issue or PR still needs to be triaged. labels Oct 19, 2023
@indrora
Copy link
Contributor

indrora commented Oct 19, 2023

Thank you for bringing this to our attention. This clearly shouldn't be happening, and this very much does look to be a regression. Thank you.

@pahud
Copy link
Contributor

pahud commented Oct 20, 2023

Hi,

Can you help us verify if this still exists in the latest 2.102.0 ?

@dpilch
Copy link
Contributor

dpilch commented Oct 20, 2023

I am still seeing the issue in 2.102.0.

@eduborto
Copy link

eduborto commented Oct 20, 2023

Hi,

Can you help us verify if this still exists in the latest 2.102.0 ?

Hi @pahud,

It is still happening for me (I deployed two different solutions with the same error):
Error occurred while monitoring stack: Error [ValidationError]: 2 validation errors detected: Value '' at 'stackName' failed to satisfy constraint: Member must have length greater than or equal to 1; Value '' at 'stackName' failed to satisfy constraint: Member must satisfy regular expression pattern: [a-zA-Z][-a-zA-Z0-9]*|arn:[-a-zA-Z0-9:/._+]*

❯ cdk --version
2.102.0 (build 2abc59a)

@pahud
Copy link
Contributor

pahud commented Oct 20, 2023

@eduborto Thanks for your prompt response. We'll review this internally.

@jonslo
Copy link

jonslo commented Oct 25, 2023

Screenshot 2023-10-25 at 7 27 26 AM I am experiencing the same issue with nested stacks. Had this issue with 2.93.0 and 2.102.0. The deployment appears successful, but not without the validation message errors.

@indrora indrora removed jsii This issue originates in jsii, or this feature must be implemented in jsii. needs-review labels Oct 25, 2023
@maxjiang153
Copy link

maxjiang153 commented Oct 31, 2023

same issue with the 2.103.1 (build 3bb19ac) version.

here is the demo code:


const cdk = require('aws-cdk-lib');
const eks = require('aws-cdk-lib/aws-eks');
const { KubectlV27Layer } = require('@aws-cdk/lambda-layer-kubectl-v27');


class Demo extends cdk.Stack {

  constructor(scope, id, props) {
    super(scope, id, props);

    const cluster = new eks.Cluster(this, 'eks', {
      version: eks.KubernetesVersion.V1_27,
      clusterName: 'demo-cluster',
      kubectlLayer: new KubectlV27Layer(this, 'kubectl'),
    });
  }

}

@pahud
Copy link
Contributor

pahud commented Apr 17, 2024

As this issue is related to the blog post, I will reach out to the blog post authors for inputs and verification.

@wmz7year your comment seems to be related to EKS instead of Amplify?

@pahud pahud added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Apr 23, 2024
@pahud
Copy link
Contributor

pahud commented Apr 23, 2024

Reproduction Steps
Follow instructions found here: https://aws.amazon.com/blogs/mobile/announcing-aws-amplifys-graphql-api-cdk-construct-deploy-real-time-graphql-api-and-data-stack-on-aws/

Hi @AnilMaktala

If this error only happens with the code provided by that blog post, I'd recommend cutting a ticket to https://github.com/aws-amplify/amplify-category-api for clarifying.

If you believe it's a general issue that exists in aws-cdk-lib, please provide a minimal code snippet in this issue so we can reproduce it on our end.

@pahud pahud added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. p2 and removed p1 labels Apr 23, 2024
@dpilch
Copy link
Contributor

dpilch commented Apr 24, 2024

The issue did exist in aws-cdk-lib and was surfaced when using the Amplify GraphQL API L3 construct.

This issue was resolved with #27692. This issue can be closed now.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Apr 24, 2024
@pahud
Copy link
Contributor

pahud commented Aug 7, 2024

Closing by #27692.

@pahud pahud closed this as completed Aug 7, 2024
@pahud pahud removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
@aws-cdk/aws-logs Related to Amazon CloudWatch Logs bug This issue is a bug. p2
Projects
None yet
Development

No branches or pull requests

8 participants