diff --git a/packages/@aws-cdk/integ-tests-alpha/README.md b/packages/@aws-cdk/integ-tests-alpha/README.md index 3972bcff72645..9ca5a2416d016 100644 --- a/packages/@aws-cdk/integ-tests-alpha/README.md +++ b/packages/@aws-cdk/integ-tests-alpha/README.md @@ -306,6 +306,20 @@ integ.assertions.awsApiCall('SQS', 'receiveMessage', { }); ``` +You must specify the `service` and the `api` when using The `AwsApiCall` construct. +The `service` is the name of an AWS service, in one of the following forms: + +- An AWS SDK for JavaScript v3 package name (`@aws-sdk/client-api-gateway`) +- An AWS SDK for JavaScript v3 client name (`api-gateway`) +- An AWS SDK for JavaScript v2 constructor name (`APIGateway`) +- A lowercase AWS SDK for JavaScript v2 constructor name (`apigateway`) + +The `api` is the name of an AWS API call, in one of the following forms: + +- An API call name as found in the API Reference documentation (`GetObject`) +- The API call name starting with a lowercase letter (`getObject`) +- The AWS SDK for JavaScript v3 command class name (`GetObjectCommand`) + By default, the `AwsApiCall` construct will automatically add the correct IAM policies to allow the Lambda function to make the API call. It does this based on the `service` and `api` that is provided. In the above example the service is `SQS` and the api is diff --git a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts index fff9f88cc8f0e..d437f54c5ddbf 100644 --- a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts +++ b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/sdk.ts @@ -97,7 +97,10 @@ export class AwsApiCall extends ApiCallBase { outputPaths: Lazy.list({ produce: () => this.outputPaths }), salt: Date.now().toString(), }, - resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`.substring(0, 60), + // Remove the slash from the resource type because when using the v3 package name as the service name, + // the `service` props includes the slash, but the resource type name cannot contain the slash + // See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-customresource.html#aws-resource-cloudformation-customresource--remarks + resourceType: `${SDK_RESOURCE_TYPE_PREFIX}${this.name}`.substring(0, 60).replace(/[\/]/g, ''), }); // Needed so that all the policies set up by the provider should be available before the custom resource is provisioned. this.apiCallResource.node.addDependency(this.provider); @@ -112,7 +115,10 @@ export class AwsApiCall extends ApiCallBase { new CfnOutput(node, 'AssertionResults', { value: result, - }).overrideLogicalId(`AssertionResults${id}`); + // Remove the at sign, slash, and hyphen because when using the v3 package name or client name as the service name, + // the `id` includes them, but they are not allowed in the `CfnOutput` logical id + // See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/outputs-section-structure.html#outputs-section-syntax + }).overrideLogicalId(`AssertionResults${id}`.replace(/[\@\/\-]/g, '')); } } }, diff --git a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/types.ts b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/types.ts index e1a5843a9f3be..7ebbda99126fd 100644 --- a/packages/@aws-cdk/integ-tests-alpha/lib/assertions/types.ts +++ b/packages/@aws-cdk/integ-tests-alpha/lib/assertions/types.ts @@ -10,10 +10,21 @@ import { LambdaInvokeFunctionProps } from './sdk'; */ export interface IDeployAssert { /** - * Query AWS using JavaScript SDK V2 API calls. This can be used to either + * Query AWS using JavaScript SDK API calls. This can be used to either * trigger an action or to return a result that can then be asserted against * an expected value * + * The `service` is the name of an AWS service, in one of the following forms: + * - An AWS SDK for JavaScript v3 package name (`@aws-sdk/client-api-gateway`) + * - An AWS SDK for JavaScript v3 client name (`api-gateway`) + * - An AWS SDK for JavaScript v2 constructor name (`APIGateway`) + * - A lowercase AWS SDK for JavaScript v2 constructor name (`apigateway`) + * + * The `api` is the name of an AWS API call, in one of the following forms: + * - An API call name as found in the API Reference documentation (`GetObject`) + * - The API call name starting with a lowercase letter (`getObject`) + * - The AWS SDK for JavaScript v3 command class name (`GetObjectCommand`) + * * @example * declare const app: App; * declare const integ: IntegTest; diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts b/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts index 88a449610b3d1..b31e8328fe465 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/deploy-assert.test.ts @@ -191,6 +191,57 @@ describe('DeployAssert', () => { template.resourceCountIs('AWS::Lambda::Function', 1); template.resourceCountIs(truncatedType, 1); }); + + test('can use v3 package name and command class name', () => { + // GIVEN + const app = new App(); + + // WHEN + const deplossert = new DeployAssert(app); + deplossert.awsApiCall('@aws-sdk/client-ssm', 'GetParameterCommand'); + + // THEN + const template = Template.fromStack(deplossert.scope); + + template.resourceCountIs('AWS::Lambda::Function', 1); + template.resourcePropertiesCountIs( + 'Custom::DeployAssert@SdkCall@aws-sdkclient-ssmGetParameterC', + { + service: '@aws-sdk/client-ssm', + api: 'GetParameterCommand', + }, + 1, + ); + }); + + test('can use v3 package name and command class name with assertions', () => { + // GIVEN + const app = new App(); + + // WHEN + const deplossert = new DeployAssert(app); + deplossert.awsApiCall('@aws-sdk/client-ssm', 'GetParameterCommand').expect( + ExpectedResult.objectLike({}), + );; + + // THEN + const template = Template.fromStack(deplossert.scope); + + template.resourceCountIs('AWS::Lambda::Function', 1); + template.resourcePropertiesCountIs( + 'Custom::DeployAssert@SdkCall@aws-sdkclient-ssmGetParameterC', + { + service: '@aws-sdk/client-ssm', + api: 'GetParameterCommand', + }, + 1, + ); + template.hasOutput('AssertionResultsAwsApiCallawssdkclientssmGetParameterCommand', { + Value: { + 'Fn::GetAtt': ['AwsApiCallawssdkclientssmGetParameterCommand', 'assertion'], + }, + }); + }); }); describe('httpApiCall', () => { diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/Assertions.assets.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/Assertions.assets.json index 13c479a2e33d8..a6897a847d3e0 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/Assertions.assets.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/Assertions.assets.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "36.0.0", "files": { "95e75e09df57bf020e079977e10353bf8899e195d27f0b3dbb4b0e6b316d3fab": { "source": { diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json index 3e39b1129f6c0..2eb280e133cd6 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.assets.json @@ -1,20 +1,20 @@ { - "version": "34.0.0", + "version": "36.0.0", "files": { - "725b0df96c2f47516947f7471b1187d8db70a7b45e4ae44c5e9430cdf9e75767": { + "3f0f15596be1e3fbbf4a0571522aa1e5312d44abff27360f8d043c1b0704bcf4": { "source": { - "path": "asset.725b0df96c2f47516947f7471b1187d8db70a7b45e4ae44c5e9430cdf9e75767.bundle", + "path": "asset.3f0f15596be1e3fbbf4a0571522aa1e5312d44abff27360f8d043c1b0704bcf4.bundle", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "725b0df96c2f47516947f7471b1187d8db70a7b45e4ae44c5e9430cdf9e75767.zip", + "objectKey": "3f0f15596be1e3fbbf4a0571522aa1e5312d44abff27360f8d043c1b0704bcf4.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "4e01d7d1d71b079819d9e433311d9475a6aaece447884c16b6b41f29619e0920": { + "deb0e1633db00cfb33f701e2e3833a30bfea3ff4eeb19de099a3ffde8e833dd6": { "source": { "path": "AssertionsTestDefaultTestDeployAssertDC0672BB.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "4e01d7d1d71b079819d9e433311d9475a6aaece447884c16b6b41f29619e0920.json", + "objectKey": "deb0e1633db00cfb33f701e2e3833a30bfea3ff4eeb19de099a3ffde8e833dd6.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json index 4d7660a9dc833..40de090fc1893 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/AssertionsTestDefaultTestDeployAssertDC0672BB.template.json @@ -28,7 +28,7 @@ "WithDecryption": "true" }, "flattenResponse": "false", - "salt": "1696292331033" + "salt": "1706364262631" }, "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" @@ -59,6 +59,24 @@ "PolicyDocument": { "Version": "2012-10-17", "Statement": [ + { + "Action": [ + "ssm:GetParameter" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + }, + { + "Action": [ + "ssm:GetParameter" + ], + "Effect": "Allow", + "Resource": [ + "*" + ] + }, { "Action": [ "ssm:GetParameter" @@ -91,7 +109,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "725b0df96c2f47516947f7471b1187d8db70a7b45e4ae44c5e9430cdf9e75767.zip" + "S3Key": "3f0f15596be1e3fbbf4a0571522aa1e5312d44abff27360f8d043c1b0704bcf4.zip" }, "Timeout": 120, "Handler": "index.handler", @@ -131,13 +149,85 @@ "WithDecryption": "true" }, "flattenResponse": "false", - "salt": "1696292331034" + "salt": "1706364262632" }, "DependsOn": [ "AwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f2" ], "UpdateReplacePolicy": "Delete", "DeletionPolicy": "Delete" + }, + "AwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "Type": "Custom::DeployAssert@SdkCall@aws-sdkclient-ssmGetParameterC", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "service": "@aws-sdk/client-ssm", + "api": "GetParameterCommand", + "expected": "{\"$ObjectLike\":{\"Parameter\":{\"Type\":\"String\",\"Value\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ!\\\"#¤%&/()=?`´^*+~_-.,:;<>|\"}}}", + "parameters": { + "Name": { + "Fn::Join": [ + "", + [ + "\"", + { + "Fn::ImportValue": "Assertions:ExportsOutputRefUtf8Parameter528A4835" + }, + "\"" + ] + ] + }, + "WithDecryption": "true" + }, + "flattenResponse": "false", + "salt": "1706364262633" + }, + "DependsOn": [ + "AwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f21" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" + }, + "AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "Type": "Custom::DeployAssert@SdkCallssmGetParameterCommand", + "Properties": { + "ServiceToken": { + "Fn::GetAtt": [ + "SingletonFunction1488541a7b23466481b69b4408076b81HandlerCD40AE9F", + "Arn" + ] + }, + "service": "ssm", + "api": "GetParameterCommand", + "expected": "{\"$ObjectLike\":{\"Parameter\":{\"Type\":\"String\",\"Value\":\"ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ!\\\"#¤%&/()=?`´^*+~_-.,:;<>|\"}}}", + "parameters": { + "Name": { + "Fn::Join": [ + "", + [ + "\"", + { + "Fn::ImportValue": "Assertions:ExportsOutputRefUtf8Parameter528A4835" + }, + "\"" + ] + ] + }, + "WithDecryption": "true" + }, + "flattenResponse": "false", + "salt": "1706364262633" + }, + "DependsOn": [ + "AwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2" + ], + "UpdateReplacePolicy": "Delete", + "DeletionPolicy": "Delete" } }, "Outputs": { @@ -156,6 +246,22 @@ "assertion" ] } + }, + "AssertionResultsAwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "Value": { + "Fn::GetAtt": [ + "AwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "assertion" + ] + } + }, + "AssertionResultsAwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "Value": { + "Fn::GetAtt": [ + "AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "assertion" + ] + } } }, "Parameters": { diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/cdk.out b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/cdk.out index 2313ab5436501..1f0068d32659a 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/cdk.out +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"34.0.0"} \ No newline at end of file +{"version":"36.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/integ.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/integ.json index bb3d3fc159353..7dac09028252c 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/integ.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "36.0.0", "testCases": { "AssertionsTest/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/manifest.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/manifest.json index 0a35d3dd6173e..02e32b5ef214d 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/manifest.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "34.0.0", + "version": "36.0.0", "artifacts": { "Assertions.assets": { "type": "cdk:asset-manifest", @@ -78,7 +78,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/4e01d7d1d71b079819d9e433311d9475a6aaece447884c16b6b41f29619e0920.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/deb0e1633db00cfb33f701e2e3833a30bfea3ff4eeb19de099a3ffde8e833dd6.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -131,6 +131,30 @@ "data": "AssertionResultsAwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f21" } ], + "/AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsAwsApiCallawssdkclientssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default/Default": [ + { + "type": "aws:cdk:logicalId", + "data": "AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2" + } + ], + "/AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/AssertionResults": [ + { + "type": "aws:cdk:logicalId", + "data": "AssertionResultsAwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2" + } + ], "/AssertionsTest/DefaultTest/DeployAssert/BootstrapVersion": [ { "type": "aws:cdk:logicalId", diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/tree.json b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/tree.json index d21164a73ea85..0e48a09846141 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/tree.json +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.js.snapshot/tree.json @@ -31,7 +31,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } }, "BootstrapVersion": { @@ -69,7 +69,7 @@ "path": "AssertionsTest/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } }, "DeployAssert": { @@ -89,7 +89,7 @@ "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f2/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } } }, @@ -161,7 +161,7 @@ }, "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } }, "AwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f21": { @@ -177,7 +177,7 @@ "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallSSMgetParametere2d1ba6ca5f8b296a8dfc6b4036a90f21/SdkProvider/AssertionsProvider", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } } }, @@ -218,6 +218,114 @@ "version": "0.0.0" } }, + "AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "id": "AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/SdkProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/SdkProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCall@aws-sdk--client-ssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AwsApiCall", + "version": "0.0.0" + } + }, + "AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2": { + "id": "AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2", + "children": { + "SdkProvider": { + "id": "SdkProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/SdkProvider", + "children": { + "AssertionsProvider": { + "id": "AssertionsProvider", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/SdkProvider/AssertionsProvider", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.3.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AssertionsProvider", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default", + "children": { + "Default": { + "id": "Default", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/Default/Default", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnResource", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "aws-cdk-lib.CustomResource", + "version": "0.0.0" + } + }, + "AssertionResults": { + "id": "AssertionResults", + "path": "AssertionsTest/DefaultTest/DeployAssert/AwsApiCallssmGetParameterCommande2d1ba6ca5f8b296a8dfc6b4036a90f2/AssertionResults", + "constructInfo": { + "fqn": "aws-cdk-lib.CfnOutput", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests-alpha.AwsApiCall", + "version": "0.0.0" + } + }, "BootstrapVersion": { "id": "BootstrapVersion", "path": "AssertionsTest/DefaultTest/DeployAssert/BootstrapVersion", @@ -257,7 +365,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.70" + "version": "10.3.0" } } }, diff --git a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.ts b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.ts index bac88417f2e42..18ddf36afc4bd 100644 --- a/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.ts +++ b/packages/@aws-cdk/integ-tests-alpha/test/assertions/providers/integ.assertions.ts @@ -40,4 +40,30 @@ const secondAssertion = integ.assertions.awsApiCall('SSM', 'getParameter', { }), ); -firstAssertion.next(secondAssertion); \ No newline at end of file +// use v3 package name and command class name +const thirdAssertion = integ.assertions.awsApiCall('@aws-sdk/client-ssm', 'GetParameterCommand', { + Name: ssmParameter.ref, + WithDecryption: true, +}).expect( + ExpectedResult.objectLike({ + Parameter: { + Type: 'String', + Value: 'ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ!"#¤%&/()=?`´^*+~_-.,:;<>|', + }, + }), +); + +// use v3 client name and command class name +const forthAssertion = integ.assertions.awsApiCall('ssm', 'GetParameterCommand', { + Name: ssmParameter.ref, + WithDecryption: true, +}).expect( + ExpectedResult.objectLike({ + Parameter: { + Type: 'String', + Value: 'ABCDEFGHIJKLMNOPQRSTUVWXYZÅÄÖ!"#¤%&/()=?`´^*+~_-.,:;<>|', + }, + }), +); + +firstAssertion.next(secondAssertion).next(thirdAssertion).next(forthAssertion);