I have successfully created resources using the aws cdk library. I am now facing an issue with testing a stack that contains multiple resources. When testing a single resource, everything works fine, but I'm unsure how to test a stack with multiple resources.
Here is the code used to create the 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
});
}
When attempting to test the stack, the following code fails due to a reference within the stack:
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' }");
});
The error received is:
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)
Any assistance on resolving this issue would be greatly appreciated. Alternatively, is there a way to test a specific property for a resource type?