- Newest
- Most votes
- Most comments
Hi Dan.
To pass the API Gateway URL from the RestSvcStack to the test action in the same stage, you need to ensure that the URL is accessible as an output of the stack and then use that output in your pipeline stage.
I would suggest you to declare a variable both on your Stack and on your Stage as follow:
public readonly loadBalancerAddress: CfnOutput;
This documentation shows how you can define an atribute/value via CfnOutput as follow:
this.loadBalancerAddress = new cdk.CfnOutput(lbStack, 'LbAddress', { value: `https://${lbStack.loadBalancer.loadBalancerDnsName}/` });
And then use it as follow as part of your action:
// pass the load balancer address to a shell step stage.addPost(new ShellStep("lbaddr", { envFromCfnOutputs: {lb_addr: lbStack.loadBalancerAddress}, commands: ['echo $lb_addr'] }));
Please accept this answer if it helped you. Otherwise, feel free to ping me so we can troubleshoot.
Regards, Pablo Silva
As a workaround, you can capture the API Gateway URL in the context of the RestSvcStack
, retrieve it in the WeatherServiceStack
, and then pass it as an environment variable to the E2ETests
CodeBuild step. Additionally, you can use the pipeline's wave mechanism to automatically roll back the RestSvc
deployment if the E2ETests
fail.
Relevant content
- Accepted Answerasked 4 months ago
- asked 2 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
This worked! I think the key was the
envFromCfnOutputs
property. I just needed to modify it from a load balancer to the API GW URL and it worked like a treat :-)