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

integ-tests-alpha: Can't use full SDKv3 package name in an awsApiCall #28844

Closed
dontirun opened this issue Jan 24, 2024 · 6 comments · Fixed by #28895
Closed

integ-tests-alpha: Can't use full SDKv3 package name in an awsApiCall #28844

dontirun opened this issue Jan 24, 2024 · 6 comments · Fixed by #28895
Labels
@aws-cdk/integ-tests bug This issue is a bug. documentation This is a problem with documentation. effort/medium Medium work item – several days of effort p1

Comments

@dontirun
Copy link
Contributor

Describe the bug

Using the full SDKv3 package name (as described here #27313) causes the CDK to throw an error when attempting to run a test

Expected Behavior

Using the full SDKv3 package name does not throw an error

Current Behavior

The / in the full SDKv3 package name causes the naming constraints for the custom resource type name to errir

Error: Custom resource type name can only include alphanumeric characters and _@- (DeployAssert@SdkCall@aws-sdk/client-redshift-serverl)

Reproduction Steps

import * as integ from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';

const app = new cdk.App();
const stack = new cdk.Stack();
const test = new integ.IntegTest(app, 'integ', {
  testCases: [stack],
});

const describeUsageLimit = test.assertions.awsApiCall('@aws-sdk/client-redshift-serverless', 'GetUsageLimitCommand' {
  UsageLimitId: 'foo',
});

describeUsageLimit.expect(
  integ.ExpectedResult.objectLike({
    amount: 100,
    breachAction: 'deactivate',
    period: 'monthly',
  }),
);

app.synth();

Possible Solution

Remove the @aws-sdk/client- from the full SDKv3 package name when naming the custom resource type

Additional Information/Context

No response

CDK CLI Version

2.121.0 (build 9f2b78c)

Framework Version

No response

Node.js Version

v18.15.0

OS

Osx

Language

TypeScript

Language Version

No response

Other information

No response

@dontirun dontirun added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jan 24, 2024
@dontirun
Copy link
Contributor Author

Additionally it looks like having any non alphanumeric characters - in the service name (like with the SDKv3 service name: redshift-serverless)

causes template validation errors with CloudFormation Outputs

assertions: deploying... [3/3]
assertions: creating CloudFormation changeset...

 ❌  assertions failed: Error [ValidationError]: Template format error: Outputs name 'AssertionResultsAwsApiCallredshift-serverlessGetUsageLimitCommand6e1bf0d7444675e4ba3cb27c0240fd75' is non alphanumeric.

@sakurai-ryo
Copy link
Contributor

sakurai-ryo commented Jan 26, 2024

Hi @dontirun
Thanks for reaching out!
As you said, The problem seems to be that the resourceType of CustomResource contains a slash.
I will create a PR to fix this.

resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`.substring(0, 60),

if (!/^[a-z0-9_@-]+$/i.test(typeName)) {

@dontirun
Copy link
Contributor Author

@sakurai-ryo Thank you! The PR should also fix the second part of the issue that I put in the comments with CloudFormation outputs not supporting -

@sakurai-ryo
Copy link
Contributor

sakurai-ryo commented Jan 26, 2024

@dontirun
Yes, as you wrote in this issue, both need to be fixed.

I just noticed that the documentation says to use SDK v2 to call AWS APIs, but it is probably the same code internally, so it can be fixed.
Sorry, the PR (#27313) also fixed the integ-tests-alpha module, so the documentation is probably omitted from the update.
https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_integ-tests-alpha.IDeployAssert.html#awswbrapiwbrcallservice-api-parameters-outputpathsspan-classapi-icon-api-icon-experimental-titlethis-api-element-is-experimental-it-may-change-without-noticespan

@tim-finnigan tim-finnigan added documentation This is a problem with documentation. p1 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Jan 27, 2024
@tim-finnigan
Copy link

Thanks for reaching out - based on the discussion here I've marked this as a documentation issue.

@mergify mergify bot closed this as completed in #28895 Feb 2, 2024
mergify bot pushed a commit that referenced this issue Feb 2, 2024
When using the `awsApiCall` of integ-tests, several possible ways exist to specify the `service` and `api`.
This is made possible by the following PR.
https://github.com/aws/aws-cdk/pull/27313/files#diff-3ab65cbf843775673ff370c9c90deceba5f0ead8a3e016e0c2f243d27bf84609

However, currently, when specifying the package name or client name in SDK V3, the resource type in custom resource or the logical id in CloudFormation Output contains non-alphanumeric (`@`, `/`, `-`), which results in an error.

For custom resources, the resource type can include alphanumeric characters and the following characters: `_@-`
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#aws-resource-cloudformation-customresource--remarks

For `CfnOutput`, the logical id can include only alphanumeric.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html#outputs-section-syntax

This PR fixes to remove these strings that cannot be included and allows users to specify the SDK v3 package name and client name when using `awsApiCall`.


Closes #28844

----

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

github-actions bot commented Feb 2, 2024

⚠️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.

SankyRed pushed a commit that referenced this issue Feb 8, 2024
When using the `awsApiCall` of integ-tests, several possible ways exist to specify the `service` and `api`.
This is made possible by the following PR.
https://github.com/aws/aws-cdk/pull/27313/files#diff-3ab65cbf843775673ff370c9c90deceba5f0ead8a3e016e0c2f243d27bf84609

However, currently, when specifying the package name or client name in SDK V3, the resource type in custom resource or the logical id in CloudFormation Output contains non-alphanumeric (`@`, `/`, `-`), which results in an error.

For custom resources, the resource type can include alphanumeric characters and the following characters: `_@-`
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#aws-resource-cloudformation-customresource--remarks

For `CfnOutput`, the logical id can include only alphanumeric.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html#outputs-section-syntax

This PR fixes to remove these strings that cannot be included and allows users to specify the SDK v3 package name and client name when using `awsApiCall`.


Closes #28844

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
TheRealAmazonKendra pushed a commit that referenced this issue Feb 9, 2024
When using the `awsApiCall` of integ-tests, several possible ways exist to specify the `service` and `api`.
This is made possible by the following PR.
https://github.com/aws/aws-cdk/pull/27313/files#diff-3ab65cbf843775673ff370c9c90deceba5f0ead8a3e016e0c2f243d27bf84609

However, currently, when specifying the package name or client name in SDK V3, the resource type in custom resource or the logical id in CloudFormation Output contains non-alphanumeric (`@`, `/`, `-`), which results in an error.

For custom resources, the resource type can include alphanumeric characters and the following characters: `_@-`
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#aws-resource-cloudformation-customresource--remarks

For `CfnOutput`, the logical id can include only alphanumeric.
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html#outputs-section-syntax

This PR fixes to remove these strings that cannot be included and allows users to specify the SDK v3 package name and client name when using `awsApiCall`.


Closes #28844

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/integ-tests bug This issue is a bug. documentation This is a problem with documentation. effort/medium Medium work item – several days of effort p1
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants