-
Notifications
You must be signed in to change notification settings - Fork 4k
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
add a command to cloudformation wait any final state, and display events while waiting #2887
Comments
|
Thanks for the suggestion, marking as a feature request. |
|
FYI the AWS Tools for PowerShell currently offer this feature, starting with version 3.3.119.0. The SDK includes a There's an example of its use in the blog post and documentation, linked to below. AWS Developer Blog Post (2017-07-11) Cheers, |
|
Good Morning! We're closing this issue here on GitHub, as part of our migration to UserVoice for feature requests involving the AWS CLI. This will let us get the most important features to you, by making it easier to search for and show support for the features you care the most about, without diluting the conversation with bug reports. As a quick UserVoice primer (if not already familiar): after an idea is posted, people can vote on the ideas, and the product team will be responding directly to the most popular suggestions. We’ve imported existing feature requests from GitHub - Search for this issue there! And don't worry, this issue will still exist on GitHub for posterity's sake. As it’s a text-only import of the original post into UserVoice, we’ll still be keeping in mind the comments and discussion that already exist here on the GitHub issue. GitHub will remain the channel for reporting bugs. Once again, this issue can now be found by searching for the title on: https://aws.uservoice.com/forums/598381-aws-command-line-interface -The AWS SDKs & Tools Team |
|
Based on community feedback, we have decided to return feature requests to GitHub issues. |
|
Would be great to have this implemented. aws cloudformation deploy --stack-name "${stack_name}" \
--template-file "${stack_template_file}" \
--no-fail-on-empty-changeset \
| while read -r line; do echo "$line"
if [[ "$line" = "Waiting for stack create/update to complete" ]]; then
"aws-cloudformation-deploy-watch.sh" --stack-name "${stack_name}"
fi
done
#!/usr/bin/env sh -euo pipefail
############################## Usage ################################
#
# aws-cloudformation-deploy-watch.sh --stack 'STACK_NAME'
#
#####################################################################
while [ $# -gt 0 ]; do
case $1 in
--stack-name) stack_name_opt="$2"; shift 2;;
--profile) profile_opt="$2"; shift 2 ;;
--region) region_opt="$2"; shift 2;;
*) echo "$0: unexpected argument: $1" >&2; exit 1;;
esac
done
_TAB=$'\t'
most_recent_event_id='???'
while : ; do
# get recent stack events
most_recent_event_id_sed_escaped="$(echo "$most_recent_event_id" | sed -e 's/[]\/$*.^[]/\\&/g')"
recent_events="$(aws cloudformation describe-stack-events \
$([ -n "${stack_name_opt:-}" ] && echo "--stack-name $stack_name_opt") \
--query 'StackEvents[*].[EventId,Timestamp,LogicalResourceId,ResourceStatus,ResourceStatusReason]' \
$([ -n "${profile_opt:-}" ] && echo "--profile $profile_opt") \
$([ -n "${region_opt:-}" ] && echo "--region $region_opt") \
--output text \
| sed "/${_TAB}User Initiated\$/q" | sed "/^${most_recent_event_id_sed_escaped}${_TAB}/,\$d" \
| tail -r)"
if [ -n "$recent_events" ]; then
# save last event id
most_recent_event_id=$(echo "$recent_events" | tail -1 | awk -F $'\t' '{printf $1}')
while read -r event; do
# print new event
echo "$event" | awk -F $'\t' '{printf "%-28s %-48s %-24s %s\n",$2,$3,$4,$5}' | sed "s/None$//"
# looking for stack resource events
event_resouce=$(echo "$event" | awk -F $'\t' '{printf $3}')
if [ "$event_resouce" == "$stack_name_opt" ]; then
stack_status="$(echo "$event" | awk '{printf $4}')"
# exit on final stack status
if [[ "$stack_status" = *'_FAILED' ]] || [[ "$stack_status" = *'_ROLLBACK_COMPLETE' ]]; then exit 1; fi
if [[ "$stack_status" = *'_COMPLETE' ]]; then exit 0; fi
fi
done <<< "$recent_events"
fi
sleep 1
done |
|
Can we re-open this here since the uservoice migration appears no longer to be a thing? (or at least the links here are broken) |
|
It seems this has been implemented here: However you need to call different operations with the CLI to differentiate between waiting for a Stack Create vs. a Stack Update to be complete: aws cloudformation wait stack-create-complete --stack-name mystack
aws cloudformation wait stack-update-complete --stack-name mystackThe Powershell implementation of this (Wait-CFNStack) uses one command to hit Wait-CFNStack -StackName mystack -Timeout 300 -Status CREATE_COMPLETE,UPDATE_COMPLETEIt's a bit of a strange situation though. CLI and Powershell SDK usage are flipped in the way they work. With the CLI I can use
However with PowerShell SDK I can also use the DescribeStacks API to determine if the stack was created OR updated, however I get a single cmdlet I can use
I've written PowerShell to detect if the stack exists, and do change sets - but this is onerous. |
|
This feature would be super useful for scripting test deployments of my cloudformation stack in CI |
|
+1 |
1 similar comment
|
+1 |
|
Would love to see, any updates on this feature request? |
|
Any progress on this? It is really annoying to have to specify in jenkins whether you need an update or creation. |
|
+1 |
1 similar comment
|
+1 |
|
Are there any plans to implement this? It's crazy that we all have to write scripts ourselves to do this (and they always end up being a little flakey in my experience). This command would be more useful than any of the individual "wait for a specific state" commands that already exist. |
|
These are the wait commands currently available for cloudformation:
(https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudformation/wait/index.html) A few different topics have been mentioned here in the discussion so I want to confirm what the feature request is. @hnafar I believe you’re asking for the ability to see every stack status logged while waiting to reach one of those states above. Is that correct? |
|
I don't mean to speak for @hnafar, but it's the idea that "wait commands" should be allowed to be bundled. Either do that by saying:
As an example, imagine a ci/cd pipeline where you want to auto-update your cloud formation stack when you've pushed new code. It's a simple idea, but to avoid errors from the AWS CLI, you must define a series of waits based on the current status of the stack.
This is not to mention that it's not clear what happens mid update when your stack has to roll back, but you're in the middle of Simply, it's cumbersome. I'd not say it's all bad, however. The wait clauses being there are far better than the alternative (but that's neither here nor there). Here's an example implementation (still a bit limited) that collects final states: https://www.npmjs.com/package/@cumulusds/aws-cloudformation-wait-ready Another implementation to look at would be the aforementioned one in PowerShell (as called out by @pcgeek86 & @lantrix). Doing this but in AWS CLI is what I would think the goal is. I imagine a day where we're done in 2 lines (please don't take the following as a concrete task, it's an expression of thought and is simply for ideation):
Or, what if one line? |
|
While I also don't claim to speak for @hnafar, what @dfehrenbach says describes my issue exactly. We also use the npm package The usefulness of this feature for CI pipelines cannot be overstated IMO. |
This is specially useful during automated deployments.
Currently I achieve this using the following script, but having this as part of the cli would be much more helpful:
which produces the following result on an update:
The text was updated successfully, but these errors were encountered: