-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
config: set default region for EC2 SD #2789
Conversation
f18fa37
to
a1ddab4
Compare
I forgot to mention maintainers. @brian-brazil Would you check this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change seems fine to me in general if that's how AWS clients work with regions in general.
config/config.go
Outdated
@@ -1126,7 +1128,13 @@ func (c *EC2SDConfig) UnmarshalYAML(unmarshal func(interface{}) error) error { | |||
return err | |||
} | |||
if c.Region == "" { | |||
return fmt.Errorf("EC2 SD configuration requires a region") | |||
sess := session.Must(session.NewSession()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds like this could panic if something goes wrong. Better to check potential errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The errors seems to be caused by wrong configuration.
https://github.com/aws/aws-sdk-go/blob/v1.8.35/aws/session/session.go#L100
https://github.com/aws/aws-sdk-go/blob/v1.8.35/aws/session/session.go#L257
https://github.com/aws/aws-sdk-go/blob/v1.8.35/aws/session/session.go#L335
https://github.com/aws/aws-sdk-go/blob/v1.8.35/aws/session/session.go#L339
https://github.com/aws/aws-sdk-go/blob/v1.8.35/aws/session/session.go#L352
But it is better to add error handling, so I add it :-)
I think..., the |
@fabxc @brian-brazil How I can proceed this PR? |
My bad, looks all good. Thanks! |
Thanks!! |
If Prometheus is running on EC2, most of the case
region
might be same region where Prometheus is running.I want to set default region for the case.