Comments (2)
Hi @bryanhiestand, thanks for reaching out. This behavior makes sense; AWS Health only has two endpoints as you mentioned, and you should make requests to those endpoints. What behavior were you anticipating in the event of a request being sent to an endpoint that isn't supported?
Hi @RyanFitzSimmonsAK, thank you for taking a look!
I agree that it's a bit silly to expect aws health describe-events --region nope
to work, and I would expect passing an invalid --endpoint-url
to break things.
Since Health appears to be a global service, I would actually expect to not have to specify a region, similar to the way IAM works. So I would expect to be able to have the AWS_DEFAULT_REGION
environment variable set and still be able to access health
. I would also expect to be able to access health while having region environment variables set or after defining a non-us-east region in aws configure
.
This isn't quite what I am trying to do, but perhaps this untested script will illustrate what I am getting at. If one wanted to see if any of their instances tagged environment=production had health events, they might try a script like this, running it with the AWS_REGION environment variable for each of their regions:
# List EC2 instances tagged with "environment=production"
INSTANCE_IDS=$(aws ec2 describe-instances --filter "Name=tag:environment,Values=production" --query 'Reservations[*].Instances[*].[InstanceId]' --output json | jq -r '.[][]')
# Get all upcoming AWS health events
EVENTS=$(aws health describe-events --filter eventStatusCodes=upcoming,eventTypeCodes=AWS_EC2_INSTANCE_MAINTENANCE_SCHEDULED --query 'events[*].arn' --output json | jq -r '.[]')
for event in $EVENTS
do
# Get details for each event
EVENT_DETAILS=$(aws health describe-event-details --filter eventArns=$event --query 'successfulSet[*].eventDescription.latestDescription' --output text)
for id in $INSTANCE_IDS
do
# Check if the event details contain the instance ID
if echo "$EVENT_DETAILS" | grep -q "$id"; then
echo "Scheduled events for instance $id: $EVENT_DETAILS"
fi
done
done
However, the above will only work in us-east-1 or us-east-2. For any other region, we must override the region only when calling health. This seems like either a burdensome design or a bug:
export AWS_REGION=us-west-2
# List EC2 instances tagged with "environment=production"
INSTANCE_IDS=$(aws ec2 describe-instances --filter "Name=tag:environment,Values=production" --query 'Reservations[*].Instances[*].[InstanceId]' --output json | jq -r '.[][]')
# some more regional commands
# Health is only available in us-east-1
aws health describe-event-details --region us-east-1 ...
With IAM, this would not be required:
export AWS_REGION='us-west-2'
# Get all IAM instance profiles
ALL_ROLES=$(aws iam list-instance-profiles --query 'InstanceProfiles[*].Roles[*].RoleName' --output json | jq -r '.[][]')
# Get roles used by EC2 instances in the specified region
USED_ROLES=$(aws ec2 describe-instances --query 'Reservations[*].Instances[*].IamInstanceProfile.Arn' --output json | jq -r '.[][]' | awk -F '/' '{print $2}')
I hope this helps clarify. Thanks again for looking.
from aws-cli.
Hi @bryanhiestand, thanks for reaching out. This behavior makes sense; AWS Health only has two endpoints as you mentioned, and you should make requests to those endpoints. What behavior were you anticipating in the event of a request being sent to an endpoint that isn't supported?
from aws-cli.
Related Issues (20)
- `aws sso login` hangs when users cancels in the browser HOT 2
- Error exit value doesn't quite match what `help return-codes` describe HOT 1
- In `aws ecr create-repository` example the `repositoryName` is not consistent with parameter
- We should be able to change the "Controls" menu name HOT 2
- [SSO] - Add CLI parameters to skip prompted values (`--start-url`, etc.)
- `GLIBC_2.28' not found with aws-actions/configure-aws-credentials@v4 action HOT 2
- In aws cloudformation package command, !Sub or !Ref function cannot work properly in Code property of AWS::Lambda::Function resource. HOT 2
- aws-cli/2.17.8 on Linux is flagged as vulnerable to CVE-2024-0397 HOT 4
- AWS CLI SSO stuck in browser loading state when click Allow
- Feature request: Support publishing SAM template to SAR that leverages an existing macro HOT 3
- OpenSSL 1.1.1y out of date in ARM distributions HOT 4
- aws sso login still broken for profiles outside of us-east-1 HOT 1
- --profile mandatory even if there is just one profile HOT 2
- setup.py(short issue description) HOT 1
- Option to preserve `role_session_name` when chaining roles HOT 2
- aws rds describe-db-instances missing LatestRestorableTime in output HOT 1
- Installing in relative path installs broken symlinks HOT 2
- awscli IAM list-users and list-access-keys doesn't parse max-items to request body HOT 2
- `aws ec2-instance-connect` times out too fast on MacOS HOT 2
- Support `DescribeExection` for Express Step Functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aws-cli.