- Newest
- Most votes
- Most comments
The second option you mentioned, adding a custom resource Lambda function that checks on the environment status after the deployment as part of the CDK deployment process, would be the best approach to accomplish this task.
This approach would allow you to programmatically check the status of the Beanstalk environment after the deployment and return a failure status to the pipeline if the environment is in an unhealthy state. This would allow the pipeline to be marked as failed and block promotion to subsequent stages.
You can use the AWS SDK for JavaScript in Node.js, AWS SDK for Python (Boto3), or any other SDK to interact with Elastic Beanstalk and check the environment status.
Here's an example of how you might implement this using a Lambda function and the AWS SDK for Python (Boto3):
Create a new Lambda function in the same region as your Elastic Beanstalk environment.
In the Lambda function, import the Boto3 library and create a new Elastic Beanstalk client.
Use the describe_environment_health method to check the status of the environment.
If the environment is in an unhealthy state, raise an exception that will be caught by CloudFormation and mark the pipeline execution as failed.
In your CDK code, include the Lambda function as a custom resource in your CloudFormation stack.
After the CDK deployment, the Lambda function will be invoked and will check the status of the Beanstalk environment.
You can also use CloudWatch Event Rules to schedule your Lambda function to check the environment status periodically and raise an exception if the environment is in an unhealthy state.
This approach would provide a more automated solution that would make sure that the pipeline execution is marked as failed whenever there's a problem with the Beanstalk deployment, and that it
Relevant content
- asked 9 months ago
- asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated 4 months ago
Awesome, thanks for your input!