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-appsync): Datasource not found after migrating from aws-appsync-alpha #23743

Closed
danrivett opened this issue Jan 19, 2023 · 2 comments · Fixed by #23802
Closed

(aws-appsync): Datasource not found after migrating from aws-appsync-alpha #23743

danrivett opened this issue Jan 19, 2023 · 2 comments · Fixed by #23802
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@danrivett
Copy link

Describe the bug

We were previously using @aws-cdk/aws-appsync-alpha version 2.12.0-alpha.0 and recently migrated to the stable AppSync CDK construct in 2.60.0.

CDK deploys are now failing as the AWS::AppSync::Resolver generated cannot find associated AWS::AppSync::DataSource:

12:30:25 p.m. | CREATE_FAILED        | AWS::AppSync::Resolver          | apiQuerygetCart3792FB8F
No data source found named Query-getCart (Service: AWSAppSync; Status Code: 404; Error Code: NotFoundException; Request ID: 33df3ea5-79c8-49d0-acd3-b8b0cf1c6549; Proxy: null)

We think it's related to this PR merged 3 months ago: #22378 which changed how DataSource names are sanitized to remove invalid characters (such as hyphens in our case).

It used to sanitize the name and apply the sanitized name to both the L1 and L2 Construct name field, however now it only santitizes the underlying L1 CfnDataSource name field and not the L2 name field leaving it inconsistent and resulting in the above error.

Expected Behavior

I would expect that both the L2 and L1 names be the same like it was prior to #22378 to avoid issues such as we encountered where the wrong name is used and can't be found.

Current Behavior

The L1 CfnDataSource name field is sanitized (in our case stripping out hyphens) whilst the L2 DataSource Construct is not. This leads to the CDK not deploying the stack correctly since it cannot find the DataSource:

  apiQuerygetCart3792FB8F:
    Type: AWS::AppSync::Resolver
    Properties:
      ApiId:
        Fn::GetAtt:
          - apiC8550315
          - ApiId
      FieldName: getCart
      TypeName: Query
      DataSourceName: Query-getCart
      Kind: UNIT
...
  cartcartresolversQuerygetCartdatasource4A98C914:
    Type: AWS::AppSync::DataSource
    Properties:
      ApiId:
        Fn::GetAtt:
          - apiC8550315
          - ApiId
      Name: QuerygetCart
      Type: AWS_LAMBDA
...

Reproduction Steps

Create an AppSync Resolver with a DataSource (such as a LambdaDataSource) that has a name with a hypen in it.

Possible Solution

The L2 name field should be set to supportedName so that it matches the L1 name field.

See here.

Additional Information/Context

No response

CDK CLI Version

2.60.0

Framework Version

No response

Node.js Version

16.19.0

OS

MacOS

Language

Typescript

Language Version

No response

Other information

No response

@danrivett danrivett added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 19, 2023
@github-actions github-actions bot added the @aws-cdk/aws-appsync Related to AWS AppSync label Jan 19, 2023
@ramblingenzyme
Copy link
Contributor

Also ran into this. Looks like they just missed updating the assignment to this.name

@mergify mergify bot closed this as completed in #23802 Jan 27, 2023
mergify bot pushed a commit that referenced this issue Jan 27, 2023
Closes #23743
When providing a name with unsupported characters to an AppSync datasource, it is sanitized internally. #22378 introduced a bug where the sanitized name was no longer exposed on DataSource class instances.

----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Construct Runtime Dependencies:

* [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*

![image](https://user-images.githubusercontent.com/5336472/214185923-6e90b49a-e834-4932-a23a-12094546181d.png)

![image](https://user-images.githubusercontent.com/5336472/214186095-a4ee51f7-37e1-451c-ba08-d27277cba0b9.png)

The above code generates the shown diff. This is due to #23743 where the name is sanitised, but not when setting `this.name`.
@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-appsync Related to AWS AppSync bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants