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): Set environment for Deploy Assert Stack #22332

Closed
1 of 2 tasks
dontirun opened this issue Oct 3, 2022 · 5 comments · Fixed by #22404
Closed
1 of 2 tasks

(integ-tests): Set environment for Deploy Assert Stack #22332

dontirun opened this issue Oct 3, 2022 · 5 comments · Fixed by #22404
Assignees
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. p2

Comments

@dontirun
Copy link
Contributor

dontirun commented Oct 3, 2022

Describe the feature

Allow setting the AWS environment (account/region) for the deploy assert stack

Use Case

I have a construct that uses ELBv2 access logging. ELBv2 access logging requires setting the region for the cdk environment. As showcased by this error

Error: Region is required to enable ELBv2 access logging

After setting the environment, I received the following error when I attempted to pass a reference to an Api Call in the Integ Test

Error: Stack "foo/DefaultTest/DeployAssert" cannot consume a cross reference from stack "bar". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack

Proposed Solution

Allow setting the cdk environment in IntegTestProps

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.41.0

Environment details (OS name and version, etc.)

Osx

@dontirun dontirun added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 3, 2022
@github-actions github-actions bot added the @aws-cdk/assert Related to the @aws-cdk/assert package label Oct 3, 2022
@kaizencc kaizencc removed the @aws-cdk/assert Related to the @aws-cdk/assert package label Oct 3, 2022
@kaizencc kaizencc assigned corymhall and unassigned kaizencc Oct 3, 2022
@corymhall
Copy link
Contributor

@dontirun can you provide an example of the integ test where you see the behavior?

@dontirun
Copy link
Contributor Author

dontirun commented Oct 4, 2022

import * as cdk from 'monocdk';
import * as ec2 from 'monocdk/aws-ec2';
import * as elbv2 from 'monocdk/aws-elasticloadbalancingv2';
import * as s3 from 'monocdk/aws-s3';
import * as integ from 'monocdk/integ-tests';


const app = new cdk.App();

const stack = new cdk.Stack(app, 'stack',
    {
        env: { region: 'us-west-2' }
    })

const nlb = new elbv2.NetworkLoadBalancer(stack, 'nlb', { vpc: new ec2.Vpc(stack, 'vpc') })
// requires region to be set
nlb.logAccessLogs(new s3.Bucket(stack, 'logbucket'))


const test = new integ.IntegTest(app, 'integ', {
    testCases: [stack],
    regions: ['us-west-2'],
});

test.assertions.awsApiCall('Elbv2', 'describeLoadBalancers', {
    Names: [nlb.loadBalancerName]
});

app.synth();

Error: Stack "integ/DefaultTest/DeployAssert" cannot consume a cross reference from stack "stack". Cross stack references are only supported for stacks deployed to the same environment or between nested stacks and their parent stack

@dontirun
Copy link
Contributor Author

dontirun commented Oct 4, 2022

I'm giving a CDKv1 example here because this issue is preventing me from using v2 (without a hacky patch)

@corymhall corymhall added p2 effort/small Small work item – less than a day of effort labels Oct 4, 2022
@corymhall
Copy link
Contributor

@dontirun thanks for the example, the makes perfect sense and we should definitely add this.

@mergify mergify bot closed this as completed in #22404 Oct 10, 2022
mergify bot pushed a commit that referenced this issue Oct 10, 2022
Closes #22332

----

### All Submissions:

* [X] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. p2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants