I am using aws cdk library to create resource and was able to create resources succuessfully. Now want to test this generated statck. Again if its single resources then able to test it fine but when stack has more than one resources then don't how to rest that.
Following is code to create resources.
constructor(scope: cdk.Construct, id: string, props: CIAMSQSProps = {} ) {
super(scope, id);
const queue = new sqs.Queue(this, id, {
queueName: props.queueName!,
});
let ssmParamters = new CreateSSMParamaters(this, id, {
envName: props.envName!,
envValue: sqsQueue.queueUrl
});
}
Following is the code for testing and it fails because stack contains reference.
test('Test SSM Parameter', () => {
const app = new App();
const sqsStack = new TestSQS(app, 'test-sqs-stack', {
queueName: 'TestQueue',
envName: 'TestQueue',
});
const template = Template.fromStack(sqsStack);
template.hasResourceProperties(ResourceTypes.SSM_PARAM_TYPE, "{ Name: 'TestQueue', Value: 'TestQueue', Type: 'String' }");
});
Following is the error.
Template has 1 resources with type AWS::SSM::Parameter, but none match as expected.
The closest result is:
{
"Type": "AWS::SSM::Parameter",
"Properties": {
"Type": "String",
"Value": {
"Ref": "testsqsstackEDC1E09E"
},
"Name": "TestQueue"
}
}
with the following mismatches:
Expected type string but received object at /Properties (using objectLike matcher)
can someone help me on this? Or is there any way to test specific property for resource type?