aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.57k stars 3.88k forks source link

integ-tests: allow for different props during the stack update workflow #30402

Open dontirun opened 4 months ago

dontirun commented 4 months ago

Describe the feature

Allow testCase stacks to use different props on the stack create and update workflows

Use Case

I have CDK constructs that utilize custom resources. This would allow me to properly test custom resources onUpdate operations by changing the properties passed to them

Proposed Solution

No response

Other Information

I can currently achieve this behavior with the following "workaround". It forces two instances of the stack to use the same stack name to achieve the update functionality


import * as integ from '@aws-cdk/integ-tests-alpha';
import * as cdk from 'aws-cdk-lib';
import { Construct } from "constructs";

const app = new cdk.App();
interface TestStackProps extends cdk.StackProps {
  someParameter: string;
}

class TestStack extends cdk.Stack {
  constructor(scope: Construct, id: string, props: TestStackProps) {
    super(scope, id, props);
    // insert construct code here
  }
} 

const createStack = new TestStack(app, 'test-stack-create', {
   someParameter: 'foo',
   stackName:'test-stack'
});

const updateStack = new TestStack(app, 'test-stack-update', {
   someParameter: 'bar',
   stackName:'test-stack'
});

updateStack.addDependency(createStack);

new integ.IntegTest(app, 'integration-test', {
  testCases: [createStack, updateStack],
  stackUpdateWorkflow: false,
  diffAssets: true,
});

Acknowledgements

CDK version used

2.143.1

Environment details (OS name and version, etc.)

N/A

pahud commented 4 months ago

Thank you for sharing your use cases. It makes sense to me and we need to figure out how to support that.