-
Notifications
You must be signed in to change notification settings - Fork 634
Improve AWS runner attribution and watchdog coverage #3851
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
Open
shi-eric
wants to merge
1
commit into
newton-physics:main
Choose a base branch
from
shi-eric:ershi/update-aws-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # AWS CI infrastructure | ||
|
|
||
| This directory contains the source templates for AWS resources used by Newton | ||
| CI. If the templates exist only in AWS, maintainers have to reconstruct the | ||
| deployed configuration from console history during an incident. Checking them | ||
| into Git gives us a reviewable change history and a known version to restore. | ||
|
|
||
| That history is why these files belong in the repository. They are source files, | ||
| not examples or generated output. The templates contain no credentials, | ||
| secrets, private endpoints, or notification subscribers. They do not grant | ||
| access to AWS, and commits to this directory do not deploy automatically. | ||
|
|
||
| Put future AWS CI templates here too. This gives the small group that maintains | ||
| the infrastructure one place to look and keeps AWS details out of the rest of | ||
| the project. | ||
|
|
||
| ## Inventory | ||
|
|
||
| | Template | Stack | Region | Required parameters | | ||
| | --- | --- | --- | --- | | ||
| | `overdue-newton-github-runner-watchdog.yaml` | `overdue-newton-github-runner-watchdog` | `us-east-1` | `AlertTopicArn` | | ||
|
|
||
| The deployer must supply `AlertTopicArn` because the template has no default. | ||
| This keeps notification routing and subscriber details outside the repository. | ||
|
|
||
| ## Validate and review a change | ||
|
|
||
| Authenticate the AWS CLI, check that the selected profile points to the intended | ||
| account, then validate the template: | ||
|
|
||
| ```bash | ||
| NEWTON_AWS_PROFILE=isaac-sim-CS-Admin | ||
| NEWTON_AWS_REGION=us-east-1 | ||
| NEWTON_WATCHDOG_STACK=overdue-newton-github-runner-watchdog | ||
| NEWTON_CHANGE_SET=aws-runner-watchdog-update | ||
|
|
||
| aws --profile "$NEWTON_AWS_PROFILE" sts get-caller-identity | ||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation validate-template \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --template-body file://scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml | ||
| ``` | ||
|
|
||
| Before creating a change set, save the stack's current template and parameters | ||
| outside the repository in case you need to roll back. Read the alert action on | ||
| the deployed alarm and verify that it points to the intended SNS topic: | ||
|
|
||
| ```bash | ||
| NEWTON_ALERT_TOPIC_ARN="$( | ||
| aws --profile "$NEWTON_AWS_PROFILE" cloudwatch describe-alarms \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --alarm-names overdue-newton-github-runner-watchdog \ | ||
| --query 'MetricAlarms[0].AlarmActions[0]' \ | ||
| --output text | ||
| )" | ||
|
|
||
| case "$NEWTON_ALERT_TOPIC_ARN" in | ||
| arn:aws:sns:us-east-1:*) ;; | ||
| *) echo "Unexpected alert topic ARN" >&2; exit 1 ;; | ||
| esac | ||
|
|
||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation create-change-set \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --stack-name "$NEWTON_WATCHDOG_STACK" \ | ||
| --change-set-name "$NEWTON_CHANGE_SET" \ | ||
| --change-set-type UPDATE \ | ||
| --template-body file://scripts/ci/aws/overdue-newton-github-runner-watchdog.yaml \ | ||
| --parameters "ParameterKey=AlertTopicArn,ParameterValue=$NEWTON_ALERT_TOPIC_ARN" \ | ||
| --capabilities CAPABILITY_NAMED_IAM | ||
|
|
||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation wait change-set-create-complete \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --stack-name "$NEWTON_WATCHDOG_STACK" \ | ||
| --change-set-name "$NEWTON_CHANGE_SET" | ||
|
|
||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation describe-change-set \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --stack-name "$NEWTON_WATCHDOG_STACK" \ | ||
| --change-set-name "$NEWTON_CHANGE_SET" | ||
| ``` | ||
|
|
||
| Read the complete change set before executing it. This stack has a named IAM | ||
| role, so the update requires `CAPABILITY_NAMED_IAM`. Pay close attention to IAM | ||
| changes, and stop if the change set contains an unexpected replacement, | ||
| deletion, resource, or permission change. | ||
|
|
||
| Execute only after review: | ||
|
|
||
| ```bash | ||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation execute-change-set \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --stack-name "$NEWTON_WATCHDOG_STACK" \ | ||
| --change-set-name "$NEWTON_CHANGE_SET" | ||
|
|
||
| aws --profile "$NEWTON_AWS_PROFILE" cloudformation wait stack-update-complete \ | ||
| --region "$NEWTON_AWS_REGION" \ | ||
| --stack-name "$NEWTON_WATCHDOG_STACK" | ||
| ``` | ||
|
|
||
| After deployment, invoke the watchdog, confirm that it emits fresh metrics and | ||
| logs, then check the alarm state. Investigate any stack drift before making | ||
| another change. If verification fails, restore the saved template and parameters | ||
| with a reviewed reverse change set. Do not update stack-managed resources | ||
| directly because CloudFormation will no longer have an accurate record of their | ||
| configuration. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.